use of org.kie.api.builder.Results in project drools by kiegroup.
the class QueryTest method testQueryWithIncompatibleArgs.
@Test
public void testQueryWithIncompatibleArgs() {
String drl = "global java.util.List list; " + "" + "query foo( String $s, String $s, String $s ) end " + "" + "rule React \n" + "when\n" + " $i : Integer() " + " foo( $i, $x, $i ; ) " + "then\n" + "end";
KieHelper helper = new KieHelper();
helper.addContent(drl, ResourceType.DRL);
Results results = helper.verify();
assertTrue(results.hasMessages(Message.Level.ERROR));
assertEquals(2, results.getMessages(Message.Level.ERROR).size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class QueryTest method testNotExistingDeclarationInQuery.
@Test
public void testNotExistingDeclarationInQuery() {
// DROOLS-414
String drl = "import org.drools.compiler.Person\n" + "global java.util.List persons;\n" + "\n" + "query checkLength(String $s, int $l)\n" + " $s := String( length == $l )\n" + "end\n" + "\n" + "rule R when\n" + " $i : Integer()\n" + " $p : Person()\n" + " checkLength( $p.name, 1 + $x + $p.age; )\n" + "then\n" + " persons.add( $p );\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 AbductionTest method testAbductiveLogicWithWrongTypeArgsMapping.
@Test
public void testAbductiveLogicWithWrongTypeArgsMapping() {
String droolsSource = "package org.drools.abductive.test; \n" + "" + "import " + Abducible.class.getName() + "; \n" + "global java.util.List list; \n" + "" + "declare Foo \n" + " @Abducible \n" + " id : String @key \n" + " name : String @key \n" + "end \n" + "query foo( String $name, int $x ) \n" + " @Abductive( target=Foo.class, args={ $x, $name } ) \n" + "end \n" + "rule R0 " + "when " + " $f := foo( \"name_test\", 99 ; ) " + "then " + " list.add( $f ); " + "end \n" + "";
// ///////////////////////////////////
KieHelper kieHelper = new KieHelper();
kieHelper.addContent(droolsSource, ResourceType.DRL);
Results res = kieHelper.verify();
assertEquals(1, res.getMessages(Message.Level.ERROR).size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class AbductionTest method testAbductiveLogicNoConstructorFoundError.
@Test
public void testAbductiveLogicNoConstructorFoundError() {
String droolsSource = "package org.drools.abductive.test; \n" + "" + "import " + Abducible.class.getName() + "; \n" + "global java.util.List list; \n" + "" + "declare Foo \n" + " @Abducible \n" + " id : Integer @key \n" + "end \n" + "query foo( String $x ) \n" + // Foo does not have a String constructor
" @Abductive( target=Foo.class ) \n" + "end \n" + "rule R1 " + "when " + " $x : foo( \"x\" ; ) " + "then " + " list.add( $x ); " + "end \n" + "" + "";
// ///////////////////////////////////
KieHelper kieHelper = new KieHelper();
kieHelper.addContent(droolsSource, ResourceType.DRL);
Results res = kieHelper.verify();
assertEquals(1, res.getMessages(Message.Level.ERROR).size());
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class KieBaseTest method testKieBaseCompilation.
@Test
public void testKieBaseCompilation() {
KieServices ks = KieServices.Factory.get();
Results rs = ks.getKieClasspathContainer().verify();
System.out.println(rs.getMessages());
assertFalse(rs.hasMessages(Message.Level.ERROR));
}
Aggregations