droolskiedmnkogito

Kogito Debugging DMN Test Scenarios


Using Kogito I'm trying to create a test scenario for a DMN file that returns an array. I created a simple DMN that would return an array of objects regardless of the input for the sake of testing.

But tests are failing if I add a value to the return array, they pass if I have zero elements as the expected result which makes no sense. Looks like DMN returns no values if executed from the test.

If I run this on the api it always returns an element on the array as expected.

I have been trying to figure out how to debug this on visual studio with no luck

Expected result is being written like this on the file, but again appear no result is coming back

[{"name":"\"jose\"", "ages":"[12,13]"}]

simple.dmn

simpleTest.scesim

Basically some method to debug this would be great or any help that can point me in the right direction.

Thanks in advance

Jose


Solution

  • There are two points to tackle here, one is related to the error you faced, and the second is to understand how to debug a scesim asset during its running phase.

    enter image description here

    The problem here is with ages fields, which is a nested List. Providing [12,13] as a parameter of that list, is formally correct. But, due to the limitation I mentioned, it currently it doesn't work. There's a workaround you can use, which is to Define a List using an expression, as shown in the following screenshot:

    enter image description here

    The expression ? = {"name":"jose","ages":[12, 13]} means to check for the equality of the actual value (?) with an object which contains a field name with value jose and a field ages with [12, 13] as the value. Please note, according to your defined logic, you expect a Simple type list with one item only. If you Simple type returns a list with multiple items, the expression should be composed by a List rather than a single object (Eg. ? = [{"name":"jose","ages":[12, 13]}, {"name":"john","ages":[1, 3]}, .. ] We are aware this is not ideal, we are defining a way to improve this use-case experience. Stay tuned with KIE channels to know more or to give hints to improve this!

    enter image description here

    Put a breakpoint on that line. Now, to launch the scesim engine in debug mode, go to your scesim activator class (typically named KogitoScenarioJunitActivatorTest). Here, you can Run/Debug your scesim assets like a Junit test class.

    enter image description here