This is a Spring Boot API to enable:
- 406Mhz beacon owners to register their details with the Maritime & Coastguard Agency
- Search and rescue Mission Control Centres to retrieve information about beacons during distress signal activations
Follow the instructions in the root README to get started.
- In IntelliJ, ensure your run configuration Environment variables include
spring_profiles_active=dev. This will enable the IDE to use your new application-dev.yml configuration settings.
You will need these running before you try to run the API or continue down from here if you want to work on the API in isolation.
# From the repository root
docker compose up --build postgres opensearchThe service can be run either locally in your IDE of choice or from the command line...
# From the service directory
./gradlew bootRun --args='--spring.profiles.active=dev'Note that it will stop reporting progress at 80 something percent.
- The test project has its own application.yml file containing several sensitive MICROSOFT_GRAPH environment variables
- These do not have values in the actual file as they are secrets. To ensure these variables have values at runtime, make a .sh file on your machine and fill it with the contents of 'Set Microsoft Graph sensitive values as local Bash env vars' in 1Password.
- Make sure your environment includes the variables in the
.envrc.samplefile in the root of this repository. - The integration tests need these settings in order to create, update and delete a user in the test Azure AD B2C environment.
Integration tests use the naming convention <name>IntegrationTest. Unit tests use the naming convention
<name>UnitTest.
Both unit and integration tests go in src/test/java/uk/gov/mca/beacons/api.
Note that the integration tests require Docker to be running on your local development environment.
./gradlew clean testruns unit tests./gradlew clean integrationTestruns integration tests./gradlew clean checkruns both unit and integration tests
You can run the tests in Intellij for better click through, debugging etc. For the integration tests to work, make sure
the run command in the run configuration starts with :integretionTest, not :test.
We use Prettier-Java to format our code and use Husky to run the formatting as a pre-commit hook.
Wildcard imports, import java.util.*; should not be used within the application.
See GDS Programming Languages
guidance on this and how to configure IntelliJ to ensure it does not use wildcard imports.
As well as during the pre-commit hook, the formatter can be run manually with:
$ npm run formatWe use OpenSearch to support advanced querying of beacon registrations. Beacons are streamed into OpenSearch automatically on registration, though if necessary OpenSearch can be manually re-indexed using a job. This will update OpenSearch to the latest version of the data in Postgres.
To trigger the reindexSearch job, access the /admin path of the Backoffice application on the required environment,
where you'll see a button to trigger the job.
The progress of the job can then be monitored in the logs.
With the Beacons Service API running, execute docker compose up -f docker-compose.schemacrawler.yml. This will create
a diagram of the database schema at
schemacrawler/beacons-schema.html.