tree: 4dac2cf3311c33cfdc20858f02e7c78283a372a3 [path history] [tgz]
  1. src/
  2. pom.xml
  3. README.md
kogito-springboot-examples/rules-legacy-scesim-springboot-example/README.md

RuleUnit + Spring Boot + Test Scenario example

Description

A simple rule service to validate Hello fact and testing it using Scenario Simulation.

An injectable KieRuntimeBuilder is generated, so you can create Drools v7 KieBase and KieSession out of it.

Installing and Running

Prerequisites

You will need:

  • Java 11+ installed
  • Environment variable JAVA_HOME set accordingly
  • Maven 3.8.6+ installed

Compile and Run

mvn clean compile spring-boot:run

Package and Run

mvn clean package
java -jar target/rules-legacy-scesim-springboot-example.jar

OpenAPI (Swagger) documentation

Specification at swagger.io

The Swagger page shows all the available endpoints, and it could be used to test them. You can take a look at the OpenAPI definition - automatically generated and included in this service - to determine all available operations exposed by this service. For easy readability you can visualize the OpenAPI definition file using a UI tool like for example available Swagger Editor.

In addition, various clients to interact with this service can be easily generated using this OpenAPI definition.

Example Usage

Once the service is up and running, you can use the following examples to interact with the service.

POST /find-approved

Returns approved Hello from the given fact:

curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"approved":false,  "greeting":"foo"}' http://localhost:8080/find-approved

or on windows

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"approved\":false,  \"greeting\":\"foo\"}" http://localhost:8080/find-approved

As response the modified Hello is returned.

Example response:

{"greeting":"foo","approved":true}

Returns denied Hello from the given fact:

curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"approved":false,  "greeting":"bar"}' http://localhost:8080/find-approved

or on windows

curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"approved\":false,  \"greeting\":\"bar\"}" http://localhost:8080/find-approved

As response the modified Hello is returned.

Example response:

{"greeting":"bar","approved":false}

Test Scenario usage

Test Scenario + rules project created inside Business central should work, with the following requirements:

  1. use the pom as defined in the current project
  2. set the kogito.sources.keep variable to true

Caveat

Requires org.drools:drools-xml-support dependency For the moment being, “globals” are unsupported