use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class DroolsAbstractPMMLTest method getModelSession.
protected KieSession getModelSession(String[] pmmlSources, boolean verbose) {
KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieFileSystem kfs = ks.newKieFileSystem();
for (int j = 0; j < pmmlSources.length; j++) {
Resource res = ResourceFactory.newClassPathResource(pmmlSources[j]).setResourceType(ResourceType.PMML);
kfs.write(res);
}
KieModuleModel model = ks.newKieModuleModel();
model.setConfigurationProperty("drools.propertySpecific", "ALLOWED");
KieBaseModel kbModel = model.newKieBaseModel(DEFAULT_KIEBASE).setDefault(true).addPackage(BASE_PACK).setEventProcessingMode(EventProcessingOption.STREAM);
kfs.writeKModuleXML(model.toXML());
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
if (kb.getResults().hasMessages(Message.Level.ERROR)) {
throw new RuntimeException("Build Errors:\n" + kb.getResults().toString());
}
KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
KieBase kieBase = kContainer.getKieBase();
setKbase(kieBase);
return kieBase.newKieSession();
}
use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class PMMLErrorTest method testNoErrorDuringGeneration.
@Test
public void testNoErrorDuringGeneration() {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write(ResourceFactory.newByteArrayResource(pmml.getBytes()).setResourceType(ResourceType.PMML).setSourcePath("pmml.pmml"));
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
assertEquals(0, kb.getResults().getMessages(Message.Level.ERROR).size());
}
use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class PMMLErrorTest method testErrorDuringGeneration.
@Test
public void testErrorDuringGeneration() {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write(ResourceFactory.newByteArrayResource(pmlm.getBytes()).setResourceType(ResourceType.PMML).setSourcePath("pmlm.pmml"));
KieBuilder kb = ks.newKieBuilder(kfs);
kb.buildAll();
assertEquals(1, kb.getResults().getMessages(Message.Level.ERROR).size());
}
use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class CalendarTimerResourcesTest method init.
@Before
public void init() {
final KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
KieModuleModel kmodule = ks.newKieModuleModel();
KieBaseModel baseModel = kmodule.newKieBaseModel("defaultKBase").setDefault(true).setEventProcessingMode(EventProcessingOption.STREAM);
baseModel.newKieSessionModel("defaultKSession").setDefault(true).setClockType(ClockTypeOption.get("pseudo"));
kfs.writeKModuleXML(kmodule.toXML());
// README when path is set then test works
kfs.write(ks.getResources().newClassPathResource("calendar_timer.xls", this.getClass()));
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
clock = ksession.getSessionClock();
}
use of org.kie.api.builder.KieBuilder in project drools by kiegroup.
the class PrioritySetWithFormulaTest method init.
@Before
public void init() {
final KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
KieModuleModel kmodule = ks.newKieModuleModel();
kfs.writeKModuleXML(kmodule.toXML());
kfs.write(ks.getResources().newClassPathResource("prioritySetWithFormula.xls", this.getClass()));
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
kieBase = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).getKieBase();
}
Aggregations