View Javadoc

1   /**
2    * Copyright 2004-2013 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.core.calendar;
17  
18  import org.junit.Assert;
19  import org.junit.Ignore;
20  import org.junit.Test;
21  import org.kuali.hr.KPMEWebTestCase;
22  import org.kuali.hr.util.HtmlUnitUtil;
23  import org.kuali.kpme.core.FunctionalTest;
24  import org.kuali.kpme.core.util.HrTestConstants;
25  
26  import com.gargoylesoftware.htmlunit.html.HtmlElement;
27  import com.gargoylesoftware.htmlunit.html.HtmlPage;
28  import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
29  
30  @FunctionalTest
31  public class PayCalendarEntriesMaintenaceTest extends KPMEWebTestCase {
32  	@Override
33  	public void setUp() throws Exception {
34  		super.setUp();
35  	}
36  	
37  	@Override
38  	public void tearDown() throws Exception {
39  		super.tearDown();
40  	}
41  	
42  	@Test
43      @Ignore
44      // ignorning for now.  page changed to not have text field for calendarName, only lookup...
45  	//tests PayCalendarEntriesRule
46  	public void testSubmitPayCalendarEntriesMaint() throws Exception {
47      	//String baseUrl = HtmlUnitUtil.getBaseURL() + "/kr/maintenance.do?businessObjectClassName=org.kuali.kpme.tklm.time.paycalendar.PayCalendarEntry&methodToCall=start";
48  		String baseUrl = HrTestConstants.Urls.PAY_CALENDAR_ENTRY_MAINT_NEW_URL;
49      	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
50      	Assert.assertNotNull(page);
51  
52  		HtmlTextInput text  = (HtmlTextInput) page.getHtmlElementById("document.documentHeader.documentDescription");
53  		text.setValueAttribute("test");
54  		HtmlUnitUtil.createTempFile(page);
55  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "calendarName");
56  		text.setValueAttribute("TTT");	// set an invalid pay calendar		
57  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "beginPeriodDate");
58  		text.setValueAttribute("02/21/2011");		
59  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "beginPeriodTime");
60  		text.setValueAttribute("08:00 am");		
61  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "endPeriodDate");
62  		text.setValueAttribute("02/28/2011");		
63  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "endPeriodTime");
64  		text.setValueAttribute("08:00 am");    
65  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchInitiateDate");
66  		text.setValueAttribute("02/16/2011");		
67  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchInitiateTime");
68  		text.setValueAttribute("08:00 am");		
69  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEndPayPeriodDate");
70  		text.setValueAttribute("02/21/2011");		
71  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEndPayPeriodTime");
72  		text.setValueAttribute("08:00 am"); 
73  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEmployeeApprovalDate");
74  		text.setValueAttribute("02/17/2011");		
75  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchEmployeeApprovalTime");
76  		text.setValueAttribute("08:00 am");
77  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchSupervisorApprovalDate");
78  		text.setValueAttribute("02/18/2011");		
79  		text  = (HtmlTextInput) page.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "batchSupervisorApprovalTime");
80  		text.setValueAttribute("08:00 am");
81  		
82  		HtmlElement element = page.getElementByName("methodToCall.route");
83          HtmlPage page1 = element.click();
84          HtmlUnitUtil.createTempFile(page1);
85  		// error for invalid pay calendar
86          Assert.assertTrue("Maintenance Page contains error messages", page1.asText().contains("You must specify a valid Calendar."));
87  
88  		text  = (HtmlTextInput) page1.getHtmlElementById(HrTestConstants.DOC_NEW_ELEMENT_ID_PREFIX + "calendarName");
89  		text.setValueAttribute("BW-CAL");	// set a valid pay calendar	
90          
91  		element = page1.getElementByName("methodToCall.route");
92          HtmlPage page2 = element.click();
93          Assert.assertTrue("Maintenance page is submitted successfully", page2.asText().contains("Document was successfully submitted."));
94          Assert.assertTrue("Maintenance page is submitted successfully", page2.asText().contains("Status: 	 FINAL"));
95  	}
96  }