View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.hr.time.workarea;
17  
18  import java.sql.Date;
19  
20  import org.junit.Assert;
21  import org.junit.Test;
22  import org.kuali.hr.test.KPMETestCase;
23  import org.kuali.hr.time.service.base.TkServiceLocator;
24  import org.kuali.hr.time.test.HtmlUnitUtil;
25  import org.kuali.hr.time.util.TKUtils;
26  import org.kuali.hr.time.util.TkConstants;
27  import org.kuali.rice.krad.service.KRADServiceLocator;
28  
29  import com.gargoylesoftware.htmlunit.html.HtmlPage;
30  
31  public class WorkAreaMaintenanceTest extends KPMETestCase {
32  
33  	@Test
34  	public void testWorkAreaMaintenanceScreen() throws Exception{
35      	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";
36      	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
37      	setFieldValue(page,"workArea","30");
38      	page = HtmlUnitUtil.clickInputContainingText(page, "search");
39      	page = HtmlUnitUtil.clickAnchorContainingText(page, "edit");
40      	Assert.assertTrue("Test that maintenance screen rendered", page.asText().contains("30"));
41  	}
42  
43  	@Override
44  	public void setUp() throws Exception {
45  		super.setUp();
46  		WorkArea workArea = new WorkArea();
47  		workArea.setTkWorkAreaId("1111");
48  		workArea.setWorkArea(4444L);
49  		workArea.setOvertimeEditRole(TkConstants.ROLE_TK_EMPLOYEE);
50  		workArea.setEffectiveDate(new Date(System.currentTimeMillis()));
51  		KRADServiceLocator.getBusinessObjectService().save(workArea);
52  	}
53  
54  	@Override
55  	public void tearDown() throws Exception {
56  		WorkArea workArea = (WorkArea)KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(WorkArea.class, 1111);
57  		KRADServiceLocator.getBusinessObjectService().delete(workArea);
58  		super.tearDown();
59  	}
60  	
61  	@Test
62  	public void testWorkAreaFetch() throws Exception{
63  		WorkArea workArea = TkServiceLocator.getWorkAreaService().getWorkArea(1234L, TKUtils.getCurrentDate());
64  		Assert.assertTrue("Work area is not null and valid", workArea != null && workArea.getWorkArea().longValue() == 1234L);
65  	}
66  	
67  }