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