View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }