1
2
3
4
5
6
7
8
9
10
11
12
13
14
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(getWebClient(), 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
41 HtmlForm form = page.getFormByName("KualiForm");
42 Assert.assertNotNull("Search form was missing from page.", form);
43 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.search");
44 Assert.assertNotNull("Could not locate search submit button", input);
45 page = (HtmlPage) input.click();
46 Assert.assertNotNull("Page not returned from click.", page);
47 HtmlUnitUtil.createTempFile(page);
48 Assert.assertTrue("Expected 6 result.", StringUtils.contains(page.asText(), "6 items retrieved"));
49
50 setFieldValue(page, "workArea", "30");
51 HtmlPage searchPage = HtmlUnitUtil.clickInputContainingText(page, "search");
52 Assert.assertTrue("Expected 1 result.", StringUtils.contains(searchPage.asText(), "One item retrieved"));
53 Assert.assertTrue("Could not find text 'SDR1 task' in page.", StringUtils.contains(searchPage.asText(), "SDR1 task"));
54
55 }
56 }