This is a microservice rest for ZARA recruitment.
Business rules
Given a day and time, a database search is carried out to bring up the price with the tariff to be applied. If more than one element is found, some rules will apply:
- If the result finds two rates that coincide, the one with the highest value will apply.
Layer that implements the UseCase and contains the business rule
This module is responsible for instantiating the other modules of the application. As the name suggests, it is the bootstrap.
Module containing the application entities.
Infrastructure layer that connects to database and other services.
- Java 21
- Spring boot 3.2.3
- Spring Data
- Database H2 Memory
- Mapstruct
- Junit
- Mockito
- Jacoco Reporter
Clone the repository:
git clone clone https://github.com/LauroSilveira/appzara.git
Get in the appzara folder:
cd appzara/appzara
how to execute the Spring context put following command in your prompt:
mvn spring-boot:run
And how to stop:
ctrl c
In the Infrastructure module there is a PriceController with a GET endpoint with the following parameters:
- startDate (mandatory): date must be int the format yyyy-MM-dd-HH.mm.ss e.g. 2020-06-16-21.00.00
- productId (mandatory): id of product e.g. 35455
- brandId (mandatory): id of brand e.g: 1 (ZARA)
Lets see some examples of request
Request to day 14 of 2020 at 10:00 hrs
curl --location 'http://localhost:8080/price/startDate/2020-06-14-10.00.00/productId/35455/brandId/1'
The response will be:
{
"brandId": 1,
"productId": "35455",
"priority": 1,
"rate": 4,
"startDate": "2020-06-15T16:00:00",
"endDate": "2020-12-31T23:59:59",
"amount": 38.95
}
Request to day 14 of 2020 at 16:00 hrs
curl --location 'http://localhost:8080/price/startDate/2020-06-14-16.00.00/productId/35455/brandId/1'
The response will be:
{
"brandId": 1,
"productId": "35455",
"priority": 1,
"rate": 4,
"startDate": "2020-06-15T16:00:00",
"endDate": "2020-12-31T23:59:59",
"amount": 38.95
}
Request to day 14 of 2020 at 21:00 hrs
curl --location 'http://localhost:8080/price/startDate/2020-06-14-21.00.00/productId/35455/brandId/1'
The response will be:
{
"brandId": 1,
"productId": "35455",
"priority": 1,
"rate": 4,
"startDate": "2020-06-15T16:00:00",
"endDate": "2020-12-31T23:59:59",
"amount": 38.95
}
Request to day 15 of 2020 at 21:00 hrs
curl --location 'http://localhost:8080/price/startDate/2020-06-15-21.00.00/productId/35455/brandId/1'
The response will be:
{
"brandId": 1,
"productId": "35455",
"priority": 1,
"rate": 3,
"startDate": "2020-06-15T00:00:00",
"endDate": "2020-06-15T11:00:00",
"amount": 30.50
}
Request to day 16 of 2020 at 21:00 hrs
curl --location 'http://localhost:8080/price/startDate/2020-06-16-21.00.00/productId/35455/brandId/1'
The response will be:
{
"brandId": 1,
"productId": "35455",
"priority": 1,
"rate": 3,
"startDate": "2020-06-15T00:00:00",
"endDate": "2020-06-15T11:00:00",
"amount": 30.50
}
This project has jacoco-report with we are able to see coverage after execute tests. There is unit tests and integration test. The integration test has the annotation @ActiveProfile("test") with you want to execute it. To execute all test just run:
mvn test
After execute tests jacoco-report will generate an index.html file with coverage.
The directory of this file is appzara/bootstrap/target/site/jacoco-aggregate/index.html
.
Open it in your default browser to see the coverage of each module