Search in sources :

Example 1 with MessageImpl

use of org.drools.drl.parser.MessageImpl in project drools by kiegroup.

the class KieModuleIncrementalCompilationTest method checkIncrementalCompilationWithMultipleKieBases.

@Test
public void checkIncrementalCompilationWithMultipleKieBases() throws Exception {
    String rule = "package org.kie.scanner\n" + "rule R1 when\n" + "then\n" + "end\n";
    String invalidRule = "package org.kie.scanner\n" + "rule R2 when\n" + // missing import
    "   Cheese()\n" + "then\n" + "end\n";
    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = createKieFileSystemWithTwoKBases(ks);
    kfs.write("src/main/resources/org/kie/scanner/rule.drl", rule);
    KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
    assertEquals(0, kieBuilder.getResults().getMessages().size());
    kfs.write("src/main/resources/org/kie/scanner/invalidRule.drl", invalidRule);
    IncrementalResults addResults = ((InternalKieBuilder) kieBuilder).createFileSet("src/main/resources/org/kie/scanner/invalidRule.drl").build();
    assertEquals(2, addResults.getAddedMessages().size());
    addResults.getAddedMessages().stream().map(m -> (MessageImpl) m).forEach(m -> assertNotNull(m.getKieBaseName()));
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) KieBuilder(org.kie.api.builder.KieBuilder) EventProcessingOption(org.kie.api.conf.EventProcessingOption) MessageImpl(org.drools.drl.parser.MessageImpl) Assert.assertNotNull(org.junit.Assert.assertNotNull) Collection(java.util.Collection) EqualityBehaviorOption(org.kie.api.conf.EqualityBehaviorOption) HashMap(java.util.HashMap) Test(org.junit.Test) IncrementalResults(org.kie.internal.builder.IncrementalResults) ReleaseId(org.kie.api.builder.ReleaseId) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) KieModuleModel(org.kie.api.builder.model.KieModuleModel) KieServices(org.kie.api.KieServices) Assert.assertEquals(org.junit.Assert.assertEquals) KieFileSystem(org.kie.api.builder.KieFileSystem) KieServices(org.kie.api.KieServices) KieBuilder(org.kie.api.builder.KieBuilder) InternalKieBuilder(org.kie.internal.builder.InternalKieBuilder) MessageImpl(org.drools.drl.parser.MessageImpl) IncrementalResults(org.kie.internal.builder.IncrementalResults) Test(org.junit.Test)

Example 2 with MessageImpl

use of org.drools.drl.parser.MessageImpl in project drools by kiegroup.

the class ResultsImpl method addMessage.

public InternalMessage addMessage(Level level, String path, String text) {
    InternalMessage message = new MessageImpl(idGenerator++, level, path, text);
    messages.add(message);
    return message;
}
Also used : InternalMessage(org.kie.internal.builder.InternalMessage) MessageImpl(org.drools.drl.parser.MessageImpl)

Aggregations

MessageImpl (org.drools.drl.parser.MessageImpl)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Test (org.junit.Test)1 KieServices (org.kie.api.KieServices)1 KieBuilder (org.kie.api.builder.KieBuilder)1 KieFileSystem (org.kie.api.builder.KieFileSystem)1 ReleaseId (org.kie.api.builder.ReleaseId)1 KieModuleModel (org.kie.api.builder.model.KieModuleModel)1 EqualityBehaviorOption (org.kie.api.conf.EqualityBehaviorOption)1 EventProcessingOption (org.kie.api.conf.EventProcessingOption)1 IncrementalResults (org.kie.internal.builder.IncrementalResults)1 InternalKieBuilder (org.kie.internal.builder.InternalKieBuilder)1 InternalMessage (org.kie.internal.builder.InternalMessage)1