View Javadoc
1   /**
2    * Copyright 2005-2015 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.lookup.conditionalresults;
17  
18  import org.junit.Assert;
19  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20  import org.junit.Test;
21  
22  import static org.junit.Assert.assertEquals;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class DemoLookUpConditionalResultsBasedOnCriteriaAft extends WebDriverLegacyITBase {
28  
29      /**
30       * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalResultsBasedOnCriteria
31       */
32      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalResultsBasedOnCriteria";
33  
34      /**
35       *  lookupCriteria[number]
36       */
37      private static final String LOOKUP_CRITERIA_TYPE_CODE="lookupCriteria[typeCode]";
38  
39      /**
40       *  Search
41       */
42      private static final String SEARCH="Search";
43  
44      /**
45       *  Principal Name column
46       */
47      private static final String PRINCIPAL_NAME_COLUMN_NAME = "Principal Name";
48  
49      /**
50       *  Group Name column
51       */
52      private static final String GROUP_NAME_COLUMN_NAME = "Group Name";
53  
54      /**
55       *  Role Name column
56       */
57      private static final String ROLE_NAME_COLUMN_NAME = "Role Name";
58  
59      /**
60       *  Description column
61       */
62      private static final String DESCRIPTION_COLUMN_NAME = "Description";
63  
64      @Override
65      public String getBookmarkUrl() {
66          return BOOKMARK_URL;
67      }
68  
69      @Override
70      protected void navigate() throws Exception {
71          waitAndClickDemoLink();
72          waitAndClickByLinkText("Lookup Conditional Results Based On Criteria");
73      }
74  
75      protected void testLookUpConditionalResultsBasedOnCriteria() throws InterruptedException {
76          // Case 1 - Search by Principal
77          waitAndTypeByName(LOOKUP_CRITERIA_TYPE_CODE,"P");
78          waitAndClickButtonByText(SEARCH);
79          Thread.sleep(3000);
80          Assert.assertEquals(2, getCssCount(DATA_TABLE_TH_CSS));
81          assertElementPresent(DATA_TABLE_TH_CSS + ":nth-child(2)");
82          assertTextPresent(PRINCIPAL_NAME_COLUMN_NAME, DATA_TABLE_TH_CSS + ":nth-child(2) label",
83          		"Principal Name column not present");
84  
85          // Case 2 - Search by Group
86          waitAndTypeByName(LOOKUP_CRITERIA_TYPE_CODE, "G");
87          waitAndClickButtonByText(SEARCH);
88          Thread.sleep(3000);
89          Assert.assertEquals(3, getCssCount(DATA_TABLE_TH_CSS));
90          assertElementPresent(DATA_TABLE_TH_CSS + ":nth-child(2)");
91          assertTextPresent(GROUP_NAME_COLUMN_NAME, DATA_TABLE_TH_CSS + ":nth-child(2) label",
92                  "Group Name column not present");
93          assertElementPresent(DATA_TABLE_TH_CSS + ":nth-child(3)");
94          assertTextPresent(DESCRIPTION_COLUMN_NAME, DATA_TABLE_TH_CSS + ":nth-child(3) label",
95                  "Description column not present");
96  
97          // Case 3 - Search by Role
98          waitAndTypeByName(LOOKUP_CRITERIA_TYPE_CODE, "R");
99          waitAndClickButtonByText(SEARCH);
100         Thread.sleep(3000);
101         Assert.assertEquals(3, getCssCount(DATA_TABLE_TH_CSS));
102         assertTextPresent(ROLE_NAME_COLUMN_NAME, DATA_TABLE_TH_CSS + ":nth-child(2) label",
103                 "Role Name column not present");
104         assertElementPresent(DATA_TABLE_TH_CSS + ":nth-child(3)");
105         assertTextPresent(DESCRIPTION_COLUMN_NAME, DATA_TABLE_TH_CSS + ":nth-child(3) label",
106                 "Description column not present");
107     }
108 
109     @Test
110     public void testLookUpConditionalResultsBasedOnCriteriaBookmark() throws Exception {
111         testLookUpConditionalResultsBasedOnCriteria();
112         passed();
113     }
114 
115     @Test
116     public void testLookUpConditionalResultsBasedOnCriteriaNav() throws Exception {
117         testLookUpConditionalResultsBasedOnCriteria();
118         passed();
119     }
120 }