1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.krms.test;
18
19 import org.junit.Before;
20 import org.kuali.rice.krad.util.ObjectUtils;
21 import org.kuali.rice.krms.api.repository.action.ActionDefinition;
22 import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
23 import org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition;
24 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
25 import org.kuali.rice.krms.api.repository.language.NaturalLanguageTemplate;
26 import org.kuali.rice.krms.api.repository.language.NaturalLanguageUsage;
27 import org.kuali.rice.krms.api.repository.proposition.PropositionDefinition;
28 import org.kuali.rice.krms.api.repository.proposition.PropositionParameter;
29 import org.kuali.rice.krms.api.repository.proposition.PropositionParameterType;
30 import org.kuali.rice.krms.api.repository.proposition.PropositionType;
31 import org.kuali.rice.krms.api.repository.reference.ReferenceObjectBinding;
32 import org.kuali.rice.krms.api.repository.rule.RuleDefinition;
33 import org.kuali.rice.krms.api.repository.term.TermSpecificationDefinition;
34 import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinition;
35 import org.kuali.rice.krms.api.repository.type.KrmsTypeDefinition;
36 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
37 import org.kuali.rice.krms.impl.repository.NaturalLanguageTemplateBoServiceImpl;
38 import org.kuali.rice.krms.impl.repository.NaturalLanguageTemplateIntegrationGenTest;
39 import org.kuali.rice.krms.impl.repository.RuleManagementServiceImpl;
40 import org.kuali.rice.test.BaselineTestCase;
41
42 import java.util.ArrayList;
43 import java.util.HashMap;
44 import java.util.List;
45 import java.util.Map;
46
47 import static org.junit.Assert.assertEquals;
48 import static org.junit.Assert.assertNull;
49 import static org.junit.Assert.assertTrue;
50
51
52
53
54 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.CLEAR_DB)
55 public class RuleManagementBaseTest extends AbstractAgendaBoTest{
56
57
58 RuleManagementServiceImpl ruleManagementServiceImpl;
59
60 protected String CLASS_DISCRIMINATOR = "0";
61
62 @Override
63 @Before
64 public void setup() {
65 ruleManagementServiceImpl = new RuleManagementServiceImpl();
66 NaturalLanguageTemplateBoServiceImpl naturalLanguageTemplateBoServiceImpl = new NaturalLanguageTemplateBoServiceImpl();
67 naturalLanguageTemplateBoServiceImpl.setNaturalLanguageTemplater(
68 NaturalLanguageTemplateIntegrationGenTest.newStringReplaceTemplater());
69 ruleManagementServiceImpl.setNaturalLanguageTemplateBoService(naturalLanguageTemplateBoServiceImpl);
70 ruleManagementServiceImpl.setBusinessObjectService(getBoService());
71 termBoService = KrmsRepositoryServiceLocator.getTermBoService();
72
73 contextRepository = KrmsRepositoryServiceLocator.getContextBoService();
74 krmsTypeRepository = KrmsRepositoryServiceLocator.getKrmsTypeRepositoryService();
75 ruleBoService = KrmsRepositoryServiceLocator.getRuleBoService();
76 agendaBoService = KrmsRepositoryServiceLocator.getAgendaBoService();
77 actionBoService = KrmsRepositoryServiceLocator.getBean("actionBoService");
78 functionBoService = KrmsRepositoryServiceLocator.getBean("functionRepositoryService");
79 krmsAttributeDefinitionService = KrmsRepositoryServiceLocator.getKrmsAttributeDefinitionService();
80 }
81
82
83
84
85
86
87
88
89
90
91
92 @Before
93 public void setClassDiscriminator() {
94
95 CLASS_DISCRIMINATOR = "BaseTest";
96 }
97
98 protected RuleDefinition createTestRule(String namespace, String ruleId) {
99 return ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, ruleId));
100 }
101
102 protected RuleDefinition newTestRuleDefinition(String namespace, String objectDiscriminator) {
103 String ruleId = "RuleId" + objectDiscriminator;
104 PropositionDefinition prop = createTestPropositionForRule(objectDiscriminator);
105 PropositionDefinition.Builder propBuilder = PropositionDefinition.Builder.create(prop);
106 RuleDefinition.Builder builder = RuleDefinition.Builder.create(ruleId, "RuleName" + objectDiscriminator, namespace, null, prop.getId());
107 builder.setProposition(propBuilder);
108
109 return builder.build();
110 }
111
112 protected AgendaItemDefinition newTestAgendaItemDefinition(String id, String agendaId, String ruleId) {
113 AgendaItemDefinition.Builder agendaItemDefinitionBuilder = AgendaItemDefinition.Builder.create(id, agendaId);
114 agendaItemDefinitionBuilder.setRuleId(ruleId);
115
116 return agendaItemDefinitionBuilder.build();
117 }
118
119 protected ActionDefinition createTestActions(String actionId, String actionName, String actionDescr, int actionSequence, String ruleId, String namespace) {
120 KrmsTypeDefinition krmsTypeDefinition = createKrmsActionTypeDefinition(namespace);
121
122
123 if(ruleManagementServiceImpl.getRule(ruleId) == null) {
124 RuleDefinition ruleDefinition = createTestRule(namespace, ruleId);
125 ruleId = ruleDefinition.getId();
126 }
127
128 ActionDefinition actionDefinition = ActionDefinition.Builder.create(actionId,actionName,
129 NAMESPACE1,krmsTypeDefinition.getId(),ruleId,actionSequence).build();
130
131 assertNull("action[" + actionId + "] should not already be in database:", ruleManagementServiceImpl.getAction(actionId ));
132
133 actionDefinition = ruleManagementServiceImpl.createAction(actionDefinition);
134 ActionDefinition returnActionDefinition = ruleManagementServiceImpl.getAction(actionDefinition.getId());
135 ActionDefinition.Builder builder = ActionDefinition.Builder.create(returnActionDefinition);
136 builder.setDescription(actionDescr);
137 ruleManagementServiceImpl.updateAction(builder.build());
138
139 return ruleManagementServiceImpl.getAction(actionDefinition.getId());
140 }
141
142 protected PropositionDefinition createTestPropositionForRule(String objectDiscriminator) {
143 KrmsTypeDefinition krmsTypeDefinition = createKrmsActionTypeDefinition("Namespace" + objectDiscriminator);
144 String ruleId = "RuleId" + objectDiscriminator;
145 String propId = "P" + objectDiscriminator;
146
147 return createTestSimpleProposition("Namespace" + objectDiscriminator, propId, "TSI_" + propId, "ABC", "=", "java.lang.String", ruleId,
148 "TSI_" + propId + "_Descr");
149 }
150
151 protected PropositionDefinition createTestSimpleProposition(String namespace, String propId, String termSpecId, String propConstant, String propOperator, String termSpecType, String ruleId, String termSpecDescr){
152 TermSpecificationDefinition termSpecificationDefinition = createTestTermSpecification(termSpecId, termSpecId, namespace, termSpecType, termSpecDescr);
153 KrmsTypeDefinition krmsTypeDefinition = createKrmsTypeDefinition(namespace, termSpecId, "testTypeService");
154
155 List<PropositionParameter.Builder> propParam = new ArrayList<PropositionParameter.Builder>();
156 propParam.add(PropositionParameter.Builder.create(propId + "_0", "unused_notnull", termSpecId, PropositionParameterType.TERM.getCode(), 0));
157 propParam.add(PropositionParameter.Builder.create(propId + "_1", "unused_notnull", propConstant, PropositionParameterType.CONSTANT.getCode(), 1));
158 propParam.add(PropositionParameter.Builder.create(propId + "_2", "unused_notnull", propOperator, PropositionParameterType.OPERATOR.getCode(), 2));
159 PropositionDefinition.Builder propBuilder = PropositionDefinition.Builder.create(null, PropositionType.SIMPLE.getCode(), ruleId, krmsTypeDefinition.getId(), propParam);
160 propBuilder.setDescription(propId + "_simple_proposition");
161
162 return ruleManagementServiceImpl.createProposition(propBuilder.build());
163 }
164
165 protected TermSpecificationDefinition createTestTermSpecification(String termSpecId, String termSpecName, String namespace, String type, String termSpecDescr){
166 TermSpecificationDefinition termSpecificationDefinition = termBoService.getTermSpecificationByNameAndNamespace(termSpecName,namespace);
167
168 if(termSpecificationDefinition != null) {
169
170 return termSpecificationDefinition;
171 }
172
173 TermSpecificationDefinition.Builder termSpecificationDefinitionBuilder =
174 TermSpecificationDefinition.Builder.create(null, termSpecName, namespace, type);
175 termSpecificationDefinitionBuilder.setDescription(termSpecDescr);
176 termSpecificationDefinition = termSpecificationDefinitionBuilder.build();
177
178 return termBoService.createTermSpecification(termSpecificationDefinition);
179 }
180
181 protected KrmsTypeDefinition createKrmsTypeDefinition(String nameSpace, String typeName, String serviceName) {
182 KrmsTypeDefinition krmsTypeDefinition = krmsTypeRepository.getTypeByName(nameSpace, typeName);
183
184 if (krmsTypeDefinition == null) {
185 KrmsTypeDefinition.Builder krmsTypeDefnBuilder = KrmsTypeDefinition.Builder.create(typeName, nameSpace);
186 krmsTypeDefnBuilder.setServiceName(serviceName);
187 krmsTypeDefinition = krmsTypeRepository.createKrmsType(krmsTypeDefnBuilder.build());
188 }
189
190 return krmsTypeDefinition;
191 }
192
193
194
195
196
197 protected AgendaDefinition.Builder buildAgenda(String objectDiscriminator) {
198 String namespace = "Namespace" + objectDiscriminator;
199
200 ContextDefinition.Builder contextDefinitionBuilder = ContextDefinition.Builder.create(
201 namespace, "ContextName" + objectDiscriminator);
202 contextDefinitionBuilder.setId("ContextId" + objectDiscriminator);
203 ContextDefinition contextDefinition = contextDefinitionBuilder.build();
204 contextDefinition = ruleManagementServiceImpl.createContext(contextDefinition );
205
206
207 AgendaDefinition.Builder agendaBuilder = AgendaDefinition.Builder.create(
208 "AgendaId" + objectDiscriminator, "AgendaName" + objectDiscriminator, null, "ContextId" + objectDiscriminator);
209 AgendaDefinition agenda = agendaBuilder.build();
210 agenda = ruleManagementServiceImpl.createAgenda(agenda);
211
212
213 RuleDefinition rule = ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, objectDiscriminator));
214
215
216 AgendaItemDefinition agendaItem = newTestAgendaItemDefinition("AI" + objectDiscriminator, agenda.getId(), rule.getId());
217 agendaItem = ruleManagementServiceImpl.createAgendaItem(agendaItem);
218
219 agendaBuilder = AgendaDefinition.Builder.create(ruleManagementServiceImpl.getAgenda("AgendaId" + objectDiscriminator));
220 String defaultAgendaItemId = agendaBuilder.getFirstItemId();
221 agendaBuilder.setFirstItemId("AI" + objectDiscriminator);
222 ruleManagementServiceImpl.updateAgenda(agendaBuilder.build());
223
224
225 ruleManagementServiceImpl.deleteAgendaItem(defaultAgendaItemId);
226
227 return AgendaDefinition.Builder.create(ruleManagementServiceImpl.getAgenda(agenda.getId()));
228 }
229
230 protected AgendaDefinition.Builder buildComplexAgenda(RuleManagementBaseTestObjectNames names) {
231 String namespace = "Namespace" + names.discriminator;
232 return buildComplexAgenda(namespace,"AGENDA",names);
233 }
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258 protected AgendaDefinition.Builder buildComplexAgenda(String namespace, String namespaceType, RuleManagementBaseTestObjectNames names) {
259
260 ContextDefinition.Builder contextBuilder = ContextDefinition.Builder.create(
261 namespace, names.contextName);
262 contextBuilder.setId(names.contextId);
263 ContextDefinition context = contextBuilder.build();
264 ruleManagementServiceImpl.createContext(context );
265
266
267 createKrmsTypeDefinition(namespace, namespaceType, null);
268
269
270 AgendaDefinition.Builder agendaBuilder = AgendaDefinition.Builder.create(
271 names.agenda_Id, names.agenda_Name, namespaceType, names.contextId);
272 AgendaDefinition agenda = agendaBuilder.build();
273 agenda = ruleManagementServiceImpl.createAgenda(agenda);
274
275
276 RuleDefinition rule0 = ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, names.object0));
277 RuleDefinition rule1 = ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, names.object1));
278 RuleDefinition rule2 = ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, names.object2));
279 RuleDefinition rule3 = ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, names.object3));
280 RuleDefinition rule4 = ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, names.object4));
281 RuleDefinition rule5 = ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, names.object5));
282 RuleDefinition rule6 = ruleManagementServiceImpl.createRule(newTestRuleDefinition(namespace, names.object6));
283
284
285 AgendaItemDefinition agendaItemOBJECT6 = newTestAgendaItemDefinition(names.agendaItem_6_Id, agenda.getId(), rule6.getId());
286 AgendaItemDefinition.Builder itemBuilderOBJECT6 = AgendaItemDefinition.Builder.create(agendaItemOBJECT6);
287 itemBuilderOBJECT6 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.createAgendaItem(itemBuilderOBJECT6.build()));
288
289 AgendaItemDefinition agendaItemOBJECT5 = newTestAgendaItemDefinition(names.agendaItem_5_Id, agenda.getId(), rule5.getId());
290 AgendaItemDefinition.Builder itemBuilderOBJECT5 = AgendaItemDefinition.Builder.create(agendaItemOBJECT5);
291 itemBuilderOBJECT5 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.createAgendaItem(itemBuilderOBJECT5.build()));
292
293 AgendaItemDefinition agendaItemOBJECT4 = newTestAgendaItemDefinition(names.agendaItem_4_Id, agenda.getId(), rule4.getId());
294 AgendaItemDefinition.Builder itemBuilderOBJECT4 = AgendaItemDefinition.Builder.create(agendaItemOBJECT4);
295 itemBuilderOBJECT4 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.createAgendaItem(
296 itemBuilderOBJECT4.build()));
297
298 AgendaItemDefinition agendaItemOBJECT3 = newTestAgendaItemDefinition(names.agendaItem_3_Id, agenda.getId(), rule3.getId());
299 AgendaItemDefinition.Builder itemBuilderOBJECT3 = AgendaItemDefinition.Builder.create(agendaItemOBJECT3);
300 itemBuilderOBJECT3 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.createAgendaItem(
301 itemBuilderOBJECT3.build()));
302
303 AgendaItemDefinition agendaItemOBJECT2 = newTestAgendaItemDefinition(names.agendaItem_2_Id, agenda.getId(), rule2.getId());
304 AgendaItemDefinition.Builder itemBuilderOBJECT2 = AgendaItemDefinition.Builder.create(agendaItemOBJECT2);
305 itemBuilderOBJECT4 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.getAgendaItem(itemBuilderOBJECT4.getId()));
306 itemBuilderOBJECT2.setWhenFalse(itemBuilderOBJECT4);
307 itemBuilderOBJECT2.setWhenFalseId(itemBuilderOBJECT4.getId());
308 itemBuilderOBJECT6 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.getAgendaItem(itemBuilderOBJECT6.getId()));
309 itemBuilderOBJECT2.setAlways(itemBuilderOBJECT6);
310 itemBuilderOBJECT2.setAlwaysId(itemBuilderOBJECT6.getId());
311 itemBuilderOBJECT2 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.createAgendaItem(
312 itemBuilderOBJECT2.build()));
313
314 AgendaItemDefinition agendaItemOBJECT1 = newTestAgendaItemDefinition(names.agendaItem_1_Id, agenda.getId(), rule1.getId());
315 AgendaItemDefinition.Builder itemBuilderOBJECT1 = AgendaItemDefinition.Builder.create(agendaItemOBJECT1);
316 itemBuilderOBJECT5 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.getAgendaItem(itemBuilderOBJECT5.getId()));
317 itemBuilderOBJECT1.setAlways(itemBuilderOBJECT5);
318 itemBuilderOBJECT1.setAlwaysId(itemBuilderOBJECT5.getId());
319 itemBuilderOBJECT1 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.createAgendaItem(
320 itemBuilderOBJECT1.build()));
321
322 AgendaItemDefinition agendaItemOBJECT0 = newTestAgendaItemDefinition(names.agendaItem_0_Id, agenda.getId(), rule0.getId());
323 AgendaItemDefinition.Builder itemBuilderOBJECT0 = AgendaItemDefinition.Builder.create(agendaItemOBJECT0);
324 itemBuilderOBJECT1 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.getAgendaItem(itemBuilderOBJECT1.getId()));
325 itemBuilderOBJECT0.setWhenTrue(itemBuilderOBJECT1);
326 itemBuilderOBJECT0.setWhenTrueId(itemBuilderOBJECT1.getId());
327 itemBuilderOBJECT2 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.getAgendaItem(itemBuilderOBJECT2.getId()));
328 itemBuilderOBJECT0.setWhenFalse(itemBuilderOBJECT2);
329 itemBuilderOBJECT0.setWhenFalseId(itemBuilderOBJECT2.getId());
330 itemBuilderOBJECT3 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.getAgendaItem(itemBuilderOBJECT3.getId()));
331 itemBuilderOBJECT0.setAlways(itemBuilderOBJECT3);
332 itemBuilderOBJECT0.setAlwaysId(itemBuilderOBJECT3.getId());
333 itemBuilderOBJECT0 = AgendaItemDefinition.Builder.create(ruleManagementServiceImpl.createAgendaItem(itemBuilderOBJECT0.build()));
334
335 agendaBuilder = AgendaDefinition.Builder.create(ruleManagementServiceImpl.getAgenda(agenda.getId()));
336 String defaultAgendaItemId = agendaBuilder.getFirstItemId();
337 agendaBuilder.setFirstItemId(itemBuilderOBJECT0.getId());
338 ruleManagementServiceImpl.updateAgenda(agendaBuilder.build());
339 ruleManagementServiceImpl.deleteAgendaItem(defaultAgendaItemId);
340 List<AgendaItemDefinition> agendaItems = ruleManagementServiceImpl.getAgendaItemsByContext(names.contextId);
341
342 assertEquals("Invalid number of agendaItems created", 7, agendaItems.size());
343
344 return AgendaDefinition.Builder.create(ruleManagementServiceImpl.getAgenda(agenda.getId()));
345 }
346
347
348 protected ReferenceObjectBinding.Builder buildReferenceObjectBinding(String objectDiscriminator) {
349 String namespace = "Namespace" + objectDiscriminator;
350 AgendaDefinition.Builder agendaBuilder = buildAgenda(objectDiscriminator);
351
352 KrmsTypeDefinition krmsTypeDefinition = createKrmsTypeDefinition(namespace, "AgendaType" + objectDiscriminator, null);
353
354 return buildReferenceObjectBinding("ParkingPolicies", agendaBuilder.getId(), krmsTypeDefinition.getId(),
355 namespace, "PA" + objectDiscriminator, "ParkingAffiliationType", true);
356 }
357
358
359 protected ReferenceObjectBinding.Builder buildReferenceObjectBinding(String collectionName, String krmsObjectId, String krmsDiscriminatorType,
360 String namespace, String referenceObjectId, String referenceDiscriminatorType, boolean active) {
361
362 ReferenceObjectBinding.Builder refObjBindingBuilder = ReferenceObjectBinding.Builder.
363 create(krmsDiscriminatorType, krmsObjectId, namespace, referenceDiscriminatorType, referenceObjectId);
364 refObjBindingBuilder.setCollectionName(collectionName);
365 refObjBindingBuilder.setActive(active);
366
367 return ReferenceObjectBinding.Builder.create(ruleManagementServiceImpl.createReferenceObjectBinding(
368 refObjBindingBuilder.build()));
369 }
370
371
372
373
374
375
376
377
378
379
380
381 protected NaturalLanguageTemplate buildTestNaturalLanguageTemplate(String namespace, String langCode, String nlObjectName, String template) {
382 KrmsTypeDefinition krmsType = createKrmsTypeDefinition(namespace, nlObjectName, null);
383
384
385 if (ObjectUtils.isNull(ruleManagementServiceImpl.getNaturalLanguageUsage("krms.nl." + nlObjectName))) {
386 NaturalLanguageUsage.Builder naturalLanguageUsageBuilder = NaturalLanguageUsage.Builder.create(nlObjectName,namespace );
387 naturalLanguageUsageBuilder.setId("krms.nl." + nlObjectName);
388 naturalLanguageUsageBuilder.setDescription("Description-" + nlObjectName);
389 naturalLanguageUsageBuilder.setActive(true);
390 NaturalLanguageUsage naturalLangumageUsage = ruleManagementServiceImpl.createNaturalLanguageUsage(naturalLanguageUsageBuilder.build());
391 }
392
393
394 createTestKrmsAttribute("TemplateAttribute1", "TemplateAttributeName1", namespace);
395 createTestKrmsAttribute("TemplateAttribute2", "TemplateAttributeName2", namespace);
396 Map<String, String> nlAttributes = new HashMap<String, String>();
397 nlAttributes.put("TemplateAttributeName1","value1");
398 nlAttributes.put("TemplateAttributeName2","value2");
399
400
401
402 String naturalLanguageUsageId = "krms.nl." + nlObjectName;
403 String typeId = krmsType.getId();
404 NaturalLanguageTemplate.Builder naturalLanguageTemplateBuilder = NaturalLanguageTemplate.Builder.create(langCode,naturalLanguageUsageId,template,typeId);
405 naturalLanguageTemplateBuilder.setActive(true);
406 naturalLanguageTemplateBuilder.setId(langCode + "-" + nlObjectName);
407 naturalLanguageTemplateBuilder.setAttributes(nlAttributes);
408
409 return ruleManagementServiceImpl.createNaturalLanguageTemplate(naturalLanguageTemplateBuilder.build());
410 }
411
412 protected KrmsAttributeDefinition createTestKrmsAttribute(String id, String name, String namespace) {
413
414 if (ObjectUtils.isNull(krmsAttributeDefinitionService.getAttributeDefinitionById(id))) {
415 KrmsAttributeDefinition.Builder krmsAttributeDefinitionBuilder = KrmsAttributeDefinition.Builder.create(id, name, namespace);
416 KrmsAttributeDefinition krmsAttributeDefinition = krmsAttributeDefinitionService.createAttributeDefinition(krmsAttributeDefinitionBuilder.build());
417 }
418
419 return krmsAttributeDefinitionService.getAttributeDefinitionById(id);
420 }
421
422 protected NaturalLanguageUsage buildTestNaturalLanguageUsage(String namespace, String nlUsageName ) {
423 KrmsTypeDefinition krmsType = createKrmsTypeDefinition(namespace, nlUsageName, null);
424
425
426 NaturalLanguageUsage.Builder naturalLanguageUsageBuilder = NaturalLanguageUsage.Builder.create(nlUsageName,namespace );
427 naturalLanguageUsageBuilder.setId("krms.nl." + nlUsageName);
428 naturalLanguageUsageBuilder.setDescription("Description-" + nlUsageName);
429 naturalLanguageUsageBuilder.setActive(true);
430
431 return ruleManagementServiceImpl.createNaturalLanguageUsage(naturalLanguageUsageBuilder.build());
432 }
433
434 protected ContextDefinition buildTestContext(String objectDiscriminator) {
435 String namespace = "Namespace" + objectDiscriminator;
436
437 ContextDefinition.Builder contextDefinitionBuilder = ContextDefinition.Builder.create(
438 namespace, "ContextName" + objectDiscriminator);
439 contextDefinitionBuilder.setId("ContextId" + objectDiscriminator);
440 ContextDefinition contextDefinition = contextDefinitionBuilder.build();
441
442 return ruleManagementServiceImpl.createContext(contextDefinition );
443 }
444 }