A simple rule service to validate LoanApplication
fact.
The intent of this project is demonstrating the new programming model introduced in Kogito that is based on the concept of rule units.
A rule unit encapsulates a set of rules, defined in a DRL file, and the facts against which those rules will be matched, implemented with a simple POJO.
A rule unit comes with a second abstraction called data source, that defines a typed entry-point to insert the facts.
You will need:
- Java 11+ installed
- Environment variable JAVA_HOME set accordingly
- Maven 3.6.2+ installed
mvn clean package
java -jar target/quarkus-app/quarkus-run.jar
or on windows
mvn clean package
java -jar target\quarkus-app\quarkus-run.jar
Returns approved loan applications from the given facts:
curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"maxAmount":5000,"loanApplications":[{"id":"ABC10001","amount":2000,"deposit":100,"applicant":{"age":45,"name":"John"}}, {"id":"ABC10002","amount":5000,"deposit":100,"applicant":{"age":25,"name":"Paul"}}, {"id":"ABC10015","amount":1000,"deposit":100,"applicant":{"age":12,"name":"George"}}]}' http://localhost:8080/find-approved
or on windows
curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"maxAmount\":5000,\"loanApplications\":[{\"id\":\"ABC10001\",\"amount\":2000,\"deposit\":100,\"applicant\":{\"age\":45,\"name\":\"John\"}}, {\"id\":\"ABC10002\",\"amount\":5000,\"deposit\":100,\"applicant\":{\"age\":25,\"name\":\"Paul\"}}, {\"id\":\"ABC10015\",\"amount\":1000,\"deposit\":100,\"applicant\":{\"age\":12,\"name\":\"George\"}}]}" http://localhost:8080/find-approved
As response an array of loan applications is returned.
Example response:
[
{
"id":"ABC10001",
"applicant":{
"name":"John",
"age":45
},
"amount":2000,
"deposit":100,
"approved":true
}
]