Skip to content

Latest commit

 

History

History
54 lines (41 loc) · 4.92 KB

README.md

File metadata and controls

54 lines (41 loc) · 4.92 KB

htbhf-claimant-service

Build Status Known Vulnerabilities Coverage Status License

View latest test reports

This is a Spring Boot project with dual responsibilities:

  • To expose a REST service responsible for evaluating eligibility and storing the details of claimants.
  • A Payments Engine - a suite of scheduled services and message processors that maintain the state of all claims on a 28-day payment cycle (each claim has its own cycle), ensuring payments are made for the correct amount and that claimants are notified of both payments and changes in circumstance.

As both tasks involve updating the database, they are combined into a single service. This makes the claimant service rather large, but the alternative is to have two services updating the same database.

Documentation of the API is available online when the service is running (e.g. http://localhost:8080/v2/api-docs), and is also available as swagger.yml - paste the contents into https://editor.swagger.io/ for a friendly UI.

Documentation of the scheduled services and message processors that make up the Payments Engine can be found in api/payments-engine.md.

Deployment to the PaaS

The jar artefact of the API project is deployed to the PaaS, using the manifest.yml file in the parent project. Note that this requires some services be present in the space to which it is deployed - see manifest.yml for the full list. These include:

Running locally

In order to run the application locally, a valid notify api key will need to be set in an environment variable called NOTIFY_API_KEY. e.g. export NOTIFY_API_KEY=MY-API-KEY and an environment variable called GOOGLE-ANALYTICS_TRACKING-ID (exact value doesn't matter), e.g. export GOOGLE-ANALYTICS_TRACKING-ID=test-key. Note, you must set the environment variable in the same context you are running the application in.

If you are running the application in intellij, environment variables can be set via run/debug configurations.

You will also need a local Postgres server running on the default port (5432) - see db/README.md for instructions on setting up the database.

Database problems when testing locally

If you see this error when running tests locally:

Caused by: java.io.IOException: Cannot run program "...": error=2, No such file or directory

This might be caused by a mis-match between the version of Postgres you have installed and the version used by the embedded database (see: zonkyio/embedded-database-spring-test#4). It is possible to use a docker image for the embedded database instead by setting an environment variable EMBEDDED_DATABASE_PROVIDER=docker (see api/src/test/resources/application.yml and https://github.com/zonkyio/embedded-database-spring-test for details).

Create claims for local testing

There is a test utility for creating claims in a locally running persisted database. See the test-claimant-creator README for details on how to run it.

There is also a utility for artificially ageing claims by 28 days (the length of a single payment cycle) - so that you can manually run claims through one payment cycle at a time. Run the main method of the DatabaseFastForwarder.