1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }