1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }