1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.impl.peopleflow;
18
19 import org.kuali.rice.kew.api.action.ActionType;
20 import org.kuali.rice.kew.engine.RouteContext;
21 import org.kuali.rice.kew.framework.support.krms.RulesEngineExecutor;
22 import org.kuali.rice.krms.api.engine.Engine;
23 import org.kuali.rice.krms.api.engine.EngineResults;
24 import org.kuali.rice.krms.framework.engine.EngineResultsImpl;
25 import org.kuali.rice.krms.impl.peopleflow.PeopleFlowActionTypeService;
26
27 import java.lang.reflect.Field;
28
29
30
31
32
33 public class RulesEngineExecutorMock implements RulesEngineExecutor {
34
35 private static String peopleFlowId = null;
36
37 public static void setPeopleFlowId(String ppfId) {
38 peopleFlowId = ppfId;
39 }
40
41 @Override
42 public EngineResults execute(RouteContext routeContext, Engine engine) {
43 EngineResultsImpl engineResults = new EngineResultsImpl();
44
45 String ppfAttributeName = "";
46
47 try {
48 Field field = PeopleFlowActionTypeService.class.getDeclaredField("PEOPLE_FLOWS_SELECTED_ATTRIBUTE");
49 field.setAccessible(true);
50 ppfAttributeName = (String)field.get(new PeopleFlowActionTypeService(PeopleFlowActionTypeService.Type.APPROVAL));
51 } catch (NoSuchFieldException e) {
52 e.printStackTrace();
53 } catch (IllegalAccessException e) {
54 e.printStackTrace();
55 }
56
57 engineResults.setAttribute(ppfAttributeName, ActionType.APPROVE.getCode() + ":" + peopleFlowId);
58
59 return engineResults;
60 }
61
62 }