1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.overtime.weekly;
17
18 import java.math.BigDecimal;
19
20 import org.joda.time.LocalDate;
21 import org.junit.Assert;
22 import org.junit.Test;
23 import org.kuali.hr.KPMEWebTestCase;
24 import org.kuali.hr.util.HtmlUnitUtil;
25 import org.kuali.kpme.core.FunctionalTest;
26 import org.kuali.kpme.core.util.TKUtils;
27 import org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRule;
28 import org.kuali.kpme.tklm.utils.TkTestConstants;
29 import org.kuali.rice.krad.service.KRADServiceLocator;
30
31 import com.gargoylesoftware.htmlunit.html.HtmlElement;
32 import com.gargoylesoftware.htmlunit.html.HtmlPage;
33
34 @FunctionalTest
35 public class WeeklyOvertimeRuleMaintenanceTest extends KPMEWebTestCase {
36
37 protected static final String TEST_CODE="TST";
38 private static final BigDecimal TEST_NO=new BigDecimal(10);
39 private static String weeklyOvertimeRuleId;
40 private static final LocalDate TEST_DATE = LocalDate.now();
41
42 @Test
43 public void testWeeklyOvertimeRuleMaint() throws Exception {
44 HtmlPage maintPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.WEEKLY_OVERTIME_RULE_MAINT_URL);
45 Assert.assertTrue("Maintenance Page contains test WeeklyOvertimeRule",maintPage.asText().contains(TEST_CODE));
46
47
48 HtmlPage newMaintPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.WEEKLY_OVERTIME_RULE_MAINT_NEW_URL);
49 HtmlUnitUtil.setFieldValue(newMaintPage, "document.documentHeader.documentDescription", "Test");
50 HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.effectiveDate", "01/01/2010");
51 HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHoursEarnGroup", "REG");
52 HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertFromEarnGroup", "OVT");
53 HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertToEarnCode", "RGN");
54 HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.step", "1");
55 HtmlUnitUtil.setFieldValue(newMaintPage, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHours", "8");
56
57 HtmlElement element = (HtmlElement)newMaintPage.getElementById("methodToCall.addLine.lstWeeklyOvertimeRules.(!!org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRule!!)");
58 HtmlPage finalPage = element.click();
59 Assert.assertTrue("Maintenance Page should contains EarnCodeGroup has overtime earn code error",
60 finalPage.asText().contains("Earn Group 'OVT' has overtime earn codes."));
61 }
62
63 @Override
64 public void setUp() throws Exception {
65 super.setUp();
66 WeeklyOvertimeRule weeklyOvertimeRule = new WeeklyOvertimeRule();
67 weeklyOvertimeRule.setActive(true);
68 weeklyOvertimeRule.setConvertFromEarnGroup(TEST_CODE);
69 weeklyOvertimeRule.setConvertToEarnCode(TEST_CODE);
70 weeklyOvertimeRule.setEffectiveLocalDate(TEST_DATE);
71 weeklyOvertimeRule.setMaxHours(TEST_NO);
72 weeklyOvertimeRule.setMaxHoursEarnGroup(TEST_CODE);
73 weeklyOvertimeRule.setStep(TEST_NO);
74 weeklyOvertimeRule.setTimestamp(TKUtils.getCurrentTimestamp());
75 weeklyOvertimeRule.setUserPrincipalId(TEST_CODE);
76 KRADServiceLocator.getBusinessObjectService().save(weeklyOvertimeRule);
77 weeklyOvertimeRuleId=weeklyOvertimeRule.getTkWeeklyOvertimeRuleId();
78 }
79
80 @Override
81 public void tearDown() throws Exception {
82
83 WeeklyOvertimeRule weeklyOvertimeRuleObj= KRADServiceLocator.getBusinessObjectService().findBySinglePrimaryKey(WeeklyOvertimeRule.class, weeklyOvertimeRuleId);
84 KRADServiceLocator.getBusinessObjectService().delete(weeklyOvertimeRuleObj);
85 super.tearDown();
86 }
87
88 }