An integration of BPMN workflow using Kogito, and Quarkus Framework. This shows BPMN capability to validate and process REST API with a specific JSON format and gives response based on workflow.
Also having the capability to connect BPMN workflow with external existing database thru Quarkus database functionality.
$ mvn clean package -s settings.xml
$ java -jar .\target\quarkus-app\quarkus-run.jar
$ curl -X POST http://localhost:8080/customer_risk \
-H 'content-type: application/json' \
-H 'accept: application/json' \
-d '{"name" : "Regular User", "salary":500, "age": 15}'
{"id":"c4fcc5eb-9aab-4c99-8620-5ff1c27be79e","name":"Regular User", "risk":"High","salary":500,"age":15,"status":"Loan is Rejected because Customer is High Risk"}
Open http://localhost:8080/q
from web browser to see all the BPMN endpoints.
@Test
public void testHighRiskCustomer() {
given()
.body("{ \"name\":\"Regular User\", \"age\": 15, \"salary\": 300 }")
.contentType(ContentType.JSON)
.when()
.post("/customer_risk")
.then()
.statusCode(201)
.body("'status'", equalTo("Loan is Rejected because Customer is High Risk"));
}
create table t_blacklist
(
id int auto_increment,
name varchar(16) not null,
constraint t_blacklist_pk
primary key (id)
);
com.edw.service.BlacklistService blacklistService = new com.edw.service.BlacklistService();
if(blacklistService.isBlacklist(name)) {
kcontext.setVariable("blacklist", true);
kcontext.setVariable("status", "Loan is Rejected because Customer is Blacklisted");
}
else {
kcontext.setVariable("blacklist", false);
}