use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class JpaPersistentStatefulSessionTest method testSessionConfigurationFromContainer.
@Test
public void testSessionConfigurationFromContainer() {
// DROOLS-1002
String str = "rule R when then end";
KieServices ks = KieServices.Factory.get();
KieModuleModel kmodel = ks.newKieModuleModel();
kmodel.newKieBaseModel("kbase1").newKieSessionModel("ksession1").setClockType(ClockTypeOption.get("pseudo"));
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", str).writeKModuleXML(kmodel.toXML());
ks.newKieBuilder(kfs).buildAll();
KieContainer kcontainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
KieSessionConfiguration conf = kcontainer.getKieSessionConfiguration("ksession1");
assertEquals("pseudo", conf.getOption(ClockTypeOption.class).getClockType());
KieSession ksession = ks.getStoreServices().newKieSession(kcontainer.getKieBase("kbase1"), conf, env);
assertTrue(ksession.getSessionClock() instanceof SessionPseudoClock);
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieBaseUtil method getKieModuleAndBuildInstallModule.
public static KieModule getKieModuleAndBuildInstallModule(final ReleaseId releaseId, final KieBaseTestConfiguration kieBaseTestConfiguration, final Resource... resources) {
final KieModuleModel module = KieUtil.createKieModuleModel();
kieBaseTestConfiguration.getKieBaseModel(module);
return KieUtil.buildAndInstallKieModuleIntoRepo(kieBaseTestConfiguration, releaseId, module, resources);
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieUtil method getDefaultKieModuleModel.
public static KieModuleModel getDefaultKieModuleModel(KieServices ks) {
final KieModuleModel kproj = KieServices.get().newKieModuleModel();
final KieBaseModel kieBaseModel1 = kproj.newKieBaseModel("kbase").setDefault(true);
final KieSessionModel ksession1 = kieBaseModel1.newKieSessionModel("ksession").setDefault(true);
return kproj;
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieSessionUtil method getKieSessionFromKieBaseModel.
public static Session getKieSessionFromKieBaseModel(final String moduleGroupId, final KieBaseTestConfiguration kieBaseTestConfiguration, final KieSessionTestConfiguration kieSessionTestConfiguration, final Resource... resources) {
final KieModuleModel module = KieUtil.createKieModuleModel();
final KieBaseModel kieBaseModel = kieBaseTestConfiguration.getKieBaseModel(module);
kieSessionTestConfiguration.getKieSessionModel(kieBaseModel);
final KieModule kieModule = KieUtil.buildAndInstallKieModuleIntoRepo(kieBaseTestConfiguration, moduleGroupId, module, resources);
return getDefaultKieSessionFromReleaseId(kieModule.getReleaseId(), kieSessionTestConfiguration.isStateful(), false);
}
use of org.kie.api.builder.model.KieModuleModel in project drools by kiegroup.
the class KieContainerDefaultsTest method testTwoKieSessionsNoneDefault.
/**
* This test checks how KieSessions behave when all are explicitly set not to be default.
*/
@Test
public void testTwoKieSessionsNoneDefault() {
final KieModuleModel kieModule = kieServices.newKieModuleModel();
kieModule.newKieBaseModel("firstKBase").setDefault(true).newKieSessionModel("firstKSession").setDefault(false);
kieModule.newKieBaseModel("secondKBase").setDefault(true).newKieSessionModel("secondKSession").setDefault(false);
buildKieModule(kieModule);
final KieContainer kieContainer = kieServices.newKieContainer(RELEASE_ID);
Assertions.assertThatThrownBy(() -> kieContainer.newKieSession()).isInstanceOf(RuntimeException.class).hasMessageContaining("Cannot find a default KieSession");
}
Aggregations