use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class BaseModelTest method getDefaultKieModuleModel.
protected KieModuleModel getDefaultKieModuleModel(KieServices ks) {
KieModuleModel kproj = ks.newKieModuleModel();
kproj.newKieBaseModel("kbase").setDefault(true).newKieSessionModel("ksession").setDefault(true);
return kproj;
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class BuildFromKJarTest method getDefaultKieModuleModel.
private KieModuleModel getDefaultKieModuleModel(KieServices ks) {
KieModuleModel kproj = ks.newKieModuleModel();
KieBaseModel kieBaseModel1 = kproj.newKieBaseModel("kbase").setDefault(true);
KieSessionModel ksession1 = kieBaseModel1.newKieSessionModel("ksession").setDefault(true);
return kproj;
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieContainerDefaultsTest method testTwoStatelessKieSessionsBothDefault.
/**
* This test checks how StatelessKieSessions behave when more than one is set as default.
*/
@Test
public void testTwoStatelessKieSessionsBothDefault() {
final KieModuleModel kieModule = kieServices.newKieModuleModel();
kieModule.newKieBaseModel("firstKBase").setDefault(true).newKieSessionModel("firstKSession").setType(KieSessionModel.KieSessionType.STATELESS).setDefault(true);
kieModule.newKieBaseModel("secondKBase").setDefault(true).newKieSessionModel("secondKSession").setType(KieSessionModel.KieSessionType.STATELESS).setDefault(true);
buildKieModule(kieModule);
final KieContainer kieContainer = kieServices.newKieContainer(RELEASE_ID);
Assertions.assertThatThrownBy(() -> kieContainer.newStatelessKieSession()).isInstanceOf(RuntimeException.class).hasMessageContaining("Cannot find a default StatelessKieSession");
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieContainerDefaultsTest method testTwoKieBasesOneDefault.
/**
* This test checks if default KieBases behave as expected.
*/
@Test
public void testTwoKieBasesOneDefault() {
final KieModuleModel kieModule = kieServices.newKieModuleModel();
kieModule.newKieBaseModel("firstKBase").setDefault(true);
kieModule.newKieBaseModel("secondKBase").setDefault(false);
buildKieModule(kieModule);
final KieContainer kieContainer = kieServices.newKieContainer(RELEASE_ID);
final KieBase firstKBase = kieContainer.getKieBase("firstKBase");
final KieBase secondKBase = kieContainer.getKieBase("secondKBase");
Assertions.assertThat(kieContainer.getKieBase()).isEqualTo(firstKBase);
Assertions.assertThat(kieContainer.getKieBase()).isNotEqualTo(secondKBase);
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieContainerDefaultsTest method testTwoKieSessionsOneDefault.
/**
* This test checks if default KieSessions behave as expected.
*/
@Test
public void testTwoKieSessionsOneDefault() {
final KieModuleModel kieModule = kieServices.newKieModuleModel();
kieModule.newKieBaseModel("firstKBase").setDefault(true).newKieSessionModel("firstKSession").setDefault(true);
kieModule.newKieBaseModel("secondKBase").setDefault(true).newKieSessionModel("secondKSession");
buildKieModule(kieModule);
final KieContainer kieContainer = kieServices.newKieContainer(RELEASE_ID);
final KieSession firstKSession = kieContainer.newKieSession("firstKSession");
final KieSession secondKSession = kieContainer.newKieSession("secondKSession");
try {
Assertions.assertThat(firstKSession).isEqualTo(((InternalKieContainer) kieContainer).getKieSession());
Assertions.assertThat(secondKSession).isNotEqualTo(((InternalKieContainer) kieContainer).getKieSession());
} finally {
firstKSession.dispose();
secondKSession.dispose();
}
}
Aggregations