use of org.kie.internal.builder.IncrementalResults in project jbpm by kiegroup.
the class IncrementalCompilationTest method testIncrementalProcessCompilation.
@Test
public void testIncrementalProcessCompilation() throws Exception {
String invalidProcessDefinition = getResource("/BPMN2-Incremental-Build-Invalid.bpmn2");
String validProcessDefinition = getResource("/BPMN2-Incremental-Build-Valid.bpmn2");
KieServices ks = KieServices.Factory.get();
// This process file contains 4 errors
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/p1.bpmn2", invalidProcessDefinition);
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
Results results = kieBuilder.getResults();
assertEquals(3, results.getMessages(org.kie.api.builder.Message.Level.ERROR).size());
// This process file has the errors fixed
kfs.write("src/main/resources/p1.bpmn2", validProcessDefinition);
IncrementalResults addResults = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/p1.bpmn2").build();
// I'd expect the 4 previous errors to be cleared
assertEquals(0, addResults.getAddedMessages().size());
assertEquals(3, addResults.getRemovedMessages().size());
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class WBCompilationTest method testSteppedCompilation.
@Test
public void testSteppedCompilation() {
KieServices ks = KieServices.Factory.get();
ReleaseId id = ks.newReleaseId("org.test", "foo", "1.0-SNAPSHOT");
KieFileSystem kfs = ks.newKieFileSystem();
kfs.generateAndWritePomXML(id);
kfs.write("src/main/resources/org/kie/scanner/dmn1.dmn", DMN_1);
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll(DrlProject.class);
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
kfs.write("src/main/resources/org/kie/scanner/dmn2.dmn", DMN_2);
IncrementalResults addResults = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/org/kie/scanner/dmn2.dmn").build();
assertEquals(0, addResults.getAddedMessages().size());
assertEquals(0, addResults.getRemovedMessages().size());
KieContainer kieContainer = ks.newKieContainer(id);
DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
assertEquals(2, runtime.getModels().size());
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class WBCompilationTest method testSteppedCompilationFromEmptyKbuilder.
@Test
public void testSteppedCompilationFromEmptyKbuilder() {
// DROOLS-5584
KieServices ks = KieServices.Factory.get();
ReleaseId id = ks.newReleaseId("org.test", "foo", "1.0-SNAPSHOT");
KieFileSystem kfs = ks.newKieFileSystem();
kfs.generateAndWritePomXML(id);
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll(DrlProject.class);
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
kfs.write("src/main/resources/org/kie/scanner/dmn1.dmn", DMN_1);
IncrementalResults addResults = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/org/kie/scanner/dmn1.dmn").build();
assertEquals(0, addResults.getAddedMessages().size());
assertEquals(0, addResults.getRemovedMessages().size());
kfs.write("src/main/resources/org/kie/scanner/dmn2.dmn", DMN_2);
addResults = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/org/kie/scanner/dmn2.dmn").build();
assertEquals(0, addResults.getAddedMessages().size());
assertEquals(0, addResults.getRemovedMessages().size());
KieContainer kieContainer = ks.newKieContainer(id);
DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
assertEquals(2, runtime.getModels().size());
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class DMNRuntimePMMLTest method testSteppedCompilation.
/**
* test to use same building steps of BC/WB
*/
@Test
public void testSteppedCompilation() {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("src/main/resources/org/acme/test_scorecard.pmml", ks.getResources().newClassPathResource("test_scorecard.pmml", DMNRuntimePMMLTest.class));
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll(DrlProject.class);
assertEquals(0, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
kfs.write("src/main/resources/org/acme/KiePMMLScoreCard.dmn", ks.getResources().newClassPathResource("KiePMMLScoreCard.dmn", DMNRuntimePMMLTest.class));
IncrementalResults addResults = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/org/acme/KiePMMLScoreCard.dmn").build();
assertEquals(0, addResults.getAddedMessages().size());
assertEquals(0, addResults.getRemovedMessages().size());
KieRepository kr = ks.getRepository();
KieContainer kieContainer = ks.newKieContainer(kr.getDefaultReleaseId());
DMNRuntime dmnRuntime = KieRuntimeFactory.of(kieContainer.getKieBase()).get(DMNRuntime.class);
runDMNModelInvokingPMML(dmnRuntime);
}
use of org.kie.internal.builder.IncrementalResults in project drools by kiegroup.
the class KieModuleIncrementalCompilationTest method checkIncrementalCompilationWithRuleThenFunction.
@Test
public void checkIncrementalCompilationWithRuleThenFunction() throws Exception {
String rule = "package org.kie.scanner\n" + "rule R1 when\n" + " String()\n" + "then\n" + " System.out.println(MyFunction());\n" + "end\n";
String function = "package org.kie.scanner\n" + "function int MyFunction() {\n" + " return 1;\n" + "}\n";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write("src/main/resources/org/kie/scanner/rule.drl", rule);
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
assertEquals(1, kieBuilder.getResults().getMessages(org.kie.api.builder.Message.Level.ERROR).size());
kfs.write("src/main/resources/org/kie/scanner/function.drl", function);
IncrementalResults addResults1 = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/org/kie/scanner/function.drl").build();
assertEquals(0, addResults1.getAddedMessages().size());
assertEquals(1, addResults1.getRemovedMessages().size());
}
Aggregations