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.paygrade.validation;
17  
18  import junit.framework.Assert;
19  
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.HtmlForm;
27  import com.gargoylesoftware.htmlunit.html.HtmlInput;
28  import com.gargoylesoftware.htmlunit.html.HtmlPage;
29  
30  public class PayGradeValidationTest extends KPMETestCase{
31  	@Test
32  	public void testValidateSalGroup() throws Exception {
33  		String baseUrl = TkTestConstants.Urls.PAY_GRADE_MAINT_NEW_URL;
34  	  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
35  	  	Assert.assertNotNull(page);
36  	 
37  	  	HtmlForm form = page.getFormByName("KualiForm");
38  	  	Assert.assertNotNull("Search form was missing from page.", form);
39  	  	
40  	  	setFieldValue(page, "document.documentHeader.documentDescription", "Pay Grade - test");
41  	    setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2012");
42  	    setFieldValue(page, "document.newMaintainableObject.payGrade", "test");
43  	    setFieldValue(page, "document.newMaintainableObject.salGroup", "testSG");	//nonexisting salary group
44  	    setFieldValue(page, "document.newMaintainableObject.description", "test");	
45  	  	
46  	  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
47  	  	Assert.assertNotNull("Could not locate submit button", input);
48  	  	HtmlElement element = page.getElementByName("methodToCall.route");
49  	  	page = element.click();
50  	  	HtmlUnitUtil.createTempFile(page);
51  	  	Assert.assertTrue("page text contains:\n" + "'testSG' does not exist", page.asText().contains("'testSG' does not exist"));
52  	  	
53  	  	setFieldValue(page, "document.newMaintainableObject.salGroup", "SD1");	//existing salary group
54  	  	element = page.getElementByName("methodToCall.route");
55  	  	page = element.click();
56  	  	Assert.assertFalse("page text contains: error", page.asText().contains("error"));
57  	  	Assert.assertTrue("New Pay grade successfully submitted.", page.asText().contains("Document was successfully submitted"));
58  	}
59  	
60  }