001/* 002 * Copyright 2006-2014 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 017package org.kuali.rice.kew.impl.peopleflow; 018 019import org.kuali.rice.kew.api.action.ActionType; 020import org.kuali.rice.kew.engine.RouteContext; 021import org.kuali.rice.kew.framework.support.krms.RulesEngineExecutor; 022import org.kuali.rice.krms.api.engine.Engine; 023import org.kuali.rice.krms.api.engine.EngineResults; 024import org.kuali.rice.krms.framework.engine.EngineResultsImpl; 025import org.kuali.rice.krms.impl.peopleflow.PeopleFlowActionTypeService; 026 027import java.lang.reflect.Field; 028 029/** 030 * A test RulesEngineExecutor that doesn't actually call KRMS, it just dummies up some EngineResults and passes them 031 * back. 032 */ 033public class RulesEngineExecutorMock implements RulesEngineExecutor { 034 035 private static String peopleFlowId = null; 036 037 public static void setPeopleFlowId(String ppfId) { 038 peopleFlowId = ppfId; 039 } 040 041 @Override 042 public EngineResults execute(RouteContext routeContext, Engine engine) { 043 EngineResultsImpl engineResults = new EngineResultsImpl(); 044 045 String ppfAttributeName = ""; 046 047 try { 048 Field field = PeopleFlowActionTypeService.class.getDeclaredField("PEOPLE_FLOWS_SELECTED_ATTRIBUTE"); 049 field.setAccessible(true); 050 ppfAttributeName = (String)field.get(new PeopleFlowActionTypeService(PeopleFlowActionTypeService.Type.APPROVAL)); 051 } catch (NoSuchFieldException e) { 052 e.printStackTrace(); 053 } catch (IllegalAccessException e) { 054 e.printStackTrace(); 055 } 056 057 engineResults.setAttribute(ppfAttributeName, ActionType.APPROVE.getCode() + ":" + peopleFlowId); 058 059 return engineResults; 060 } 061 062}