View Javadoc

1   /**
2    * Copyright 2005-2013 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 org.kuali.rice.krms.framework;
17  
18  import java.util.HashSet;
19  import java.util.Set;
20  
21  import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
22  import org.kuali.rice.krms.framework.engine.Action;
23  
24  /**
25   * Used to help test agendas
26   * @author gilesp
27   *
28   */
29  public class ActionMock implements Action {
30  
31  	private static final Set<String> actionsFired = new HashSet<String>();
32  	
33  	public static void resetActionsFired() {
34  		actionsFired.clear();
35  	}
36  	
37  	public static boolean actionFired(String name) {
38  		return actionsFired.contains(name);
39  	}
40  	
41  	public ActionMock(String name) {
42  		this.name = name;
43  	}
44  	
45  	private final String name;
46  	
47  	@Override
48  	public void execute(ExecutionEnvironment environment) {
49  		actionsFired.add(name);
50  	}
51  	
52  	/**
53  	 * @see org.kuali.rice.krms.framework.engine.Action#executeSimulation(org.kuali.rice.krms.api.engine.ExecutionEnvironment)
54  	 */
55  	@Override
56  	public void executeSimulation(ExecutionEnvironment environment) {
57  		throw new UnsupportedOperationException();
58  	}
59  	
60  	public boolean actionFired() {
61  		return actionFired(name);
62  	}
63  	
64  }