View Javadoc
1   /**
2    * Copyright 2005-2014 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.rice.krad.demo.travel.application;
17  
18  import org.kuali.rice.krad.demo.ViewDemoAftBase;
19  import org.junit.Test;
20  
21  /**
22   * @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  public class DemoTravelDestinationLookUpAft extends ViewDemoAftBase {
25  
26      /**
27       * /kr-krad/lookup?methodToCall=start&dataObjectClassName=edu.sampleu.travel.dataobject.TravelDestination
28       */
29      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&dataObjectClassName=edu.sampleu.travel.dataobject.TravelDestination";
30  
31      /**
32       * Search
33       */
34      public static final String SEARCH = "Search";
35      
36      /**
37       * Clear Values
38       */
39      public static final String CLEAR_VALUES = "Clear Values";
40  
41      /**
42       * lookupCriteria[travelDestinationId]
43       */
44      public static final String DESTINATION_ID = "lookupCriteria[travelDestinationId]";
45  
46      /**
47       * lookupCriteria[travelDestinationName]
48       */
49      public static final String DESTINATION_NAME = "lookupCriteria[travelDestinationName]";
50      
51      @Override
52      public String getBookmarkUrl() {
53          return BOOKMARK_URL;
54      }
55  
56      @Override
57      protected void navigate() throws Exception {
58          waitAndClickDemoLink();
59          waitAndClickByLinkText("Travel Destination Lookup");
60      }
61  
62      protected void testTravelDestinationLookUp() throws Exception {
63      	waitAndTypeByName(DESTINATION_ID,"1");
64      	waitAndTypeByName(DESTINATION_NAME,"a*");
65      	waitAndClickButtonByText(SEARCH);
66      	waitForTextPresent("No values match this search.");
67      	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.");
68      	waitAndClickButtonByText(CLEAR_VALUES);
69      	waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='Y']");
70      	waitAndClickButtonByText(SEARCH);
71      	String activeResults [] ={"10000","Colorado","United States","Colorado","true"};
72      	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.
73      	assertTextPresent(activeResults);
74      }
75  
76      @Test
77      public void testTravelDestinationLookUpBookmark() throws Exception {
78          testTravelDestinationLookUp();
79          passed();
80      }
81  
82      @Test
83      public void testTravelDestinationLookUpNav() throws Exception {
84          testTravelDestinationLookUp();
85          passed();
86      }
87  }