001 /**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.sampleu.admin;
017
018 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
019 import org.kuali.rice.testtools.selenium.WebDriverUtils;
020
021 /**
022 * @author Kuali Rice Team (rice.collab@kuali.org)
023 */
024 public abstract class ConfigComponentActionListAftBase extends ConfigComponentAftBase {
025
026 /**
027 * ITUtil.PORTAL+"?channelTitle=Component&channelUrl="+WebDriverUtils.getBaseUrlString()+
028 * "/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.rice.coreservice.impl.component.ComponentBo&docFormKey=88888888&returnLocation="+
029 * +ITUtil.PORTAL_URL+ ITUtil.HIDE_RETURN_LINK;
030 */
031 public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL+"?channelTitle=Component&channelUrl="+ WebDriverUtils
032 .getBaseUrlString()+"/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.rice.coreservice.impl.component.ComponentBo&docFormKey=88888888&returnLocation="+
033 AutomatedFunctionalTestUtils.PORTAL_URL+ AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
034
035 @Override
036 protected String getBookmarkUrl() {
037 return BOOKMARK_URL;
038 }
039
040 private void assertActionListRequestGroup(String userInGroup, String group, String namespace, String actionCode, String beforeState, String afterState) throws InterruptedException {
041 namespaceCode = namespace;
042 String docId = testCreateActionRequestGroup(group, namespace, actionCode);
043 impersonateUser(userInGroup);
044 assertActionList(docId, actionCode, beforeState);
045 assertOutbox(docId, afterState);
046 selectTopFrame();
047 }
048
049 private void assertActionListRequestPerson(String user, String actionType, String beforeState, String afterState) throws Exception {
050 String[][] adhocRequests = new String [][]{{user, actionType}};
051 assertActionListRequestPerson(adhocRequests, beforeState, afterState);
052 }
053
054 private void assertActionListRequestPerson(String[][] adhocRequests, String beforeState, String afterState) throws Exception {
055 String docId = testCreateActionRequestPerson(adhocRequests);
056 impersonateUser(adhocRequests[0][0]);
057 assertActionList(docId, adhocRequests[0][1], beforeState);
058 assertOutbox(docId, afterState);
059 selectTopFrame();
060 }
061
062 protected String testCreateActionRequestGroup(String user, String namespace, String actionType) throws InterruptedException{
063 String docId = testCreateNew();
064 addAdHocRecipientsGroup(new String[]{user, actionType, namespace});
065 submitAndClose();
066 return docId;
067 }
068
069 /**
070 * Creates an Action Request in a users action list.
071 *
072 * Initiates a new maintenance document (Component BO) with added adHoc request to create an action request
073 * in a users action list for the document
074 * @param userActions 2d array containing username, action pairs. (ex: "fred","A")
075 *
076 * @return documentID of the newly initiated document to which the created action request applies.
077 */
078 protected String testCreateActionRequestPerson(String[][] userActions) throws InterruptedException {
079 String docId = testCreateNew();
080 if (!userActions[0][0].isEmpty()){
081 addAdHocRecipientsPerson(userActions);
082 }
083 submitAndClose();
084 return docId;
085 }
086
087 public void testActionListAcknowledgeGroup() throws Exception {
088 assertActionListRequestGroup("fran", "RecipeMasters", "KR-WKFLW", "K", "PROCESSED", "FINAL");
089 passed();
090 }
091
092 /**
093 * tests the Acknowledge ActionRequest.
094 * Creates an Acknowledge request for a user. Then performs the Acknowledge action.
095 * @throws Exception
096 */
097 public void testActionListAcknowledgePerson() throws Exception {
098 assertActionListRequestPerson("erin", "K", "PROCESSED", "FINAL");
099 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 testComponentRecallAndCancel_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 testComponentRecallToActionList_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 testComponentCancel_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 testComponentSave_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 assertComponentSubmit_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 testComponentSubmit() throws Exception {
293 assertComponentSubmit_WithPersonRequest("", "", "FINAL");
294 passed();
295 }
296
297 public void testComponentSubmit_WithPendingPersonApprove() throws Exception {
298 assertComponentSubmit_WithPersonRequest("erin", "A", "ENROUTE");
299 passed();
300 }
301
302 public void testComponentSubmit_WithPendingPersonAcknowledge() throws Exception {
303 assertComponentSubmit_WithPersonRequest("erin", "K", "PROCESSED");
304 passed();
305 }
306
307 public void testComponentSubmit_WithPendingPersonFyi() throws Exception {
308 assertComponentSubmit_WithPersonRequest("erin", "F", "FINAL");
309 passed();
310 }
311
312
313 }