Skip to content

MicroProfile LRA Testability Evaluation

This project is part of the evaluation of a Saga pattern implementation using MicroProfile LRA. The original Saga Pattern Realization with MicroProfile LRA has been extended by automated tests that relate to the BookTripSaga.

Start the Application

  1. Run ./gradlew clean build -x test

  2. Execute docker-compose up

  3. Requesting trip bookings is now possible. Either use curl commands, the provided TravelApplication.json insomnia file, which includes different trip booking requests, or access the Swagger UI of the different services:

    Service URL to Swagger UI
    TravelService http://localhost:8090/openapi/ui/
    LRA Coordinator (included in TravelService)
    HotelService http://localhost:8081/openapi/ui/
    FlightService http://localhost:8082/openapi/ui/

An example for such a request:

TravelRequest
{
    "duration":
    {
        "start":"2021-12-01",
        "end":"2021-12-12"
    },
    "start":
    {
        "country":"Scotland",
        "city":"Stirling"
    },
    "destination":
    {
        "country":"Sweden",
        "city":"Stockholm"
    },
    "travellerName": "Max Mustermann",
    "boardType":"breakfast",
    "customerId":"1"
}

To simulate a Saga that fails because no hotel or no flight is available, use one of the following Strings as destination country in the trip booking request:

"Provoke hotel failure"

"Provoke flight failure"

The services also provide a general health endpoint that shows information about the system whether it is up and running. These endpoints can be accessed via:

Service
URL to health endpoint
TravelService http://localhost:8090/health
HotelService http://localhost:8081/health
FlightService http://localhost:8082/health

If you are on Windows or Mac, you sometimes have to replace localhost with the default IP of your docker machine (use docker-machine ip default to get this default IP).

Stop the Application

To stop the application and remove the created containers, execute the following command:

docker-compose down --remove-orphans


Testability

The TravelService as well as the HotelService have a testing directory that includes several tests concerning Saga–related code.

1. Unit Test Saga Definition

Unit tests regarding the Saga orchestrator and the Saga definition can be found within the TravelService. However, Camunda does not provide a testing framework and it is only possible to test the Saga definition for a successful Saga execution due to the annotation–based compensation mechanism. The tests are realized using JUnit and Mockito.

2. Unit Test Saga Participant

Examples for unit testing the Saga participant can be found within the HotelService. Again, unit tests for a Saga participant are realized using JUnit and Mockito.


MicroProfile_Implementations/MicroProfile_Testability-Evaluation


Last update: 2022-02-15
Back to top