View Javadoc

1   /**
2    * Copyright 2005-2011 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.kew.actionlist;
17  
18  import org.junit.Test;
19  import org.kuali.rice.core.api.delegation.DelegationType;
20  import org.kuali.rice.kew.actionitem.ActionItem;
21  import org.kuali.rice.kew.actionlist.service.ActionListService;
22  import org.kuali.rice.kew.actionrequest.Recipient;
23  import org.kuali.rice.kew.api.KewApiConstants;
24  import org.kuali.rice.kew.api.WorkflowDocument;
25  import org.kuali.rice.kew.api.WorkflowDocumentFactory;
26  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
27  import org.kuali.rice.kew.routeheader.service.RouteHeaderService;
28  import org.kuali.rice.kew.service.KEWServiceLocator;
29  import org.kuali.rice.kew.test.KEWTestCase;
30  import org.kuali.rice.kew.test.TestUtilities;
31  import org.kuali.rice.kew.util.WebFriendlyRecipient;
32  import org.kuali.rice.kim.api.KimConstants;
33  import org.kuali.rice.kim.api.group.Group;
34  import org.kuali.rice.kim.api.identity.Person;
35  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
36  import org.springframework.jdbc.core.StatementCallback;
37  import org.springframework.transaction.TransactionStatus;
38  import org.springframework.transaction.support.TransactionCallback;
39  import org.springframework.transaction.support.TransactionTemplate;
40  
41  import java.sql.Connection;
42  import java.sql.PreparedStatement;
43  import java.sql.ResultSet;
44  import java.sql.Statement;
45  import java.sql.Timestamp;
46  import java.util.ArrayList;
47  import java.util.Collection;
48  import java.util.Date;
49  import java.util.Iterator;
50  import java.util.List;
51  
52  import static org.junit.Assert.*;
53  
54  /**
55   * @author Kuali Rice Team (rice.collab@kuali.org)
56   */
57  public class ActionListTest extends KEWTestCase {
58  
59      private static final String[] AUTHENTICATION_IDS = { "ewestfal", "rkirkend", "jhopf", "bmcgough" };
60      private static final String[] WORKGROUP_IDS = { "1", "2", "3", "4" };
61  
62      private DocumentRouteHeaderValue routeHeader1;
63      private DocumentRouteHeaderValue routeHeader2;
64      private DocumentRouteHeaderValue routeHeader3;
65      private List<ActionItem> actionItems = new ArrayList<ActionItem>();
66  
67      protected void loadTestData() throws Exception {
68          loadXmlFile("ActionListConfig.xml");
69      }
70  
71      private void setUpOldSchool() throws Exception {
72          super.setUpAfterDataLoad();
73          List<ActionItem> actionItems1 = new ArrayList<ActionItem>();
74          List<ActionItem> actionItems2 = new ArrayList<ActionItem>();
75          List<ActionItem> actionItems3 = new ArrayList<ActionItem>();
76          routeHeader1 = generateDocRouteHeader();
77          routeHeader2 = generateDocRouteHeader();
78          routeHeader3 = generateDocRouteHeader();
79          
80          getRouteHeaderService().saveRouteHeader(routeHeader1);
81          getRouteHeaderService().saveRouteHeader(routeHeader2);
82          getRouteHeaderService().saveRouteHeader(routeHeader3);
83  
84          for (int i = 0; i < AUTHENTICATION_IDS.length; i++) {
85              actionItems1.add(generateActionItem(routeHeader1, "K", AUTHENTICATION_IDS[i], null));
86              actionItems2.add(generateActionItem(routeHeader2, "A", AUTHENTICATION_IDS[i], null));
87          }
88          for (int i = 0; i < WORKGROUP_IDS.length; i++) {
89              actionItems3.add(generateActionItem(routeHeader3, "A", AUTHENTICATION_IDS[i], WORKGROUP_IDS[i]));
90          }
91          
92          actionItems.addAll(actionItems1);
93          actionItems.addAll(actionItems2);
94          actionItems.addAll(actionItems3);
95          for (Iterator<ActionItem> iterator = actionItems.iterator(); iterator.hasNext();) {
96              ActionItem actionItem = iterator.next();
97              getActionListService().saveActionItem(actionItem);
98          }
99      }
100 
101     @Test public void testRouteHeaderDelete() throws Exception {
102     	setUpOldSchool();
103         Collection<ActionItem> actionItems = getActionListService().findByDocumentId(routeHeader1.getDocumentId());
104         assertEquals("Route header " + routeHeader1.getDocumentId() + " should have action items.", AUTHENTICATION_IDS.length, actionItems.size());
105         getActionListService().deleteByDocumentId(routeHeader1.getDocumentId());
106         actionItems = getActionListService().findByDocumentId(routeHeader1.getDocumentId());
107         assertEquals("There should be no remaining action items for route header " + routeHeader1.getDocumentId(), 0, actionItems.size());
108         actionItems = getActionListService().findByDocumentId(routeHeader2.getDocumentId());
109         assertEquals("Route header " + routeHeader2.getDocumentId() + " should have action items.", AUTHENTICATION_IDS.length, actionItems.size());
110     }
111 
112     @Test public void testActionListCount() throws Exception {
113     	setUpOldSchool();
114         TransactionTemplate transactionTemplate = getTransactionTemplate();
115         transactionTemplate.execute(new TransactionCallback() {
116             public Object doInTransaction(TransactionStatus status) {
117             	return TestUtilities.getJdbcTemplate().execute(new StatementCallback() {
118             		public Object doInStatement(Statement stmt) {
119                         try {
120                             Connection conn = stmt.getConnection();
121                             PreparedStatement ps = conn.prepareStatement("select distinct PRNCPL_ID from krew_actn_itm_t");
122                             ResultSet rs = ps.executeQuery();
123                             int emplIdCnt = 0;
124                             int loopCnt = 0;
125                             //do first 5 for time sake
126                             while (rs.next() && ++loopCnt < 6) {
127                                 String workflowId = rs.getString(1);
128                                 PreparedStatement ps1 = conn.prepareStatement("select count(*) from krew_actn_itm_t where PRNCPL_ID = ?");
129                                 ps1.setString(1, workflowId);
130                                 ResultSet rsWorkflowIdCnt = ps1.executeQuery();
131                                 if (rsWorkflowIdCnt.next()) {
132                                     emplIdCnt = rsWorkflowIdCnt.getInt(1);
133                                 } else {
134                                     throw new Exception("WorkflowId " + workflowId + " didn't return a count.  Test SQL invalid.");
135                                 }
136                                 Collection<ActionItem> actionList = getActionListService().findByPrincipalId(workflowId);
137                                 assertEquals("ActionItemService returned incorrect number of ActionItems for user " + workflowId + " ActionList", emplIdCnt, actionList.size());
138                                 ps1.close();
139                                 rsWorkflowIdCnt.close();
140                             }
141                             rs.close();
142                             ps.close();
143                         } catch (Exception e) {
144                             throw new RuntimeException(e);
145                         }
146                         return null;
147                     }
148                 });
149             }
150         });
151     }
152 
153     /**
154      * Tests that the user's secondary action list works appropriately.  Also checks that if a user
155      * is their own secondary delegate, their request shows up in their main action list rather than
156      * their secondary list.
157      */
158     @Test public void testSecondaryActionList() throws Exception {
159     	WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jhopf"), "ActionListDocumentType");
160     	document.route("");
161 
162     	// at this point the document should be routed to the following people
163     	// 1) approve to bmcgough with primary delegate of rkirkend and secondary delegates of ewestfal and bmcgough (himself)
164     	// 2) approve to jitrue with a secondary delegate of jitrue (himself)
165     	// 3) acknowledge to user1
166     	// 4) approve to NonSIT workgroup (which should include user1)
167 
168     	// now lets verify that everyone's action lists look correct
169 
170     	String bmcgoughPrincipalId = getPrincipalIdForName("bmcgough");
171     	String rkirkendPrincipalId = getPrincipalIdForName("rkirkend");
172     	String ewestfalPrincipalId = getPrincipalIdForName("ewestfal");
173     	String jitruePrincipalId = getPrincipalIdForName("jitrue");
174     	String user1PrincipalId = getPrincipalIdForName("user1");
175 
176     	Group NonSIT = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName(
177                 KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "NonSIT");
178 
179     	ActionListFilter noFilter = new ActionListFilter();
180     	ActionListFilter excludeSecondaryFilter = new ActionListFilter();
181     	excludeSecondaryFilter.setDelegationType(DelegationType.SECONDARY.getCode());
182     	excludeSecondaryFilter.setExcludeDelegationType(true);
183     	ActionListFilter secondaryFilter = new ActionListFilter();
184     	secondaryFilter.setDelegationType(DelegationType.SECONDARY.getCode());
185     	Collection<ActionItem> actionItems = null;
186     	ActionItem actionItem = null;
187 
188     	actionItems = getActionListService().getActionList(bmcgoughPrincipalId, excludeSecondaryFilter);
189     	assertEquals("bmcgough should have 0 items in his primary action list.", 0, actionItems.size());
190     	actionItems = getActionListService().getActionList(bmcgoughPrincipalId, secondaryFilter);
191     	assertEquals("bmcgough should have 1 item in his secondary action list.", 1, actionItems.size());
192         actionItem = actionItems.iterator().next();
193         assertEquals("Should be an approve request.", KewApiConstants.ACTION_REQUEST_APPROVE_REQ, actionItem.getActionRequestCd());
194         assertEquals("Should be a secondary delegation request.", DelegationType.SECONDARY, actionItem.getDelegationType());
195     	actionItem = actionItems.iterator().next();
196     	assertEquals("Should be an approve request.", KewApiConstants.ACTION_REQUEST_APPROVE_REQ, actionItem.getActionRequestCd());
197     	assertEquals("Should be a secondary delegation request.", DelegationType.SECONDARY, actionItem.getDelegationType());
198     	actionItems = getActionListService().getActionList(bmcgoughPrincipalId, noFilter);
199     	assertEquals("bmcgough should have 1 item in his entire action list.", 1, actionItems.size());
200 
201     	actionItems = getActionListService().getActionList(rkirkendPrincipalId, excludeSecondaryFilter);
202     	assertEquals("bmcgough should have 1 item in his primary action list.", 1, actionItems.size());
203 
204     	actionItems = getActionListService().getActionList(jitruePrincipalId, excludeSecondaryFilter);
205     	assertEquals("jitrue should have 1 item in his primary action list.", 1, actionItems.size());
206 
207     	actionItems = getActionListService().getActionList(ewestfalPrincipalId, secondaryFilter);
208     	assertEquals("ewestfal should have 1 item in his secondary action list.", 1, actionItems.size());
209 
210     	// check that user1's approve comes out as their action item from the action list
211     	actionItems = getActionListService().getActionList(user1PrincipalId, noFilter);
212     	assertEquals("user1 should have 1 item in his primary action list.", 1, actionItems.size());
213     	actionItem = actionItems.iterator().next();
214     	assertEquals("Should be an approve request.", KewApiConstants.ACTION_REQUEST_APPROVE_REQ, actionItem.getActionRequestCd());
215     	assertEquals("Should be to a workgroup.", NonSIT.getId(), actionItem.getGroupId());
216     	// check that user1 acknowledge shows up when filtering
217     	ActionListFilter ackFilter = new ActionListFilter();
218     	ackFilter.setActionRequestCd(KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ);
219     	actionItems = getActionListService().getActionList(user1PrincipalId, ackFilter);
220     	assertEquals("user1 should have 1 item in his primary action list.", 1, actionItems.size());
221     	actionItem = (ActionItem)actionItems.iterator().next();
222     	assertEquals("Should be an acknowledge request.", KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, actionItem.getActionRequestCd());
223     	assertNull("Should not be to a workgroup.", actionItem.getGroupId());
224 
225     	// all members of NonSIT should have a single primary Approve Request
226         List<String> memberPrincipalIds = KimApiServiceLocator.getGroupService().getMemberPrincipalIds(NonSIT.getId());
227         for (String memberPrincipalId : memberPrincipalIds)
228         {
229             //will want to convert to Kim Principal
230             actionItems = getActionListService().getActionList(memberPrincipalId, excludeSecondaryFilter);
231             assertEquals("Workgroup Member " + memberPrincipalId + " should have 1 action item.", 1, actionItems.size());
232             actionItem = (ActionItem) actionItems.iterator().next();
233             assertEquals("Should be an approve request.", KewApiConstants.ACTION_REQUEST_APPROVE_REQ, actionItem.getActionRequestCd());
234             assertEquals("Should be to a workgroup.", NonSIT.getId(), actionItem.getGroupId());
235         }
236 
237         document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jhopf"), "ActionListDocumentType_PrimaryDelegate");
238         document.route("");
239         document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jhopf"), "ActionListDocumentType_PrimaryDelegate2");
240         document.route("");
241 
242         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, excludeSecondaryFilter);
243         assertEquals("bmcgough should have 0 items in his primary action list.", 0, actionItems.size());
244         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, secondaryFilter);
245         assertEquals("bmcgough should have 1 item in his secondary action list.", 3, actionItems.size());
246         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, new ActionListFilter());
247         assertEquals("bmcgough should have 1 item in his entire action list.", 3, actionItems.size());
248 
249         ActionListFilter filter = null;
250         // test a standard filter with no delegations
251         filter = new ActionListFilter();
252         filter.setDelegatorId(KewApiConstants.DELEGATION_DEFAULT);
253         filter.setPrimaryDelegateId(KewApiConstants.PRIMARY_DELEGATION_DEFAULT);
254         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
255         assertEquals("bmcgough should have 0 items in his entire action list.", 0, actionItems.size());
256 
257         // test secondary delegation with all selected returns all
258         filter = new ActionListFilter();
259         filter.setDelegationType(DelegationType.SECONDARY.getCode());
260         filter.setDelegatorId(KewApiConstants.ALL_CODE);
261         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
262         assertEquals("bmcgough has incorrect action list item count.", 3, actionItems.size());
263 
264         // test that primary delegation with none selected returns none
265         filter = new ActionListFilter();
266         filter.setDelegationType(DelegationType.SECONDARY.getCode());
267         filter.setDelegatorId(KewApiConstants.DELEGATION_DEFAULT);
268         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
269         assertEquals("bmcgough has incorrect action list item count.", 0, actionItems.size());
270 
271         // test that primary delegation with single user ids works corectly
272         filter = new ActionListFilter();
273         filter.setDelegationType(DelegationType.SECONDARY.getCode());
274         filter.setDelegatorId(bmcgoughPrincipalId);
275         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
276         assertEquals("bmcgough has incorrect action list item count.", 3, actionItems.size());
277         filter = new ActionListFilter();
278         filter.setDelegationType(DelegationType.SECONDARY.getCode());
279         filter.setDelegatorId(bmcgoughPrincipalId);
280         actionItems = getActionListService().getActionList(ewestfalPrincipalId, filter);
281         assertEquals("ewestfal has incorrect action list item count.", 3, actionItems.size());
282         filter = new ActionListFilter();
283         filter.setDelegationType(DelegationType.SECONDARY.getCode());
284         filter.setDelegatorId(jitruePrincipalId);
285         actionItems = getActionListService().getActionList(jitruePrincipalId, filter);
286         assertEquals("jitrue has incorrect action list item count.", 3, actionItems.size());
287     }
288 
289     /**
290      * Tests that the user's secondary action list works appropriately.  Also checks that if a user
291      * is their own secondary delegate, their request shows up in their main action list rather than
292      * their secondary list.
293      */
294     @Test public void testPrimaryDelegationActionList() throws Exception {
295     	WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jhopf"), "ActionListDocumentType");
296     	document.route("");
297 
298     	// at this point the document should be routed to the following people
299     	// 1) approve to bmcgough with primary delegate of rkirkend and secondary delegates of ewestfal and bmcgough (himself)
300     	// 2) approve to jitrue with a secondary delegate of jitrue (himself)
301     	// 3) acknowledge to user1
302     	// 4) approve to NonSIT workgroup (which should include user1)
303 
304     	// now lets verify that everyone's action lists look correct
305 
306     	String bmcgoughPrincipalId = getPrincipalIdForName("bmcgough");
307     	String rkirkendPrincipalId = getPrincipalIdForName("rkirkend");
308     	String delyeaPrincipalId = getPrincipalIdForName("delyea");
309     	String temayPrincipalId = getPrincipalIdForName("temay");
310     	String jhopfPrincipalId = getPrincipalIdForName("jhopf");
311 
312     	ActionListFilter showPrimaryFilter = new ActionListFilter();
313     	showPrimaryFilter.setDelegationType(DelegationType.PRIMARY.getCode());
314     	Collection<ActionItem> actionItems = null;
315     	ActionItem actionItem = null;
316 
317     	// make sure showing primary delegations show primary delegated action items
318     	actionItems = getActionListService().getActionList(bmcgoughPrincipalId, showPrimaryFilter);
319     	assertEquals("bmcgough should have 1 item in his primary delegation action list.", 1, actionItems.size());
320     	actionItems = getActionListService().getActionList(bmcgoughPrincipalId, new ActionListFilter());
321     	assertEquals("bmcgough should have 1 item in his entire action list.", 1, actionItems.size());
322 
323     	document = WorkflowDocumentFactory.createDocument(jhopfPrincipalId, "ActionListDocumentType_PrimaryDelegate");
324     	document.route("");
325     	document = WorkflowDocumentFactory.createDocument(jhopfPrincipalId, "ActionListDocumentType_PrimaryDelegate2");
326         document.route("");
327 
328         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, showPrimaryFilter);
329         // should be 6 total action items but 3 distinct doc ids
330         assertEquals("bmcgough should have 1 item in his primary delegation action list.", 3, actionItems.size());
331 
332         ActionListFilter filter = null;
333 
334         // test a standard filter with no delegations
335         filter = new ActionListFilter();
336         filter.setDelegatorId(KewApiConstants.DELEGATION_DEFAULT);
337         filter.setPrimaryDelegateId(KewApiConstants.PRIMARY_DELEGATION_DEFAULT);
338         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
339         assertEquals("bmcgough should have 0 items in his entire action list.", 0, actionItems.size());
340 
341         // test primary delegation with all selected returns all
342         filter = new ActionListFilter();
343         filter.setDelegationType(DelegationType.PRIMARY.getCode());
344         filter.setPrimaryDelegateId(KewApiConstants.ALL_CODE);
345         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
346         assertEquals("bmcgough should have 1 item in his entire action list.", 3, actionItems.size());
347 
348         // test that primary delegation with none selected returns none
349         filter = new ActionListFilter();
350         filter.setDelegationType(DelegationType.PRIMARY.getCode());
351         filter.setPrimaryDelegateId(KewApiConstants.PRIMARY_DELEGATION_DEFAULT);
352         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
353         assertEquals("bmcgough should have 1 item in his entire action list.", 0, actionItems.size());
354 
355         // test that primary delegation with single user ids works corectly
356         filter = new ActionListFilter();
357         filter.setDelegationType(DelegationType.PRIMARY.getCode());
358         filter.setPrimaryDelegateId(rkirkendPrincipalId);
359         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
360         assertEquals("bmcgough should have 3 items in his entire action list.", 3, actionItems.size());
361         filter = new ActionListFilter();
362         filter.setDelegationType(DelegationType.PRIMARY.getCode());
363         filter.setPrimaryDelegateId(delyeaPrincipalId);
364         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
365         assertEquals("bmcgough should have 2 items in his entire action list.", 2, actionItems.size());
366         filter = new ActionListFilter();
367         filter.setDelegationType(DelegationType.PRIMARY.getCode());
368         filter.setPrimaryDelegateId(temayPrincipalId);
369         actionItems = getActionListService().getActionList(bmcgoughPrincipalId, filter);
370         assertEquals("bmcgough should have 1 item in his entire action list.", 1, actionItems.size());
371 
372     }
373 
374     /**
375      * Tests that the retrieval of primary and secondary delegation users is working correctly
376      */
377     @Test public void testGettingDelegationUsers() throws Exception {
378 
379         Person jhopf = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("jhopf");
380         Person bmcgough = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("bmcgough");
381     	WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jhopf"), "ActionListDocumentType");
382     	document.route("");
383         document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jhopf"), "ActionListDocumentType_PrimaryDelegate");
384         document.route("");
385         document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jhopf"), "ActionListDocumentType_PrimaryDelegate2");
386         document.route("");
387 
388         Collection<Recipient> recipients = getActionListService().findUserPrimaryDelegations(jhopf.getPrincipalId());
389         assertEquals("Wrong size of users who were delegated to via Primary Delegation", 0, recipients.size());
390     	recipients = getActionListService().findUserPrimaryDelegations(bmcgough.getPrincipalId());
391     	assertEquals("Wrong size of users who were delegated to via Primary Delegation", 3, recipients.size());
392     	String user1 = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("rkirkend").getPrincipalId();
393     	String user2 = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("temay").getPrincipalId();
394     	String user3 = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("delyea").getPrincipalId();
395 
396     	boolean foundUser1 = false;
397         boolean foundUser2 = false;
398         boolean foundUser3 = false;
399     	for (Recipient recipient : recipients) {
400             if (user1.equals(((WebFriendlyRecipient)recipient).getRecipientId())) {
401                 foundUser1 = true;
402             } else if (user2.equals(((WebFriendlyRecipient)recipient).getRecipientId())) {
403                 foundUser2 = true;
404             } else if (user3.equals(((WebFriendlyRecipient)recipient).getRecipientId())) {
405                 foundUser3 = true;
406             } else {
407                 fail("Found invalid recipient in list with display name '" + ((WebFriendlyRecipient)recipient).getDisplayName() + "'");
408             }
409         }
410     	assertTrue("Should have found user " + user1, foundUser1);
411         assertTrue("Should have found user " + user2, foundUser2);
412         assertTrue("Should have found user " + user3, foundUser3);
413 
414     	recipients = getActionListService().findUserSecondaryDelegators(bmcgough.getPrincipalId());
415     	assertEquals("Wrong size of users who were have delegated to given user via Secondary Delegation", 1, recipients.size());
416     	WebFriendlyRecipient recipient = (WebFriendlyRecipient)recipients.iterator().next();
417     	assertEquals("Wrong employee id of primary delegate", "bmcgough", getPrincipalNameForId(recipient.getRecipientId()));
418     }
419 
420     private DocumentRouteHeaderValue generateDocRouteHeader() {
421         DocumentRouteHeaderValue routeHeader = new DocumentRouteHeaderValue();
422         routeHeader.setAppDocId("Test");
423         routeHeader.setApprovedDate(null);
424         routeHeader.setCreateDate(new Timestamp(new Date().getTime()));
425         routeHeader.setDocContent("test");
426         routeHeader.setDocRouteLevel(1);
427         routeHeader.setDocRouteStatus(KewApiConstants.ROUTE_HEADER_ENROUTE_CD);
428         routeHeader.setDocTitle("Test");
429         routeHeader.setDocumentTypeId("1");
430         routeHeader.setDocVersion(KewApiConstants.DocumentContentVersions.CURRENT);
431         routeHeader.setRouteStatusDate(new Timestamp(new Date().getTime()));
432         routeHeader.setDateModified(new Timestamp(new Date().getTime()));
433         routeHeader.setInitiatorWorkflowId("someone");
434         return routeHeader;
435     }
436 
437     private ActionItem generateActionItem(DocumentRouteHeaderValue routeHeader, String actionRequested, String authenticationId, String groupId) {
438         ActionItem actionItem = new ActionItem();
439         actionItem.setActionRequestCd(actionRequested);
440         actionItem.setActionRequestId("1");
441         actionItem.setPrincipalId(getPrincipalIdForName(authenticationId));
442         actionItem.setDocumentId(routeHeader.getDocumentId());
443         actionItem.setDateAssigned(new Timestamp(new Date().getTime()));
444         actionItem.setDocHandlerURL("Unit testing");
445         actionItem.setDocLabel("unit testing");
446         actionItem.setDocTitle(routeHeader.getDocTitle());
447         actionItem.setDocName("docname");
448         actionItem.setGroupId(groupId);
449 //        actionItem.setResponsibilityId(new Long(-1));
450         return actionItem;
451     }
452 
453     private ActionListService getActionListService() {
454         return KEWServiceLocator.getActionListService();
455     }
456 
457     private RouteHeaderService getRouteHeaderService() {
458         return KEWServiceLocator.getRouteHeaderService();
459     }
460 }