use of org.kie.dmn.feel.lang.types.BuiltInType in project drools by kiegroup.
the class DMNRuntimeTest method testYearsAndMonthsDuration.
@Test
public void testYearsAndMonthsDuration() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("yearMonthDuration.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_6eda1490-21ca-441e-8a26-ab3ca800e43c", "Drawing 1");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
final BuiltInType feelType = (BuiltInType) BuiltInType.determineTypeFromName("yearMonthDuration");
final ChronoPeriod period = (ChronoPeriod) feelType.fromString("P2Y1M");
final DMNContext context = runtime.newContext();
context.set("iDuration", period);
final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
final DMNContext result = dmnResult.getContext();
assertThat(result.get("How long"), is("Longer than a year"));
}
Aggregations