1
2
3
4
5
6
7
8
9
10
11
12
13
14
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");
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");
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 }