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 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 }