View Javadoc
1   /**
2    * Copyright 2005-2016 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.sampleu.admin;
17  
18  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
19  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20  import org.kuali.rice.testtools.selenium.WebDriverUtils;
21  import org.apache.commons.lang.RandomStringUtils;
22  import org.junit.Test;
23  import org.openqa.selenium.By;
24  
25  import java.text.SimpleDateFormat;
26  import java.util.Calendar;
27  
28  /**
29   * Tests whether the ENABLE_FIELD_LEVEL_HELP_IND parameter is being considered and loaded on each request.
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  public class DetailedDocSearchAft extends WebDriverLegacyITBase {
34      /*
35       * AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Document%20Search&channelUrl=" + WebDriverUtils
36       * .getBaseUrlString() + "/kew/DocumentSearch.do?docFormKey=88888888&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
37       */
38      
39      public static String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Document%20Search&channelUrl=" + WebDriverUtils
40              .getBaseUrlString() + "/kew/DocumentSearch.do?docFormKey=88888888&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
41  
42      private String groupId = null;
43      private String groupName = null;
44      private String groupRandomCode = null;
45      private String parameterDocId = null;
46      private String todayDate = null;
47  
48      @Override
49      protected String getBookmarkUrl() {
50          return BOOKMARK_URL;
51      }
52  
53      @Override
54      protected void navigate() throws Exception {
55         waitAndClickByXpath("//img[@alt='doc search']"); 
56      }
57  
58      @Test
59      public void testAdvancedDocSearchNav() throws Exception {
60          advancedDocSearchAll();
61      }
62      
63      @Test
64      public void testAdvancedDocSearchBookmark() throws Exception {
65          advancedDocSearchAll();
66      }
67      
68      private void advancedDocSearchAll() throws Exception{
69          todayDate = getDateToUseForSearch();
70      	createGroupDocument();
71          selectTopFrame();
72          createGroupDocumentFinal();
73          selectTopFrame();
74          createGroupDocumentFinal();
75          selectTopFrame();
76          createParameterDocument();
77      	selectTopFrame();
78      	waitAndClickByXpath("//a[@title='Document Search']");
79      	acceptAlertIfPresent();
80      	selectFrameIframePortlet();
81          waitAndClickByName("toggleAdvancedSearch");
82          acceptAlertIfPresent();
83          searchByDocumentType();
84          searchByInitiator();
85          searchByApprover();
86          searchByViewer();
87          searchByGroupViewer();
88          searchByDocumentId();
89          searchByApplicationDocumentId();
90          searchByDocumentStatus();
91          searchByDateCreatedFrom();
92          searchByDateCreatedTo();
93          searchByDateApprovedFrom();
94          searchByDateApprovedTo();
95          searchByDateLastModifiedFrom();
96          searchByDateLastModifiedTo();
97          searchByDateLastFinalizedFrom();
98          searchByDateLastFinalizedTo();
99          searchByTitle();
100         passed();
101     }
102 
103     private String getDateToUseForSearch() {
104         Calendar nextYearCal = Calendar.getInstance();
105         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
106         return sdf.format(nextYearCal.getTime());
107     }
108 
109     private void createGroupDocument() throws Exception{
110         waitAndClickAdministration();
111         selectFrameIframePortlet();
112         waitAndClickByLinkText("Group");
113         selectFrameIframePortlet();
114         waitAndClickByXpath("//a[@title='Create a new record']");
115         selectFrameIframePortlet();
116         String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
117         waitAndSelectByName("document.groupNamespace","KR-BUS - Service Bus");
118         waitAndTypeByName("document.documentHeader.documentDescription","Group");
119         groupName = "Group 1"+randomCode;
120         waitAndTypeByName("document.groupName", groupName);
121         groupId=waitForElementPresentByXpath("//div[@id='tab-Overview-div']/div[@class='tab-container']/table/tbody/tr/td").getText();
122 
123         // Add an acknowledgement request for user1 so we can search by viewer
124         waitAndClickByName("methodToCall.toggleTab.tabAdHocRecipients");
125         waitAndSelectByName("newAdHocRoutePerson.actionRequested", "ACKNOWLEDGE");
126         waitAndTypeByName("newAdHocRoutePerson.id", "user1");
127         WebDriverUtils.jGrowl(getDriver(), "Click Add Person", false, "Click Add Person");
128         waitAndClickByName("methodToCall.insertAdHocRoutePerson");
129 
130         waitAndClickByXpath("//input[@name='methodToCall.route']");
131     }
132 
133     private void createGroupDocumentFinal() throws Exception{
134         waitAndClickAdministration();
135         selectFrameIframePortlet();
136         waitAndClickByLinkText("Group");
137         selectFrameIframePortlet();
138         waitAndClickByXpath("//a[@title='Create a new record']");
139         selectFrameIframePortlet();
140         String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
141         waitAndSelectByName("document.groupNamespace", "KR-BUS - Service Bus");
142         waitAndTypeByName("document.documentHeader.documentDescription","Group");
143         waitAndTypeByName("document.groupName", "Group Final "+randomCode);
144         waitAndClickByXpath("//input[@name='methodToCall.blanketApprove']");
145     }
146 
147     private void createParameterDocument() throws Exception{
148         waitAndClickAdministration();
149         selectFrameIframePortlet();
150         waitAndClickByLinkText("Parameter");
151         selectFrameIframePortlet();
152         waitAndClickByXpath("//a[@title='Create a new record']");
153         selectFrameIframePortlet();
154         groupRandomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
155         waitAndTypeByName("document.documentHeader.documentDescription","New Paramater " + groupRandomCode);
156         waitAndTypeByName("document.documentHeader.organizationDocumentNumber","7777777");
157         waitAndSelectByName("document.newMaintainableObject.namespaceCode", "KR-SAP - Sample App");
158         waitAndTypeByName("document.newMaintainableObject.componentCode", "TestComponent");
159         waitAndTypeByName("document.newMaintainableObject.name", "Parameter" + groupRandomCode);
160         waitAndTypeByName("document.newMaintainableObject.description", "Description " + groupRandomCode);
161         waitAndSelectByName("document.newMaintainableObject.parameterTypeCode", "Config");
162         waitAndClickByXpath(
163                 "//input[@type='radio' and @id='document.newMaintainableObject.evaluationOperatorCodeAllowed' and @value='A']");
164         parameterDocId = driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText();
165 
166         // Add an acknowledgement request for user1 so we can search by viewer
167         waitAndClickByName("methodToCall.toggleTab.tabAdHocRecipients");
168         waitAndSelectByName("newAdHocRoutePerson.actionRequested", "ACKNOWLEDGE");
169         waitAndTypeByName("newAdHocRoutePerson.id", "user1");
170         WebDriverUtils.jGrowl(getDriver(), "Click Add Person", false, "Click Add Person");
171         waitAndClickByName("methodToCall.insertAdHocRoutePerson");
172 
173         selectOptionByName("newAdHocRouteWorkgroup.actionRequested", "ACKNOWLEDGE");
174         waitAndTypeByName("newAdHocRouteWorkgroup.recipientName", groupName);
175         waitAndTypeByName("newAdHocRouteWorkgroup.recipientNamespaceCode", "KR-BUS");
176         WebDriverUtils.jGrowl(getDriver(), "Click Add Group", false, "Click Add Group");
177         waitAndClickByName("methodToCall.insertAdHocRouteWorkgroup");
178 
179         waitAndClickByXpath("//input[@name='methodToCall.route']");
180     }
181 
182     private void searchByDocumentType() throws Exception {
183         selectFrameIframePortlet();
184         waitAndTypeByName("documentTypeName","ParameterMaintenanceDocument");
185         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","03/24/2000");
186         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
187         waitForTextPresent("Parameter Maintenance Document");
188         waitAndClickByName("methodToCall.clearValues");
189     }
190     
191     private void searchByInitiator() throws Exception {
192         selectFrameIframePortlet();
193         waitAndTypeByName("initiatorPrincipalName","admin");
194         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
195         waitForTextPresent("items retrieved");
196         waitForElementPresentByXpath("//a[contains(text(),'admin, admin')]");
197         waitAndClickByName("methodToCall.clearValues");
198     }
199 
200     private void searchByApprover() throws Exception {
201         selectFrameIframePortlet();
202         waitAndTypeByName("approverPrincipalName", "admin");
203         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
204         waitForTextPresent("items retrieved");
205         waitForTextPresent("Group - Group");
206         waitAndClickByName("methodToCall.clearValues");
207     }
208 
209     private void searchByViewer() throws Exception {
210         waitAndTypeByName("viewerPrincipalName","user1");
211         clearTextByName("approverPrincipalName");
212         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","03/24/2000");
213         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
214         waitForTextPresent("items retrieved");
215         waitForTextPresent("Parameter Maintenance Document");
216         waitForTextPresent("Group - Group");
217         waitAndClickByName("methodToCall.clearValues");
218     }
219     
220     private void searchByGroupViewer() throws Exception {
221         waitAndClickByXpath("//input[@type='image' and @alt='Search Group Viewer Id']");
222         selectFrameIframePortlet();
223         waitAndTypeByName("id",groupId);
224         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
225         waitAndClickLinkContainingText("return value");
226         selectFrameIframePortlet();
227         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","03/24/2000");
228         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
229         waitForTextPresent("Parameter Maintenance Document");
230         waitForElementPresentByXpath("//a[contains(text(),'admin, admin')]");
231         waitAndClickByName("methodToCall.clearValues");
232     }
233     
234     private void searchByDocumentId() throws Exception {
235         waitAndTypeByName("documentId", parameterDocId);
236         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
237         waitForElementPresentByXpath("//a[contains(text(),parameterDocId)]");
238         waitForTextPresent("Parameter Maintenance Document");
239         waitAndClickByName("methodToCall.clearValues");
240     }
241     
242     private void searchByApplicationDocumentId() throws Exception {
243         waitAndTypeByName("applicationDocumentId","7777777");
244         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
245         waitForElementPresentByXpath("//a[contains(text(),parameterDocId)]");
246         waitForTextPresent("Parameter Maintenance Document");
247         waitAndClickByName("methodToCall.clearValues");
248     }
249     
250     private void searchByDocumentStatus() throws Exception {
251         selectByName("statusCode","Successful Statuses");
252         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
253         waitForTextPresent("PROCESSED");
254         waitForTextPresent("FINAL");
255         waitAndClickByName("methodToCall.clearValues");
256     }
257     
258     private void searchByDateCreatedFrom() throws Exception {
259         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","04/17/2005");
260         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
261         waitForTextPresent("items retrieved");
262         waitAndClickByName("methodToCall.clearValues");
263     }
264     
265     private void searchByDateCreatedTo() throws Exception {
266         waitAndTypeByName("dateCreated", todayDate);
267         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
268         waitForTextPresent("items retrieved");
269         waitAndClickByName("methodToCall.clearValues");
270 
271         // At the time this test was updated, there were no old documents in the testing data.
272         // If that changes, this test will also need to be updated.
273         waitAndTypeByName("dateCreated","04/17/2014");
274         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
275         waitForTextPresent("No values match this search.");
276         waitAndClickByName("methodToCall.clearValues");
277     }
278     
279     private void searchByDateApprovedFrom() throws Exception {
280         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateApproved","04/17/2005");
281         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
282         waitForTextPresent("items retrieved");
283         waitAndClickByName("methodToCall.clearValues");
284     }
285     
286     private void searchByDateApprovedTo() throws Exception {
287         waitAndTypeByName("dateApproved", todayDate);
288         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
289         waitForTextPresent("items retrieved");
290         waitAndClickByName("methodToCall.clearValues");
291 
292         // At the time this test was updated, there were no old documents in the testing data.
293         // If that changes, this test will also need to be updated.
294         waitAndTypeByName("dateApproved","04/17/2014");
295         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
296         waitForTextPresent("No values match this search.");
297         waitAndClickByName("methodToCall.clearValues");
298     }
299     
300     private void searchByDateLastModifiedFrom() throws Exception {
301         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateLastModified","04/17/2005");
302         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
303         waitForTextPresent("items retrieved");
304         waitAndClickByName("methodToCall.clearValues");
305     }
306  
307     private void searchByDateLastModifiedTo() throws Exception {
308         waitAndTypeByName("dateLastModified", todayDate);
309         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
310         waitForTextPresent("items retrieved");
311         waitAndClickByName("methodToCall.clearValues");
312 
313         // At the time this test was updated, there were no old documents in the testing data.
314         // If that changes, this test will also need to be updated.
315         waitAndTypeByName("dateLastModified","04/17/2014");
316         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
317         waitForTextPresent("No values match this search.");
318         waitAndClickByName("methodToCall.clearValues");
319     }
320     
321     private void searchByDateLastFinalizedFrom() throws Exception {
322         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateFinalized","04/17/2005");
323         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
324         waitForTextPresent("items retrieved");
325         waitAndClickByName("methodToCall.clearValues");
326     }
327 
328     private void searchByDateLastFinalizedTo() throws Exception {
329         waitAndTypeByName("dateFinalized", todayDate);
330         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
331         waitForTextPresent("items retrieved");
332         waitAndClickByName("methodToCall.clearValues");
333 
334         // At the time this test was updated, there were no old documents in the testing data.
335         // If that changes, this test will also need to be updated.
336         waitAndTypeByName("dateFinalized","04/17/2014");
337         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
338         waitForTextPresent("No values match this search.");
339         waitAndClickByName("methodToCall.clearValues");
340     }
341     
342     private void searchByTitle() throws Exception {
343         waitAndTypeByName("title","New ParameterBo - New Paramater*");
344         waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","03/24/2000");
345         waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
346         waitForTextPresent("New ParameterBo - New Paramater " + groupRandomCode);
347         waitAndClickByName("methodToCall.clearValues");
348     }
349 }