use of org.drools.compiler.kie.builder.impl.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()));
}
use of org.drools.compiler.kie.builder.impl.MessageImpl in project kie-wb-common by kiegroup.
the class MessageConverterTest method checkMessageWithKieBase.
@Test
public void checkMessageWithKieBase() {
final MessageImpl m = new MessageImpl(ID, Message.Level.ERROR, FILE, TEXT);
m.setKieBaseName(KIE_BASE_NAME);
final BuildMessage bm = MessageConverter.convertMessage(m, handles);
assertConversion(bm, () -> "[KBase: " + KIE_BASE_NAME + "]: " + TEXT);
}
use of org.drools.compiler.kie.builder.impl.MessageImpl in project kie-wb-common by kiegroup.
the class MessageConverter method convertMessageText.
private static String convertMessageText(final Message message) {
final StringBuilder sb = new StringBuilder();
if (message instanceof MessageImpl) {
final MessageImpl impl = (MessageImpl) message;
final String kieBaseName = impl.getKieBaseName();
if (!(kieBaseName == null || kieBaseName.isEmpty())) {
sb.append("[KBase: ").append(kieBaseName).append("]: ");
}
}
sb.append(message.getText());
return sb.toString();
}
use of org.drools.compiler.kie.builder.impl.MessageImpl in project kie-wb-common by kiegroup.
the class MessageConverterTest method checkMessageWithoutKieBase.
@Test
public void checkMessageWithoutKieBase() {
final Message m = new MessageImpl(ID, Message.Level.ERROR, FILE, TEXT);
final BuildMessage bm = MessageConverter.convertMessage(m, handles);
assertConversion(bm, () -> TEXT);
}
Aggregations