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.core.task;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.junit.Assert;
020 import org.junit.Test;
021 import org.kuali.hr.KPMEWebTestCase;
022 import org.kuali.hr.util.HtmlUnitUtil;
023 import org.kuali.kpme.core.FunctionalTest;
024 import org.kuali.kpme.core.util.HrTestConstants;
025
026 import com.gargoylesoftware.htmlunit.html.HtmlForm;
027 import com.gargoylesoftware.htmlunit.html.HtmlInput;
028 import com.gargoylesoftware.htmlunit.html.HtmlPage;
029
030 @FunctionalTest
031 public class TaskMaintenanceTest extends KPMEWebTestCase {
032
033 @Test
034 public void testLookup() throws Exception{
035 String baseUrl = HrTestConstants.Urls.TASK_MAINT_URL;
036 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
037 Assert.assertNotNull(page);
038 Assert.assertTrue("Could not find text 'Task Lookup' in page.", StringUtils.contains(page.asText(), "Task Lookup"));
039 Assert.assertTrue("Could not find text 'Task:' in page.", StringUtils.contains(page.asText(), "Task:"));
040 Assert.assertTrue("Could not find text 'Description:' in page.", StringUtils.contains(page.asText(), "Description:"));
041 Assert.assertTrue("Could not find text 'Work Area:' in page.", StringUtils.contains(page.asText(), "Work Area:"));
042
043 HtmlForm form = page.getFormByName("KualiForm");
044 Assert.assertNotNull("Search form was missing from page.", form);
045 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.search");
046 Assert.assertNotNull("Could not locate search submit button", input);
047 page = (HtmlPage) input.click();
048 Assert.assertNotNull("Page not returned from click.", page);
049 HtmlUnitUtil.createTempFile(page);
050 Assert.assertTrue("Expected 6 result.", StringUtils.contains(page.asText(), "6 items retrieved"));
051
052 HtmlUnitUtil.setFieldValue(page, "workArea", "30");
053 HtmlPage searchPage = HtmlUnitUtil.clickInputContainingText(page, "search");
054 Assert.assertTrue("Expected 1 result.", StringUtils.contains(searchPage.asText(), "One item retrieved"));
055 Assert.assertTrue("Could not find text 'SDR1 task' in page.", StringUtils.contains(searchPage.asText(), "SDR1 task"));
056
057 }
058 }