use of org.kie.api.builder.Results in project drools by kiegroup.
the class OOPathReactiveTests method testInvalidDoubleNonReactivePart.
@Test
public void testInvalidDoubleNonReactivePart() {
final String drl = "import org.drools.compiler.oopath.model.*;\n" + "global java.util.List list\n" + "\n" + "rule R when\n" + " Man( $toy: /wife?/children[age > 10]?/toys )\n" + "then\n" + " list.add( $toy.getName() );\n" + "end\n";
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", drl);
final Results results = ks.newKieBuilder(kfs).buildAll().getResults();
assertTrue(results.hasMessages(Message.Level.ERROR));
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class FromTest method testFromWithInterfaceAndFinalClass.
@Test
public void testFromWithInterfaceAndFinalClass() {
String drl = "import " + Container3.class.getCanonicalName() + "\n" + "import " + CustomIntegerMarker.class.getCanonicalName() + "\n" + "global java.util.List out;\n" + "rule R1 when\n" + " $c3 : Container3( )\n" + " $s : CustomIntegerMarker() from $c3.singleValue\n" + "then\n" + " out.add($s);\n" + "end\n";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", drl);
Results results = ks.newKieBuilder(kfs).buildAll().getResults();
// Integer is final class, so there cannot be ever the case of pattern matching in the `from` on a non-extended interface to ever match.
assertFalse(results.getMessages().isEmpty());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class FromTest method testFromWithSingleValueAndIncompatibleType.
@Test
public void testFromWithSingleValueAndIncompatibleType() {
// DROOLS-1243
String drl = "import " + ListsContainer.class.getCanonicalName() + "\n" + "global java.util.List out;\n" + "rule R1 when\n" + " $list : ListsContainer( )\n" + " $s : String() from $list.singleValue\n" + "then\n" + " out.add($s);\n" + "end\n";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem().write("src/main/resources/r1.drl", drl);
Results results = ks.newKieBuilder(kfs).buildAll().getResults();
assertFalse(results.getMessages().isEmpty());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class KieHelper method createJar.
public static byte[] createJar(KieServices ks, ReleaseId releaseId, Resource... resources) {
KieFileSystem kfs = ks.newKieFileSystem().generateAndWritePomXML(releaseId);
for (int i = 0; i < resources.length; i++) {
if (resources[i] != null) {
kfs.write(resources[i]);
}
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
((InternalKieBuilder) kieBuilder).buildAll(o -> true);
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 DMNRuntimeTypeCheckTest method getRuntimeWithTypeCheckOption.
private DMNRuntime getRuntimeWithTypeCheckOption(String typeCheckKModuleOption, Resource... resources) {
final KieFileSystem kfs = ks.newKieFileSystem();
KieModuleModel kmm = ks.newKieModuleModel();
kmm.setConfigurationProperty(RuntimeTypeCheckOption.PROPERTY_NAME, typeCheckKModuleOption);
kfs.writeKModuleXML(kmm.toXML());
for (Resource r : resources) {
kfs.write(r);
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
Results results = kieBuilder.getResults();
assertThat(results.getMessages().toString(), results.hasMessages(org.kie.api.builder.Message.Level.ERROR), is(false));
final KieContainer kieContainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
final DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
return runtime;
}
Aggregations