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 static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertNull;
21 import static org.junit.Assert.fail;
22
23 import org.junit.Test;
24 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
25 import org.kuali.rice.kew.api.WorkflowDocument;
26 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
27 import org.kuali.rice.kew.api.doctype.IllegalDocumentTypeException;
28 import org.kuali.rice.kew.api.document.Document;
29 import org.kuali.rice.kew.api.document.DocumentStatus;
30 import org.kuali.rice.kew.service.KEWServiceLocator;
31 import org.kuali.rice.kew.test.KEWTestCase;
32
33 public class CreateDocumentTest extends KEWTestCase {
34
35 @Override
36 protected void loadTestData() throws Exception {
37 loadXmlFile("ActionsConfig.xml");
38 }
39
40
41
42
43 @Test(expected=RiceIllegalArgumentException.class)
44 public void testCreateNonExistentDocumentType() throws Exception {
45 WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "flim-flam-flooey");
46 }
47
48
49
50
51 @Test(expected=IllegalDocumentTypeException.class)
52 public void testCreateNonRoutableDocumentType() throws Exception {
53
54
55 WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "BlanketApproveTest");
56 }
57
58
59
60
61 @Test(expected=IllegalDocumentTypeException.class)
62 public void testCreateInactiveDocumentType() throws Exception {
63
64
65 WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "CreatedDocumentInactive");
66 }
67
68
69
70
71 @Test
72 public void testCreateSimpleDocumentType() throws Exception {
73 String principalId = getPrincipalIdForName("ewestfal");
74 WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(principalId, "TestDocumentType");
75 assertNotNull(workflowDocument);
76
77 assertNotNull(workflowDocument.getDocumentId());
78 Document document = workflowDocument.getDocument();
79 assertNotNull(document);
80
81 assertNotNull(document.getDateCreated());
82 assertNotNull(document.getDateLastModified());
83 assertNull(document.getDateApproved());
84 assertNull(document.getDateFinalized());
85
86 assertEquals("", document.getTitle());
87 assertNotNull(document.getDocumentTypeId());
88 assertEquals("TestDocumentType", document.getDocumentTypeName());
89 assertEquals(principalId, document.getInitiatorPrincipalId());
90 assertEquals(DocumentStatus.INITIATED, document.getStatus());
91
92 }
93
94 protected String getPrincipalIdForName(String principalName) {
95 return KEWServiceLocator.getIdentityHelperService().getIdForPrincipalName(principalName);
96 }
97 }