1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.test;
17
18 import java.util.Collections;
19
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
23 import org.kuali.rice.krms.api.repository.term.TermDefinition;
24 import org.kuali.rice.krms.api.repository.term.TermParameterDefinition;
25 import org.kuali.rice.krms.api.repository.term.TermResolverDefinition;
26 import org.kuali.rice.krms.api.repository.term.TermSpecificationDefinition;
27 import org.kuali.rice.krms.api.repository.type.KrmsTypeDefinition;
28 import org.kuali.rice.krms.api.repository.type.KrmsTypeRepositoryService;
29 import org.kuali.rice.krms.impl.repository.ContextBoService;
30 import org.kuali.rice.krms.impl.repository.ContextBoServiceImpl;
31 import org.kuali.rice.krms.impl.repository.KrmsTypeBoServiceImpl;
32 import org.kuali.rice.krms.impl.repository.TermBoService;
33 import org.kuali.rice.krms.impl.repository.TermBoServiceImpl;
34 import org.kuali.rice.test.BaselineTestCase.BaselineMode;
35 import org.kuali.rice.test.BaselineTestCase.Mode;
36
37 @BaselineMode(Mode.CLEAR_DB)
38 public class TermRelatedBoTest extends AbstractBoTest {
39
40 private TermBoService termBoService;
41 private ContextBoService contextRepository;
42 private KrmsTypeRepositoryService krmsTypeRepository;
43
44 @Before
45 public void setup() {
46
47
48
49 termBoService = new TermBoServiceImpl();
50 ((TermBoServiceImpl)termBoService).setBusinessObjectService(getBoService());
51
52 contextRepository = new ContextBoServiceImpl();
53 ((ContextBoServiceImpl)contextRepository).setBusinessObjectService(getBoService());
54
55 krmsTypeRepository = new KrmsTypeBoServiceImpl();
56 ((KrmsTypeBoServiceImpl)krmsTypeRepository).setBusinessObjectService(getBoService());
57 }
58
59 @Test
60 public void creationTest() {
61
62
63 KrmsTypeDefinition krmsContextTypeDefinition = KrmsTypeDefinition.Builder.create("KrmsTestContextType", "KRMS").build();
64 krmsContextTypeDefinition = krmsTypeRepository.createKrmsType(krmsContextTypeDefinition);
65
66
67 ContextDefinition.Builder contextBuilder = ContextDefinition.Builder.create("KRMS", "testContext");
68 contextBuilder.setTypeId(krmsContextTypeDefinition.getId());
69 ContextDefinition contextDefinition = contextBuilder.build();
70 contextDefinition = contextRepository.createContext(contextDefinition);
71
72
73 TermSpecificationDefinition outputTermSpec =
74 TermSpecificationDefinition.Builder.create(null, "outputTermSpec", contextDefinition.getId(),
75 "java.lang.String").build();
76 outputTermSpec = termBoService.createTermSpecification(outputTermSpec);
77
78
79 TermSpecificationDefinition prereqTermSpec =
80 TermSpecificationDefinition.Builder.create(null, "prereqTermSpec", contextDefinition.getId(),
81 "java.lang.String").build();
82 prereqTermSpec = termBoService.createTermSpecification(prereqTermSpec);
83
84
85 KrmsTypeDefinition krmsTermResolverTypeDefinition = KrmsTypeDefinition.Builder.create("KrmsTestResolverType", "KRMS").build();
86 krmsTermResolverTypeDefinition = krmsTypeRepository.createKrmsType(krmsTermResolverTypeDefinition);
87
88
89 TermResolverDefinition termResolverDef =
90 TermResolverDefinition.Builder.create(null, "KRMS", "testResolver", krmsTermResolverTypeDefinition.getId(),
91 TermSpecificationDefinition.Builder.create(outputTermSpec),
92 Collections.singleton(TermSpecificationDefinition.Builder.create(prereqTermSpec)),
93 null,
94 Collections.singleton("testParamName")).build();
95 termResolverDef = termBoService.createTermResolver(termResolverDef);
96
97
98 TermParameterDefinition.Builder termParamBuilder =
99 TermParameterDefinition.Builder.create(null, null, "testParamName", "testParamValue");
100
101
102 TermDefinition termDefinition =
103 TermDefinition.Builder.create(null, TermSpecificationDefinition.Builder.create(outputTermSpec), Collections.singletonList(termParamBuilder)).build();
104 termBoService.createTerm(termDefinition);
105 }
106
107 }