Search in sources :

Example 26 with Message

use of org.kie.api.builder.Message in project drools by kiegroup.

the class GuidedScoreCardIntegrationJavaClassesAddedToKieFileSystemTest method testEmptyScoreCardCompilation.

@Test
public void testEmptyScoreCardCompilation() throws Exception {
    String xml1 = Helper.createEmptyGuidedScoreCardXML();
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();
    kfs.write("pom.xml", Helper.getPom());
    kfs.write("src/main/resources/META-INF/kmodule.xml", Helper.getKModule());
    kfs.write("src/main/java/org/drools/workbench/models/guided/scorecard/backend/test2/Applicant.java", Helper.getApplicant());
    kfs.write("src/main/java/org/drools/workbench/models/guided/scorecard/backend/test2/ApplicantAttribute.java", Helper.getApplicantAttribute());
    kfs.write("src/main/resources/org/drools/workbench/models/guided/scorecard/backend/test2/sc1.scgd", xml1);
    // Add complete Score Card
    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
    final List<Message> messages = kieBuilder.getResults().getMessages();
    Helper.dumpMessages(messages);
    assertEquals(0, messages.size());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) KieServices(org.kie.api.KieServices) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) KieBuilder(org.kie.api.builder.KieBuilder) Test(org.junit.Test)

Example 27 with Message

use of org.kie.api.builder.Message in project drools by kiegroup.

the class GuidedScoreCardIntegrationJavaClassesAddedToKieFileSystemTest method testCompletedScoreCardCompilation.

@Test
public void testCompletedScoreCardCompilation() throws Exception {
    String xml1 = Helper.createGuidedScoreCardXML();
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem();
    kfs.write("pom.xml", Helper.getPom());
    kfs.write("src/main/resources/META-INF/kmodule.xml", Helper.getKModule());
    kfs.write("src/main/java/org/drools/workbench/models/guided/scorecard/backend/test2/Applicant.java", Helper.getApplicant());
    kfs.write("src/main/java/org/drools/workbench/models/guided/scorecard/backend/test2/ApplicantAttribute.java", Helper.getApplicantAttribute());
    kfs.write("src/main/resources/org/drools/workbench/models/guided/scorecard/test2/backend/sc1.scgd", xml1);
    // Add complete Score Card
    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
    final List<Message> messages = kieBuilder.getResults().getMessages();
    Helper.dumpMessages(messages);
    assertEquals(0, messages.size());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) KieServices(org.kie.api.KieServices) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) KieBuilder(org.kie.api.builder.KieBuilder) Test(org.junit.Test)

Example 28 with Message

use of org.kie.api.builder.Message in project drools by kiegroup.

the class CommonTestMethodBase method buildKJar.

public static byte[] buildKJar(KieServices ks, KieFileSystem kfs, ReleaseId releaseId) {
    KieBuilder kb = ks.newKieBuilder(kfs).buildAll();
    if (kb.getResults().hasMessages(Message.Level.ERROR)) {
        for (Message result : kb.getResults().getMessages()) {
            System.out.println(result.getText());
        }
        return null;
    }
    InternalKieModule kieModule = (InternalKieModule) ks.getRepository().getKieModule(releaseId);
    byte[] jar = kieModule.getBytes();
    return jar;
}
Also used : Message(org.kie.api.builder.Message) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) KieBuilder(org.kie.api.builder.KieBuilder) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule)

Example 29 with Message

use of org.kie.api.builder.Message in project drools by kiegroup.

the class IncrementalCompilationTest method testDuplicateXLSResources.

@Test
public void testDuplicateXLSResources() 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));
        // 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));
        // 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();
        }
    }
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) InputStream(java.io.InputStream) KieServices(org.kie.api.KieServices) Test(org.junit.Test)

Example 30 with Message

use of org.kie.api.builder.Message in project drools by kiegroup.

the class DslExpansionTest method testDSLExpansion_NoExpansion.

@Test
public void testDSLExpansion_NoExpansion() throws Exception {
    final KieServices ks = KieServices.Factory.get();
    final ReleaseId releaseId = ks.newReleaseId("org.kie", "dsl-test", "1.0-SNAPSHOT");
    final KieModuleModel kproj = ks.newKieModuleModel();
    final KieFileSystem kfs = ks.newKieFileSystem();
    kfs.writeKModuleXML(kproj.toXML()).writePomXML(generatePomXml(releaseId)).write("src/main/resources/KBase1/test-dsl.dsl", createDSL()).write("src/main/resources/KBase1/test-rule.drl", createDRL());
    final KieBuilder kieBuilder = ks.newKieBuilder(kfs);
    final List<Message> messages = kieBuilder.buildAll().getResults().getMessages();
    if (!messages.isEmpty()) {
        for (final Message m : messages) {
            System.out.println(m.getText());
        }
    }
    assertFalse(messages.isEmpty());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) KieModuleModel(org.kie.api.builder.model.KieModuleModel) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) KieBuilder(org.kie.api.builder.KieBuilder) Test(org.junit.Test)

Aggregations

Message (org.kie.api.builder.Message)33 KieBuilder (org.kie.api.builder.KieBuilder)30 KieFileSystem (org.kie.api.builder.KieFileSystem)26 Test (org.junit.Test)21 KieServices (org.kie.api.KieServices)19 InternalKieBuilder (org.kie.internal.builder.InternalKieBuilder)10 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)7 KieBase (org.kie.api.KieBase)6 ReleaseId (org.kie.api.builder.ReleaseId)5 KieModule (org.kie.api.builder.KieModule)4 KieModuleModel (org.kie.api.builder.model.KieModuleModel)4 IncrementalResults (org.kie.internal.builder.IncrementalResults)4 Before (org.junit.Before)3 Resource (org.kie.api.io.Resource)3 KieSession (org.kie.api.runtime.KieSession)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 MavenRepository (org.appformer.maven.integration.MavenRepository)1 MavenRepository.getMavenRepository (org.appformer.maven.integration.MavenRepository.getMavenRepository)1