use of org.kie.api.builder.KieFileSystem 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.KieFileSystem 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();
}
use of org.kie.api.builder.KieFileSystem in project drools by kiegroup.
the class IncrementalCompilationTest method testIncrementalCompilationDuplicateXLSResources.
@Test
public void testIncrementalCompilationDuplicateXLSResources() throws Exception {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
InputStream in1 = null;
InputStream in2 = null;
try {
// Add XLS decision table
in1 = this.getClass().getResourceAsStream("incrementalBuild.dtable.xls");
kfs.write("src/main/resources/incrementalBuild1.dtable.xls", KieServices.Factory.get().getResources().newInputStreamResource(in1));
// Expect no errors
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
// Add the same XLS decision table again as a different resource
in2 = this.getClass().getResourceAsStream("incrementalBuild.dtable.xls");
kfs.write("src/main/resources/incrementalBuild2.dtable.xls", KieServices.Factory.get().getResources().newInputStreamResource(in2));
IncrementalResults addResults = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/incrementalBuild2.dtable.xls").build();
// Expect duplicate rule errors
assertEquals(1, addResults.getAddedMessages().size());
assertEquals(0, addResults.getRemovedMessages().size());
// Check errors on a full build
List<Message> messages = ks.newKieBuilder(kfs).buildAll().getResults().getMessages();
assertFalse(messages.isEmpty());
} finally {
if (in1 != null) {
in1.close();
}
if (in2 != null) {
in2.close();
}
}
}
use of org.kie.api.builder.KieFileSystem in project drools by kiegroup.
the class XlsFormulaTest method getKieSession.
private KieSession getKieSession(Resource dt) {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write(dt);
KieBuilder kb = ks.newKieBuilder(kfs).buildAll();
assertTrue(kb.getResults().getMessages().isEmpty());
// get the session
KieSession ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
return ksession;
}
use of org.kie.api.builder.KieFileSystem in project drools by kiegroup.
the class DrlxCompiler method createKieFileSystem.
private static KieFileSystem createKieFileSystem(KieServices ks, ReleaseId releaseId) {
KieModuleModel kproj = ks.newKieModuleModel();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.writeKModuleXML(kproj.toXML());
kfs.writePomXML(getPom(releaseId));
return kfs;
}
Aggregations