Search in sources :

Example 1 with Person

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));
    }
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNContext(org.kie.dmn.api.core.DMNContext) Person(org.kie.dmn.core.model.Person) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Example 2 with Person

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));
    }
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNContext(org.kie.dmn.api.core.DMNContext) Person(org.kie.dmn.core.model.Person) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with Person

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));
    }
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNContext(org.kie.dmn.api.core.DMNContext) Person(org.kie.dmn.core.model.Person) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Example 4 with Person

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));
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNContext(org.kie.dmn.api.core.DMNContext) Person(org.kie.dmn.core.model.Person) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) BigDecimal(java.math.BigDecimal) BaseVariantTest(org.kie.dmn.core.BaseVariantTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 DMNContext (org.kie.dmn.api.core.DMNContext)4 DMNModel (org.kie.dmn.api.core.DMNModel)4 DMNResult (org.kie.dmn.api.core.DMNResult)4 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)4 Person (org.kie.dmn.core.model.Person)4 BigDecimal (java.math.BigDecimal)1 Ignore (org.junit.Ignore)1 BaseVariantTest (org.kie.dmn.core.BaseVariantTest)1