View Javadoc

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