1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leave.web;
17
18 import com.gargoylesoftware.htmlunit.html.HtmlButton;
19 import com.gargoylesoftware.htmlunit.html.HtmlPage;
20 import junit.framework.Assert;
21 import org.junit.After;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.kuali.hr.lm.leavecalendar.LeaveCalendarDocument;
25 import org.kuali.hr.test.KPMETestCase;
26 import org.kuali.hr.time.calendar.CalendarEntries;
27 import org.kuali.hr.time.service.base.TkServiceLocator;
28 import org.kuali.hr.time.test.HtmlUnitUtil;
29 import org.kuali.hr.time.test.TkTestConstants;
30
31
32 public class LeaveCalendarWebTest extends KPMETestCase {
33 private String documentId;
34
35 @Before
36 public void setUp() throws Exception {
37 super.setUp();
38
39 CalendarEntries firstCalendarEntry = TkServiceLocator.getCalendarEntriesService().getCalendarEntries("202");
40 LeaveCalendarDocument firstLeaveCalendarDocument = TkServiceLocator.getLeaveCalendarService().openLeaveCalendarDocument("admin", firstCalendarEntry);
41 documentId = firstLeaveCalendarDocument.getDocumentId();
42
43 CalendarEntries secondCalendarEntry = TkServiceLocator.getCalendarEntriesService().getCalendarEntries("203");
44 TkServiceLocator.getLeaveCalendarService().openLeaveCalendarDocument("admin", secondCalendarEntry);
45
46 CalendarEntries thirdCalendarEntry = TkServiceLocator.getCalendarEntriesService().getCalendarEntries("204");
47 TkServiceLocator.getLeaveCalendarService().openLeaveCalendarDocument("admin", thirdCalendarEntry);
48 }
49
50 @After
51 public void tearDown() throws Exception {
52 super.tearDown();
53 }
54
55 @Test
56 public void testLeaveCalendarPage() throws Exception {
57
58 HtmlPage leaveCalendarPage = HtmlUnitUtil
59 .gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_CALENDAR_URL+"?documentId=" + documentId, true);
60 Assert.assertNotNull("Leave Request page not found" ,leaveCalendarPage);
61
62
63
64 Assert.assertTrue("Page does not have Current calendar ", leaveCalendarPage.asText().contains("March 2012"));
65
66
67 HtmlButton nextButton = (HtmlButton) leaveCalendarPage
68 .getElementById("nav_next_lc");
69 Assert.assertNotNull(nextButton);
70
71 HtmlPage page = nextButton.click();
72 Assert.assertNotNull(page);
73
74 synchronized (page) {
75 page.wait(5000);
76 }
77
78
79 HtmlButton prevButton = (HtmlButton) page
80 .getElementById("nav_prev_lc");
81 Assert.assertNotNull(prevButton);
82 page = prevButton.click();
83 Assert.assertNotNull(page);
84
85 }
86
87 }