/GET /POST
APIs for managing donations.
- Java 17
- Spring boot - Create and read operations for managing donations; application exposed on port
8081
- Spring boot security - basic authentication applied to all APIs
- H2 database - for testing code
- Swagger
- OpenApi
- Wiremock - for integration tests - stubbing the external URL from where donations database is populated on application startup (see
src/test/resources/mappings/donations.json
file) - Spring integration tests using
WebTestClient
- Junit5, AssertJ
- Maven
- Docker
In order to build the project, you will have to install the following:
- Java 17
- Maven
- Docker (optional)
- This project includes Lombok Annotations, this means that in order for your IDE to correctly compile your project you'll need to add the Lombok plugin to your IDE and
Enable annotation processing
(for IntelliJ IDEA).
mvn clean install
docker build -t donation-service .
mvn spring-boot:run
docker run -p 8081:8081 donation-service
Swagger endpoint: http://localhost:8081/swagger-ui/index.html
OpenApi endpoint: http://localhost:8081/v3/api-docs
Important: swagger/openapi dependency for spring-boot 3 is now springdoc-openapi-starter-webmvc-ui
All APIs are secured using basic auth. Use the following credentials when making requests:
username=donation-user
password=donation-password-which-should-be-kept-in-a-secret-place-and-injected-when-application-is-deployed
- GET /donations
curl 'localhost:8081/donations' \
-u "donation-user:donation-password-which-should-be-kept-in-a-secret-place-and-injected-when-application-is-deployed"
- POST /donations
curl -X POST 'localhost:8081/donations' \
-u "donation-user:donation-password-which-should-be-kept-in-a-secret-place-and-injected-when-application-is-deployed" \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 0,
"title": "string",
"firstName": "string",
"lastName": "string",
"sortCode": "string",
"accountNumber": 0,
"donationAmount": 0
}'
- The
donationDatabasePopulatorTest
integration test is using Wiremock to stub the external URL for loading donations. The file mapping of that response is located undersrc/test/resources/mappings/donations.json
.