1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.repository.mock;
17
18 import java.util.ArrayList;
19 import java.util.LinkedHashMap;
20 import java.util.List;
21 import java.util.Map;
22 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
23 import org.kuali.rice.krms.api.repository.function.FunctionDefinition;
24 import org.kuali.rice.krms.api.repository.function.FunctionRepositoryService;
25
26 public class FunctionRepositoryServiceMockImpl implements FunctionRepositoryService {
27
28
29
30 private Map<String, FunctionDefinition> functionDefinitionMap = new LinkedHashMap<String, FunctionDefinition>();
31
32 public Map<String, FunctionDefinition> getFunctionDefinitionMap() {
33 return functionDefinitionMap;
34 }
35
36 public void setFunctionDefinitionMap(Map<String, FunctionDefinition> functionDefinitionMap) {
37 this.functionDefinitionMap = functionDefinitionMap;
38 }
39
40 public void clear() {
41 this.functionDefinitionMap.clear();
42 }
43
44 @Override
45 public FunctionDefinition getFunction(String functionId)
46 throws RiceIllegalArgumentException {
47
48 if (!this.functionDefinitionMap.containsKey(functionId)) {
49 throw new RiceIllegalArgumentException(functionId);
50 }
51 return this.functionDefinitionMap.get(functionId);
52 }
53
54 @Override
55 public List<FunctionDefinition> getFunctions(List<String> functionIds)
56 throws RiceIllegalArgumentException {
57 List<FunctionDefinition> list = new ArrayList<FunctionDefinition> ();
58 for (String id : functionIds) {
59 list.add (this.getFunction(id));
60 }
61 return list;
62 }
63 }