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 org.junit.Before;
19 import org.junit.Test;
20 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
21 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
22 import org.kuali.rice.krms.api.repository.term.TermSpecificationDefinition;
23 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
24 import org.kuali.rice.krms.impl.repository.TermBoService;
25 import org.kuali.rice.test.BaselineTestCase;
26
27 import java.util.Arrays;
28 import java.util.Collections;
29
30 import static org.junit.Assert.assertNotNull;
31 import static org.junit.Assert.assertTrue;
32
33 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.CLEAR_DB)
34 public class TermBoServiceTest extends AbstractBoTest {
35
36 TermBoService termBoService = null;
37
38 @Override
39 @Before
40 public void setUp() throws Exception {
41 super.setUp();
42 termBoService = KrmsRepositoryServiceLocator.getTermBoService();
43 }
44
45 @Test
46 public void testPersistTermSpecificationContextIds() {
47
48 ContextDefinition context1 = createContextDefinition("KR-SAP", "TermBoServiceTest-Context1", Collections.<String,String>emptyMap());
49 ContextDefinition context2 = createContextDefinition("KR-SAP", "TermBoServiceTest-Context2", Collections.<String,String>emptyMap());
50
51 termBoService = GlobalResourceLoader.getService("termBoService");
52
53 TermSpecificationDefinition.Builder termSpecBuilder =
54 TermSpecificationDefinition.Builder.create(null, "1", "testTermSpec", "java.lang.String");
55
56 termSpecBuilder.getContextIds().add(context1.getId());
57 termSpecBuilder.getContextIds().add(context2.getId());
58
59 TermSpecificationDefinition termSpecificationDefinition = termBoService.createTermSpecification(termSpecBuilder.build());
60
61 assertNotNull(termSpecificationDefinition);
62 assertTrue(termSpecificationDefinition.getContextIds().size() == 2);
63 for (String contextId : Arrays.asList(context1.getId(), context2.getId())) {
64 assertTrue(termSpecificationDefinition.getContextIds().contains(contextId));
65 }
66
67 TermSpecificationDefinition fetchedTermSpec = termBoService.getTermSpecificationById(termSpecificationDefinition.getId());
68
69 for (String contextId : Arrays.asList(context1.getId(), context2.getId())) {
70 assertTrue(fetchedTermSpec.getContextIds().contains(contextId));
71 }
72 }
73
74 }