001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.krad.demo.travel.application; 017 018import org.kuali.rice.krad.demo.ViewDemoAftBase; 019import org.junit.Test; 020 021/** 022 * @author Kuali Rice Team (rice.collab@kuali.org) 023 */ 024public class DemoTravelCompanyLookUpAft extends ViewDemoAftBase { 025 026 /** 027 * /kr-krad/lookup?methodToCall=start&dataObjectClassName=edu.sampleu.travel.dataobject.TravelCompany 028 */ 029 public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&dataObjectClassName=edu.sampleu.travel.dataobject.TravelCompany"; 030 031 /** 032 * Search 033 */ 034 public static final String SEARCH = "Search"; 035 036 /** 037 * Clear Values 038 */ 039 public static final String CLEAR_VALUES = "Clear Values"; 040 041 /** 042 * lookupCriteria[travelCompanyId] 043 */ 044 public static final String TRAVEL_COMPANY_ID = "lookupCriteria[travelCompanyId]"; 045 046 /** 047 * lookupCriteria[travelCompanyName] 048 */ 049 public static final String TRAVEL_COMPANY_NAME = "lookupCriteria[travelCompanyName]"; 050 051 @Override 052 public String getBookmarkUrl() { 053 return BOOKMARK_URL; 054 } 055 056 @Override 057 protected void navigate() throws Exception { 058 waitAndClickDemoLink(); 059 waitAndClickByLinkText("Travel Company Lookup"); 060 } 061 062 protected void testTravelCompanyLookUp() throws Exception { 063 waitAndTypeByName(TRAVEL_COMPANY_ID,"1"); 064 waitAndTypeByName(TRAVEL_COMPANY_NAME,"a*"); 065 waitAndClickButtonByText(SEARCH); 066 waitForTextPresent("No values match this search."); 067 waitForTextPresent("You have entered the primary key for this table (Id) in the search criteria. Since these fields can be used to uniquely identify a row in this table, the other search criteria entered will be ignored."); 068 waitAndClickButtonByText(CLEAR_VALUES); 069 waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='Y']"); 070 waitAndClickButtonByText(SEARCH); 071 String activeResults [] ={"10000","Value Rentals","true"}; 072 Thread.sleep(1000); //Required as the below method "only waits for first element" in array. Here first element gets loaded and second takes a while. 073 assertTextPresent(activeResults); 074 waitAndClickButtonByText(CLEAR_VALUES); 075 waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='N']"); 076 waitAndClickButtonByText(SEARCH); 077 String activeResultsNo [] ={"10001","AAA Travel","false"}; 078 Thread.sleep(1000); //Required as the below method "only waits for first element" in array. Here first element gets loaded and second takes a while. 079 assertTextPresent(activeResultsNo); 080 } 081 082 @Test 083 public void testTravelCompanyLookUpBookmark() throws Exception { 084 testTravelCompanyLookUp(); 085 passed(); 086 } 087 088 @Test 089 public void testTravelCompanyLookUpNav() throws Exception { 090 testTravelCompanyLookUp(); 091 passed(); 092 } 093}