As a business rules developer, you can use Business Central in IBM Business Automation Manager Open Editions or the IBM Business Automation Manager Open Editions DMN modeler in VS Code to design a variety of decision services. IBM Business Automation Manager Open Editions provides example projects with example business assets directly in Business Central as a reference. This document describes how to create and test an example traffic violation project based on the Traffic_Violation sample project included in Business Central. This sample project uses a Decision Model and Notation (DMN) model to define driver penalty and suspension rules in a traffic violation decision service. You can follow the steps in this document to create the project and the assets it contains, or open and review the existing Traffic_Violation sample project.

For more information about the DMN components and implementation in IBM Business Automation Manager Open Editions, see Designing a decision service using DMN models.

Prerequisites

Sample projects and business assets in Business Central

Business Central contains sample projects with business assets that you can use as a reference for the rules or other assets rules, processes, or other assets that you create in your own IBM Business Automation Manager Open Editions projects. Each sample project is designed differently to demonstrate decision management process automation, or decision management assets and logic in IBM Business Automation Manager Open Editions.

Note
IBM does not provide support for the sample code included in the IBM Business Automation Manager Open Editions distribution.

The following sample projects are available in Business Central:

  • IT_Orders: (Process automation and case management) Ordering case using business process and case management assets. Places an IT hardware order based on needs and approvals.

  • Mortgages: (Decision management with rules) Loan approval process using rule-based decision assets. Determines loan eligibility based on applicant data and qualifications.

  • Mortgage_Process: (Process automation) Loan approval process using business process and decision assets. Determines loan eligibility based on applicant data and qualifications.

  • Traffic_Violation: (Decision management with DMN) Traffic violation decision service using a Decision Model and Notation (DMN) model. Determines driver penalty and suspension based on traffic violations.

Accessing sample projects and business assets in Business Central

You can use the sample projects in Business Central to explore business assets as a reference for the rules or other assets that you create in your own IBM Business Automation Manager Open Editions projects.

Prerequisites
Procedure
  1. In Business Central, go to MenuDesignProjects. If there are existing projects, you can access the samples by clicking the MySpace default space and selecting Try Samples from the Add Project drop-down menu. If there are no existing projects, click Try samples.

  2. Review the descriptions for each sample project to determine which project you want to explore. Each sample project is designed differently to demonstrate decision management process automation or decision management assets and logic in IBM Business Automation Manager Open Editions.

  3. Select one or more sample projects and click Ok to add the projects to your space.

  4. In the Projects page of your space, select one of the sample projects to view the assets for that project.

  5. Select each asset to explore how the project is designed to achieve the specified goal or workflow. Some of the sample projects contain more than one page of assets. Click the left or right arrows in the upper-right corner to view the full asset list.

    Navigate through asset pages
    Figure 1. Asset page selection
  6. In the upper-right corner of the project Assets page, click Build to build the sample project or Deploy to build the project and then deploy it to KIE Server.

    Note

    You can also select the Build & Install option to build the project and publish the KJAR file to the configured Maven repository without deploying to a KIE Server. In a development environment, you can click Deploy to deploy the built KJAR file to a KIE Server without stopping any running instances (if applicable), or click Redeploy to deploy the built KJAR file and replace all instances. The next time you deploy or redeploy the built KJAR, the previous deployment unit (KIE container) is automatically updated in the same target KIE Server. In a production environment, the Redeploy option is disabled and you can click Deploy only to deploy the built KJAR file to a new deployment unit (KIE container) on a KIE Server.

    To configure the KIE Server environment mode, set the org.kie.server.mode system property to org.kie.server.mode=development or org.kie.server.mode=production. To configure the deployment behavior for a corresponding project in Business Central, go to project SettingsGeneral SettingsVersion, toggle the Development Mode option, and click Save. By default, KIE Server and all new projects in Business Central are in development mode. You cannot deploy a project with Development Mode turned on or with a manually added SNAPSHOT version suffix to a KIE Server that is in production mode.

    To review project deployment details, click View deployment details in the deployment banner at the top of the screen or in the Deploy drop-down menu. This option directs you to the MenuDeployExecution Servers page.

IBM Business Automation Manager Open Editions BPMN and DMN modelers

IBM Business Automation Manager Open Editions provides the following extensions or applications that you can use to design Business Process Model and Notation (BPMN) process models and Decision Model and Notation (DMN) decision models using graphical modelers.

  • Business Central: Enables you to view and design BPMN models, DMN models, and test scenario files in a related embedded designer.

    To use Business Central, you can set up a development environment containing a Business Central to design business rules and processes, and a KIE Server to execute and test the created business rules and processes.

  • IBM Business Automation Manager Open Editions VS Code extension: Enables you to view and design BPMN models, DMN models, and test scenario files in Visual Studio Code (VS Code). The VS Code extension requires VS Code 1.46.0 or later.

    To install the IBM Business Automation Manager Open Editions VS Code extension, select the Extensions menu option in VS Code and search for and install the KIE Business Automation Bundle extension.

  • Standalone BPMN and DMN editors: Enable you to view and design BPMN and DMN models embedded in your web applications. To download the necessary files, you can either use the NPM artifacts from the NPM registry or download the JavaScript files directly for the DMN standalone editor library at https://<YOUR_PAGE>/dmn/index.js and for the BPMN standalone editor library at https://<YOUR_PAGE>/bpmn/index.js.

Installing the IBM Business Automation Manager Open Editions VS Code extension bundle

IBM Business Automation Manager Open Editions provides a KIE Business Automation Bundle VS Code extension that enables you to design Decision Model and Notation (DMN) decision models, Business Process Model and Notation (BPMN) 2.0 business processes, and test scenarios directly in VS Code. VS Code is the preferred integrated development environment (IDE) for developing new business applications. IBM Business Automation Manager Open Editions also provides individual DMN Editor and BPMN Editor VS Code extensions for DMN or BPMN support only, if needed.

Important
The editors in the VS Code are partially compatible with the editors in the Business Central, and several Business Central features are not supported in the VS Code.
Prerequisites
  • The latest stable version of VS Code is installed.

Procedure
  1. In your VS Code IDE, select the Extensions menu option and search for KIE Business Automation Bundle for DMN, BPMN, and test scenario file support.

    For DMN or BPMN file support only, you can also search for the individual DMN Editor or BPMN Editor extensions.

  2. When the KIE Business Automation Bundle extension appears in VS Code, select it and click Install.

  3. For optimal VS Code editor behavior, after the extension installation is complete, reload or close and re-launch your instance of VS Code.

After you install the VS Code extension bundle, any .dmn, .bpmn, or .bpmn2 files that you open or create in VS Code are automatically displayed as graphical models. Additionally, any .scesim files that you open or create are automatically displayed as tabular test scenario models for testing the functionality of your business decisions.

If the DMN, BPMN, or test scenario modelers open only the XML source of a DMN, BPMN, or test scenario file and displays an error message, review the reported errors and the model file to ensure that all elements are correctly defined.

Note
For new DMN or BPMN models, you can also enter dmn.new or bpmn.new in a web browser to design your DMN or BPMN model in the online modeler. When you finish creating your model, you can click Download in the online modeler page to import your DMN or BPMN file into your IBM Business Automation Manager Open Editions project in VS Code.

Configuring the IBM Business Automation Manager Open Editions standalone editors

IBM Business Automation Manager Open Editions provides standalone editors that are distributed in a self-contained library providing an all-in-one JavaScript file for each editor. The JavaScript file uses a comprehensive API to set and control the editor.

You can install the standalone editors using the following methods:

  • Download each JavaScript file manually

  • Use the NPM package

Procedure
  1. Install the standalone editors using one of the following methods:

    Download each JavaScript file manually: For this method, follow these steps:

    1. Download the JavaScript files.

    2. Add the downloaded Javascript files to your hosted application.

    3. Add the following <script> tag to your HTML page:

      Script tag for your HTML page for the DMN editor
      <script src="https://<YOUR_PAGE>/dmn/index.js"></script>
      Script tag for your HTML page for the BPMN editor
      <script src="https://<YOUR_PAGE>/bpmn/index.js"></script>

    Use the NPM package: For this method, follow these steps:

    1. Add the NPM package to your package.json file:

      Adding the NPM package
      npm install @kie-tools/kie-editors-standalone
    2. Import each editor library to your TypeScript file:

      Importing each editor
      import * as DmnEditor from "@kie-tools/kie-editors-standalone/dist/dmn"
      import * as BpmnEditor from "@kie-tools/kie-editors-standalone/dist/bpmn"
  2. After you install the standalone editors, open the required editor by using the provided editor API, as shown in the following example for opening a DMN editor. The API is the same for each editor.

    Opening the DMN standalone editor
    const editor = DmnEditor.open({
      container: document.getElementById("dmn-editor-container"),
      initialContent: Promise.resolve(""),
      readOnly: false,
      origin: "",
      resources: new Map([
        [
          "MyIncludedModel.dmn",
          {
            contentType: "text",
            content: Promise.resolve("")
          }
        ]
      ])
    });

    Use the following parameters with the editor API:

    Table 1. Example parameters
    Parameter Description

    container

    HTML element in which the editor is appended.

    initialContent

    Promise to a DMN model content. This parameter can be empty, as shown in the following examples:

    • Promise.resolve("")

    • Promise.resolve("<DIAGRAM_CONTENT_DIRECTLY_HERE>")

    • fetch("MyDmnModel.dmn").then(content ⇒ content.text())

    readOnly (Optional)

    Enables you to allow changes in the editor. Set to false (default) to allow content editing and true for read-only mode in editor.

    origin (Optional)

    Origin of the repository. The default value is window.location.origin.

    resources (Optional)

    Map of resources for the editor. For example, this parameter is used to provide included models for the DMN editor or work item definitions for the BPMN editor. Each entry in the map contains a resource name and an object that consists of content-type (text or binary) and content (similar to the initialContent parameter).

    The returned object contains the methods that are required to manipulate the editor.

    Table 2. Returned object methods
    Method Description

    getContent(): Promise<string>

    Returns a promise containing the editor content.

    setContent(path: string, content: string): void

    Sets the content of the editor.

    getPreview(): Promise<string>

    Returns a promise containing an SVG string of the current diagram.

    subscribeToContentChanges(callback: (isDirty: boolean) ⇒ void): (isDirty: boolean) ⇒ void

    Sets a callback to be called when the content changes in the editor and returns the same callback to be used for unsubscription.

    unsubscribeToContentChanges(callback: (isDirty: boolean) ⇒ void): void

    Unsubscribes the passed callback when the content changes in the editor.

    markAsSaved(): void

    Resets the editor state that indicates that the content in the editor is saved. Also, it activates the subscribed callbacks related to content change.

    undo(): void

    Undoes the last change in the editor. Also, it activates the subscribed callbacks related to content change.

    redo(): void

    Redoes the last undone change in the editor. Also, it activates the subscribed callbacks related to content change.

    close(): void

    Closes the editor.

    getElementPosition(selector: string): Promise<Rect>

    Provides an alternative to extend the standard query selector when an element lives inside a canvas or a video component. The selector parameter must follow the <PROVIDER>:::<SELECT> format, such as Canvas:::MySquare or Video:::PresenterHand. This method returns a Rect representing the element position.

    envelopeApi: MessageBusClientApi<KogitoEditorEnvelopeApi>

    This is an advanced editor API. For more information about advanced editor API, see MessageBusClientApi and KogitoEditorEnvelopeApi.

Creating and executing DMN and BPMN models using Maven

You can use Maven archetypes to develop DMN and BPMN models in VS Code using the IBM Business Automation Manager Open Editions VS Code extension instead of Business Central. You can then integrate your archetypes with your IBM Business Automation Manager Open Editions decision and process services in Business Central as needed. This method of developing DMN and BPMN models is helpful for building new business applications using the IBM Business Automation Manager Open Editions VS Code extension.

Procedure
  1. In a command terminal, navigate to a local folder where you want to store the new IBM Business Automation Manager Open Editions project.

  2. Enter the following command to use a Maven archtype to generate a project within a defined folder:

    Generating a project using Maven archetype
    mvn archetype:generate \
        -DarchetypeGroupId=org.kie \
        -DarchetypeArtifactId=kie-kjar-archetype \
        -DarchetypeVersion=7.67.2.Final-redhat-0017

    This command generates a Maven project with required dependencies and generates required directories and files to build your business application. You can use the Git version control system (recommended) when developing a project.

    If you want to generate multiple projects in the same directory, specify the artifactId and groupId of the generated business application by adding -DgroupId=<groupid> -DartifactId=<artifactId> to the previous command.

  3. In your VS Code IDE, click File, select Open Folder, and navigate to the folder that is generated using the previous command.

  4. Before creating the first asset, set a package for your business application, for example, org.kie.businessapp, and create respective directories in the following paths:

    • PROJECT_HOME/src/main/java

    • PROJECT_HOME/src/main/resources

    • PROJECT_HOME/src/test/resources

    For example, you can create PROJECT_HOME/src/main/java/org/kie/businessapp for org.kie.businessapp package.

  5. Use VS Code to create assets for your business application. You can create the assets supported by IBM Business Automation Manager Open Editions VS Code extension using the following ways:

    • To create a business process, create a new file with .bpmn or .bpmn2 in PROJECT_HOME/src/main/resources/org/kie/businessapp directory, such as Process.bpmn.

    • To create a DMN model, create a new file with .dmn in PROJECT_HOME/src/main/resources/org/kie/businessapp directory, such as AgeDecision.dmn.

    • To create a test scenario simulation model, create a new file with .scesim in PROJECT_HOME/src/test/resources/org/kie/businessapp directory, such as TestAgeScenario.scesim.

  6. After you create the assets in your Maven archetype, navigate to the root directory (contains pom.xml) of the project in the command line and run the following command to build the knowledge JAR (KJAR) of your project:

    mvn clean install

    If the build fails, address any problems described in the command line error messages and try again to validate the project until the build is successful. However, if the build is successful, you can find the artifact of your business application in PROJECT_HOME/target directory.

    Note
    Use mvn clean install command often to validate your project after each major change during development.

You can deploy the generated knowledge JAR (KJAR) of your business application on a running KIE Server using the REST API. For more information about using REST API, see Interacting with IBM Business Automation Manager Open Editions using KIE APIs.

Creating the traffic violations project in Business Central

For this example, create a new project called traffic-violation. A project is a container for assets such as data objects, DMN assets, and test scenarios. This example project that you are creating is similar to the existing Traffic_Violation sample project in Business Central.

Procedure
  1. In Business Central, go to MenuDesignProjects.

    IBM Business Automation Manager Open Editions provides a default space called MySpace. You can use the default space to create and test example projects.

  2. Click Add Project.

  3. Enter traffic-violation in the Name field.

  4. Click Add.

    Add project window
    Figure 2. Add Project window

    The Assets view of the project opens.

Decision Model and Notation (DMN)

Decision Model and Notation (DMN) is a standard established by the Object Management Group (OMG) for describing and modeling operational decisions. DMN defines an XML schema that enables DMN models to be shared between DMN-compliant platforms and across organizations so that business analysts and business rules developers can collaborate in designing and implementing DMN decision services. The DMN standard is similar to and can be used together with the Business Process Model and Notation (BPMN) standard for designing and modeling business processes.

For more information about the background and applications of DMN, see the OMG Decision Model and Notation specification.

Creating the traffic violations DMN decision requirements diagram (DRD)

A decision requirements diagram (DRD) is a visual representation of your DMN model. Use the DMN designer in Business Central to design the DRD for the traffic violations project and to define the decision logic of the DRD components.

DRD for the Traffic Violations example
Figure 3. DRD for the Traffic Violations example
Prerequisites
  • You have created the traffic violations project in Business Central.

Procedure
  1. On the traffic-violation project’s home page, click Add Asset.

  2. On the Add Asset page, click DMN. The Create new DMN window is opened.

    1. In the Create new DMN window, enter Traffic Violation in the DMN name field.

    2. From the Package list, select com.myspace.traffic_violation.

    3. Click OK. The DMN asset in the DMN designer is opened.

  3. In the DMN designer canvas, drag two DMN Input Data input nodes onto the canvas.

    DMN Input Data nodes
    Figure 4. DMN Input Data nodes
  4. In the upper-right corner, click the Properties icon.

  5. Double-click the input nodes and rename one to Driver and the other to Violation.

  6. Drag a DMN Decision decision node onto the canvas.

  7. Double-click the decision node and rename it to Fine.

  8. Click the Violation input node, select the Create DMN Information Requirement icon and click the Fine decision node to link the two nodes.

    Create DMN Information Requirement icon
    Figure 5. Create DMN Information Requirement icon
  9. Drag a DMN Decision decision node onto the canvas.

  10. Double-click the decision node and rename it to Should the driver be suspended?.

  11. Click the Driver input node, select the Create DMN Information Requirement icon and click the Should the driver be suspended? decision node to link the two nodes.

  12. Click the Fine decision node, select the Create DMN Information Requirement icon, and select the Should the driver be suspended? decision node.

  13. Click Save.

    Note
    As you periodically save a DRD, the DMN designer performs a static validation of the DMN model and might produce error messages until the model is defined completely. After you finish defining the DMN model completely, if any errors remain, troubleshoot the specified problems accordingly.

Creating the traffic violations DMN custom data types

DMN data types determine the structure of the data that you use within a table, column, or field in a DMN boxed expression for defining decision logic. You can use default DMN data types (such as string, number, or boolean) or you can create custom data types to specify additional fields and constraints that you want to implement for the boxed expression values. Use the DMN designer’s Data Types tab in Business Central to define the custom data types for the traffic violations project.

The custom data types tab
Figure 6. The custom data types tab

The following tables list the tDriver, tViolation, and tFine custom data types that you will create for this project.

Table 3. tDriver custom data type
Name Type

tDriver

Structure

Name

string

Age

number

State

string

City

string

Points

number

Table 4. tViolation custom data type
Name Type

tViolation

Structure

Code

string

Date

date

Type

string

Speed Limit

number

Actual Speed

number

Table 5. tFine custom data type
Name Type

tFine

Structure

Amount

number

Points

number

Prerequisites
  • You created the traffic violations DMN decision requirements diagram (DRDs) in Business Central.

Procedure
  1. To create the tDriver custom data type, click Add a custom Data Type on the Data Types tab, enter tDriver in the Name field, and select Structure from the Type list.

  2. Click the check mark to the right of the new data type to save your changes.

    The tDriver custom data type
    Figure 7. The tDriver custom data type
  3. Add each of the following nested data types to the tDriver structured data type by clicking the plus sign next to tDriver for each new nested data type. Click the check mark to the right of each new data type to save your changes.

    • Name (string)

    • Age (number)

    • State (string)

    • City (string)

    • Points (number)

  4. To create the tViolation custom data type, click New Data Type, enter tViolation in the Name field, and select Structure from the Type list.

  5. Click the check mark to the right of the new data type to save your changes.

    The tViolation custom data type
    Figure 8. The tViolation custom data type
  6. Add each of the following nested data types to the tViolation structured data type by clicking the plus sign next to tViolation for each new nested data type. Click the check mark to the right of each new data type to save your changes.

    • Code (string)

    • Date (date)

    • Type (string)

    • Speed Limit (number)

    • Actual Speed (number)

  7. To add the following constraints to the Type nested data type, click the edit icon, click Add Constraints, and select Enumeration from the Select constraint type drop-down menu.

    • speed

    • parking

    • driving under the influence

  8. Click OK, then click the check mark to the right of the Type data type to save your changes.

  9. To create the tFine custom data type, click New Data Type, enter tFine in the Name field, select Structure from the Type list, and click Save.

    The tFine custom data type
    Figure 9. The tFine custom data type
  10. Add each of the following nested data types to the tFine structured data type by clicking the plus sign next to tFine for each new nested data type. Click the check mark to the right of each new data type to save your changes.

    • Amount (number)

    • Points (number)

  11. Click Save.

Assigning custom data types to the DRD input and decision nodes

After you create the DMN custom data types, assign them to the appropriate DMN Input Data and DMN Decision nodes in the traffic violations DRD.

Prerequisites
  • You have created the traffic violations DMN custom data types in Business Central.

Procedure
  1. Click the Model tab on the DMN designer and click the Properties diagram properties icon in the upper-right corner of the DMN designer to expose the DRD properties.

  2. In the DRD, select the Driver input data node and in the Properties panel, select tDriver from the Data type drop-down menu.

  3. Select the Violation input data node and select tViolation from the Data type drop-down menu.

  4. Select the Fine decision node and select tFine from the Data type drop-down menu.

  5. Select the Should the driver be suspended? decision node and set the following properties:

    • Data type: string

    • Question: Should the driver be suspended due to points on his driver license?

    • Allowed Answers: Yes,No

  6. Click Save.

You have assigned the custom data types to your DRD’s input and decision nodes.

Defining the traffic violations DMN decision logic

To calculate the fine and to decide whether the driver is to be suspended or not, you can define the traffic violations DMN decision logic using a DMN decision table and context boxed expression.

Fine expression decision table
Figure 10. Fine expression
Should the driver be suspended expression decision table
Figure 11. Should the driver be suspended expression
Prerequisites
  • You have assigned the DMN custom data types to the appropriate decision and input nodes in the traffic violations DRD in Business Central.

Procedure
  1. To calculate the fine, in the DMN designer canvas, select the Fine decision node and click the Edit icon to open the DMN boxed expression designer.

    Decision node edit icon
    Figure 12. Decision node edit icon
  2. Click Select expressionDecision Table.

    Select logic type menu
    Figure 13. Select Decisiong Table logic type
  3. For the Violation.Date, Violation.Code, and Violation.Speed Limit columns, right-click and select Delete for each field.

  4. Click the Violation.Actual Speed column header and enter the expression Violation.Actual Speed - Violation.Speed Limit in the Expression field."

  5. Enter the following values in the first row of the decision table:

    • Violation.Type: "speed"

    • Violation.Actual Speed - Violation.Speed Limit: [10..30)

    • Amount: 500

    • Points: 3

      Right-click the first row and select Insert below to add another row.

  6. Enter the following values in the second row of the decision table:

    • Violation.Type: "speed"

    • Violation.Actual Speed - Violation.Speed Limit: >= 30

    • Amount: 1000

    • Points: 7

      Right-click the second row and select Insert below to add another row.

  7. Enter the following values in the third row of the decision table:

    • Violation.Type: "parking"

    • Violation.Actual Speed - Violation.Speed Limit: -

    • Amount: 100

    • Points: 1

      Right-click the third row and select Insert below to add another row.

  8. Enter the following values in the fourth row of the decision table:

    • Violation.Type: "driving under the influence"

    • Violation.Actual Speed - Violation.Speed Limit: -

    • Amount: 1000

    • Points: 5

  9. Click Save.

  10. To define the driver suspension rule, return to the DMN designer canvas, select the Should the driver be suspended? decision node, and click the Edit icon to open the DMN boxed expression designer.

  11. Click Select expressionContext.

  12. Click ContextEntry-1, enter Total Points as the Name, and select number from the Data Type drop-down menu.

  13. Click the cell next to Total Points, select Literal expression from the context menu, and enter Driver.Points + Fine.Points as the expression.

  14. In the cell below Driver.Points + Fine.Points, select Literal Expression from the context menu, and enter if Total Points >= 20 then "Yes" else "No".

  15. Click Save.

    You have defined how to calculate the fine and the context for deciding when to suspend the driver. You can navigate to the traffic-violation project page and click Build to build the example project and address any errors noted in the Alerts panel.

Test scenarios

Test scenarios in IBM Business Automation Manager Open Editions enable you to validate the functionality of business rules and business rule data (for rules-based test scenarios) or of DMN models (for DMN-based test scenarios) before deploying them into a production environment. With a test scenario, you use data from your project to set given conditions and expected results based on one or more defined business rules. When you run the scenario, the expected results and actual results of the rule instance are compared. If the expected results match the actual results, the test is successful. If the expected results do not match the actual results, then the test fails.

IBM Business Automation Manager Open Editions includes both the new Test Scenarios designer and the former Test Scenarios (Legacy) designer. The default designer is the new test scenarios designer, which supports the testing of both rules and DMN models and provides an enhanced overall user experience with test scenarios. If required, you can continue to use the legacy test scenarios designer, which supports rule-based test scenarios only.

Important
The legacy test scenarios designer is deprecated from IBM Business Automation Manager Open Editions version 7.3.0. It will be removed in a future IBM Business Automation Manager Open Editions release. Use the new test scenarios designer instead.

You can run the defined test scenarios in a number of ways, for example, you can run available test scenarios at the project level or inside a specific test scenario asset. Test scenarios are independent and cannot affect or modify other test scenarios. You can run test scenarios at any time during project development in Business Central. You do not have to compile or deploy your decision service to run test scenarios.

You can import data objects from different packages to the same project package as the test scenario. Assets in the same package are imported by default. After you create the necessary data objects and the test scenario, you can use the Data Objects tab of the test scenarios designer to verify that all required data objects are listed or to import other existing data objects by adding a New item.

Important
Throughout the test scenarios documentation, all references to test scenarios and the test scenarios designer are for the new version, unless explicitly noted as the legacy version.

Testing the traffic violations using test scenarios

Use the test scenarios designer in Business Central to test the DMN decision requirements diagrams (DRDs) and define decision logic for the traffic violations project.

Test scenario for the traffic violations example
Figure 14. Test scenario for the traffic violations example
Prerequisites
  • You have successfully built the traffic violations project in Business Central.

Procedure
  1. On the traffic-violation project’s home screen, click Add Asset to open the Add Asset screen.

  2. Click Test Scenario to open the Create new Test Scenario dialog.

    1. Enter Violation Scenarios in the Test Scenario field.

    2. From the Package list, select com.myspace.traffic_violation.

    3. Select DMN as the Source type.

    4. From the Choose a DMN asset list, select the path to the DMN asset.

    5. Click OK to open the Violation Scenarios test scenario in the Test Scenarios designer.

  3. Under Driver column sub-header, right-click the State, City, Age, and Name value cells and select Delete column from the context menu options to remove them.

  4. Under Violation column sub-header, right-click the Date and Code value cells and select Delete column to remove them.

  5. Enter the following information in the first row of the test scenarios:

    • Scenario description: Above speed limit: 10km/h and 30 km/h

    • Points (under Given column header): 10

    • Type: "speed"

    • Speed Limit: 100

    • Actual Speed: 120

    • Points: 3

    • Amount: 500

    • Should the driver be suspended?: "No"

      Right-click the first row and select Insert row below to add another row.

  6. Enter the following information in the second row of the test scenarios:

    • Scenario description: Above speed limit: more than 30 km/h

    • Points (under Given column header): 10

    • Type: "speed"

    • Speed Limit: 100

    • Actual Speed: 150

    • Points: 7

    • Amount: 1000

    • Should the driver be suspended?: "No"

      Right-click the second row and select Insert row below to add another row.

  7. Enter the following information in the third row of the test scenarios:

    • Scenario description: Parking violation

    • Points (under Given column header): 10

    • Type: "parking"

    • Speed Limit: leave blank

    • Actual Speed: leave blank

    • Points: 1

    • Amount: 100

    • Should the driver be suspended?: "No"

      Right-click the third row and select Insert row below to add another row.

  8. Enter the following information in the fourth row of the test scenarios:

    • Scenario description: DUI violation

    • Points (under Given column header): 10

    • Type: "driving under the influence"

    • Speed Limit: leave blank

    • Actual Speed: leave blank

    • Points: 5

    • Amount: 1000

    • Should the driver be suspended?: "No"

      Right-click the fourth row and select Insert row below to add another row.

  9. Enter the following information in the fifth row of the test scenarios:

    • Scenario description: Driver suspended

    • Points (under Given column header): 15

    • Type: "speed"

    • Speed Limit: 100

    • Actual Speed: 140

    • Points: 7

    • Amount: 1000

    • Should the driver be suspended?: "Yes"

  10. Click Save.

  11. Click the Play icon dmn play icon to check whether the test scenarios pass or fail.

    Test scenario execution result for the traffic violations example
    Figure 15. Test scenario execution result for the traffic violations example

    In case of failure, correct the errors and run the test scenarios again.

DMN model execution

You can create or import DMN files in your IBM Business Automation Manager Open Editions project using Business Central or package the DMN files as part of your project knowledge JAR (KJAR) file without Business Central. After you implement your DMN files in your IBM Business Automation Manager Open Editions project, you can execute the DMN decision service by deploying the KIE container that contains it to KIE Server for remote access and interacting with the container using the KIE Server REST API.

For information about including external DMN assets with your project packaging and deployment method, see Packaging and deploying an IBM Business Automation Manager Open Editions project.

Executing a DMN service using the KIE Server REST API

Directly interacting with the REST endpoints of KIE Server provides the most separation between the calling code and the decision logic definition. The calling code is completely free of direct dependencies, and you can implement it in an entirely different development platform such as Node.js or .NET. The examples in this section demonstrate Nix-style curl commands but provide relevant information to adapt to any REST client.

When you use a REST endpoint of KIE Server, the best practice is to define a domain object POJO Java class, annotated with standard KIE Server marshalling annotations. For example, the following code is using a domain object Person class that is annotated properly:

Example POJO Java class
@javax.xml.bind.annotation.XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.FIELD)
public class Person implements java.io.Serializable {

    static final long serialVersionUID = 1L;

    private java.lang.String id;
    private java.lang.String name;
    @javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter(org.kie.internal.jaxb.LocalDateXmlAdapter.class)
    private java.time.LocalDate dojoining;

    public Person() {
    }

    public java.lang.String getId() {
        return this.id;
    }

    public void setId(java.lang.String id) {
        this.id = id;
    }

    public java.lang.String getName() {
        return this.name;
    }

    public void setName(java.lang.String name) {
        this.name = name;
    }

    public java.time.LocalDate getDojoining() {
        return this.dojoining;
    }

    public void setDojoining(java.time.LocalDate dojoining) {
        this.dojoining = dojoining;
    }

    public Person(java.lang.String id, java.lang.String name,
            java.time.LocalDate dojoining) {
        this.id = id;
        this.name = name;
        this.dojoining = dojoining;
    }

}

For more information about the KIE Server REST API, see Interacting with IBM Business Automation Manager Open Editions using KIE APIs.

Prerequisites
Procedure
  1. Determine the base URL for accessing the KIE Server REST API endpoints. This requires knowing the following values (with the default local deployment values as an example):

    • Host (localhost)

    • Port (8080)

    • Root context (kie-server)

    • Base REST path (services/rest/)

    Example base URL in local deployment for the traffic violations project:

    http://localhost:8080/kie-server/services/rest/server/containers/traffic-violation_1.0.0-SNAPSHOT

  2. Determine user authentication requirements.

    When users are defined directly in the KIE Server configuration, HTTP Basic authentication is used and requires the user name and password. Successful requests require that the user have the kie-server role.

    The following example demonstrates how to add credentials to a curl request:

    curl -u username:password <request>

    If KIE Server is configured with Red Hat Single Sign-On, the request must include a bearer token:

    curl -H "Authorization: bearer $TOKEN" <request>
  3. Specify the format of the request and response. The REST API endpoints work with both JSON and XML formats and are set using request headers:

    JSON
    curl -H "accept: application/json" -H "content-type: application/json"
    XML
    curl -H "accept: application/xml" -H "content-type: application/xml"
  4. Optional: Query the container for a list of deployed decision models:

    [GET] server/containers/{containerId}/dmn

    Example curl request:

    curl -u wbadmin:wbadmin -H "accept: application/xml" -X GET "http://localhost:8080/kie-server/services/rest/server/containers/traffic-violation_1.0.0-SNAPSHOT/dmn"

    Sample XML output:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <response type="SUCCESS" msg="Ok models successfully retrieved from container 'traffic-violation_1.0.0-SNAPSHOT'">
        <dmn-model-info-list>
            <model>
                <model-namespace>https://kiegroup.org/dmn/_60b01f4d-e407-43f7-848e-258723b5fac8</model-namespace>
                <model-name>Traffic Violation</model-name>
                <model-id>_2CD7D1AA-BD84-4B43-AD21-B0342ADE655A</model-id>
                <decisions>
                    <dmn-decision-info>
                        <decision-id>_23428EE8-DC8B-4067-8E67-9D7C53EC975F</decision-id>
                        <decision-name>Fine</decision-name>
                    </dmn-decision-info>
                    <dmn-decision-info>
                        <decision-id>_B5EEE2B1-915C-44DC-BE43-C244DC066FD8</decision-id>
                        <decision-name>Should the driver be suspended?</decision-name>
                    </dmn-decision-info>
                </decisions>
                <inputs>
                    <dmn-inputdata-info>
                        <inputdata-id>_CEB959CD-3638-4A87-93BA-03CD0FB63AE3</inputdata-id>
                        <inputdata-name>Violation</inputdata-name>
                        <inputdata-typeref>
                            <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                            <local-part>tViolation</local-part>
                            <prefix></prefix>
                        </inputdata-typeref>
                    </dmn-inputdata-info>
                    <dmn-inputdata-info>
                        <inputdata-id>_B0E810E6-7596-430A-B5CF-67CE16863B6C</inputdata-id>
                        <inputdata-name>Driver</inputdata-name>
                        <inputdata-typeref>
                            <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                            <local-part>tDriver</local-part>
                            <prefix></prefix>
                        </inputdata-typeref>
                    </dmn-inputdata-info>
                </inputs>
                <itemdefinitions>
                    <dmn-itemdefinition-info>
                        <itemdefinition-id>_9C758F4A-7D72-4D0F-B63F-2F5B8405980E</itemdefinition-id>
                        <itemdefinition-name>tViolation</itemdefinition-name>
                        <itemdefinition-itemcomponent>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_0B6FF1E2-ACE9-4FB3-876B-5BB30B88009B</itemdefinition-id>
                                <itemdefinition-name>Code</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60b01f4d-e407-43f7-848e-258723b5fac8</namespace-uri>
                                    <local-part>string</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_27A5DA18-3CA7-4C06-81B7-CF7F2F050E29</itemdefinition-id>
                                <itemdefinition-name>date</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>date</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_8961969A-8A80-4F12-B568-346920C0F038</itemdefinition-id>
                                <itemdefinition-name>type</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>string</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_7450F12A-3E95-4D5E-8DCE-2CB1FAC2BDD4</itemdefinition-id>
                                <itemdefinition-name>speed limit</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60b01f4d-e407-43f7-848e-258723b5fac8</namespace-uri>
                                    <local-part>number</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_0A9A6F26-6C14-414D-A9BF-765E5850429A</itemdefinition-id>
                                <itemdefinition-name>Actual Speed</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>number</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                        </itemdefinition-itemcomponent>
                        <itemdefinition-iscollection>false</itemdefinition-iscollection>
                    </dmn-itemdefinition-info>
                    <dmn-itemdefinition-info>
                        <itemdefinition-id>_13C7EFD8-B85C-43BF-94D3-14FABE39A4A0</itemdefinition-id>
                        <itemdefinition-name>tDriver</itemdefinition-name>
                        <itemdefinition-itemcomponent>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_EC11744C-4160-4549-9610-2C757F40DFE8</itemdefinition-id>
                                <itemdefinition-name>Name</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>string</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_E95BE3DB-4A51-4658-A166-02493EAAC9D2</itemdefinition-id>
                                <itemdefinition-name>Age</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>number</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_7B3023E2-BC44-4BF3-BF7E-773C240FB9AD</itemdefinition-id>
                                <itemdefinition-name>State</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>string</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_3D4B49DD-700C-4925-99A7-3B2B873F7800</itemdefinition-id>
                                <itemdefinition-name>city</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>string</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_B37C49E8-B0D9-4B20-9DC6-D655BB1CA7B1</itemdefinition-id>
                                <itemdefinition-name>Points</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>number</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                        </itemdefinition-itemcomponent>
                        <itemdefinition-iscollection>false</itemdefinition-iscollection>
                    </dmn-itemdefinition-info>
                    <dmn-itemdefinition-info>
                        <itemdefinition-id>_A4077C7E-B57A-4DEE-9C65-7769636316F3</itemdefinition-id>
                        <itemdefinition-name>tFine</itemdefinition-name>
                        <itemdefinition-itemcomponent>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_79B152A8-DE83-4001-B88B-52DFF0D73B2D</itemdefinition-id>
                                <itemdefinition-name>Amount</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>number</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                            <dmn-itemdefinition-info>
                                <itemdefinition-id>_D7CB5F9C-9D55-48C2-83EE-D47045EC90D0</itemdefinition-id>
                                <itemdefinition-name>Points</itemdefinition-name>
                                <itemdefinition-typeref>
                                    <namespace-uri>https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8</namespace-uri>
                                    <local-part>number</local-part>
                                    <prefix></prefix>
                                </itemdefinition-typeref>
                                <itemdefinition-itemcomponent/>
                                <itemdefinition-iscollection>false</itemdefinition-iscollection>
                            </dmn-itemdefinition-info>
                        </itemdefinition-itemcomponent>
                        <itemdefinition-iscollection>false</itemdefinition-iscollection>
                    </dmn-itemdefinition-info>
                </itemdefinitions>
                <decisionservices/>
            </model>
        </dmn-model-info-list>
    </response>

    Sample JSON output:

    {
      "type" : "SUCCESS",
      "msg" : "OK models successfully retrieved from container 'Traffic-Violation_1.0.0-SNAPSHOT'",
      "result" : {
        "dmn-model-info-list" : {
          "models" : [ {
            "model-namespace" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
            "model-name" : "Traffic Violation",
            "model-id" : "_2CD7D1AA-BD84-4B43-AD21-B0342ADE655A",
            "decisions" : [ {
              "decision-id" : "_23428EE8-DC8B-4067-8E67-9D7C53EC975F",
              "decision-name" : "Fine"
            }, {
              "decision-id" : "_B5EEE2B1-915C-44DC-BE43-C244DC066FD8",
              "decision-name" : "Should the driver be suspended?"
            } ],
            "inputs" : [ {
              "inputdata-id" : "_CEB959CD-3638-4A87-93BA-03CD0FB63AE3",
              "inputdata-name" : "Violation",
              "inputdata-typeRef" : {
                "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                "local-part" : "tViolation",
                "prefix" : ""
              }
            }, {
              "inputdata-id" : "_B0E810E6-7596-430A-B5CF-67CE16863B6C",
              "inputdata-name" : "Driver",
              "inputdata-typeRef" : {
                "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                "local-part" : "tDriver",
                "prefix" : ""
              }
            } ],
            "itemDefinitions" : [ {
              "itemdefinition-id" : "_13C7EFD8-B85C-43BF-94D3-14FABE39A4A0",
              "itemdefinition-name" : "tDriver",
              "itemdefinition-typeRef" : null,
              "itemdefinition-itemComponent" : [ {
                "itemdefinition-id" : "_EC11744C-4160-4549-9610-2C757F40DFE8",
                "itemdefinition-name" : "Name",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "string",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_E95BE3DB-4A51-4658-A166-02493EAAC9D2",
                "itemdefinition-name" : "Age",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "number",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_7B3023E2-BC44-4BF3-BF7E-773C240FB9AD",
                "itemdefinition-name" : "State",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "string",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_3D4B49DD-700C-4925-99A7-3B2B873F7800",
                "itemdefinition-name" : "City",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "string",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_B37C49E8-B0D9-4B20-9DC6-D655BB1CA7B1",
                "itemdefinition-name" : "Points",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "number",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              } ],
              "itemdefinition-isCollection" : false
            }, {
              "itemdefinition-id" : "_A4077C7E-B57A-4DEE-9C65-7769636316F3",
              "itemdefinition-name" : "tFine",
              "itemdefinition-typeRef" : null,
              "itemdefinition-itemComponent" : [ {
                "itemdefinition-id" : "_79B152A8-DE83-4001-B88B-52DFF0D73B2D",
                "itemdefinition-name" : "Amount",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "number",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_D7CB5F9C-9D55-48C2-83EE-D47045EC90D0",
                "itemdefinition-name" : "Points",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "number",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              } ],
              "itemdefinition-isCollection" : false
            }, {
              "itemdefinition-id" : "_9C758F4A-7D72-4D0F-B63F-2F5B8405980E",
              "itemdefinition-name" : "tViolation",
              "itemdefinition-typeRef" : null,
              "itemdefinition-itemComponent" : [ {
                "itemdefinition-id" : "_0B6FF1E2-ACE9-4FB3-876B-5BB30B88009B",
                "itemdefinition-name" : "Code",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "string",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_27A5DA18-3CA7-4C06-81B7-CF7F2F050E29",
                "itemdefinition-name" : "Date",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "date",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_8961969A-8A80-4F12-B568-346920C0F038",
                "itemdefinition-name" : "Type",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "string",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_7450F12A-3E95-4D5E-8DCE-2CB1FAC2BDD4",
                "itemdefinition-name" : "Speed Limit",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "number",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              }, {
                "itemdefinition-id" : "_0A9A6F26-6C14-414D-A9BF-765E5850429A",
                "itemdefinition-name" : "Actual Speed",
                "itemdefinition-typeRef" : {
                  "namespace-uri" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
                  "local-part" : "number",
                  "prefix" : ""
                },
                "itemdefinition-itemComponent" : [ ],
                "itemdefinition-isCollection" : false
              } ],
              "itemdefinition-isCollection" : false
            } ],
            "decisionServices" : [ ]
          } ]
        }
      }
    }
  5. Execute the model:

    [POST] server/containers/{containerId}/dmn

    Note

    The attribute model-namespace is automatically generated and is different for every user. Ensure that the model-namespace and model-name attributes that you use match those of the deployed model.

    Example curl request:

    curl -u wbadmin:wbadmin -H "accept: application/json" -H "content-type: application/json" -X POST "http://localhost:8080/kie-server/services/rest/server/containers/traffic-violation_1.0.0-SNAPSHOT/dmn" -d "{ \"model-namespace\" : \"https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8\", \"model-name\" : \"Traffic Violation\", \"dmn-context\" : {\"Driver\" : {\"Points\" : 15}, \"Violation\" : {\"Type\" : \"speed\", \"Actual Speed\" : 135, \"Speed Limit\" : 100}}}"

    Example JSON request:

    {
      "model-namespace" : "https://kiegroup.org/dmn/_60B01F4D-E407-43F7-848E-258723B5FAC8",
      "model-name" : "Traffic Violation",
      "dmn-context" :
      {
        "Driver" :
        {
      	   "Points" : 15
        },
      	"Violation" :
        {
      		"Type" : "speed",
      		"Actual Speed" : 135,
      		"Speed Limit" : 100
      	}
      }
    }

    Example XML request (JAXB format):

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <dmn-evaluation-context>
        <dmn-context xsi:type="jaxbListWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <type>MAP</type>
            <element xsi:type="jaxbStringObjectPair" key="Violation">
                <value xsi:type="jaxbListWrapper">
                    <type>MAP</type>
                    <element xsi:type="jaxbStringObjectPair" key="Type">
                        <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">speed</value>
                    </element>
                    <element xsi:type="jaxbStringObjectPair" key="Speed Limit">
                        <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">100</value>
                    </element>
                    <element xsi:type="jaxbStringObjectPair" key="Actual Speed">
                        <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">135</value>
                    </element>
                </value>
            </element>
            <element xsi:type="jaxbStringObjectPair" key="Driver">
                <value xsi:type="jaxbListWrapper">
                    <type>MAP</type>
                    <element xsi:type="jaxbStringObjectPair" key="Points">
                        <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">15</value>
                    </element>
                </value>
            </element>
        </dmn-context>
    </dmn-evaluation-context>
    Note

    Regardless of the request format, the request requires the following elements:

    • Model namespace

    • Model name

    • Context object containing input values

    Example JSON response:

    {
      "type": "SUCCESS",
      "msg": "OK from container 'Traffic-Violation_1.0.0-SNAPSHOT'",
      "result": {
          "dmn-evaluation-result": {
              "messages": [],
              "model-namespace": "https://kiegroup.org/dmn/_7D8116DE-ADF5-4560-A116-FE1A2EAFFF48",
              "model-name": "Traffic Violation",
              "decision-name": [],
              "dmn-context": {
                  "Violation": {
                    "Type": "speed",
                    "Speed Limit": 100,
                    "Actual Speed": 135
                  },
                  "Should Driver be Suspended?": "Yes",
                    "Driver": {
                      "Points": 15
                    },
                    "Fine": {
                      "Points": 7,
                      "Amount": 1000
                    }
                },
          "decision-results": {
              "_E1AF5AC2-E259-455C-96E4-596E30D3BC86": {
                  "messages": [],
                  "decision-id": "_E1AF5AC2-E259-455C-96E4-596E30D3BC86",
                  "decision-name": "Should the Driver be Suspended?",
                  "result": "Yes",
                  "status": "SUCCEEDED"
                },
              "_D7F02CE0-AF50-4505-AB80-C7D6DE257920": {
                  "messages": [],
                  "decision-id": "_D7F02CE0-AF50-4505-AB80-C7D6DE257920",
                  "decision-name": "Fine",
                  "result": {
                    "Points": 7,
                    "Amount": 1000
                  },
              "status": "SUCCEEDED"
            }
          }
        }
      }
    }

    Example XML (JAXB format) response:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <response type="SUCCESS" msg="OK from container 'Traffic_1.0.0-SNAPSHOT'">
        <dmn-evaluation-result>
            <model-namespace>https://kiegroup.org/dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF</model-namespace>
            <model-name>Traffic Violation</model-name>
            <dmn-context xsi:type="jaxbListWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <type>MAP</type>
                <element xsi:type="jaxbStringObjectPair" key="Violation">
                    <value xsi:type="jaxbListWrapper">
                        <type>MAP</type>
                        <element xsi:type="jaxbStringObjectPair" key="Type">
                            <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">speed</value>
                        </element>
                        <element xsi:type="jaxbStringObjectPair" key="Speed Limit">
                            <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">100</value>
                        </element>
                        <element xsi:type="jaxbStringObjectPair" key="Actual Speed">
                            <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">135</value>
                        </element>
                    </value>
                </element>
                <element xsi:type="jaxbStringObjectPair" key="Driver">
                    <value xsi:type="jaxbListWrapper">
                        <type>MAP</type>
                        <element xsi:type="jaxbStringObjectPair" key="Points">
                            <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">15</value>
                        </element>
                    </value>
                </element>
                <element xsi:type="jaxbStringObjectPair" key="Fine">
                    <value xsi:type="jaxbListWrapper">
                        <type>MAP</type>
                        <element xsi:type="jaxbStringObjectPair" key="Points">
                            <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">7</value>
                        </element>
                        <element xsi:type="jaxbStringObjectPair" key="Amount">
                            <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">1000</value>
                        </element>
                    </value>
                </element>
                <element xsi:type="jaxbStringObjectPair" key="Should the driver be suspended?">
                    <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">Yes</value>
                </element>
            </dmn-context>
            <messages/>
            <decisionResults>
                <entry>
                    <key>_4055D956-1C47-479C-B3F4-BAEB61F1C929</key>
                    <value>
                        <decision-id>_4055D956-1C47-479C-B3F4-BAEB61F1C929</decision-id>
                        <decision-name>Fine</decision-name>
                        <result xsi:type="jaxbListWrapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                            <type>MAP</type>
                            <element xsi:type="jaxbStringObjectPair" key="Points">
                                <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">7</value>
                            </element>
                            <element xsi:type="jaxbStringObjectPair" key="Amount">
                                <value xsi:type="xs:decimal" xmlns:xs="http://www.w3.org/2001/XMLSchema">1000</value>
                            </element>
                        </result>
                        <messages/>
                        <status>SUCCEEDED</status>
                    </value>
                </entry>
                <entry>
                    <key>_8A408366-D8E9-4626-ABF3-5F69AA01F880</key>
                    <value>
                        <decision-id>_8A408366-D8E9-4626-ABF3-5F69AA01F880</decision-id>
                        <decision-name>Should the driver be suspended?</decision-name>
                        <result xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Yes</result>
                        <messages/>
                        <status>SUCCEEDED</status>
                    </value>
                </entry>
            </decisionResults>
        </dmn-evaluation-result>
    </response>

Additional resources