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.clock.log;
17  
18  import org.junit.Assert;
19  import org.junit.Test;
20  import org.kuali.hr.KPMEWebTestCase;
21  import org.kuali.hr.util.HtmlUnitUtil;
22  import org.kuali.kpme.core.FunctionalTest;
23  import org.kuali.kpme.tklm.utils.TkTestConstants;
24  
25  import com.gargoylesoftware.htmlunit.html.HtmlInput;
26  import com.gargoylesoftware.htmlunit.html.HtmlPage;
27  
28  @FunctionalTest
29  public class ClockLogMaintenanceTest extends KPMEWebTestCase{
30  	private static Long TEST_CODE_INVALID_TASK_ID =9999L;
31  	private static Long TEST_CODE_INVALID_WORK_AREA_ID =9999L;
32  	private static Long clockLogId = 1L;	
33  	
34  	@Test
35  	public void testClockLogMaint() throws Exception {
36  		HtmlPage clockLogLookUp = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.CLOCK_LOG_MAINT_URL);
37  		clockLogLookUp = HtmlUnitUtil.clickInputContainingText(clockLogLookUp, "search");
38  		Assert.assertTrue("Page contains test ClockLog", clockLogLookUp.asText().contains("TEST"));		
39  		HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(clockLogLookUp, "edit",clockLogId.toString());		
40  		Assert.assertTrue("Maintenance Page contains test ClockLog",maintPage.asText().contains("TEST"));		
41  	}
42  	
43  	@Test
44  	public void testClockLogMaintForErrorMessages() throws Exception {
45  		HtmlPage clockLogLookUp = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.CLOCK_LOG_MAINT_URL);
46  		clockLogLookUp = HtmlUnitUtil.clickInputContainingText(clockLogLookUp, "search");
47  		Assert.assertTrue("Page contains test ClockLog", clockLogLookUp.asText().contains("TEST"));		
48  		HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(clockLogLookUp, "edit",clockLogId.toString());		
49  		Assert.assertTrue("Maintenance Page contains test ClockLog",maintPage.asText().contains("TEST"));
50  		
51  		HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
52  				maintPage, "* Document Description");
53  		inputForDescription.setValueAttribute("Test_Description");
54  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.workArea", TEST_CODE_INVALID_WORK_AREA_ID.toString());
55  		HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.task", TEST_CODE_INVALID_TASK_ID.toString());
56  		HtmlPage resultantPageAfterEdit = HtmlUnitUtil
57  				.clickInputContainingText(maintPage, "submit");
58  		HtmlUnitUtil.createTempFile(resultantPageAfterEdit);
59  		
60  		Assert.assertTrue("Maintenance Page contains test Workarea ",
61  				resultantPageAfterEdit.asText().contains(
62  						"The specified Workarea '"
63  								+ TEST_CODE_INVALID_WORK_AREA_ID
64  								+ "' does not exist."));
65  		
66  		HtmlUnitUtil.createTempFile(resultantPageAfterEdit);
67  		
68  		Assert.assertTrue("Maintenance Page contains test Task ",
69  				resultantPageAfterEdit.asText().contains(
70  						"The specified Task '"
71  								+ TEST_CODE_INVALID_TASK_ID
72  								+ "' does not exist."));
73  		
74  		
75  	}
76  	
77  }