Search in sources :

Example 6 with IncrementalResults

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());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Results(org.kie.api.builder.Results) IncrementalResults(org.kie.internal.builder.IncrementalResults) KieServices(org.kie.api.KieServices) KieBuilder(org.kie.api.builder.KieBuilder) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) IncrementalResults(org.kie.internal.builder.IncrementalResults) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 7 with IncrementalResults

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());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) KieBuilder(org.kie.api.builder.KieBuilder) IncrementalResults(org.kie.internal.builder.IncrementalResults) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) KieContainer(org.kie.api.runtime.KieContainer) Test(org.junit.Test)

Example 8 with IncrementalResults

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());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) KieBuilder(org.kie.api.builder.KieBuilder) IncrementalResults(org.kie.internal.builder.IncrementalResults) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) KieContainer(org.kie.api.runtime.KieContainer) Test(org.junit.Test)

Example 9 with IncrementalResults

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);
}
Also used : KieRepository(org.kie.api.builder.KieRepository) KieFileSystem(org.kie.api.builder.KieFileSystem) KieServices(org.kie.api.KieServices) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) KieBuilder(org.kie.api.builder.KieBuilder) IncrementalResults(org.kie.internal.builder.IncrementalResults) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) KieContainer(org.kie.api.runtime.KieContainer) Test(org.junit.Test)

Example 10 with IncrementalResults

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());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) KieServices(org.kie.api.KieServices) KieBuilder(org.kie.api.builder.KieBuilder) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) IncrementalResults(org.kie.internal.builder.IncrementalResults) Test(org.junit.Test)

Aggregations

IncrementalResults (org.kie.internal.builder.IncrementalResults)44 Test (org.junit.Test)42 KieServices (org.kie.api.KieServices)42 KieFileSystem (org.kie.api.builder.KieFileSystem)42 KieBuilder (org.kie.api.builder.KieBuilder)39 InternalKieBuilder (org.kie.internal.builder.InternalKieBuilder)39 KieContainer (org.kie.api.runtime.KieContainer)14 ReleaseId (org.kie.api.builder.ReleaseId)13 KieSession (org.kie.api.runtime.KieSession)10 Results (org.kie.api.builder.Results)8 StatelessKieSession (org.kie.api.runtime.StatelessKieSession)8 Message (org.kie.api.builder.Message)5 ArrayList (java.util.ArrayList)4 StringReader (java.io.StringReader)3 Message (org.drools.testcoverage.common.model.Message)3 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)3 KieBuilderSetImpl (org.drools.compiler.kie.builder.impl.KieBuilderSetImpl)2 KieModuleModel (org.kie.api.builder.model.KieModuleModel)2 ClassObjectFilter (org.kie.api.runtime.ClassObjectFilter)2 InputStream (java.io.InputStream)1