001 /** 002 * Copyright 2004-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.time.workarea; 017 018 import com.gargoylesoftware.htmlunit.html.HtmlPage; 019 import org.junit.Assert; 020 import org.junit.Test; 021 import org.kuali.hr.test.KPMETestCase; 022 import org.kuali.hr.time.service.base.TkServiceLocator; 023 import org.kuali.hr.time.test.HtmlUnitUtil; 024 import org.kuali.hr.time.util.TKUtils; 025 import org.kuali.hr.time.util.TkConstants; 026 import org.kuali.rice.krad.service.KRADServiceLocator; 027 028 import java.sql.Date; 029 030 public class WorkAreaMaintenanceTest extends KPMETestCase { 031 032 @Test 033 public void testWorkAreaMaintenanceScreen() throws Exception{ 034 String baseUrl = HtmlUnitUtil.getBaseURL() + "/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.hr.time.workarea.WorkArea&returnLocation=" + HtmlUnitUtil.getBaseURL() + "/portal.do&hideReturnLink=true&docFormKey=88888888"; 035 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl); 036 setFieldValue(page,"workArea","30"); 037 page = HtmlUnitUtil.clickInputContainingText(page, "search"); 038 page = HtmlUnitUtil.clickAnchorContainingText(page, "edit"); 039 Assert.assertTrue("Test that maintenance screen rendered", page.asText().contains("30")); 040 } 041 042 @Override 043 public void setUp() throws Exception { 044 super.setUp(); 045 WorkArea workArea = new WorkArea(); 046 workArea.setTkWorkAreaId("1111"); 047 workArea.setWorkArea(4444L); 048 workArea.setOvertimeEditRole(TkConstants.ROLE_TK_EMPLOYEE); 049 workArea.setEffectiveDate(new Date(System.currentTimeMillis())); 050 KRADServiceLocator.getBusinessObjectService().save(workArea); 051 } 052 053 @Override 054 public void tearDown() throws Exception { 055 WorkArea workArea = (WorkArea)KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(WorkArea.class, 1111); 056 KRADServiceLocator.getBusinessObjectService().delete(workArea); 057 super.tearDown(); 058 } 059 060 @Test 061 public void testWorkAreaFetch() throws Exception{ 062 WorkArea workArea = TkServiceLocator.getWorkAreaService().getWorkArea(1234L, TKUtils.getCurrentDate()); 063 Assert.assertTrue("Work area is not null and valid", workArea != null && workArea.getWorkArea().longValue() == 1234L); 064 } 065 066 }