1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.holidaycalendar;
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.HtmlForm;
26 import com.gargoylesoftware.htmlunit.html.HtmlInput;
27 import com.gargoylesoftware.htmlunit.html.HtmlPage;
28
29 public class HolidayCalendarTest extends KPMETestCase {
30
31 private static Long holidayGroupId = 1L;
32 @Test
33 public void testHolidayCalendarMaintenancePage() throws Exception{
34 HtmlPage earnCodeLookUp = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.HOLIDAY_CALENDAR_MAINT_URL);
35 earnCodeLookUp = HtmlUnitUtil.clickInputContainingText(earnCodeLookUp, "search");
36 Assert.assertTrue("Page contains REG entry", earnCodeLookUp.asText().contains("REG"));
37 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(earnCodeLookUp, "edit",holidayGroupId.toString());
38 Assert.assertTrue("Maintenance Page contains REG entry",maintPage.asText().contains("REG"));
39 }
40
41 @Test
42 public void testHolidayCalendarCreateNew() throws Exception {
43
44 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.HOLIDAY_CALENDAR_MAINT_NEW_URL);
45 Assert.assertNotNull(page);
46 HtmlForm form = page.getFormByName("KualiForm");
47 Assert.assertNotNull("Search form was missing from page.", form);
48 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
49 Assert.assertNotNull("Could not locate submit button", input);
50
51 setFieldValue(page, "document.documentHeader.documentDescription", "HolidayCalendar - test");
52 setFieldValue(page, "document.newMaintainableObject.holidayCalendarGroup", "TT");
53 setFieldValue(page, "document.newMaintainableObject.descr", "desc");
54 setFieldValue(page, "document.newMaintainableObject.add.dateEntries.holidayDescr", "desc");
55 setFieldValue(page, "document.newMaintainableObject.add.dateEntries.holidayDate", "7/4/2011");
56 setFieldValue(page, "document.newMaintainableObject.add.dateEntries.holidayHours", "8");
57 HtmlElement element = page.getElementByName("methodToCall.route");
58 HtmlPage nextPage = element.click();
59 Assert.assertTrue("Page was submitted successfully", nextPage.asText().contains("submitted"));
60
61 }
62
63
64 }