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.core.task;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.junit.Assert;
20  import org.junit.Test;
21  import org.kuali.hr.KPMEWebTestCase;
22  import org.kuali.hr.util.HtmlUnitUtil;
23  import org.kuali.kpme.core.FunctionalTest;
24  import org.kuali.kpme.core.util.HrTestConstants;
25  
26  import com.gargoylesoftware.htmlunit.html.HtmlForm;
27  import com.gargoylesoftware.htmlunit.html.HtmlInput;
28  import com.gargoylesoftware.htmlunit.html.HtmlPage;
29  
30  @FunctionalTest
31  public class TaskMaintenanceTest extends KPMEWebTestCase {
32  	
33  	@Test
34      public void testLookup() throws Exception{
35      	String baseUrl = HrTestConstants.Urls.TASK_MAINT_URL;	
36      	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
37      	Assert.assertNotNull(page);
38      	Assert.assertTrue("Could not find text 'Task Lookup' in page.", StringUtils.contains(page.asText(), "Task Lookup"));
39      	Assert.assertTrue("Could not find text 'Task:' in page.", StringUtils.contains(page.asText(), "Task:"));
40      	Assert.assertTrue("Could not find text 'Description:' in page.", StringUtils.contains(page.asText(), "Description:"));
41      	Assert.assertTrue("Could not find text 'Work Area:' in page.", StringUtils.contains(page.asText(), "Work Area:"));
42  
43      	HtmlForm form = page.getFormByName("KualiForm");
44      	Assert.assertNotNull("Search form was missing from page.", form);
45      	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.search");
46      	Assert.assertNotNull("Could not locate search submit button", input);
47      	page = (HtmlPage) input.click();
48      	Assert.assertNotNull("Page not returned from click.", page);
49      	HtmlUnitUtil.createTempFile(page);
50      	Assert.assertTrue("Expected 6 result.", StringUtils.contains(page.asText(), "6 items retrieved"));
51      	
52      	HtmlUnitUtil.setFieldValue(page, "workArea", "30");
53      	HtmlPage searchPage = HtmlUnitUtil.clickInputContainingText(page, "search");
54      	Assert.assertTrue("Expected 1 result.", StringUtils.contains(searchPage.asText(), "One item retrieved"));
55      	Assert.assertTrue("Could not find text 'SDR1 task' in page.", StringUtils.contains(searchPage.asText(), "SDR1 task"));
56  
57     }
58  }