001 /** 002 * Copyright 2004-2012 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(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 Assert.assertTrue("Could not find text 'Work Area Description:' in page.", StringUtils.contains(page.asText(), "Work Area Description:")); 041 042 HtmlForm form = page.getFormByName("KualiForm"); 043 Assert.assertNotNull("Search form was missing from page.", form); 044 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.search"); 045 Assert.assertNotNull("Could not locate search submit button", input); 046 page = (HtmlPage) input.click(); 047 Assert.assertNotNull("Page not returned from click.", page); 048 HtmlUnitUtil.createTempFile(page); 049 Assert.assertTrue("Expected 6 result.", StringUtils.contains(page.asText(), "6 items retrieved")); 050 051 setFieldValue(page, "workArea", "30"); 052 HtmlPage searchPage = HtmlUnitUtil.clickInputContainingText(page, "search"); 053 Assert.assertTrue("Expected 1 result.", StringUtils.contains(searchPage.asText(), "One item retrieved")); 054 Assert.assertTrue("Could not find text 'SDR1 Work Area' in page.", StringUtils.contains(searchPage.asText(), "SDR1 Work Area")); 055 056 } 057 }