1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.actions;
17
18 import org.junit.Test;
19 import org.kuali.rice.kew.api.WorkflowDocument;
20 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
21 import org.kuali.rice.kew.api.action.ActionRequestType;
22 import org.kuali.rice.kew.test.KEWTestCase;
23 import org.kuali.rice.kew.api.KewApiConstants;
24 import org.kuali.rice.kim.api.KimConstants;
25
26 import static org.junit.Assert.assertTrue;
27 import static org.junit.Assert.fail;
28
29
30
31
32
33 public class ClearFYIActionTest extends KEWTestCase {
34
35 private String getSavedStatusDisplayValue() {
36 return (String) KewApiConstants.DOCUMENT_STATUSES.get(KewApiConstants.ROUTE_HEADER_SAVED_CD);
37 }
38
39 @Test public void testSavedDocumentAdhocRequest() throws Exception {
40 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "TestDocumentType");
41 doc.saveDocument("");
42 doc.adHocToPrincipal(ActionRequestType.FYI, "annotation1", getPrincipalIdForName("dewey"), "respDesc1", false);
43 String userId = getPrincipalIdForName("dewey");
44 doc = WorkflowDocumentFactory.loadDocument(userId, doc.getDocumentId());
45 assertTrue("FYI should be requested of user " + userId, doc.isFYIRequested());
46 try {
47 doc.fyi();
48 } catch (Exception e) {
49 fail("A non-initator with an FYI request should be allowed to take the FYI action on a " + getSavedStatusDisplayValue() + " document");
50 }
51 assertTrue("Document should be " + getSavedStatusDisplayValue(), doc.isSaved());
52
53 String workgroupUserId = getPrincipalIdForName("dewey");
54 doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "TestDocumentType");
55 doc.saveDocument("");
56
57 doc.adHocToGroup(ActionRequestType.FYI, "annotation1", getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "NonSIT"), "respDesc1", false);
58 doc = WorkflowDocumentFactory.loadDocument(workgroupUserId, doc.getDocumentId());
59 assertTrue("FYI should be requested of user " + workgroupUserId, doc.isFYIRequested());
60 try {
61 doc.fyi();
62 } catch (Exception e) {
63 fail("A non-initator with an FYI request should be allowed to take the FYI action on a " + getSavedStatusDisplayValue() + " document");
64 }
65 assertTrue("Document should be " + getSavedStatusDisplayValue(), doc.isSaved());
66 }
67 }