View Javadoc

1   /*
2    * Copyright 2005-2008 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.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   * @author delyea
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  }