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