#######################
#######################
- Spring Boot
- Spring Data JPA
- Spring Security
- JWT
- Swagger
- Lombok
- H2 In memory database
- Maven
- Junit
- Mockito
#########################
######################### The microservice is developed in Spring boot. I have used Spring MVC and Spring Data JPA. The layers of microservice are-
- Controller - This accepts the GET Request.
Versioning added in url to support multiple versions for future enhancements.
There are 3 REST endpoints configured in the controller
- GET - /v1/api/search/postCode/{postCode} - Used to fetch details using the postcode.
- GET - /v1/api/search/suburb/{suburb} - Used to fetch details using the suburb name.
- POST - /v1/api/update/addressRecord - To add a new record
- Service - The service layer of application
- Repository - Used to perform Data Access Operation
- Model - DTO and Entity
- The H2 database table created and the initial values is added using the data.sql
- Spring security is enabled using the JWT token.
- Validation is done on postcode
- Exceptions are handled
#########################
#########################
The project is executable and the microservices will run on the port: 9000
- Build:
mvn clean package
- Run:
java -jar target/demo-0.0.1-SNAPSHOT.jar
#########################
Testing the Restful Web Services:t
#########################################
HTTP STATUS -
200 OK
RESPONSE BODY
[ { "postCode": "3000", "suburb": "Melbourne" } ]
$ curl -s http://localhost:9000/v1/api/search/suburb/Melbourne
200 OK
RESPONSE BODY
[ { "postCode": "3000", "suburb": "Melbourne" } ]
curl --location --request POST 'http://localhost:9000/authenticate'
--header 'Content-Type: application/json'
--data-raw '{ "username": "foo", "password": "foo" }'
{ "jwt": "sampleToken" }
Copy the token and use in the next request.
curl --location --request POST 'http://localhost:9000/v1/api/update/addressRecord'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer sampleToken'
--data-raw '{ "postCode":"3009", "suburb":"ABC" }'
201 CREATED
RESPONSE BODY
{ "postCode": "3008", "suburb": "North Melbourne" }
#########################
#########################
Location: src/test/resources/samplejar/demo-0.0.1-SNAPSHOT.jar
- Take the JAR file from "src/test/resources/samplejar/demo-0.0.1-SNAPSHOT.jar"
- Copy the Spring boot JAR on EC2 instance
- Allow port 8080 on the instance security group
- Test the application deployed on EC2
#########################
#########################
- System testing can also be implemented by using cucumber.
- More unit testing can be added to improve coverage.
- Swagger can be added.
- Security keys can be placed in AWS parameter store and password encoding can be added for better security.
- Any hardcoded values can be parameterized.