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