use of org.kie.api.builder.Results in project drools by kiegroup.
the class SignavioTest method testUsingSignavioFunctions.
@Test
public void testUsingSignavioFunctions() {
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem();
KieModuleModel kmm = ks.newKieModuleModel();
kmm.setConfigurationProperty("org.kie.dmn.profiles.signavio", "org.kie.dmn.signavio.KieDMNSignavioProfile");
kfs.writeKModuleXML(kmm.toXML());
kfs.write(ks.getResources().newClassPathResource("Using_Signavio_functions.dmn", this.getClass()));
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
Results results = kieBuilder.getResults();
LOG.info("buildAll() completed.");
results.getMessages(Level.WARNING).forEach(e -> LOG.warn("{}", e));
assertTrue(results.getMessages(Level.WARNING).size() == 0);
final KieContainer kieContainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
List<DMNModel> models = runtime.getModels();
DMNContext context = runtime.newContext();
DMNModel model0 = models.get(0);
System.out.println("EVALUATE ALL:");
DMNResult evaluateAll = runtime.evaluateAll(model0, context);
System.out.println(evaluateAll);
System.out.println(evaluateAll.getContext());
evaluateAll.getMessages().forEach(System.out::println);
assertEquals(true, evaluateAll.getContext().get("myContext"));
}
use of org.kie.api.builder.Results in project drools by kiegroup.
the class SignavioTest method testUsingSignavioFunctionsInLiteralExpression.
/**
* Check the custom Signavio functions work in the LiteralExpression too
*/
@Test
public void testUsingSignavioFunctionsInLiteralExpression() {
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem();
KieModuleModel kmm = ks.newKieModuleModel();
kmm.setConfigurationProperty("org.kie.dmn.profiles.signavio", "org.kie.dmn.signavio.KieDMNSignavioProfile");
kfs.writeKModuleXML(kmm.toXML());
kfs.write(ks.getResources().newClassPathResource("Starts_with_an_A.dmn", this.getClass()));
KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
Results results = kieBuilder.getResults();
LOG.info("buildAll() completed.");
results.getMessages(Level.WARNING).forEach(e -> LOG.warn("{}", e));
assertTrue(results.getMessages(Level.WARNING).size() == 0);
final KieContainer kieContainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
assertStartsWithAnA(runtime, "Abc", true);
assertStartsWithAnA(runtime, "Xyz", false);
}
Aggregations