1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.actions;
18
19 import org.junit.Test;
20 import org.kuali.rice.kew.dto.NetworkIdDTO;
21 import org.kuali.rice.kew.dto.UserIdDTO;
22 import org.kuali.rice.kew.service.WorkflowDocument;
23 import org.kuali.rice.kew.test.KEWTestCase;
24 import org.kuali.rice.kew.util.KEWConstants;
25 import org.kuali.rice.kim.util.KimConstants;
26
27
28
29
30
31
32 public class AcknowledgeActionTest extends KEWTestCase {
33
34 private String getSavedStatusDisplayValue() {
35 return (String) KEWConstants.DOCUMENT_STATUSES.get(KEWConstants.ROUTE_HEADER_SAVED_CD);
36 }
37
38 @Test public void testSavedDocumentAdhocRequest() throws Exception {
39 WorkflowDocument doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), "TestDocumentType");
40 doc.saveDocument("");
41 doc.adHocRouteDocumentToPrincipal(KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, "annotation1", getPrincipalIdForName("dewey"), "respDesc1", false);
42 UserIdDTO user = new NetworkIdDTO("dewey");
43 doc = new WorkflowDocument(user, doc.getRouteHeaderId());
44 assertTrue("Acknowledge should be requested of user " + user, doc.isAcknowledgeRequested());
45 try {
46 doc.acknowledge("");
47 } catch (Exception e) {
48 fail("A non-initator with an Ack request should be allowed to take the Ack action on a " + getSavedStatusDisplayValue() + " document");
49 }
50 assertTrue("Document should be " + getSavedStatusDisplayValue(), doc.stateIsSaved());
51
52 UserIdDTO workgroupUser = new NetworkIdDTO("dewey");
53 doc = new WorkflowDocument(new NetworkIdDTO("rkirkend"), "TestDocumentType");
54 doc.saveDocument("");
55
56 doc.adHocRouteDocumentToGroup(KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, "annotation1", getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "NonSIT"), "respDesc1", false);
57 doc = new WorkflowDocument(workgroupUser, doc.getRouteHeaderId());
58 assertTrue("Acknowledge should be requested of user " + workgroupUser, doc.isAcknowledgeRequested());
59 try {
60 doc.acknowledge("");
61 } catch (Exception e) {
62 fail("A non-initator with an Ack request should be allowed to take the Ack action on a " + getSavedStatusDisplayValue() + " document");
63 }
64 assertTrue("Document should be " + getSavedStatusDisplayValue(), doc.stateIsSaved());
65 }
66 }