1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leavecode;
17
18 import java.text.SimpleDateFormat;
19 import java.util.Calendar;
20
21 import junit.framework.Assert;
22
23 import org.junit.Test;
24 import org.kuali.hr.test.KPMETestCase;
25 import org.kuali.hr.time.test.HtmlUnitUtil;
26 import org.kuali.hr.time.test.TkTestConstants;
27
28 import com.gargoylesoftware.htmlunit.html.HtmlElement;
29 import com.gargoylesoftware.htmlunit.html.HtmlForm;
30 import com.gargoylesoftware.htmlunit.html.HtmlPage;
31
32 public class LeaveCodeMaintTest extends KPMETestCase{
33 private static final String SUCCESS_MESSAGE = "Document was successfully submitted.";
34 private static final String ERROR_MESSAGE_ALLOW_NEGATIVE_ACC_BAN_REQUIRED = "Allow Negative Accrual Balance (Allow Negative Accrual Balance) is a required field";
35
36 @Test
37 public void testLookupPage() throws Exception {
38 HtmlPage lcLookup = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.LEAVE_CODE_MAINT_URL);
39 lcLookup = HtmlUnitUtil.clickInputContainingText(lcLookup, "search");
40 Assert.assertTrue("Page contains test Leave Code", lcLookup.asText().contains("testLC"));
41 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(lcLookup, "edit");
42 Assert.assertTrue("Maintenance Page contains test Leave Code",maintPage.asText().contains("testLC"));
43 }
44
45
46
47
48
49
50
51 @Test
52 public void testGetLeavePlanBasedOnAccrualCategory() throws Exception {
53 String baseUrl = TkTestConstants.Urls.LEAVE_CODE_MAINT_NEW_URL;
54 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
55 Assert.assertNotNull(page);
56
57 HtmlForm form = page.getFormByName("KualiForm");
58 Assert.assertNotNull("Search form was missing from page.", form);
59 Assert.assertTrue("page text contains:\n" + "Leave Code Maintenance", page.asText().contains("Leave Code Maintenance"));
60 Assert.assertTrue("page text contains:\n" + "Allow Scheduled Leave", page.asText().contains("Allow Scheduled Leave"));
61
62 Calendar validDate = Calendar.getInstance();
63
64
65 validDate.add(Calendar.DATE, 150);
66 String validDateString = new SimpleDateFormat("MM/dd/yyyy").format(validDate.getTime());
67
68 setFieldValue(page, "document.documentHeader.documentDescription", "Leave Code - test");
69 setFieldValue(page, "document.newMaintainableObject.defaultAmountofTime", "25");
70 setFieldValue(page, "document.newMaintainableObject.effectiveDate", validDateString);
71 setFieldValue(page, "document.newMaintainableObject.accrualCategory", "AC1");
72
73 HtmlElement element = page.getElementByName("methodToCall.route");
74 page = element.click();
75 HtmlUnitUtil.createTempFile(page);
76 Assert.assertTrue("page text contains:\n" + "should be between 0 and 24", page.asText().contains("should be between 0 and 24"));
77 Assert.assertTrue("page text contains:\n" + "IU-SM", page.asText().contains("IU-SM"));
78 Assert.assertTrue("page text contains:\n" + "IU-SM", page.asText().contains("Affect Pay"));
79 }
80 }