001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krms.framework;
017    
018    import java.util.HashSet;
019    import java.util.Set;
020    
021    import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
022    import org.kuali.rice.krms.framework.engine.Action;
023    
024    /**
025     * Used to help test agendas
026     * @author gilesp
027     *
028     */
029    public class ActionMock implements Action {
030    
031            private static final Set<String> actionsFired = new HashSet<String>();
032            
033            public static void resetActionsFired() {
034                    actionsFired.clear();
035            }
036            
037            public static boolean actionFired(String name) {
038                    return actionsFired.contains(name);
039            }
040            
041            public ActionMock(String name) {
042                    this.name = name;
043            }
044            
045            private final String name;
046            
047            @Override
048            public void execute(ExecutionEnvironment environment) {
049                    actionsFired.add(name);
050            }
051            
052            /**
053             * @see org.kuali.rice.krms.framework.engine.Action#executeSimulation(org.kuali.rice.krms.api.engine.ExecutionEnvironment)
054             */
055            @Override
056            public void executeSimulation(ExecutionEnvironment environment) {
057                    throw new UnsupportedOperationException();
058            }
059            
060            public boolean actionFired() {
061                    return actionFired(name);
062            }
063            
064    }