001    /**
002     * Copyright 2004-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.hr.time.holidaycalendar;
017    
018    import org.junit.Assert;
019    import org.junit.Test;
020    import org.kuali.hr.test.KPMETestCase;
021    import org.kuali.hr.time.test.HtmlUnitUtil;
022    import org.kuali.hr.time.test.TkTestConstants;
023    
024    import com.gargoylesoftware.htmlunit.html.HtmlElement;
025    import com.gargoylesoftware.htmlunit.html.HtmlForm;
026    import com.gargoylesoftware.htmlunit.html.HtmlInput;
027    import com.gargoylesoftware.htmlunit.html.HtmlPage;
028    
029    public class HolidayCalendarTest extends KPMETestCase {
030    
031            private static Long holidayGroupId = 1L;//id entered in the bootstrap SQL
032            @Test
033            public void testHolidayCalendarMaintenancePage() throws Exception{
034                    HtmlPage earnCodeLookUp = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.HOLIDAY_CALENDAR_MAINT_URL);
035                    earnCodeLookUp = HtmlUnitUtil.clickInputContainingText(earnCodeLookUp, "search");
036                    Assert.assertTrue("Page contains REG entry", earnCodeLookUp.asText().contains("REG"));
037                    HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(earnCodeLookUp, "edit",holidayGroupId.toString());
038                    Assert.assertTrue("Maintenance Page contains REG entry",maintPage.asText().contains("REG"));
039            }
040    
041            @Test
042            public void testHolidayCalendarCreateNew() throws Exception {
043    
044            HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.HOLIDAY_CALENDAR_MAINT_NEW_URL);
045            Assert.assertNotNull(page);
046            HtmlForm form = page.getFormByName("KualiForm");
047            Assert.assertNotNull("Search form was missing from page.", form);
048            HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
049            Assert.assertNotNull("Could not locate submit button", input);
050    
051            setFieldValue(page, "document.documentHeader.documentDescription", "HolidayCalendar - test");
052            setFieldValue(page, "document.newMaintainableObject.holidayCalendarGroup", "TT");
053            setFieldValue(page, "document.newMaintainableObject.descr", "desc");
054            setFieldValue(page, "document.newMaintainableObject.add.dateEntries.holidayDescr", "desc");
055            setFieldValue(page, "document.newMaintainableObject.add.dateEntries.holidayDate", "7/4/2011");
056            setFieldValue(page, "document.newMaintainableObject.add.dateEntries.holidayHours", "8");
057            HtmlElement element = page.getElementByName("methodToCall.route");
058            HtmlPage nextPage = element.click();
059            Assert.assertTrue("Page was submitted successfully", nextPage.asText().contains("submitted"));
060    
061            }
062    
063    
064    }