use of org.kie.dmn.core.model.Person in project drools by kiegroup.
the class DMNRuntimeTest method testAccessorCache.
@Test(timeout = 30_000L)
public void testAccessorCache() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("20180731-pr1997.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_7a39d775-bce9-45e3-aa3b-147d6f0028c7", "20180731-pr1997");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
for (int i = 0; i < 10_000; i++) {
final DMNContext context = DMNFactory.newContext();
context.set("a Person", new Person("John", "Doe", i));
final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
LOG.debug("{}", dmnResult);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Say hello and age"), is("Hello John Doe, your age is: " + i));
}
}
use of org.kie.dmn.core.model.Person in project drools by kiegroup.
the class DMNStronglyTypedSupportTest method testAccessorCache.
@Test(timeout = 30_000L)
@Ignore("This shouldn't be supported by Typesafe DMN")
public void testAccessorCache() {
final DMNRuntime runtime = createRuntime("20180731-pr1997.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_7a39d775-bce9-45e3-aa3b-147d6f0028c7", "20180731-pr1997");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
for (int i = 0; i < 10_000; i++) {
final DMNContext context = DMNFactory.newContext();
context.set("a Person", new Person("John", "Doe", i));
final DMNResult dmnResult = evaluateModel(runtime, dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Say hello and age"), is("Hello John Doe, your age is: " + i));
}
}
use of org.kie.dmn.core.model.Person in project drools by kiegroup.
the class DMNRuntimeTest method testAccessorCache.
@Test(timeout = 30_000L)
public void testAccessorCache() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("20180731-pr1997.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_7a39d775-bce9-45e3-aa3b-147d6f0028c7", "20180731-pr1997");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
for (int i = 0; i < 10_000; i++) {
final DMNContext context = DMNFactory.newContext();
context.set("a Person", new Person("John", "Doe", i));
final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
LOG.debug("{}", dmnResult);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Say hello and age"), is("Hello John Doe, your age is: " + i));
}
}
use of org.kie.dmn.core.model.Person in project drools by kiegroup.
the class DMN14specificTest method testDMNv1_4_putAll.
@Test
public void testDMNv1_4_putAll() {
final DMNRuntime runtime = createRuntime("exampleContextMerge.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_864E9A62-12E5-41DC-A7A6-7F028822A067", "examplePutAll");
assertThat(dmnModel).isNotNull();
assertThat(dmnModel.hasErrors()).describedAs(formatMessages(dmnModel.getMessages())).isFalse();
final DMNContext context = DMNFactory.newContext();
context.set("Partial Person", new Person("John", "Wick"));
final DMNResult dmnResult = evaluateModel(runtime, dmnModel, context);
LOG.debug("{}", dmnResult);
assertThat(dmnResult.hasErrors()).describedAs(formatMessages(dmnResult.getMessages())).isFalse();
assertThat(dmnResult.getDecisionResultByName("Complete Person").getResult()).hasFieldOrPropertyWithValue("last name", "Doe").hasFieldOrPropertyWithValue("age", new BigDecimal(47));
}
Aggregations