use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testDROOLS2192.
@Test
public void testDROOLS2192() {
// DROOLS-2192
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("hardcoded_function_definition.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_99854980-65c8-4e9b-b365-bd30ded69f40", "hardcoded_function_definition");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext emptyContext = DMNFactory.newContext();
DMNResult dmnResult = runtime.evaluateAll(dmnModel, emptyContext);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext resultContext = dmnResult.getContext();
assertThat(((BigDecimal) resultContext.get("hardcoded decision")).intValue(), is(47));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testAlternativeNSDecl.
@Test
public void testAlternativeNSDecl() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("alternative_feel_ns_declaration.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0001-input-data-string");
assertThat(dmnModel, notNullValue());
DMNContext context = DMNFactory.newContext();
context.set("Full Name", "John Doe");
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getResult(), is("Hello John Doe"));
DMNContext result = dmnResult.getContext();
assertThat(result.get("Greeting Message"), is("Hello John Doe"));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testJavaFunctionContext.
@Test
public void testJavaFunctionContext() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("java_function_context.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_b42317c4-4f0c-474e-a0bf-2895b0b3c314", "Dessin 1");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext ctx = runtime.newContext();
ctx.set("Input", 3.14);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, ctx);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext result = dmnResult.getContext();
assertThat(((BigDecimal) result.get("D1")).setScale(4, BigDecimal.ROUND_HALF_UP), is(new BigDecimal("-1.0000")));
assertThat(((BigDecimal) result.get("D2")).setScale(4, BigDecimal.ROUND_HALF_UP), is(new BigDecimal("-1.0000")));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testCycleDetectionSelfReference.
@Test
public void testCycleDetectionSelfReference() {
DecisionNodeImpl decision = new DecisionNodeImpl();
decision.addDependency("self", decision);
DMNModelImpl model = new DMNModelImpl();
model.addDecision(decision);
DMNRuntime runtime = DMNRuntimeUtil.createRuntime(this.getClass());
DMNResult result = runtime.evaluateAll(model, DMNFactory.newContext());
assertTrue(result.hasErrors());
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testItemDefDependencies.
@Test
public void testItemDefDependencies() {
// DROOLS-1505
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("itemDef-dependency.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_2374ee6d-75ed-4e9d-95d3-a88c135e1c43", "Drawing 1a");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = runtime.newContext();
Map<String, String> person = new HashMap<>();
person.put("Full Name", "John Doe");
person.put("Address", "100 East Davie Street");
context.set("Input Person", person);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext result = dmnResult.getContext();
assertThat(result.get("My Decision"), is("The person John Doe is located at 100 East Davie Street"));
}
Aggregations