1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.paycalendar.validation;
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.HtmlElement;
25 import com.gargoylesoftware.htmlunit.html.HtmlPage;
26 import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
27
28 public class PayCalendarEntriesMaintenaceTest extends KPMETestCase {
29 @Override
30 public void setUp() throws Exception {
31 super.setUp();
32 }
33
34 @Override
35 public void tearDown() throws Exception {
36 super.tearDown();
37 }
38
39 @Test
40
41 public void testSubmitPayCalendarEntriesMaint() throws Exception {
42
43 String baseUrl = TkTestConstants.Urls.PAY_CALENDAR_ENTRIES_MAINT_NEW_URL;
44 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
45 Assert.assertNotNull(page);
46
47 HtmlTextInput text = (HtmlTextInput) page.getHtmlElementById("document.documentHeader.documentDescription");
48 text.setValueAttribute("test");
49 HtmlUnitUtil.createTempFile(page);
50 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "calendarName");
51 text.setValueAttribute("TTT");
52 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "beginPeriodDate");
53 text.setValueAttribute("02/21/2011");
54 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "beginPeriodTime");
55 text.setValueAttribute("08:00 am");
56 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "endPeriodDate");
57 text.setValueAttribute("02/28/2011");
58 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "endPeriodTime");
59 text.setValueAttribute("08:00 am");
60 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchInitiateDate");
61 text.setValueAttribute("02/16/2011");
62 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchInitiateTime");
63 text.setValueAttribute("08:00 am");
64 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEndPayPeriodDate");
65 text.setValueAttribute("02/21/2011");
66 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEndPayPeriodTime");
67 text.setValueAttribute("08:00 am");
68 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEmployeeApprovalDate");
69 text.setValueAttribute("02/17/2011");
70 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEmployeeApprovalTime");
71 text.setValueAttribute("08:00 am");
72 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchSupervisorApprovalDate");
73 text.setValueAttribute("02/18/2011");
74 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchSupervisorApprovalTime");
75 text.setValueAttribute("08:00 am");
76
77 HtmlElement element = page.getElementByName("methodToCall.route");
78 HtmlPage page1 = element.click();
79 HtmlUnitUtil.createTempFile(page1);
80
81 Assert.assertTrue("Maintenance Page contains error messages", page1.asText().contains("You must specify a valid Calendar."));
82
83 text = (HtmlTextInput) page1.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "calendarName");
84 text.setValueAttribute("BW-CAL");
85
86 element = page1.getElementByName("methodToCall.route");
87 HtmlPage page2 = element.click();
88 Assert.assertTrue("Maintenance page is submitted successfully", page2.asText().contains("Document was successfully submitted."));
89 Assert.assertTrue("Maintenance page is submitted successfully", page2.asText().contains("Status: FINAL"));
90 }
91 }