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 edu.sampleu.admin;
17  
18  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
19  import org.kuali.rice.testtools.selenium.WebDriverUtils;
20  
21  /**
22   *  @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  public abstract class PermissionActionListAftBase extends PermissionAftBase {
25  
26      /**
27       * AutomatedFunctionalTestUtils.PORTAL+"?channelTitle=Permission&channelUrl="+ WebDriverUtils
28       * .getBaseUrlString()+"/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.rice.kim.impl.permission.UberPermissionBo&docFormKey=88888888&returnLocation="+
29       * AutomatedFunctionalTestUtils.PORTAL_URL+ AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
30       */    
31      public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL+"?channelTitle=Permission&channelUrl="+ WebDriverUtils
32              .getBaseUrlString()+"/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.rice.kim.impl.permission.UberPermissionBo&docFormKey=88888888&returnLocation="+
33              AutomatedFunctionalTestUtils.PORTAL_URL+ AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
34  
35      @Override
36      protected String getBookmarkUrl() {
37          return BOOKMARK_URL;
38      }
39  
40      private void assertActionListRequestGroup(String userInGroup, String group, String namespace, String actionCode, String beforeState, String afterState) throws InterruptedException {
41          namespaceCode = namespace;
42          String docId = testCreateActionRequestGroup(group, namespace, actionCode);
43          impersonateUser(userInGroup);
44          assertActionList(docId, actionCode, beforeState);
45          assertOutbox(docId, afterState);
46          selectTopFrame();
47      }
48  
49      private void assertActionListRequestPerson(String user, String actionType, String beforeState, String afterState) throws Exception {
50          String[][] adhocRequests = new String [][]{{user, actionType}};
51          assertActionListRequestPerson(adhocRequests, beforeState, afterState);
52      }
53  
54      private void assertActionListRequestPerson(String[][] adhocRequests, String beforeState, String afterState) throws Exception {
55          String docId = testCreateActionRequestPerson(adhocRequests);
56          impersonateUser(adhocRequests[0][0]);
57          assertActionList(docId, adhocRequests[0][1], beforeState);
58          assertOutbox(docId, afterState);
59          selectTopFrame();
60      }
61  
62      protected String testCreateActionRequestGroup(String user, String namespace, String actionType) throws InterruptedException{
63          String docId = testCreateNew();
64          addAdHocRecipientsGroup(new String[]{user, actionType, namespace});
65          submitAndClose();
66          return docId;
67      }
68  
69      /**
70       * Creates an Action Request in a users action list.
71       *
72       * Initiates a new maintenance document (Component BO) with added adHoc request to create an action request
73       * in a users action list for the document
74       * @param userActions 2d array containing username, action pairs. (ex: "fred","A")
75       *
76       * @return documentID of the newly initiated document to which the created action request applies.
77       */
78      protected String testCreateActionRequestPerson(String[][] userActions) throws InterruptedException {
79          String docId = testCreateNew();
80          if (!userActions[0][0].isEmpty()){
81              addAdHocRecipientsPerson(userActions);
82          }
83          submitAndClose();
84          return docId;
85      }
86  
87      public void testActionListAcknowledgeGroup() throws Exception {
88          assertActionListRequestGroup("fran", "RecipeMasters", "KR-WKFLW", "K", "PROCESSED", "FINAL");
89          passed();
90      }
91  
92      /**
93       * tests the Acknowledge ActionRequest.
94       * Creates an Acknowledge request for a user. Then performs the Acknowledge action.
95       * @throws Exception
96       */
97      public void testActionListAcknowledgePerson() throws Exception {
98          assertActionListRequestPerson("erin", "K", "PROCESSED", "FINAL");
99          passed();
100     }
101 
102     /**
103      * tests the Acknowledge ActionRequest.
104      * Creates an Acknowledge request for a user and an approve request for a different user.
105      * Then performs the Acknowledge action.
106      * @throws Exception
107      */
108     public void testActionListAcknowledgePerson_WithPendingApprove() throws Exception {
109         String[][] adhocRequests = new String [][]{{"fred","A"},{"fran","K"}};
110         String docId = testCreateActionRequestPerson(adhocRequests);
111         impersonateUser("fran");
112         assertActionList(docId, "K", "ENROUTE");
113         assertOutbox(docId, "ENROUTE");
114         selectTopFrame();
115         passed();
116     }
117 
118     /**
119      * tests the Acknowledge ActionRequest.
120      * Creates an Acknowledge request for a user and an approve request for a different user.
121      * Then performs the Acknowledge action.
122      * @throws Exception
123      */
124     public void testActionListAcknowledgePerson_WithPendingAcknowledge() throws Exception {
125         String[][] adhocRequests = new String [][]{{"fred","K"},{"fran","K"}};
126         String docId = testCreateActionRequestPerson(adhocRequests);
127         impersonateUser("fran");
128         assertActionList(docId, "K", "PROCESSED");
129         assertOutbox(docId, "PROCESSED");
130         selectTopFrame();
131         passed();
132     }
133 
134     /**
135      * tests the Approve ActionRequest.
136      * Creates an approve request for a user. Then performs the Approve action.
137      * @throws Exception
138      */
139     public void testActionListApprovePerson() throws Exception {
140         assertActionListRequestPerson("fred", "A", "ENROUTE", "FINAL");
141         passed();
142     }
143 
144     /**
145      * tests the Approve ActionRequest.
146      * Creates an Approve request for a user and a separate approve request for a different user.
147      * Then performs the first users Approve action.
148      * @throws Exception
149      */
150     public void testActionListApprovePerson_WithPendingApprove() throws Exception {
151         String[][] adhocRequests = new String [][]{{"fred","A"},{"fran","A"}};
152         assertActionListRequestPerson(adhocRequests, "ENROUTE", "ENROUTE");
153         passed();
154     }
155 
156     /**
157      * tests the Approve ActionRequest.
158      * Creates an Approve request for a user and a separate approve request for a different user.
159      * Then performs the first users Approve action.
160      * @throws Exception
161      */
162     public void testActionListApprovePerson_WithPendingAcknowledge() throws Exception {
163         String[][] adhocRequests = new String [][]{{"fran","A"},{"fred","K"}};
164         assertActionListRequestPerson(adhocRequests, "ENROUTE", "PROCESSED");
165         passed();
166     }
167 
168     public void testActionListApproveGroup() throws Exception {
169         assertActionListRequestGroup("fred", "RecipeMasters", "KR-WKFLW", "A", "ENROUTE", "FINAL");
170         passed();
171     }
172 
173     public void testActionListCompleteGroup() throws Exception {
174         assertActionListRequestGroup("dev1", "Kuali Developers", "KUALI", "C", "ENROUTE", "FINAL");
175         passed();
176     }
177 
178     /**
179      * tests the complete ActionRequest.
180      * Creates an complete request for a user. Then performs the Complete action.
181      * @throws Exception
182      */
183     public void testActionListCompletePerson() throws Exception {
184         assertActionListRequestPerson("fran", "C", "ENROUTE", "FINAL");
185         passed();
186     }
187 
188     public void testActionListCompletePerson_WithPendingAcknowledge() throws Exception {
189         String[][] adhocRequests = new String [][]{{"fran","C"},{"fred","K"}};
190         assertActionListRequestPerson(adhocRequests, "ENROUTE", "PROCESSED");
191         passed();
192     }
193 
194     public void testActionListDisapproveGroup() throws Exception {
195         assertActionListRequestGroup("director", "ChickenRecipeMasters", "KR-WKFLW", "D", "ENROUTE", "DISAPPROVED");
196         passed();
197     }
198 
199     /**
200      * tests the  ActionRequest.
201      * Creates an approve request for a user. Then performs the Disapprove action.
202      * @throws Exception
203      */
204     public void testActionListDisapprovePerson() throws Exception {
205         assertActionListRequestPerson("fred", "D", "ENROUTE", "DISAPPROVED");
206         passed();
207     }
208 
209     public void testActionListFyiGroup() throws Exception {
210         assertActionListRequestGroup("dev2", "Kuali Developers", "KUALI", "F", "FINAL", "FINAL");
211         passed();
212     }
213 
214     /**
215      * tests the FYI ActionRequest.
216      * Creates an FYI request for a user. Then performs the FYI action.
217      * @throws Exception
218      */
219     public void testActionListFyiPerson() throws Exception {
220         assertActionListRequestPerson("eric", "F", "FINAL", "FINAL");
221         passed();
222     }
223 
224 
225 
226     public void testActionListCancelPerson() throws Exception {
227         assertActionListRequestGroup("dev2", "Kuali Developers", "KUALI", "F", "FINAL", "FINAL");
228         passed();
229     }
230 
231     public void testPermissionActionListRecallAndCancel_WithPendingPersonApprove() throws Exception {
232         String user = "erin";
233         String docId = testCreateNew();
234         addAdHocRecipientsPerson(new String[]{user, "A"});
235         submit();
236         recall(true);
237         impersonateUser(user);
238         assertNotInActionList(docId);
239         passed();
240     }
241 
242     public void testPermissionActionListRecallToActionList_WithPendingPersonApprove() throws Exception {
243         String user = "erin";
244 
245         String docId = testCreateNew();
246         addAdHocRecipientsPerson(new String[]{user, "A"});
247         submit();
248         waitForTextPresent("ENROUTE");
249         recall(false);
250         // TODO: new window vs. new tab issue
251         assertActionList(docId, "CR", "SAVED");
252 
253         driver.navigate().to(WebDriverUtils.getBaseUrlString() + BOOKMARK_URL);
254         waitAndClickDocSearch();
255         selectFrameIframePortlet();
256         waitAndTypeByName("documentId",docId);
257         waitAndClickByXpath(SEARCH_XPATH);
258         waitForTextPresent("FINAL");
259         passed();
260     }
261 
262     public void testPermissionActionListCancel_WithPendingPersonApprove()throws Exception {
263         String docId = testCreateNew();
264         addAdHocRecipientsPerson(new String[]{"fred", "A"});
265         waitAndClickByName("methodToCall.cancel");
266         assertDocSearchNoResults(docId);
267         passed();
268     }
269 
270     public void testPermissionActionListSave_WithPendingPersonApprove() throws Exception {
271         String user = "erin";
272         String docId = testCreateNew();
273         addAdHocRecipientsPerson(new String[]{user, "A"});
274         saveAndReload();
275         waitForTextPresent("SAVED");
276         passed();
277     }
278 
279     public void assertPermissionActionListSubmit_WithPersonRequest(String user, String action, String state) throws Exception {
280         String[][] userActions = new String [][]{{user, action}};
281         String docId = testCreateNew();
282         if (!userActions[0][0].isEmpty()){
283             addAdHocRecipientsPerson(userActions);
284         }
285         submit();
286         waitForTextPresent("ENROUTE");
287         waitAndClickByName("methodToCall.reload");
288         waitForTextPresent(state);
289         close();
290     }
291 
292     public void testPermissionActionListSubmit() throws Exception {
293         assertPermissionActionListSubmit_WithPersonRequest("", "", "FINAL");
294         passed();
295     }
296 
297     public void testPermissionActionListSubmit_WithPendingPersonApprove() throws Exception {
298         assertPermissionActionListSubmit_WithPersonRequest("erin", "A", "ENROUTE");
299         passed();
300     }
301 
302     public void testPermissionActionListSubmit_WithPendingPersonAcknowledge() throws Exception {
303         assertPermissionActionListSubmit_WithPersonRequest("erin", "K", "PROCESSED");
304         passed();
305     }
306 
307     public void testPermissionActionListSubmit_WithPendingPersonFyi() throws Exception {
308         assertPermissionActionListSubmit_WithPersonRequest("erin", "F", "FINAL");
309         passed();
310     }
311 
312 
313 }