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 com.gargoylesoftware.htmlunit.html.HtmlPage;
19  import org.junit.Assert;
20  import org.junit.Test;
21  import org.kuali.hr.test.KPMETestCase;
22  import org.kuali.hr.time.service.base.TkServiceLocator;
23  import org.kuali.hr.time.test.HtmlUnitUtil;
24  import org.kuali.hr.time.util.TKUtils;
25  import org.kuali.hr.time.util.TkConstants;
26  import org.kuali.rice.krad.service.KRADServiceLocator;
27  
28  import java.sql.Date;
29  
30  public class WorkAreaMaintenanceTest extends KPMETestCase {
31  
32  	@Test
33  	public void testWorkAreaMaintenanceScreen() throws Exception{
34      	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";
35      	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
36      	setFieldValue(page,"workArea","30");
37      	page = HtmlUnitUtil.clickInputContainingText(page, "search");
38      	page = HtmlUnitUtil.clickAnchorContainingText(page, "edit");
39      	Assert.assertTrue("Test that maintenance screen rendered", page.asText().contains("30"));
40  	}
41  
42  	@Override
43  	public void setUp() throws Exception {
44  		super.setUp();
45  		WorkArea workArea = new WorkArea();
46  		workArea.setTkWorkAreaId("1111");
47  		workArea.setWorkArea(4444L);
48  		workArea.setOvertimeEditRole(TkConstants.ROLE_TK_EMPLOYEE);
49  		workArea.setEffectiveDate(new Date(System.currentTimeMillis()));
50  		KRADServiceLocator.getBusinessObjectService().save(workArea);
51  	}
52  
53  	@Override
54  	public void tearDown() throws Exception {
55  		WorkArea workArea = (WorkArea)KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(WorkArea.class, 1111);
56  		KRADServiceLocator.getBusinessObjectService().delete(workArea);
57  		super.tearDown();
58  	}
59  
60  	@Test
61  	public void testWorkAreaFetch() throws Exception{
62  		WorkArea workArea = TkServiceLocator.getWorkAreaService().getWorkArea(1234L, TKUtils.getCurrentDate());
63  		Assert.assertTrue("Work area is not null and valid", workArea != null && workArea.getWorkArea().longValue() == 1234L);
64  	}
65  
66  }