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 org.junit.Assert;
19 import org.junit.Test;
20 import org.kuali.hr.util.HtmlUnitUtil;
21 import org.kuali.kpme.core.FunctionalTest;
22
23 import com.gargoylesoftware.htmlunit.html.HtmlElement;
24 import com.gargoylesoftware.htmlunit.html.HtmlForm;
25 import com.gargoylesoftware.htmlunit.html.HtmlInput;
26 import com.gargoylesoftware.htmlunit.html.HtmlPage;
27
28
29 @FunctionalTest
30 public class WeeklyOvertimeRuleGroupMaintenanceTest extends WeeklyOvertimeRuleMaintenanceTest {
31
32 protected static final String OVERTIME_EARN_GROUP="OVT";
33 @Test
34
35 public void testSubmitWeeklyOvertimeRuleGroupMaint() throws Exception {
36 String baseUrl = getBaseURL() + "/kr/maintenance.do?businessObjectClassName=org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRuleGroup&methodToCall=edit";
37 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
38 Assert.assertNotNull(page);
39
40 HtmlForm form = page.getFormByName("KualiForm");
41 Assert.assertNotNull("Search form was missing from page.", form);
42
43 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
44 Assert.assertNotNull("Could not locate submit button", input);
45 HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "test");
46 HtmlElement element = page.getElementByName("methodToCall.route");
47 HtmlPage finalPage = element.click();
48
49 Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified maxHoursEarnGroup '" + TEST_CODE + "' does not exist."));
50 Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified convertFromEarnGroup '" + TEST_CODE + "' does not exist."));
51 Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified convertToEarnCode '" + TEST_CODE + "' does not exist."));
52
53 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.effectiveDate", "4/01/2011");
54 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHoursEarnGroup", "REG");
55 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertFromEarnGroup", "REG");
56 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertToEarnCode", OVERTIME_EARN_GROUP);
57 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHours", "5");
58 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.step", "10");
59 element = (HtmlElement)page.getElementById("methodToCall.addLine.lstWeeklyOvertimeRules.(!!org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRule!!)");
60 Assert.assertNotNull("Missing Add Line button", element);
61
62 HtmlPage addPage = element.click();
63
64
65 Assert.assertTrue("Maintenance Page contains error messages",addPage.asText().contains("Rule already exists for step '10'."));
66 }
67
68 }