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.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  		//look up a work area
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  		//submit a changed work area
44  	  	setFieldValue(positionMaintPage, "document.documentHeader.documentDescription", "Position workArea - test");
45  		HtmlInput workAreaText = HtmlUnitUtil.getInputContainingText(positionMaintPage, "id=\"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  		//look up the changed work area
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  		//test the work area inquiry from the position page note that this returns the first work area in tk_work_area_t in all cases for now -- see KPME-1219
65  		HtmlPage workAreaInquiryPage = HtmlUnitUtil.clickAnchorContainingText(resultPage, "workarea", "1000");
66  		HtmlUnitUtil.createTempFile(workAreaInquiryPage);
67  		Assert.assertTrue("Inquiry page text contains:\n" + "WorkArea Inquiry", workAreaInquiryPage.asText().contains("WorkArea Inquiry"));
68  		//first work area in tk-test -- see comment above for this test
69  		Assert.assertTrue("Inquiry page text contains:\n" + "First work area in tk-test", workAreaInquiryPage.asText().contains("1000"));
70  		
71  	}
72  	
73  }