001 /** 002 * Copyright 2004-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.time.task.service; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.junit.Assert; 020 import org.junit.Test; 021 import org.kuali.hr.test.KPMETestCase; 022 import org.kuali.hr.time.test.HtmlUnitUtil; 023 import org.kuali.hr.time.test.TkTestConstants; 024 025 import com.gargoylesoftware.htmlunit.html.HtmlForm; 026 import com.gargoylesoftware.htmlunit.html.HtmlInput; 027 import com.gargoylesoftware.htmlunit.html.HtmlPage; 028 029 public class TaskLookupTest extends KPMETestCase { 030 031 @Test 032 public void testLookup() throws Exception{ 033 String baseUrl = TkTestConstants.Urls.TASK_MAINT_URL; 034 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl); 035 Assert.assertNotNull(page); 036 Assert.assertTrue("Could not find text 'Task Lookup' in page.", StringUtils.contains(page.asText(), "Task Lookup")); 037 Assert.assertTrue("Could not find text 'Task:' in page.", StringUtils.contains(page.asText(), "Task:")); 038 Assert.assertTrue("Could not find text 'Description:' in page.", StringUtils.contains(page.asText(), "Description:")); 039 Assert.assertTrue("Could not find text 'Work Area:' in page.", StringUtils.contains(page.asText(), "Work Area:")); 040 041 HtmlForm form = page.getFormByName("KualiForm"); 042 Assert.assertNotNull("Search form was missing from page.", form); 043 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.search"); 044 Assert.assertNotNull("Could not locate search submit button", input); 045 page = (HtmlPage) input.click(); 046 Assert.assertNotNull("Page not returned from click.", page); 047 HtmlUnitUtil.createTempFile(page); 048 Assert.assertTrue("Expected 6 result.", StringUtils.contains(page.asText(), "6 items retrieved")); 049 050 setFieldValue(page, "workArea", "30"); 051 HtmlPage searchPage = HtmlUnitUtil.clickInputContainingText(page, "search"); 052 Assert.assertTrue("Expected 1 result.", StringUtils.contains(searchPage.asText(), "One item retrieved")); 053 Assert.assertTrue("Could not find text 'SDR1 task' in page.", StringUtils.contains(searchPage.asText(), "SDR1 task")); 054 055 } 056 }