1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.overtime.daily;
17
18
19 import org.apache.log4j.Logger;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.kuali.hr.KPMEWebTestCase;
23 import org.kuali.hr.util.HtmlUnitUtil;
24 import org.kuali.kpme.core.FunctionalTest;
25 import org.kuali.kpme.tklm.utils.TkTestConstants;
26
27 import com.gargoylesoftware.htmlunit.html.HtmlInput;
28 import com.gargoylesoftware.htmlunit.html.HtmlPage;
29
30 @FunctionalTest
31 public class DailyOvertimeRuleMaintenanceTest extends KPMEWebTestCase{
32 private static final Logger LOG = Logger.getLogger(DailyOvertimeRuleMaintenanceTest.class);
33 private static final String TEST_CODE="BL";
34 private static String TEST_CODE_INVALID_DEPT_ID ="INVALID";
35 private static Long TEST_CODE_INVALID_TASK_ID =-1L;
36 private static Long TEST_CODE_INVALID_WORK_AREA_ID =-1L;
37 private static String dailyOvertimeRuleId = "5";
38
39 @Test
40 public void testDailyOvertimeRuleMaintForErrorMessages() throws Exception {
41 HtmlPage maintPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.DAILY_OVERTIME_RULE_MAINT_NEW_URL);
42
43 HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
44 maintPage, "* Document Description");
45 inputForDescription.setValueAttribute("Test_Description");
46
47 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.effectiveDate", "01/01/2010");
48 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.groupKeyCode", "IU-IN");
49 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.paytype", "HR");
50 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.dept", TEST_CODE_INVALID_DEPT_ID);
51 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.workArea", TEST_CODE_INVALID_WORK_AREA_ID.toString());
52 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.maxGap", "1.0");
53 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.minHours", "2");
54 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.earnCode", "OVT");
55 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.fromEarnGroup", "RGN");
56
57 HtmlPage resultantPageAfterEdit = HtmlUnitUtil
58 .clickInputContainingText(maintPage, "submit");
59 LOG.debug(resultantPageAfterEdit.asText());
60 Assert.assertTrue("Maintenance Page contains test deptErrormessage",
61 resultantPageAfterEdit.asText().contains(
62 "The specified department '"
63 + TEST_CODE_INVALID_DEPT_ID
64 + "' does not exist."));
65
66
67 HtmlUnitUtil.setFieldValue(resultantPageAfterEdit, "document.newMaintainableObject.fromEarnGroup", "OVT");
68 HtmlPage finalPage = HtmlUnitUtil.clickInputContainingText(resultantPageAfterEdit, "submit");
69 Assert.assertTrue("Maintenance Page should contains EarnCodeGroup has overtime earn code error",
70 finalPage.asText().contains("Earn Group 'OVT' has overtime earn codes."));
71
72 }
73
74 }