1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.position;
17
18 import org.junit.Assert;
19 import org.junit.Test;
20 import org.kuali.hr.test.KPMETestCase;
21 import org.kuali.hr.time.test.HtmlUnitUtil;
22 import org.kuali.hr.time.test.TkTestConstants;
23
24 import com.gargoylesoftware.htmlunit.html.HtmlInput;
25 import com.gargoylesoftware.htmlunit.html.HtmlPage;
26
27 public class PositionTest extends KPMETestCase {
28
29 public static final String TEST_USER = "admin";
30
31
32 @Test
33 public void testPositionMaintWorkAreaSave() throws Exception {
34
35 HtmlPage positionLookup = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.POSITION_MAINT_URL);
36 HtmlPage resultPage = HtmlUnitUtil.clickInputContainingText(positionLookup, "search");
37
38
39 HtmlPage positionMaintPage = HtmlUnitUtil.clickAnchorContainingText(resultPage, "edit", "2085");
40 HtmlUnitUtil.createTempFile(positionMaintPage);
41 Assert.assertTrue("Maintenance page contains:\n" + "Work area for Position 2085 is 1003", positionMaintPage.asText().contains("1003"));
42
43
44 setFieldValue(positionMaintPage, "document.documentHeader.documentDescription", "Position workArea - test");
45 HtmlInput workAreaText = HtmlUnitUtil.getInputContainingText(positionMaintPage, "document.newMaintainableObject.workArea");
46 workAreaText.setValueAttribute("30");
47 HtmlPage outputPage = HtmlUnitUtil.clickInputContainingText(positionMaintPage, "submit");
48 HtmlUnitUtil.createTempFile(outputPage);
49 Assert.assertTrue("Maintenance page text contains:\n" + "Document was successfully submitted", outputPage.asText().contains("Document was successfully submitted"));
50 Assert.assertTrue("Maintenance page contains:\n" + "Work area changed to 30", outputPage.asText().contains("30"));
51
52
53 HtmlPage fetchedPositionMaintPage = HtmlUnitUtil.clickAnchorContainingText(resultPage, "edit", "2085");
54 HtmlUnitUtil.createTempFile(fetchedPositionMaintPage);
55 Assert.assertTrue("Fetched maintenance page now contains:\n" + "Work area for Position 2085 is 30", fetchedPositionMaintPage.asText().contains("30"));
56 }
57
58 @Test
59 public void testPositionMaintWorkAreaInquiry() throws Exception {
60
61 HtmlPage positionLookup = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.POSITION_MAINT_URL);
62 HtmlPage resultPage = HtmlUnitUtil.clickInputContainingText(positionLookup, "search");
63
64
65 HtmlPage workAreaInquiryPage = HtmlUnitUtil.clickAnchorContainingText(resultPage, "workarea", "1009");
66 HtmlUnitUtil.createTempFile(workAreaInquiryPage);
67 Assert.assertTrue("Inquiry page text contains:\n" + "WorkArea Inquiry", workAreaInquiryPage.asText().contains("WorkArea Inquiry"));
68
69 Assert.assertTrue("Inquiry page text contains:\n" + "First work area in tk-test", workAreaInquiryPage.asText().contains("30"));
70
71 }
72
73 }