From 527e6099cc893bee97d27925d48b1e9646235057 Mon Sep 17 00:00:00 2001 From: Gabriele-Cardosi Date: Wed, 6 Mar 2024 11:39:24 +0100 Subject: [PATCH 1/2] [incubator-kie-issues#847] Implemented kogito-examples with models from external jar --- .../README.md | 141 ++++ .../dmn-consumer-example/pom.xml | 147 ++++ .../src/main/resources/application.properties | 22 + .../example/NativeTrafficViolationIT.java | 27 + .../example/TrafficViolationTest.java | 52 ++ .../KogitoScenarioJunitActivatorTest.java | 29 + .../resources/TrafficViolationTest.scesim | 766 ++++++++++++++++++ .../src/test/resources/application.properties | 21 + .../dmn-resource-jar/pom.xml | 32 + .../src/main/resources/Traffic Violation.dmn | 230 ++++++ .../dmn-resource-jar-quarkus-example/pom.xml | 48 ++ kogito-quarkus-examples/pom.xml | 1 + 12 files changed, 1516 insertions(+) create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/pom.xml create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/main/resources/application.properties create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/TrafficViolationTest.scesim create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/application.properties create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/pom.xml create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/src/main/resources/Traffic Violation.dmn create mode 100644 kogito-quarkus-examples/dmn-resource-jar-quarkus-example/pom.xml diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md new file mode 100644 index 0000000000..f12e74acd6 --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md @@ -0,0 +1,141 @@ +# DMN + Quarkus example with model included in different jar + +## Description + +A simple DMN service to evaluate a model (traffic violation) that is imported from a different jar. + +Demonstrates DMN on Kogito capabilities, including REST interface code generation. + +## Installing and Running + +### Prerequisites + +You will need: + - Java 11+ installed + - Environment variable JAVA_HOME set accordingly + - Maven 3.8.6+ installed + +When using native image compilation, you will also need: + - [GraalVM 19.3.1](https://github.com/oracle/graal/releases/tag/vm-19.3.1) installed + - Environment variable GRAALVM_HOME set accordingly + - Note that GraalVM native image compilation typically requires other packages (glibc-devel, zlib-devel and gcc) to be installed too. You also need 'native-image' installed in GraalVM (using 'gu install native-image'). Please refer to [GraalVM installation documentation](https://www.graalvm.org/docs/reference-manual/aot-compilation/#prerequisites) for more details. + +### Compile and Run in Local Dev Mode + +``` +cd ./dmn-consumer-example +mvn clean compile quarkus:dev +``` + +(This requires a previous installation of `dmn-resource-jar`) + +### Package and Run in JVM mode + +``` +mvn clean package +java -jar ./dmn-consumer-example/target/quarkus-app/quarkus-run.jar +``` + +or on Windows + +``` +mvn clean package +java -jar .\dmn-consumer-example\target\quarkus-app\quarkus-run.jar +``` + +### Package and Run using Local Native Image +Note that this requires GRAALVM_HOME to point to a valid GraalVM installation + +``` +mvn clean package -Pnative +``` + +To run the generated native executable, generated in `./dmn-consumer-example/target/`, execute + +``` +./dmn-consumer-example/target/dmn-consumer-example-runner +``` + +Note: This does not yet work on Windows, GraalVM and Quarkus should be rolling out support for Windows soon. + +## OpenAPI (Swagger) documentation +[Specification at swagger.io](https://swagger.io/docs/specification/about/) + +You can take a look at the [OpenAPI definition](http://localhost:8080/openapi?format=json) - 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 UI](https://editor.swagger.io). + +In addition, various clients to interact with this service can be easily generated using this OpenAPI definition. + +When running in either Quarkus Development or Native mode, we also leverage the [Quarkus OpenAPI extension](https://quarkus.io/guides/openapi-swaggerui#use-swagger-ui-for-development) that exposes [Swagger UI](http://localhost:8080/swagger-ui/) that you can use to look at available REST endpoints and send test requests. + +## Test DMN Model using Maven + +Validate the functionality of DMN models before deploying them into a production environment by defining test scenarios in Test Scenario Editor. + +To define test scenarios you need to create a .scesim file inside your project and link it to the DMN model you want to be tested. Run all Test Scenarios, executing: + +```sh +cd ./dmn-consumer-example +mvn clean test +``` +See results in surefire test report `target/surefire-reports` + +(This requires a previous installation of `dmn-resource-jar`) + +## Example Usage + +Once the service is up and running, you can use the following example to interact with the service. + +### POST /Traffic Violation + +Returns penalty information from the given inputs -- driver and violation: + +Given inputs: + +```json +{ + "Driver":{"Points":2}, + "Violation":{ + "Type":"speed", + "Actual Speed":120, + "Speed Limit":100 + } +} +``` + +Curl command (using the JSON object above): + +```sh +curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"Driver":{"Points":2},"Violation":{"Type":"speed","Actual Speed":120,"Speed Limit":100}}' http://localhost:8080/Traffic%20Violation +``` +or on Windows: + +```sh +curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"Driver\":{\"Points\":2},\"Violation\":{\"Type\":\"speed\",\"Actual Speed\":120,\"Speed Limit\":100}}" http://localhost:8080/Traffic%20Violation +``` + +As response, penalty information is returned. + +Example response: + +```json +{ + "Violation":{ + "Type":"speed", + "Speed Limit":100, + "Actual Speed":120 + }, + "Driver":{ + "Points":2 + }, + "Fine":{ + "Points":3, + "Amount":500 + }, + "Should the driver be suspended?":"No" +} +``` + +The difference from the [dmn-quarkus-example](../dmn-quarkus-example) is that, in the current one, the `Traffic Model.dml` is defined in a different jar. + + + diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/pom.xml b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/pom.xml new file mode 100644 index 0000000000..082b23fbd8 --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/pom.xml @@ -0,0 +1,147 @@ + + + 4.0.0 + + org.kie.kogito.examples + dmn-resource-jar-quarkus-example + 999-SNAPSHOT + + + dmn-consumer-example + + + 3.2.10.Final + quarkus-bom + io.quarkus + 3.2.10.Final + org.kie.kogito + kogito-bom + 999-SNAPSHOT + 999-SNAPSHOT + 3.6.1 + + + + + org.kie.kogito.examples + dmn-resource-jar + ${project.version} + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + ${kogito.bom.group-id} + ${kogito.bom.artifact-id} + ${kogito.bom.version} + pom + import + + + + + + org.kie.kogito.examples + dmn-resource-jar + + + org.drools + drools-quarkus-decisions + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-resteasy-jackson + + + io.quarkus + quarkus-smallrye-openapi + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.kie.kogito + kogito-scenario-simulation + test + + + io.quarkus + quarkus-smallrye-health + + + + ${project.artifactId} + + + src/main/resources + + + + ${project.build.directory}/generated-resources + + + + + ${quarkus.platform.group-id} + quarkus-maven-plugin + ${quarkus-plugin.version} + + + + build + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${dependency-plugin.version} + + + unpack + generate-resources + + unpack + + + + + org.kie.kogito.examples + dmn-resource-jar + ${project.version} + jar + true + ${project.build.directory}/generated-resources + **/*.dmn + + + + + + + + + diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/main/resources/application.properties b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/main/resources/application.properties new file mode 100644 index 0000000000..727b6c82f1 --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/main/resources/application.properties @@ -0,0 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Packaging + +quarkus.swagger-ui.always-include=true diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java new file mode 100644 index 0000000000..1d1a4103cc --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.dmn.consumer.example; + +import io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +public class NativeTrafficViolationIT extends TrafficViolationTest { + + // Execute the same tests but in native mode. +} \ No newline at end of file diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java new file mode 100644 index 0000000000..612166f5ea --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.dmn.consumer.example; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.is; + +@QuarkusTest +public class TrafficViolationTest { + + @Test + public void testEvaluateTrafficViolation() { + given() + .body("{\n" + + " \"Driver\": {\n" + + " \"Points\": 2\n" + + " },\n" + + " \"Violation\": {\n" + + " \"Type\": \"speed\",\n" + + " \"Actual Speed\": 120,\n" + + " \"Speed Limit\": 100\n" + + " }\n" + + "}") + .contentType(ContentType.JSON) + .when() + .post("/Traffic Violation") + .then() + .statusCode(200) + .body("'Should the driver be suspended?'", is("No")); + } +} diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java new file mode 100644 index 0000000000..4b19a12015 --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package testscenario; + +/** + * KogitoJunitActivator is a custom JUnit runner that enables the execution of Test Scenario files (*.scesim). + * This activator class, when executed, will load all scesim files available in the project and run them. + * Each row of the scenario will generate a test JUnit result. + */ +@org.junit.runner.RunWith(org.kogito.scenariosimulation.runner.KogitoJunitActivator.class) +public class KogitoScenarioJunitActivatorTest { + +} \ No newline at end of file diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/TrafficViolationTest.scesim b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/TrafficViolationTest.scesim new file mode 100644 index 0000000000..0a8d8c3f68 --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/TrafficViolationTest.scesim @@ -0,0 +1,766 @@ + + + + + + + + + Index + OTHER + + + # + java.lang.Integer + + java.lang.Integer + # + 70 + NOT_EXPRESSION + + + + + Description + OTHER + + + Scenario description + java.lang.String + + java.lang.String + Scenario description + 300 + NOT_EXPRESSION + + + + + Driver + + + Points + + + + 1|5 + GIVEN + + + Driver + Driver + + number + Driver + Points + + 114 + NOT_EXPRESSION + + + + + Violation + + + Type + + + + 1|8 + GIVEN + + + Violation + Violation + + Type + Violation + Type + + 114 + NOT_EXPRESSION + + + + + Violation + + + Speed Limit + + + + 1|9 + GIVEN + + + Violation + Violation + + number + Violation + Speed Limit + + 114 + NOT_EXPRESSION + + + + + Violation + + + Actual Speed + + + + 1|10 + GIVEN + + + Violation + Violation + + number + Violation + Actual Speed + + 114 + NOT_EXPRESSION + + + + + Fine + + + Amount + + + + 1|11 + EXPECT + + + Fine + Fine + + number + Fine + Amount + + 114 + NOT_EXPRESSION + + + + + Fine + + + Points + + + + 1|12 + EXPECT + + + Fine + Fine + + number + Fine + Points + + 114 + NOT_EXPRESSION + + + + + Should the driver be suspended? + + + + 1|13 + EXPECT + + + Should the driver be suspended? + Should the driver be suspended? + + string + Should the driver be suspended? + value + + 114 + NOT_EXPRESSION + + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + Above speed limit: 10km/h and 30 km/h + + + + Driver + Driver + + + 1|5 + GIVEN + + 10 + + + + Violation + Violation + + + 1|8 + GIVEN + + "speed" + + + + Violation + Violation + + + 1|9 + GIVEN + + 100 + + + + Violation + Violation + + + 1|10 + GIVEN + + 120 + + + + Fine + Fine + + + 1|11 + EXPECT + + 500 + + + + Fine + Fine + + + 1|12 + EXPECT + + 3 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "No" + + + + # + java.lang.Integer + + + Index + OTHER + + 1 + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + Above speed limit: more than 30 km/h + + + + Driver + Driver + + + 1|5 + GIVEN + + 10 + + + + Violation + Violation + + + 1|8 + GIVEN + + "speed" + + + + Violation + Violation + + + 1|9 + GIVEN + + 100 + + + + Violation + Violation + + + 1|10 + GIVEN + + 150 + + + + Fine + Fine + + + 1|11 + EXPECT + + 1000 + + + + Fine + Fine + + + 1|12 + EXPECT + + 7 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "No" + + + + # + java.lang.Integer + + + Index + OTHER + + 2 + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + Parking violation + + + + Driver + Driver + + + 1|5 + GIVEN + + 10 + + + + Violation + Violation + + + 1|8 + GIVEN + + "parking" + + + + Violation + Violation + + + 1|9 + GIVEN + + + + + Violation + Violation + + + 1|10 + GIVEN + + + + + Fine + Fine + + + 1|11 + EXPECT + + 100 + + + + Fine + Fine + + + 1|12 + EXPECT + + 1 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "No" + + + + # + java.lang.Integer + + + Index + OTHER + + 3 + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + DUI violation + + + + Driver + Driver + + + 1|5 + GIVEN + + 10 + + + + Violation + Violation + + + 1|8 + GIVEN + + "driving under the influence" + + + + Violation + Violation + + + 1|9 + GIVEN + + + + + Violation + Violation + + + 1|10 + GIVEN + + + + + Fine + Fine + + + 1|11 + EXPECT + + 1000 + + + + Fine + Fine + + + 1|12 + EXPECT + + 5 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "No" + + + + # + java.lang.Integer + + + Index + OTHER + + 4 + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + Driver suspended + + + + Driver + Driver + + + 1|5 + GIVEN + + 15 + + + + Violation + Violation + + + 1|8 + GIVEN + + "speed" + + + + Violation + Violation + + + 1|9 + GIVEN + + 100 + + + + Violation + Violation + + + 1|10 + GIVEN + + 140 + + + + Fine + Fine + + + 1|11 + EXPECT + + 1000 + + + + Fine + Fine + + + 1|12 + EXPECT + + 7 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "Yes" + + + + # + java.lang.Integer + + + Index + OTHER + + 5 + + + + + + + + + + + + 1|1 + GIVEN + + + Empty + java.lang.Void + + java.lang.Void + INSTANCE 1 + PROPERTY 1 + 114 + NOT_EXPRESSION + + + + + + + + + Empty + java.lang.Void + + + 1|1 + GIVEN + + + + + + + + target/generated-resources/Traffic Violation.dmn + DMN + https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF + Traffic Violation + false + false + + + + + \ No newline at end of file diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/application.properties b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/application.properties new file mode 100644 index 0000000000..a047ea13ba --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/application.properties @@ -0,0 +1,21 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Quarkus +quarkus.http.test-port=0 \ No newline at end of file diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/pom.xml b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/pom.xml new file mode 100644 index 0000000000..5b18fbe235 --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + org.kie.kogito.examples + dmn-resource-jar-quarkus-example + 999-SNAPSHOT + + + dmn-resource-jar + + + 17 + 17 + UTF-8 + + + + + maven-compiler-plugin + + + -parameters + + + + + + + \ No newline at end of file diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/src/main/resources/Traffic Violation.dmn b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/src/main/resources/Traffic Violation.dmn new file mode 100644 index 0000000000..109d4689e1 --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/src/main/resources/Traffic Violation.dmn @@ -0,0 +1,230 @@ + + + + + + string + + + number + + + string + + + string + + + number + + + + + string + + + date + + + string + + "speed", "parking", "driving under the influence" + + + + number + + + number + + + + + number + + + number + + + + + + + + + + + + + + Violation.Type + + + + + Violation.Actual Speed - Violation.Speed Limit + + + + + + + "speed" + + + [10..30) + + + 500 + + + 3 + + + + + "speed" + + + >= 30 + + + 1000 + + + 7 + + + + + "parking" + + + - + + + 100 + + + 1 + + + + + "driving under the influence" + + + - + + + 1000 + + + 5 + + + + + + + + + Should the driver be suspended due to points on his license? + "Yes", "No" + + + + + + + + + + + + Driver.Points + Fine.Points + + + + + if Total Points >= 20 then "Yes" else "No" + + + + + + + + + + 50.0 + 254.0 + 329.0 + 119.0 + 100.0 + 186.0 + + + 50.0 + 100.0 + 398.0 + + + 398.0 + + + 398.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/pom.xml b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/pom.xml new file mode 100644 index 0000000000..c55419f979 --- /dev/null +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + org.kie.kogito.examples + kogito-quarkus-examples + 999-SNAPSHOT + + dmn-resource-jar-quarkus-example + Kogito Example :: DMN :: Resource jar providing model + + + 3.2.10.Final + quarkus-bom + io.quarkus + 3.2.10.Final + org.kie.kogito + kogito-bom + 999-SNAPSHOT + 999-SNAPSHOT + + pom + + dmn-resource-jar + dmn-consumer-example + + diff --git a/kogito-quarkus-examples/pom.xml b/kogito-quarkus-examples/pom.xml index 67e4b8a8dc..bf549d34a5 100644 --- a/kogito-quarkus-examples/pom.xml +++ b/kogito-quarkus-examples/pom.xml @@ -58,6 +58,7 @@ dmn-listener-dtable dmn-pmml-quarkus-example dmn-quarkus-example + dmn-resource-jar-quarkus-example dmn-tracing-quarkus flexible-process-quarkus kogito-travel-agency From bea3faed31643dc00cd82e8468f7a3759a9daa91 Mon Sep 17 00:00:00 2001 From: Gabriele-Cardosi Date: Thu, 7 Mar 2024 08:52:56 +0100 Subject: [PATCH 2/2] [incubator-kie-issues#847] Fix as per PR suggestion --- .../dmn-resource-jar-quarkus-example/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md index f12e74acd6..8a49a17980 100644 --- a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md @@ -11,9 +11,9 @@ Demonstrates DMN on Kogito capabilities, including REST interface code generatio ### Prerequisites You will need: - - Java 11+ installed + - Java 17+ installed - Environment variable JAVA_HOME set accordingly - - Maven 3.8.6+ installed + - Maven 3.9.6+ installed When using native image compilation, you will also need: - [GraalVM 19.3.1](https://github.com/oracle/graal/releases/tag/vm-19.3.1) installed