1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.core.calendar;
17
18
19 import org.junit.Assert;
20 import org.junit.Test;
21 import org.kuali.hr.KPMEWebTestCase;
22 import org.kuali.hr.util.HtmlUnitUtil;
23 import org.kuali.kpme.core.FunctionalTest;
24 import org.kuali.kpme.core.util.HrTestConstants;
25
26 import com.gargoylesoftware.htmlunit.html.HtmlElement;
27 import com.gargoylesoftware.htmlunit.html.HtmlForm;
28 import com.gargoylesoftware.htmlunit.html.HtmlInput;
29 import com.gargoylesoftware.htmlunit.html.HtmlPage;
30
31 @FunctionalTest
32 public class CalendarMaintTest extends KPMEWebTestCase {
33
34 public static final String TEST_USER = "admin";
35 private static final String CAL_NAME_REQUIRED = "Calendar Name (Calendar Name) is a required field.";
36 private static final String CAL_DESP_REQUIRED = "Calendar Description (Calendar Description) is a required field.";
37 private static final String CAL_TYPES_REQUIRED = "Calendar Type (Calendar Type) is a required field.";
38 private static final String FLSA_DAY_REQUIRED = "FLSA Begin Day is a required field.";
39 private static final String FLSA_TIME_REQUIRED = "FLSA Begin Time is a required field.";
40
41 @Test
42 public void testDisplayCalendarTypeRadioOptions() throws Exception {
43
44
45 HtmlPage calendarPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), HrTestConstants.Urls.CALENDAR_MAINT_URL);
46 HtmlPage resultPage = HtmlUnitUtil.clickInputContainingText(calendarPage, "search");
47 HtmlUnitUtil.createTempFile(resultPage);
48 Assert.assertTrue("Lookup page contains:\n" + "The both radio button is not present", resultPage.asText().contains("Both"));
49
50
51 HtmlPage calendarMaintPage = HtmlUnitUtil.clickAnchorContainingText(resultPage, "edit");
52 HtmlUnitUtil.createTempFile(calendarMaintPage);
53 Assert.assertFalse("Maintenance page contains:\n" + "The both radio button is present", calendarMaintPage.asText().contains("Both"));
54
55 }
56
57 @Test
58 public void testRequiredFields() throws Exception {
59 String baseUrl = HrTestConstants.Urls.CALENDAR_MAINT_NEW_URL;
60 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
61 Assert.assertNotNull(page);
62
63 HtmlForm form = page.getFormByName("KualiForm");
64 Assert.assertNotNull("Search form was missing from page.", form);
65
66 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
67 Assert.assertNotNull("Could not locate submit button", input);
68
69 HtmlElement element = page.getElementByName("methodToCall.route");
70 page = element.click();
71 Assert.assertFalse("page text contains: Incident Report", page.asText().contains("Incident Report"));
72 Assert.assertTrue("page text does not contain:\n" + CAL_NAME_REQUIRED, page.asText().contains(CAL_NAME_REQUIRED));
73 Assert.assertTrue("page text does not contain:\n" + CAL_DESP_REQUIRED, page.asText().contains(CAL_DESP_REQUIRED));
74 Assert.assertTrue("page text does not contain:\n" + CAL_TYPES_REQUIRED, page.asText().contains(CAL_TYPES_REQUIRED));
75 Assert.assertFalse("page text contains:\n" + FLSA_DAY_REQUIRED, page.asText().contains(FLSA_DAY_REQUIRED));
76 Assert.assertFalse("page text contains:\n" + FLSA_TIME_REQUIRED, page.asText().contains(FLSA_TIME_REQUIRED));
77
78 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.calendarName", "testCal");
79 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.calendarDescriptions", "testDes");
80
81 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.calendarTypesLeave", "on");
82 page = ((HtmlElement)page.getElementByName("methodToCall.route")).click();
83 Assert.assertFalse("page text contains:\n" + FLSA_DAY_REQUIRED, page.asText().contains(FLSA_DAY_REQUIRED));
84 Assert.assertFalse("page text contains:\n" + FLSA_TIME_REQUIRED, page.asText().contains(FLSA_TIME_REQUIRED));
85
86
87 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.calendarTypesPay", "on");
88 page = ((HtmlElement)page.getElementByName("methodToCall.route")).click();
89 Assert.assertTrue("page text does not contain:\n" + FLSA_DAY_REQUIRED, page.asText().contains(FLSA_DAY_REQUIRED));
90 Assert.assertTrue("page text does not contain:\n" + FLSA_TIME_REQUIRED, page.asText().contains(FLSA_TIME_REQUIRED));
91 }
92 }