Skip to content

35. Authoring a Decision

Let's author a simple decision and test it.

The use case we'll try out is the automation of a repeated decision for requests approval.

35.1 Create a new Decision

In the project we've just created:

  1. Select the folder where you want to create the new file. Click on resources. Next, click on the new folder icon:

  2. Name the file automated-request-approval.dmn and press enter. The file should open in the DMN Editor.

  3. Create the following DMN:

  4. This DRD contains:

    • A decision node Approval of type boolean;
    • Two inputs:
      • A request type , which is string
      • A request price, that is a number.
  5. Implement the following decision table, in the decision node:

  6. Save the diagram

35.2 Testing the decision

Before deploying the decision service in KIE Server, let's do some unit testing using the Test Scenario Simulation tooling.

35.2.1 Configuring the project

In order to use test scenarios, you need to add at least three dependencies to your project:

  • junit:junit
  • org.drools:drools-scenario-simulation-backend
  • org.drools:drools-scenario-simulation-api

Open the pom.xml file and add the following dependencies:


35.2.2 Adding the JUnit Runner

In this scenario, the should be compatible with the product version you want to use. In this scenario, we are using IBAMOE 7.10, which would be <>7.67.2.Final-redhat-00006</>.

  1. Create a new folder testscenario: /src/test/java/testscenario

  2. In the folder you just created, add a file and name it

  3. In this class, you should add a the Scenario Activator. This class allows the test scenarios to run along with the junit tests.

  package testscenario;
  * Do not remove this file

  public class ScenarioJunitActivatorTest {

It should look like this:

35.2.3 Creating the test scenario

  1. On the folder src/test/resources/org/kie/businessapp create a new file named ValidateAutomaticDecision.scesim.

  2. The editor should open up with the option to choose the Source type. This is the type of rule you want to test.

  3. Select DMN, next, choose your DMN file and click on the create button.

  4. The tool will already bring the inputs and expected result columns based on your DMN. Now, implement the following test:

35.2.4 Runing the tests

You can run the tests in two ways: using maven or the JUnit activator class. To run the test with maven you can for example run:

mvn test

If you want to run the tests using the activator class:

  1. Right click the file and select Run Java:

  2. The execution results should show up:

  3. Try changing the line one expected result from true to false. Click on the re-run button to see the results.

Finally, adjust the tests and make sure that your project can compile when you run:

mvn clean install

35.3 Next Steps

Now it's time to deploy our project to KIE Server and test it out.

Last update: 2024-03-25