View Javadoc

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