1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.web.lookup;
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
24 import com.gargoylesoftware.htmlunit.html.HtmlForm;
25 import com.gargoylesoftware.htmlunit.html.HtmlInput;
26 import com.gargoylesoftware.htmlunit.html.HtmlPage;
27
28 public class ClockLocationRuleLookupTest extends KPMETestCase {
29
30 @Test
31 public void testLookup() throws Exception{
32 String baseUrl = HtmlUnitUtil.getBaseURL() + "/kr/lookup.do?__login_user=admin&methodToCall=start&businessObjectClassName=org.kuali.hr.time.clock.location.ClockLocationRule&returnLocation=" + HtmlUnitUtil.getBaseURL() + "/portal.do&hideReturnLink=true&docFormKey=88888888";
33 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
34 Assert.assertNotNull(page);
35 Assert.assertTrue("Could not find text 'Clock Location Rule Lookup' in page.", StringUtils.contains(page.asText(), "Clock Location Rule Lookup"));
36 HtmlForm form = page.getFormByName("KualiForm");
37 Assert.assertNotNull("Search form was missing from page.", form);
38
39 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.search");
40 Assert.assertNotNull("Could not locate search submit button", input);
41 page = (HtmlPage) input.click();
42 Assert.assertNotNull("Page not returned from click.", page);
43 HtmlUnitUtil.createTempFile(page);
44 Assert.assertTrue("Expected one result.", StringUtils.contains(page.asText(), "One item retrieved"));
45
46 page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
47 form = page.getFormByName("KualiForm");
48 Assert.assertNotNull("Search form was missing from page.", form);
49 HtmlUnitUtil.createTempFile(page);
50 form.getInputByName("dept").setValueAttribute("20");
51 input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.search");
52 Assert.assertNotNull("Could not locate search submit button", input);
53 page = (HtmlPage) input.click();
54 Assert.assertNotNull("Page not returned from click.", page);
55 Assert.assertTrue("Expected zero results.", StringUtils.contains(page.asText(), "No values match this search."));
56 }
57
58 }