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