View Javadoc
1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package mocks;
17  
18  import java.util.List;
19  
20  import org.kuali.rice.kew.api.action.ActionType;
21  import org.kuali.rice.kew.framework.postprocessor.ActionTakenEvent;
22  import org.kuali.rice.kew.framework.postprocessor.AfterProcessEvent;
23  import org.kuali.rice.kew.framework.postprocessor.BeforeProcessEvent;
24  import org.kuali.rice.kew.framework.postprocessor.DeleteEvent;
25  import org.kuali.rice.kew.framework.postprocessor.DocumentLockingEvent;
26  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange;
27  import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
28  import org.kuali.rice.kew.framework.postprocessor.PostProcessor;
29  import org.kuali.rice.kew.framework.postprocessor.ProcessDocReport;
30  
31  public class MockPostProcessor implements PostProcessor {
32  
33      private boolean processDocReportResult = true;
34      private boolean actionTakenResult = true;
35      private boolean processMethodsDocReportResult = true;
36      private List<String> documentIdsToLockResult = null;
37      
38      public MockPostProcessor() {
39          this(true);
40      }
41      
42      public MockPostProcessor(boolean processDocReportResult) {
43      	this(processDocReportResult, true);
44      }
45      
46      public MockPostProcessor(boolean processDocReportResult, boolean actionTakenResult) {
47          this(processDocReportResult, actionTakenResult, true);
48      }
49          
50      public MockPostProcessor(boolean processDocReportResult, boolean actionTakenResult, boolean processMethodsDocReportResult) {
51      	this(processDocReportResult, actionTakenResult, processMethodsDocReportResult, null);
52      }
53      
54      public MockPostProcessor(boolean processDocReportResult, boolean actionTakenResult, boolean processMethodsDocReportResult, List<String> documentIdsToLockResult) {
55          this.processDocReportResult = processDocReportResult;
56          this.actionTakenResult = actionTakenResult;
57          this.processMethodsDocReportResult = processMethodsDocReportResult;
58          this.documentIdsToLockResult = documentIdsToLockResult;
59      }
60          
61      public ProcessDocReport doDeleteRouteHeader(DeleteEvent event) throws Exception {
62          return new ProcessDocReport(processDocReportResult, "testing");
63      }
64      public ProcessDocReport doRouteLevelChange(DocumentRouteLevelChange levelChangeEvent) throws Exception {
65          return new ProcessDocReport(processDocReportResult, "testing");
66      }
67      public ProcessDocReport doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) throws Exception {
68          return new ProcessDocReport(processDocReportResult, "testing");
69      }
70      
71      public ProcessDocReport doActionTaken(ActionTakenEvent event) throws Exception {
72      	return new ProcessDocReport(actionTakenResult, "testing");
73  	}
74  
75      public ProcessDocReport afterActionTaken(ActionType performed, ActionTakenEvent event) throws Exception {
76          return new ProcessDocReport(actionTakenResult, "testing");
77      }
78  
79      public ProcessDocReport beforeProcess(BeforeProcessEvent event) throws Exception {
80          return new ProcessDocReport(processMethodsDocReportResult, "testing");
81      }
82  
83      public ProcessDocReport afterProcess(AfterProcessEvent event) throws Exception {
84          return new ProcessDocReport(processMethodsDocReportResult, "testing");
85      }
86  
87      public List<String> getDocumentIdsToLock(DocumentLockingEvent lockingEvent) throws Exception {
88  		return documentIdsToLockResult;
89  	}
90  
91  	public void setProcessDocReportResult(boolean processDocReportResult) {
92          this.processDocReportResult = processDocReportResult;
93      }
94  
95  	public void setActionTakenResult(boolean actionTakenResult) {
96  		this.actionTakenResult = actionTakenResult;
97  	}
98  
99      public void setProcessMethodsDocReportResult(boolean processMethodsDocReportResult) {
100         this.processMethodsDocReportResult = processMethodsDocReportResult;
101     }
102     
103     public void setDocumentIdsToLockResult(List<String> documentIdsToLockResult) {
104     	this.documentIdsToLockResult = documentIdsToLockResult;
105     }
106 
107 }