View Javadoc
1   /**
2    * Copyright 2004-2015 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.overtime.weekly;
17  
18  import org.junit.Assert;
19  import org.junit.Test;
20  import org.kuali.hr.util.HtmlUnitUtil;
21  import org.kuali.kpme.core.FunctionalTest;
22  
23  import com.gargoylesoftware.htmlunit.html.HtmlElement;
24  import com.gargoylesoftware.htmlunit.html.HtmlForm;
25  import com.gargoylesoftware.htmlunit.html.HtmlInput;
26  import com.gargoylesoftware.htmlunit.html.HtmlPage;
27  
28  
29  @FunctionalTest
30  public class WeeklyOvertimeRuleGroupMaintenanceTest extends WeeklyOvertimeRuleMaintenanceTest {
31  
32  	protected static final String OVERTIME_EARN_GROUP="OVT";
33  	@Test
34  	//tests WeeklyOvertimeRuleValidation
35  	public void testSubmitWeeklyOvertimeRuleGroupMaint() throws Exception {
36      	String baseUrl = getBaseURL() + "/kr/maintenance.do?businessObjectClassName=org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRuleGroup&methodToCall=edit";
37      	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
38      	Assert.assertNotNull(page);
39  
40      	HtmlForm form = page.getFormByName("KualiForm");
41      	Assert.assertNotNull("Search form was missing from page.", form);
42  
43      	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
44      	Assert.assertNotNull("Could not locate submit button", input);
45      	HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "test");
46  		HtmlElement element = page.getElementByName("methodToCall.route");
47          HtmlPage finalPage = element.click();
48          //HtmlUnitUtil.createTempFile(finalPage, "final");
49          Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified maxHoursEarnGroup '" + TEST_CODE + "' does not exist."));
50          Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified convertFromEarnGroup '" + TEST_CODE + "' does not exist."));
51          Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified convertToEarnCode '" + TEST_CODE + "' does not exist."));
52  
53  		HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.effectiveDate", "4/01/2011");
54  		HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHoursEarnGroup", "REG");
55  		HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertFromEarnGroup", "REG");
56          HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.applyToEarnGroup", "REG");
57  		HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertToEarnCode", OVERTIME_EARN_GROUP);
58  		HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHours", "5");
59  		HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.step", "10");
60          element = (HtmlElement)page.getElementById("methodToCall.addLine.lstWeeklyOvertimeRules.(!!org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRule!!)");
61          Assert.assertNotNull("Missing Add Line button", element);
62  
63          HtmlPage addPage = element.click();
64          //HtmlUnitUtil.createTempFile(addPage, "worgmt");
65  
66          Assert.assertTrue("Maintenance Page contains error messages",addPage.asText().contains("Rule already exists for step '10'."));
67  	}
68  
69  }