use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeTest method testDateAllowedValues.
@Test
public void testDateAllowedValues() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("date_allowed_values.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_fbf002a3-615b-4f02-98e4-c28d4676225a", "Error with constraints verification");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext ctx = runtime.newContext();
Object duration = BuiltInType.DURATION.fromString("P20Y");
ctx.set("yearsMonth", duration);
Object dateTime = BuiltInType.DATE_TIME.fromString("2017-05-16T17:58:00.000");
ctx.set("dateTime", dateTime);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, ctx);
DMNContext result = dmnResult.getContext();
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
assertThat((Map<String, Object>) result.get("Decision Logic 1"), hasEntry("years and months", duration));
assertThat((Map<String, Object>) result.get("Decision Logic 1"), hasEntry("Date Time", dateTime));
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeTest method testPriority_table_missing_output_values.
@Test
public void testPriority_table_missing_output_values() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("DTABLE_PRIORITY_MISSING_OUTVALS.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "DTABLE_PRIORITY_MISSING_OUTVALS");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(true));
assertThat(dmnModel.getMessages().size(), is(1));
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeTest method testUnknownVariable1.
@Test
public void testUnknownVariable1() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("unknown_variable1.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9105d4a6-6049-4ace-a9cd-88f18d29bc8f", "Loan Recommendation - context");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.getMessages().size(), is(2));
assertEquals(1, dmnModel.getMessages().stream().filter(m -> m.getMessageType().equals(DMNMessageType.ERR_COMPILING_FEEL)).filter(m -> m.getMessage().contains("Unknown variable 'NonSalaryPct'")).count());
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeTest method testVerifyExtendedKieFEELFunction_today.
@Test
public void testVerifyExtendedKieFEELFunction_today() {
// DROOLS-2322
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("just_today.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_56fd6445-ff6a-4c28-8206-71fce7f80436", "just today");
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));
assertThat(dmnResult.getDecisionResultByName("a decision just today").getResult(), notNullValue());
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class ValidatorTest method testMACDInputDefinitions.
@Test
public void testMACDInputDefinitions() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("MACD-enhanced_iteration.dmn", DMNInputRuntimeTest.class);
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6cfe7d88-6741-45d1-968c-b61a597d0964", "MACD-enhanced iteration");
assertThat(dmnModel, notNullValue());
Definitions definitions = dmnModel.getDefinitions();
assertThat(definitions, notNullValue());
List<DMNMessage> messages = DMNValidatorFactory.newValidator().validate(definitions, VALIDATE_MODEL, VALIDATE_COMPILATION);
assertThat(messages.toString(), messages.size(), is(0));
}
Aggregations