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