001 /**
002 * Copyright 2004-2013 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.paycalendar.validation;
017
018 import org.junit.Assert;
019 import org.junit.Ignore;
020 import org.junit.Test;
021 import org.kuali.hr.test.KPMETestCase;
022 import org.kuali.hr.time.test.HtmlUnitUtil;
023 import org.kuali.hr.time.test.TkTestConstants;
024
025 import com.gargoylesoftware.htmlunit.html.HtmlElement;
026 import com.gargoylesoftware.htmlunit.html.HtmlPage;
027 import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
028
029 public class PayCalendarEntriesMaintenaceTest extends KPMETestCase {
030 @Override
031 public void setUp() throws Exception {
032 super.setUp();
033 }
034
035 @Override
036 public void tearDown() throws Exception {
037 super.tearDown();
038 }
039
040 @Test
041 @Ignore
042 // ignorning for now. page changed to not have text field for calendarName, only lookup...
043 //tests PayCalendarEntriesRule
044 public void testSubmitPayCalendarEntriesMaint() throws Exception {
045 //String baseUrl = HtmlUnitUtil.getBaseURL() + "/kr/maintenance.do?businessObjectClassName=org.kuali.hr.time.paycalendar.PayCalendarEntries&methodToCall=start";
046 String baseUrl = TkTestConstants.Urls.PAY_CALENDAR_ENTRIES_MAINT_NEW_URL;
047 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
048 Assert.assertNotNull(page);
049
050 HtmlTextInput text = (HtmlTextInput) page.getHtmlElementById("document.documentHeader.documentDescription");
051 text.setValueAttribute("test");
052 HtmlUnitUtil.createTempFile(page);
053 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "calendarName");
054 text.setValueAttribute("TTT"); // set an invalid pay calendar
055 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "beginPeriodDate");
056 text.setValueAttribute("02/21/2011");
057 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "beginPeriodTime");
058 text.setValueAttribute("08:00 am");
059 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "endPeriodDate");
060 text.setValueAttribute("02/28/2011");
061 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "endPeriodTime");
062 text.setValueAttribute("08:00 am");
063 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchInitiateDate");
064 text.setValueAttribute("02/16/2011");
065 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchInitiateTime");
066 text.setValueAttribute("08:00 am");
067 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEndPayPeriodDate");
068 text.setValueAttribute("02/21/2011");
069 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEndPayPeriodTime");
070 text.setValueAttribute("08:00 am");
071 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEmployeeApprovalDate");
072 text.setValueAttribute("02/17/2011");
073 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEmployeeApprovalTime");
074 text.setValueAttribute("08:00 am");
075 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchSupervisorApprovalDate");
076 text.setValueAttribute("02/18/2011");
077 text = (HtmlTextInput) page.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchSupervisorApprovalTime");
078 text.setValueAttribute("08:00 am");
079
080 HtmlElement element = page.getElementByName("methodToCall.route");
081 HtmlPage page1 = element.click();
082 HtmlUnitUtil.createTempFile(page1);
083 // error for invalid pay calendar
084 Assert.assertTrue("Maintenance Page contains error messages", page1.asText().contains("You must specify a valid Calendar."));
085
086 text = (HtmlTextInput) page1.getHtmlElementById(TkTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "calendarName");
087 text.setValueAttribute("BW-CAL"); // set a valid pay calendar
088
089 element = page1.getElementByName("methodToCall.route");
090 HtmlPage page2 = element.click();
091 Assert.assertTrue("Maintenance page is submitted successfully", page2.asText().contains("Document was successfully submitted."));
092 Assert.assertTrue("Maintenance page is submitted successfully", page2.asText().contains("Status: FINAL"));
093 }
094 }