use of org.kie.api.builder.Results in project drools by kiegroup.
the class KieContainerTest method testUpdateToNonExistingRelease.
@Test
public void testUpdateToNonExistingRelease() {
// DROOLS-1562
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "test-release", "1.0.0");
createAndDeployJar(ks, releaseId, createDRL("ruleA"));
KieContainer kieContainer = ks.newKieContainer(releaseId);
Results results = kieContainer.updateToVersion(ks.newReleaseId("org.kie", "test-release", "1.0.1"));
assertEquals(1, results.getMessages(Level.ERROR).size());
assertEquals("1.0.0", ((InternalKieContainer) kieContainer).getContainerReleaseId().getVersion());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class Misc2Test method testMultilineStatement.
@Test
public void testMultilineStatement() {
// BZ-1092502
String str = "rule \"test\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "System \n" + " .out \n" + " .println(\"hello\");\n" + "end\n";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", str);
Results results = ks.newKieBuilder(kfs).buildAll().getResults();
assertEquals(0, results.getMessages().size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class MessageImplTests method testMessageFromInvalidDSL.
@Test
public // See DROOLS-193 (KnowledgeBuilderResult does not always contain a Resource)
void testMessageFromInvalidDSL() throws Exception {
// Some suitably duff DSL
String dsl = "bananna\n";
// Some suitably valid DRL
String drl = "import org.drools.compiler.Person;\n" + "rule R1\n" + "when\n" + "There is a Person\n" + "then\n" + "end\n";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/dsl.dsl", dsl).write("src/main/resources/drl.dslr", drl);
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
Results results = kieBuilder.getResults();
assertEquals(3, results.getMessages().size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class CommonTestMethodBase method createJar.
public static byte[] createJar(KieServices ks, String kmoduleContent, Predicate<String> classFilter, ReleaseId releaseId, Resource... resources) {
KieFileSystem kfs = ks.newKieFileSystem().generateAndWritePomXML(releaseId).writeKModuleXML(kmoduleContent);
for (int i = 0; i < resources.length; i++) {
if (resources[i] != null) {
kfs.write(resources[i]);
}
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
((InternalKieBuilder) kieBuilder).buildAll(classFilter);
Results results = kieBuilder.getResults();
if (results.hasMessages(Message.Level.ERROR)) {
throw new IllegalStateException(results.getMessages(Message.Level.ERROR).toString());
}
InternalKieModule kieModule = (InternalKieModule) ks.getRepository().getKieModule(releaseId);
byte[] jar = kieModule.getBytes();
return jar;
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class KnowledgeBuilderTest method testMalformedDrl.
@Test
public void testMalformedDrl() throws Exception {
// DROOLS-928
byte[] content = new byte[] { 0x04, 0x44, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00 };
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", new String(content));
Results results = ks.newKieBuilder(kfs).buildAll().getResults();
assertTrue(results.getMessages().size() > 0);
}
Aggregations