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(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 }