1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.framework;
17
18 import java.util.Arrays;
19 import java.util.Collections;
20 import java.util.HashSet;
21 import java.util.Map;
22 import java.util.Set;
23
24 import org.apache.commons.lang.ArrayUtils;
25 import org.kuali.rice.krms.api.engine.TermResolver;
26
27
28
29
30
31
32
33 public class TermResolverMock<T> implements TermResolver<T> {
34
35 private T result;
36 private String outputName;
37 private Set<String> params;
38
39 public TermResolverMock(String outputName, T result) {
40 this(outputName, null, result);
41 }
42
43 public TermResolverMock(String outputName, String [] params, T result) {
44 this.outputName = outputName;
45 this.result = result;
46 if (ArrayUtils.isEmpty(params)) {
47 this.params = Collections.emptySet();
48 } else {
49 this.params = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(params)));
50 }
51 }
52
53 @Override
54 public int getCost() { return 1; }
55
56 @Override
57 public String getOutput() { return outputName; }
58
59 @Override
60 public Set<String> getPrerequisites() { return Collections.emptySet(); }
61
62 @Override
63 public Set<String> getParameterNames() {
64 return params;
65 }
66
67 @Override
68 public T resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) {
69 return result;
70 }
71 };