1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.clock.log;
17
18 import org.junit.Assert;
19 import org.junit.Test;
20 import org.kuali.hr.test.KPMETestCase;
21 import org.kuali.hr.time.test.HtmlUnitUtil;
22 import org.kuali.hr.time.test.TkTestConstants;
23
24 import com.gargoylesoftware.htmlunit.html.HtmlInput;
25 import com.gargoylesoftware.htmlunit.html.HtmlPage;
26
27 public class ClockLogMaintenanceTest extends KPMETestCase{
28 private static Long TEST_CODE_INVALID_TASK_ID =9999L;
29 private static Long TEST_CODE_INVALID_WORK_AREA_ID =9999L;
30 private static Long clockLogId = 1L;
31
32 @Test
33 public void testClockLogMaint() throws Exception {
34 HtmlPage clockLogLookUp = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.CLOCK_LOG_MAINT_URL);
35 clockLogLookUp = HtmlUnitUtil.clickInputContainingText(clockLogLookUp, "search");
36 Assert.assertTrue("Page contains test ClockLog", clockLogLookUp.asText().contains("TEST"));
37 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(clockLogLookUp, "edit",clockLogId.toString());
38 Assert.assertTrue("Maintenance Page contains test ClockLog",maintPage.asText().contains("TEST"));
39 }
40
41 @Test
42 public void testClockLogMaintForErrorMessages() throws Exception {
43 HtmlPage clockLogLookUp = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.CLOCK_LOG_MAINT_URL);
44 clockLogLookUp = HtmlUnitUtil.clickInputContainingText(clockLogLookUp, "search");
45 Assert.assertTrue("Page contains test ClockLog", clockLogLookUp.asText().contains("TEST"));
46 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(clockLogLookUp, "edit",clockLogId.toString());
47 Assert.assertTrue("Maintenance Page contains test ClockLog",maintPage.asText().contains("TEST"));
48
49 HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
50 maintPage, "* Document Description");
51 inputForDescription.setValueAttribute("Test_Description");
52 setFieldValue(maintPage, "document.newMaintainableObject.workArea", TEST_CODE_INVALID_WORK_AREA_ID.toString());
53 setFieldValue(maintPage, "document.newMaintainableObject.task", TEST_CODE_INVALID_TASK_ID.toString());
54 HtmlPage resultantPageAfterEdit = HtmlUnitUtil
55 .clickInputContainingText(maintPage, "submit");
56 HtmlUnitUtil.createTempFile(resultantPageAfterEdit);
57
58 Assert.assertTrue("Maintenance Page contains test Workarea ",
59 resultantPageAfterEdit.asText().contains(
60 "The specified Workarea '"
61 + TEST_CODE_INVALID_WORK_AREA_ID
62 + "' does not exist."));
63
64 HtmlUnitUtil.createTempFile(resultantPageAfterEdit);
65
66 Assert.assertTrue("Maintenance Page contains test Task ",
67 resultantPageAfterEdit.asText().contains(
68 "The specified Task '"
69 + TEST_CODE_INVALID_TASK_ID
70 + "' does not exist."));
71
72
73 }
74
75 }