View Javadoc

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