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.demo.lookupviews.lookup.conditionalcriteria;
17  
18  import edu.samplu.common.Failable;
19  import edu.samplu.common.SmokeTestBase;
20  
21  /**
22   * @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  public class DemoLookUpConditionalCriteriaAbstractSmokeTestBase extends SmokeTestBase {
25  
26      /**
27       * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalCriteria&hideReturnLink=true
28       */
29      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalCriteria&hideReturnLink=true";
30      
31      /**
32       *  lookupCriteria[number]
33       */
34      private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
35      
36      /**
37       *  Search
38       */
39      private static final String SEARCH="Search";
40      
41      /**
42       *  lookupCriteria[rangeLowerBoundKeyPrefix_createDate]
43       */
44      private static final String LOOKUP_CRITERIA_DATE_NAME="lookupCriteria[rangeLowerBoundKeyPrefix_createDate]";
45      
46      /**
47       *  Not read only. Date input field present.
48       */
49      private static final String FAILURE_MESSAGE="Not read only. Date input field present.";
50      
51      /**
52       *  Date Created:
53       */
54      private static final String DATE_CREATED_MESSAGE="Date Created:";
55      
56      /**
57       *  Date Created is a required field.
58       */
59      private static final String DATE_REQUIRED_MESSAGE="Date Created is a required field.";
60      
61      @Override
62      public String getBookmarkUrl() {
63          return BOOKMARK_URL;
64      }
65  
66      @Override
67      protected void navigate() throws Exception {
68          waitAndClickById("Demo-DemoLink", "");
69          waitAndClickByLinkText("Lookup Conditional Criteria");
70      }
71  
72      protected void testLookUpConditionalCriteria() throws InterruptedException {
73          //Case 1 - Date field required by number a1
74          //It requires "Search" to be clicked twice, for showing message.
75          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a1");
76          waitAndClickButtonByText(SEARCH);
77          waitAndClickButtonByText(SEARCH);
78          Thread.sleep(3000);
79          assertTextPresent(DATE_REQUIRED_MESSAGE);
80          
81          //Case 2 - Date field read only by number a2
82          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
83          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a2");
84          waitAndClickButtonByText(SEARCH);
85          Thread.sleep(3000);
86          if(isElementPresentByName(LOOKUP_CRITERIA_DATE_NAME))
87          {
88              fail(FAILURE_MESSAGE);
89          }
90          
91          //Case 3 - Date field hide by number a3
92          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
93          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a3");
94          waitAndClickButtonByText(SEARCH);
95          Thread.sleep(3000);
96          assertTextNotPresent(DATE_CREATED_MESSAGE);
97      }
98  
99      public void testLookUpConditionalCriteriaBookmark(Failable failable) throws Exception {
100         testLookUpConditionalCriteria();
101         passed();
102     }
103 
104     public void testLookUpConditionalCriteriaNav(Failable failable) throws Exception {
105         testLookUpConditionalCriteria();
106         passed();
107     }
108 }