View Javadoc
1   /**
2    * Copyright 2004-2014 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.daily;
17  
18  
19  import org.apache.log4j.Logger;
20  import org.junit.Assert;
21  import org.junit.Test;
22  import org.kuali.hr.KPMEWebTestCase;
23  import org.kuali.hr.util.HtmlUnitUtil;
24  import org.kuali.kpme.core.FunctionalTest;
25  import org.kuali.kpme.tklm.utils.TkTestConstants;
26  
27  import com.gargoylesoftware.htmlunit.html.HtmlInput;
28  import com.gargoylesoftware.htmlunit.html.HtmlPage;
29  
30  @FunctionalTest
31  public class DailyOvertimeRuleMaintenanceTest extends KPMEWebTestCase{
32      private static final Logger LOG = Logger.getLogger(DailyOvertimeRuleMaintenanceTest.class);
33  	private static final String TEST_CODE="BL";		
34  	private static String TEST_CODE_INVALID_DEPT_ID ="INVALID";
35  	private static Long TEST_CODE_INVALID_TASK_ID =-1L;
36  	private static Long TEST_CODE_INVALID_WORK_AREA_ID =-1L;	
37  	private static String dailyOvertimeRuleId = "5";
38  	
39  	@Test
40  	public void testDailyOvertimeRuleMaintForErrorMessages() throws Exception {
41  		HtmlPage maintPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.DAILY_OVERTIME_RULE_MAINT_NEW_URL);
42  
43  		HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
44  				maintPage, "* Document Description");
45  		inputForDescription.setValueAttribute("Test_Description");
46  		
47  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.effectiveDate", "01/01/2010");
48  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.groupKeyCode", "IU-IN");
49  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.paytype", "HR");
50  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.dept", TEST_CODE_INVALID_DEPT_ID);
51  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.workArea", TEST_CODE_INVALID_WORK_AREA_ID.toString());
52  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.maxGap", "1.0");
53  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.minHours", "2");
54  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.earnCode", "OVT");
55  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.fromEarnGroup", "RGN");
56  		
57  		HtmlPage resultantPageAfterEdit = HtmlUnitUtil
58  				.clickInputContainingText(maintPage, "submit");
59  		LOG.debug(resultantPageAfterEdit.asText());
60  		Assert.assertTrue("Maintenance Page contains test deptErrormessage",
61  				resultantPageAfterEdit.asText().contains(
62  						"The specified department '"
63  								+ TEST_CODE_INVALID_DEPT_ID
64  								+ "' does not exist."));
65  		
66  		// test Convert from EarnCodeGroup has overtime earn codes error
67  		HtmlUnitUtil.setFieldValue(resultantPageAfterEdit, "document.newMaintainableObject.fromEarnGroup", "OVT");
68  		HtmlPage finalPage = HtmlUnitUtil.clickInputContainingText(resultantPageAfterEdit, "submit");
69  		Assert.assertTrue("Maintenance Page should contains EarnCodeGroup has overtime earn code error",
70  				finalPage.asText().contains("Earn Group 'OVT' has overtime earn codes."));
71  		
72  	}
73  
74  }