edwin / quarkus-bpmn

Quarkus and Kogito BPMN Workflow Sample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quarkus and BPMN Sample for Automatic Loan Approval

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.

Risk Table

Image

Business Workflow

Image

Build

$ mvn clean package -s settings.xml

Run

$ java -jar .\target\quarkus-app\quarkus-run.jar

Test

$ 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"} 
    

Endpoints

Open http://localhost:8080/q from web browser to see all the BPMN endpoints.

Unit Tests

    @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"));
    }

Database

    create table t_blacklist
    (
        id int auto_increment,
        name varchar(16) not null,
        constraint t_blacklist_pk
            primary key (id)
    );

Calling Quarkus Script from Inside BPMN

    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);
    }

About

Quarkus and Kogito BPMN Workflow Sample


Languages

Language:Java 100.0%