01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.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 edu.iu.uis.eden.actions;
18:
19: import org.junit.Test;
20: import org.kuali.workflow.test.WorkflowTestCase;
21:
22: import edu.iu.uis.eden.EdenConstants;
23: import edu.iu.uis.eden.clientapp.WorkflowDocument;
24: import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
25: import edu.iu.uis.eden.clientapp.vo.UserIdVO;
26: import edu.iu.uis.eden.clientapp.vo.WorkgroupIdVO;
27: import edu.iu.uis.eden.clientapp.vo.WorkgroupNameIdVO;
28:
29: /**
30: *
31: * @author delyea
32: */
33: public class AcknowledgeActionTest extends WorkflowTestCase {
34:
35: private String getSavedStatusDisplayValue() {
36: return (String) EdenConstants.DOCUMENT_STATUSES
37: .get(EdenConstants.ROUTE_HEADER_SAVED_CD);
38: }
39:
40: @Test
41: public void testSavedDocumentAdhocRequest() throws Exception {
42: WorkflowDocument doc = new WorkflowDocument(new NetworkIdVO(
43: "rkirkend"), "TestDocumentType");
44: doc.saveDocument("");
45: UserIdVO user = new NetworkIdVO("dewey");
46: doc.appSpecificRouteDocumentToUser(
47: EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
48: "annotation1", user, "respDesc1", false);
49: doc = new WorkflowDocument(user, doc.getRouteHeaderId());
50: assertTrue("Acknowledge should be requested of user " + user,
51: doc.isAcknowledgeRequested());
52: try {
53: doc.acknowledge("");
54: } catch (Exception e) {
55: fail("A non-initator with an Ack request should be allowed to take the Ack action on a "
56: + getSavedStatusDisplayValue() + " document");
57: }
58: assertTrue(
59: "Document should be " + getSavedStatusDisplayValue(),
60: doc.stateIsSaved());
61:
62: WorkgroupIdVO workgroup = new WorkgroupNameIdVO("NonSIT");
63: UserIdVO workgroupUser = new NetworkIdVO("dewey");
64: doc = new WorkflowDocument(new NetworkIdVO("rkirkend"),
65: "TestDocumentType");
66: doc.saveDocument("");
67: doc.appSpecificRouteDocumentToWorkgroup(
68: EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
69: "annotation1", workgroup, "respDesc1", false);
70: doc = new WorkflowDocument(workgroupUser, doc
71: .getRouteHeaderId());
72: assertTrue("Acknowledge should be requested of user "
73: + workgroupUser, doc.isAcknowledgeRequested());
74: try {
75: doc.acknowledge("");
76: } catch (Exception e) {
77: fail("A non-initator with an Ack request should be allowed to take the Ack action on a "
78: + getSavedStatusDisplayValue() + " document");
79: }
80: assertTrue(
81: "Document should be " + getSavedStatusDisplayValue(),
82: doc.stateIsSaved());
83: }
84: }
|