View Javadoc

1   /**
2    * Copyright 2004-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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;//id entered in the bootstrap SQL
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  }