1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.ui;
17
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
21 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
22 import org.kuali.rice.krms.api.repository.type.KrmsTypeDefinition;
23 import org.kuali.rice.krms.impl.repository.ActionBoService;
24 import org.kuali.rice.krms.impl.repository.ActionBoServiceImpl;
25 import org.kuali.rice.krms.impl.repository.AgendaBo;
26 import org.kuali.rice.krms.impl.repository.AgendaBoService;
27 import org.kuali.rice.krms.impl.repository.AgendaBoServiceImpl;
28 import org.kuali.rice.krms.impl.repository.ContextBoServiceImpl;
29 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
30 import org.kuali.rice.krms.impl.repository.PropositionBoService;
31 import org.kuali.rice.krms.impl.repository.PropositionBoServiceImpl;
32 import org.kuali.rice.krms.impl.repository.RuleBoService;
33 import org.kuali.rice.krms.impl.repository.RuleBoServiceImpl;
34 import org.kuali.rice.krms.impl.repository.TermBoService;
35 import org.kuali.rice.krms.impl.repository.TermBoServiceImpl;
36 import org.kuali.rice.krms.test.AbstractBoTest;
37 import org.kuali.rice.test.BaselineTestCase.BaselineMode;
38 import org.kuali.rice.test.BaselineTestCase.Mode;
39
40 import java.util.Collections;
41 import java.util.HashMap;
42 import java.util.Map;
43
44
45
46
47
48 @BaselineMode(Mode.CLEAR_DB)
49 public class AgendaEditorMaintainableIntegrationTest extends AbstractBoTest {
50
51 static final String NAMESPACE1 = "AEMIT_KRMS_TEST_1";
52 static final String CONTEXT1 = "AEMIT_Context1";
53
54 static final String CONTEXT1_QUALIFIER = "Context1Qualifier";
55 static final String CONTEXT1_QUALIFIER_VALUE = "BLAH1";
56 static final String AGENDA1 = "TestAgenda1";
57
58 private PropositionBoService propositionBoService;
59 private TermBoService termBoService;
60 private AgendaBoService agendaBoService;
61 private RuleBoService ruleBoService;
62 private ActionBoService actionBoService;
63
64 @Before
65 public void setup() {
66
67 krmsAttributeDefinitionService = KrmsRepositoryServiceLocator.getKrmsAttributeDefinitionService();
68 krmsTypeRepository = KrmsRepositoryServiceLocator.getKrmsTypeRepositoryService();
69
70
71 propositionBoService = new PropositionBoServiceImpl();
72 ((PropositionBoServiceImpl)propositionBoService).setBusinessObjectService(getBoService());
73 termBoService = new TermBoServiceImpl();
74 ((TermBoServiceImpl)termBoService).setBusinessObjectService(getBoService());
75 contextRepository = new ContextBoServiceImpl();
76 ((ContextBoServiceImpl)contextRepository).setBusinessObjectService(getBoService());
77 agendaBoService = new AgendaBoServiceImpl();
78 ((AgendaBoServiceImpl)agendaBoService).setBusinessObjectService(getBoService());
79 ((AgendaBoServiceImpl)agendaBoService).setAttributeDefinitionService(krmsAttributeDefinitionService);
80 ruleBoService = new RuleBoServiceImpl();
81 ((RuleBoServiceImpl)ruleBoService).setBusinessObjectService(getBoService());
82 actionBoService = new ActionBoServiceImpl();
83 ((ActionBoServiceImpl)actionBoService).setBusinessObjectService(getBoService());
84 }
85
86 @Test
87 public void testEmptyAgendaDelete() {
88 ContextDefinition contextDefintion1 = createContextDefinition(NAMESPACE1, CONTEXT1, Collections.singletonMap(
89 CONTEXT1_QUALIFIER, CONTEXT1_QUALIFIER_VALUE));
90 createAgendaDefinition(AGENDA1, "AgendaLabel", contextDefintion1);
91 AgendaDefinition agendaDefinition = agendaBoService.getAgendaByNameAndContextId(AGENDA1, contextDefintion1.getId());
92
93 lookupAndSaveDataObject(agendaDefinition);
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 private void lookupAndSaveDataObject(AgendaDefinition agendaDefinition) {
115 AgendaBo blah = findAgendaByPrimaryKey(agendaDefinition);
116
117 AgendaEditorMaintainable aem = new AgendaEditorMaintainable();
118 AgendaEditor ae = new AgendaEditor();
119 ae.setAgenda(blah);
120 aem.setDataObject(ae);
121 aem.saveDataObject();
122 }
123
124 private AgendaBo findAgendaByPrimaryKey(AgendaDefinition agendaDefinition) {Map<String,String>
125 primaryKeys = new HashMap<String, String>();
126 primaryKeys.put("id", agendaDefinition.getId());
127 return getBoService().findByPrimaryKey(AgendaBo.class, primaryKeys);
128 }
129
130 private void createAgendaDefinition(String agendaName, String agendaLabel, ContextDefinition contextDefinition) {
131 KrmsTypeDefinition krmsGenericTypeDefinition = createKrmsGenericTypeDefinition(contextDefinition.getNamespace(), "testAgendaTypeService", agendaName, agendaLabel);
132
133 AgendaDefinition agendaDefinition =
134 AgendaDefinition.Builder.create(null, agendaName, krmsGenericTypeDefinition.getId(), contextDefinition.getId()).build();
135 agendaDefinition = agendaBoService.createAgenda(agendaDefinition);
136 agendaBoService.updateAgenda(agendaDefinition);
137
138 AgendaBo blah = findAgendaByPrimaryKey(agendaDefinition);
139
140 AgendaDefinition.Builder agendaDefBuilder1 = AgendaDefinition.Builder.create(agendaBoService.to(blah));
141 agendaDefinition = agendaDefBuilder1.build();
142
143 agendaBoService.updateAgenda(agendaDefinition);
144 }
145 }