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.labs.lookups;
17  
18  import org.junit.Test;
19  
20  /**
21   * @author Kuali Rice Team (rice.collab@kuali.org)
22   */
23  public class LabsLookupValidateSearchParamsAft extends LabsLookupBase {
24  
25      /**
26       * /kr-krad/lookup?methodToCall=search&dataObjectClassName=edu.sampleu.travel.dataobject.TravelPerDiemExpense&viewId=LabsLookup-PerDiemExpenseDisabledWildcardsView
27       */
28      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=search&dataObjectClassName=edu.sampleu.travel.dataobject.TravelPerDiemExpense&viewId=LabsLookup-PerDiemExpenseDisabledWildcardsView";
29  
30      /**
31       *  are treated literally
32       */
33      private static final String WILDCARD_WARNING_MSG="are treated literally";
34  
35      /**
36       * Negative values are not allowed on this Breakfast Value field.
37       */
38      private static final String NEGATIVE_WARNING_MSG="Negative values are not allowed";
39      
40      /**
41       * _)(*
42       */
43      private static final String WILDCARD_INPUT="_)(*"; 
44      
45      /**
46       * -9_)(*
47       */
48      private static final String NEGATIVE_WILDCARD_INPUT="-9_)(*"; 
49      
50     
51      @Override
52      protected String getBookmarkUrl() {
53          return BOOKMARK_URL;
54      }
55  
56      @Override
57      protected void navigate() throws Exception {
58          navigateToLookup("Lookup Validate Search Parms");
59      }
60  
61      @Test
62      public void testLabsValidateSearchParamsBookmark() throws Exception {
63          testLabsValidateSearchParams();
64          passed();
65      }
66  
67      @Test
68      public void testLabsValidateSearchParamsNav() throws Exception {
69          testLabsValidateSearchParams();
70          passed();
71      }
72  
73      protected void testLabsValidateSearchParams()throws Exception {
74          waitAndTypeByName("lookupCriteria[travelPerDiemExpenseId]",WILDCARD_INPUT);
75          assertWarningPresent(Boolean.TRUE,Boolean.FALSE);
76          waitAndTypeByName("lookupCriteria[travelAuthorizationDocumentId]",WILDCARD_INPUT);
77          assertWarningPresent(Boolean.TRUE,Boolean.FALSE);
78          waitAndTypeByName("lookupCriteria[breakfastValue]",NEGATIVE_WILDCARD_INPUT);
79          assertWarningPresent(Boolean.TRUE,Boolean.TRUE);
80          waitAndTypeByName("lookupCriteria[lunchValue]",NEGATIVE_WILDCARD_INPUT);
81          assertWarningPresent(Boolean.TRUE,Boolean.TRUE);
82          waitAndTypeByName("lookupCriteria[dinnerValue]",NEGATIVE_WILDCARD_INPUT);
83          assertWarningPresent(Boolean.TRUE,Boolean.TRUE);
84          waitAndTypeByName("lookupCriteria[incidentalsValue]",NEGATIVE_WILDCARD_INPUT);
85          assertWarningPresent(Boolean.TRUE,Boolean.TRUE);
86          waitAndTypeByName("lookupCriteria[estimatedMileage]",NEGATIVE_WILDCARD_INPUT);
87      }
88      
89      private void assertWarningPresent(Boolean isWildCardWarningPresent , Boolean isNegativeWarningPresent) throws Exception {
90      	waitAndClickSearch3();
91      	if(isWildCardWarningPresent){
92      		waitForTextPresent(WILDCARD_WARNING_MSG);
93      	}
94      	if(isNegativeWarningPresent){
95      		waitForTextPresent(NEGATIVE_WARNING_MSG);
96      	}
97      }
98  }