This is a document generation and template management service. This allows to generate documents based on a given template name and placeholder data in JSON format and will also store the generated document in the Document Management Store (via Case Document AM).
The service provides a single RESTful endpoint that will generate the document, store it in Evidence Management Store and return the link to the stored data.
Updated with master code base until 2.1
You must pass dynamic_fileName key in the placeholders map to get a dynamic file name
Prerequisites
Building
The project uses Gradle as a build tool but you don't have to install it locally since there is a
./gradlew
wrapper script.
To build project please execute the following command:
./gradlew build
Running
First you need to create distribution by executing following command:
./gradlew installDist
To begin download the azure client cli:
brew update && brew install azure-cli
After it has finished downloaded run:
az login
This should open a browser window for you to login, use your HMCTS account
After logging in run the following command:
az acr login --name hmcts --subscription <ask the team for the secret>
Make sure you are connected to the VPN to before you run docker-compose up otherwise it won't be able to use the image.
When the distribution has been created in build/install/prl-dgs-api
directory,
you can run the application by executing following command:
docker-compose up
As a result the following container(s) will get created and started:
- long living container for API application exposing port
4007
Make sure you have added the label 'enable_keep_helm' while creating the PR. Otherwise, add the label and re-trigger the build.
Integration tests
To run all integration tests locally:
- Make a copy of
src/main/resources/example-application-aat.yml
assrc/main/resources/application-aat.yml
- Make a copy of
src/integrationTest/resources/example-application-local.properties
assrc/integrationTest/resources/application-local.properties
- Replace the
replace_me
secrets in the newly created files. You can get the values from SCM and Azure secrets key vault (the new files are in .gitignore and should not be committed to git) - Assuming you use IntelliJ, run your application
- And then run your gradle functional tests task
- Or if using command line:
- Start the app with AAT config using
./gradlew clean bootRunAat
- Start the test with AAT config using
./gradlew clean functional
- Start the app with AAT config using
If you update content in templates, you can re-generate the PDFs by running the ignored test PDFGenerationTest.ignoreMe_updateGeneratedPdfs
. The test
will output generated PDFs to the folder src/integrationTest/resources/documentgenerator/documents/regenerated
Unit tests
To run all unit tests please execute following command:
./gradlew test
Coding style tests
To run all checks (including unit tests) please execute following command:
./gradlew check
Mutation tests
To run all mutation tests execute the following command:
./gradlew pitest
Flow Diagram
API documentation
API documentation is provided with Swagger:
http://localhost:4007/swagger-ui.html
- UI to interact with the API resources
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Standard API
We follow RESTful API standards.
This project is licensed under the MIT License - see the LICENSE.md file for details.