use of org.kie.api.builder.Results in project drools by kiegroup.
the class AbductionTest method testBindNonAbductiveQueryError.
@Test
public void testBindNonAbductiveQueryError() {
String droolsSource = "package org.drools.abductive.test; \n" + "" + "" + "query foo() \n" + "end \n" + "rule R1 " + "when " + " $x : foo( ) " + "then " + "end \n" + "";
// ///////////////////////////////////
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
kfs.write(ks.getResources().newByteArrayResource(droolsSource.getBytes()).setSourcePath("drl1.drl").setResourceType(ResourceType.DRL));
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
kieBuilder.buildAll();
Results res = kieBuilder.getResults();
assertTrue(res.hasMessages(Message.Level.ERROR));
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class AbductionTest method testAbductiveLogicWithNonExistingArgsMapping.
@Test
public void testAbductiveLogicWithNonExistingArgsMapping() {
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 ) \n" + " @Abductive( target=Foo.class, args={ $missing, $name } ) \n" + "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 getSessionFromString.
protected KieSession getSessionFromString(String drlString, KieBaseConfiguration kbConf) {
KieHelper kieHelper = new KieHelper();
kieHelper.addContent(drlString, ResourceType.DRL);
Results res = kieHelper.verify();
if (res.hasMessages(Message.Level.ERROR)) {
fail(res.getMessages(Message.Level.ERROR).toString());
}
if (kbConf == null) {
kbConf = KieServices.Factory.get().newKieBaseConfiguration();
}
kbConf.setOption(EqualityBehaviorOption.EQUALITY);
KieBase kieBase = kieHelper.build(kbConf);
KieSessionConfiguration ksConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
((SessionConfiguration) ksConf).setBeliefSystemType(BeliefSystemType.DEFEASIBLE);
return kieBase.newKieSession(ksConf, null);
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class AccumulateTest method testIncompatibleTypeOnAccumulateFunction.
@Test
public void testIncompatibleTypeOnAccumulateFunction() {
// DROOLS-1243
String drl = "import " + MyPerson.class.getCanonicalName() + ";\n" + "import " + BigDecimal.class.getCanonicalName() + ";\n" + "global java.util.List list;\n" + "rule R when\n" + " $theFrom : BigDecimal() from accumulate(MyPerson( $val : age ); \n" + " sum( $val ) )\n" + "then\n" + " list.add($theFrom);\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 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