View Javadoc

1   /**
2    * Copyright 2005-2013 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 edu.samplu.krad.labs.lookups;
17  
18  import org.junit.Test;
19  
20  /**
21   * @author Kuali Rice Team (rice.collab@kuali.org)
22   */
23  public class DemoLabsLookUpConditionalCriteriaSmokeTest extends DemoLabsLookupBase {
24  
25      /**
26       * /kr-krad/lookup?methodToCall=start&viewId=LabsLookup-ConditionalCriteriaView&hideReturnLink=true
27       */
28      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LabsLookup-ConditionalCriteriaView&hideReturnLink=true";
29  
30      /**
31       *  lookupCriteria[number]
32       */
33      private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
34      
35      /**
36       *  Search
37       */
38      private static final String SEARCH="Search";
39      
40      /**
41       *  lookupCriteria[rangeLowerBoundKeyPrefix_createDate]
42       */
43      private static final String LOOKUP_CRITERIA_DATE_NAME="lookupCriteria[rangeLowerBoundKeyPrefix_createDate]";
44      
45      /**
46       *  Not read only. Date input field present.
47       */
48      private static final String FAILURE_MESSAGE="Not read only. Date input field present.";
49      
50      /**
51       *  Date Created:
52       */
53      private static final String DATE_CREATED_LABEL="Date Created:";
54      
55      /**
56       *  Date Created is a required field.
57       */
58      private static final String DATE_REQUIRED_MESSAGE="Date Created is a required field.";
59      
60      /**
61       *  LookUp Criteria Name 
62       */
63      private static final String LOOKUP_CRITERIA_NAME_NAME="lookupCriteria[name]";
64      
65      @Override
66      protected String getBookmarkUrl() {
67          return BOOKMARK_URL;
68      }
69  
70      @Override
71      protected void navigate() throws Exception {
72          navigateToLookup("Lookup Conditional Criteria");
73      }
74  
75      protected void testLookUpConditionalCriteria() throws InterruptedException {
76          //Case 1 - Date field required by number a1
77          //It requires "Search" to be clicked twice, for the date required message to show.
78          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a1");
79          waitAndClickButtonByText(SEARCH);
80          Thread.sleep(10000); // If we don't wait long enough we'll get concurrency issues.
81          checkForIncidentReport(SEARCH, "DemoLookUpConditionalCriteriaSmokeTest testLookUpConditionalCriteria");
82          waitAndClickButtonByText(SEARCH);
83          Thread.sleep(3000);
84          checkForIncidentReport();
85          assertTextPresent(DATE_REQUIRED_MESSAGE);
86          
87          //Case 2 - Date field read only by number a2
88          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
89          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a2");
90          waitAndTypeByName(LOOKUP_CRITERIA_NAME_NAME,"");
91          Thread.sleep(2000);
92          if(isElementPresentByName(LOOKUP_CRITERIA_DATE_NAME)) {
93              fail(FAILURE_MESSAGE);
94          }
95          
96          //Case 3 - Date field hide by number a3
97          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
98          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a3");
99          waitAndClickButtonByText(SEARCH);
100         Thread.sleep(3000);
101         assertTextNotPresent(DATE_CREATED_LABEL);
102     }
103 
104     @Test
105     public void testLookUpConditionalCriteriaBookmark() throws Exception {
106         testLookUpConditionalCriteria();
107         passed();
108     }
109 
110     @Test
111     public void testLookUpConditionalCriteriaNav() throws Exception {
112         testLookUpConditionalCriteria();
113         passed();
114     }
115 }