ministryofjustice / calculate-release-dates-api

Calculating release dates API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Calculate Release Dates

repo standards badge CircleCI Docker Repository on Quay API docs

This service provides a calculation engine by which release dates of sentences are calculated. It also allows for an existing calculation result to be retrieved.

Dependencies

This service requires a postgresql database.

Building the project

Tools required:

  • JDK v18+
  • Kotlin
  • docker
  • docker-compose

Install gradle

$ ./gradlew $ ./gradlew clean build

Running the service

Start up the docker dependencies using the docker-compose file in the calculate-release-dates-api service There is a script to help, which sets local profiles, port and DB connection properties to the values required.

Instructions

If this is a HMPPS project then the project will be created as part of bootstrapping - see https://github.com/ministryofjustice/hmpps-project-bootstrap.

$ ./run-full.sh +Or, to run with default properties set in the docker-compose file

$ docker-compose pull && docker-compose up

Or, to use default port and properties

$ SPRING_PROFILES_ACTIVE=dev ./gradlew bootRun

Running the unit tests

Unit tests mock all external dependencies and can be run with no dependent containers.

$ ./gradlew test

Running the integration tests

Integration tests use Wiremock to stub any API calls required, and use a local H2 database that is seeded with data specific to each test suite.

$ ./gradlew integrationTest

Linting

$ ./gradlew ktlintcheck

OWASP Dependency Checking scanning

$ ./gradlew dependencyCheckAnalyze

Running the service locally using run-local.sh

N.B. This currently still requires Adjustments and Manage Offences to be configured to look at dev environment

This will run the service locally. It starts the database runs manage-offences-api via a bash script. It connects to the dev versions of prison-api and hmpps-auth Run the following commands from the root directory of the project:

  1. docker-compose -f docker-compose-test.yml pull
  2. docker-compose -f docker-compose-test.yml up --no-start
  3. docker-compose -f docker-compose-test.yml start hmpps-auth calculate-release-dates-db prison-api
  4. ./run-local.sh

About

Calculating release dates API

License:MIT License


Languages

Language:Kotlin 99.4%Language:Shell 0.5%Language:Dockerfile 0.1%