Spring boot application using Spring Data JPA and REST APIs for creating, editing and deleting Incident Reports. The application uses MySQL db and docker compose file to configure all of the application’s service dependencies
- Download and installation of Java 8 or above
- Download and installation of maven
- Download and setup Docker desktop (https://www.docker.com/products/docker-desktop)
- Optional : Download and install MySQL Workbench (https://dev.mysql.com/downloads/workbench)
- Download and install Postman
- On terminal execute the command
mvn clean install
for downloading all the dependencies defined in pom.xml - Open docker-compose.yml and update the MYSQL_ROOT_PASSWORD with a password of your choice. The same password and the port 3306(as mentioned in docker-compose.yml file) will be used to configure MySQL Workbench to connect to incident DB(DB name is as per the yml file created).
- On terminal execute the command
docker-compose up -d --build
to run the services that are defined indocker-compose.yml
. Here it is MYSQL. - Right click on
IncidentReportApplication.java
and click onRun IncidentReportApplication.java
. Spring boot application will be started.
Swagger documentation for all the APIs created can be viewed at http://localhost:8080/swagger-ui/index.html#
To test the various REST APIs created as part of this application, I have added JUnits for the Controllers and the Services. These Junits are added at src/test/java/com/example/incidentreport/small
. For end-to-end/integration testing have added Test classes at src/test/java/com/example/incidentreport/integration
.
user_detail Table
Column Name | Description |
---|---|
user_id | PK |
first_name | First Name |
last_name | Last Name |
user_name |
incident Table
Column Name | Description |
---|---|
incident_id | PK |
status_id | Mapped to status |
title | Incident title |
assignee_id | FK referencing user_id (user_detail) |
CURLs for various APIs exposed(further details and API response code details can be found in Swagger documentation)
Postman Collection of the APIs can be found at https://www.getpostman.com/collections/c2adb7c30eb93d5b83a9
curl --location --request POST 'http://localhost:8080/user' \
--header 'Content-Type: application/json' \
--data-raw '{
"userName": "test",
"firstName": "admin",
"lastName": "user"
}'
curl --location --request PUT 'localhost:8080/user/test' \
--header 'Content-Type: application/json' \
--data-raw '{
"userName": "test",
"firstName": "amadmin",
"lastName": "user"
}'
curl --location --request DELETE 'localhost:8080/user/test'
curl --location --request GET 'localhost:8080/user/test'
curl --location --request GET 'localhost:8080/users'
curl --location --request POST 'localhost:8080/incident' \
--header 'Content-Type: application/json' \
--data-raw '{
"title": "Machine allocation",
"assignee": "test",
"creator": "test"
}'
curl --location --request GET 'localhost:8080/incidents'
curl --location --request PATCH 'localhost:8080/incident?incident_id=3&loggedin_user=test' \
--header 'Content-Type: application/json' \
--data-raw '{
"title": "Machine allocation New"
}'
curl --location --request DELETE 'localhost:8080/incident?incident_id=5&loggedin_user=test1'