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.workschedule;
17  
18  import org.junit.Assert;
19  import org.junit.Ignore;
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.HtmlInput;
26  import com.gargoylesoftware.htmlunit.html.HtmlPage;
27  
28  @Ignore
29  public class WorkScheduleMaintTest extends KPMETestCase{
30  	
31  	private static final String TEST_CODE = "test-schedule";		
32  		
33  	private static String TEST_CODE_DEPT_INVALID = "INVALID";
34  	private static Long TEST_CODE_WORKAREA_INVALID = -1L;
35  	
36  	private static Long workScheduleWithInvalidDept = 11L;
37  	private static Long workScheduleIdWithInvalidWorkArea = 12L;
38  
39  	/**
40  	 * Test to check whether it is showing error message for Department on maintenance screen
41  	 * if we supply non exist deptId
42  	 * 
43  	 * @throws Exception
44  	 */
45  	@Test
46  	@Ignore
47  	public void testworkScheduleMaintForDeptErrorMessage()
48  			throws Exception {
49  		HtmlPage workScheduleLookUp = HtmlUnitUtil
50  				.gotoPageAndLogin(TkTestConstants.Urls.WORK_SCHEDULE_MAINT_URL);
51  		workScheduleLookUp = HtmlUnitUtil.clickInputContainingText(
52  				workScheduleLookUp, "search");
53  		Assert.assertTrue("Page contains test workSchedule",
54  				workScheduleLookUp.asText().contains(TEST_CODE));
55  		HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(
56  				workScheduleLookUp, "edit",
57  				workScheduleWithInvalidDept.toString());
58  		HtmlInput inputForDept = HtmlUnitUtil.getInputContainingText(maintPage,
59  				TEST_CODE_DEPT_INVALID);
60  		inputForDept.setValueAttribute(TEST_CODE_DEPT_INVALID);
61  		HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
62  				maintPage, "* Document Description");
63  		inputForDescription.setValueAttribute("Description");
64  		HtmlPage resultantPageAfterEdit = HtmlUnitUtil
65  				.clickInputContainingText(maintPage, "submit");		
66  		Assert.assertTrue("Maintenance Page contains error message for dept",
67  				resultantPageAfterEdit.asText().contains(
68  						"The specified department '" + TEST_CODE_DEPT_INVALID
69  								+ "' does not exist."));
70  	}
71  
72  	/**
73  	 * Test to check whether it is showing error message for WorkArea on maintenance screen
74  	 * if we supply non exist workArea
75  	 * 
76  	 * @throws Exception
77  	 */
78  	@Test
79  	public void testWorkScheduleMaintForWorkAreaErrorMessage()
80  			throws Exception {
81  		HtmlPage workScheduleLookUp = HtmlUnitUtil
82  				.gotoPageAndLogin(TkTestConstants.Urls.WORK_SCHEDULE_MAINT_URL);
83  		workScheduleLookUp = HtmlUnitUtil.clickInputContainingText(
84  				workScheduleLookUp, "search");
85  		Assert.assertTrue("Page contains test workSchedule",
86  				workScheduleLookUp.asText().contains(TEST_CODE));
87  		HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(
88  				workScheduleLookUp, "edit",
89  				workScheduleIdWithInvalidWorkArea.toString());
90  		HtmlInput inputForWorkArea = HtmlUnitUtil.getInputContainingText(maintPage,
91  				Long.toString(TEST_CODE_WORKAREA_INVALID));
92  		inputForWorkArea.setValueAttribute(Long.toString(TEST_CODE_WORKAREA_INVALID));
93  		HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
94  				maintPage, "* Document Description");
95  		inputForDescription.setValueAttribute("Description");
96  		HtmlPage resultantPageAfterEdit = HtmlUnitUtil
97  				.clickInputContainingText(maintPage, "submit");		
98  		Assert.assertTrue("Maintenance Page contains contains error message for workarea",
99  				resultantPageAfterEdit.asText().contains(
100 						"The specified workarea '" + TEST_CODE_WORKAREA_INVALID
101 								+ "' does not exist."));
102 	}
103 
104 	@Test
105 	public void testWorkScheduleRuleMaint() throws Exception {
106 		HtmlPage workScheduleLookUp = HtmlUnitUtil
107 				.gotoPageAndLogin(TkTestConstants.Urls.WORK_SCHEDULE_MAINT_URL);
108 		workScheduleLookUp = HtmlUnitUtil.clickInputContainingText(
109 				workScheduleLookUp, "search");
110 		Assert.assertTrue("Page contains test workSchedule",
111 				workScheduleLookUp.asText().contains(
112 						TEST_CODE.toString()));
113 		HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(
114 				workScheduleLookUp, "edit",
115 				workScheduleWithInvalidDept.toString());
116 		Assert.assertTrue("Maintenance Page contains test WorkSchedule ",
117 				maintPage.asText().contains(TEST_CODE.toString()));
118 	}
119 }