1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.core.paygrade.validation;
17
18 import java.util.List;
19
20 import junit.framework.Assert;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.junit.Ignore;
24 import org.junit.Test;
25 import org.kuali.hr.KPMEWebTestCase;
26 import org.kuali.hr.util.HtmlUnitUtil;
27 import org.kuali.kpme.core.FunctionalTest;
28 import org.kuali.kpme.core.util.HrTestConstants;
29
30 import com.gargoylesoftware.htmlunit.html.FrameWindow;
31 import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
32 import com.gargoylesoftware.htmlunit.html.HtmlElement;
33 import com.gargoylesoftware.htmlunit.html.HtmlForm;
34 import com.gargoylesoftware.htmlunit.html.HtmlInput;
35 import com.gargoylesoftware.htmlunit.html.HtmlPage;
36
37 @FunctionalTest
38 public class PayGradeValidationTest extends KPMEWebTestCase {
39 @Ignore
40 @Test
41 public void testValidateSalGroup() throws Exception {
42 String baseUrl = HrTestConstants.Urls.PAY_GRADE_MAINT_NEW_URL;
43 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), HrTestConstants.BASE_URL, true);
44 page = HtmlUnitUtil.clickAnchorContainingText(page,"Maintenance");
45 HtmlUnitUtil.createTempFile(page);
46 page = HtmlUnitUtil.clickAnchorContainingText(page,"Pay Grade");
47 HtmlUnitUtil.createTempFile(page);
48 List<HtmlAnchor> anchors = page.getAnchors();
49 List<FrameWindow> frames = page.getFrames();
50 for (FrameWindow frame : frames) {
51 if (StringUtils.equals(frame.getName(), "iframeportlet")) {
52 page = frame.getEnclosingPage();
53 }
54 }
55 page.initialize();
56 page = HtmlUnitUtil.clickAnchorContainingText(page,"Create");
57
58 HtmlUnitUtil.createTempFile(page);
59 page.initialize();
60 Assert.assertNotNull(page);
61 frames = page.getFrames();
62 for (FrameWindow frame : frames) {
63 if (StringUtils.equals(frame.getName(), "iframeportlet")) {
64 page = frame.getEnclosingPage();
65 }
66 }
67 HtmlForm form = (HtmlForm) page.getElementById("kualiForm");
68
69
70
71
72
73
74 Assert.assertNotNull("Search form was missing from page.", form);
75
76 HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "Pay Grade - test");
77 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2012");
78 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.payGrade", "test");
79 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.salGroup", "testSG");
80 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.description", "test");
81
82 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
83 Assert.assertNotNull("Could not locate submit button", input);
84 HtmlElement element = page.getElementByName("methodToCall.route");
85 page = element.click();
86 HtmlUnitUtil.createTempFile(page);
87 Assert.assertTrue("page text contains:\n" + "'testSG' does not exist", page.asText().contains("'testSG' does not exist"));
88
89 HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.salGroup", "SD1");
90 element = page.getElementByName("methodToCall.route");
91 page = element.click();
92 Assert.assertFalse("page text contains: error", page.asText().contains("error"));
93 Assert.assertTrue("New Pay grade successfully submitted.", page.asText().contains("Document was successfully submitted"));
94 }
95
96 }