99 lines
1.8 KiB
Markdown
99 lines
1.8 KiB
Markdown
# Price Service – Technical Exercise
|
||
|
||
## Description
|
||
|
||
Spring Boot service that exposes a REST endpoint to retrieve the applicable price for a product, brand and application date.
|
||
|
||
The service uses:
|
||
- Spring Boot
|
||
- Spring Data JPA
|
||
- H2 in-memory database
|
||
- Liquibase for schema and data initialization
|
||
- Maven
|
||
- Integration tests with MockMvc
|
||
|
||
The pricing logic follows the specification provided in the exercise, including date ranges and priority handling.
|
||
|
||
---
|
||
|
||
## Data Model
|
||
|
||
The service is initialized with sample data equivalent to the provided `PRICES` table, including:
|
||
|
||
- Brand identifier
|
||
- Product identifier
|
||
- Price list
|
||
- Application date range (start / end)
|
||
- Priority
|
||
- Final price
|
||
|
||
If multiple prices apply for the same date range, the one with the highest priority is selected.
|
||
|
||
---
|
||
|
||
## REST Endpoint
|
||
|
||
### Request
|
||
|
||
GET /api/price/{brandId}/{productId}?applicationDate={applicationDate}
|
||
|
||
**Path parameters:**
|
||
- `brandId`: brand identifier
|
||
- `productId`: product identifier
|
||
|
||
**Request parameters:**
|
||
- `applicationDate`: date and time of application (ISO-8601 format)
|
||
|
||
**Example:**
|
||
|
||
/api/price/1/35455?applicationDate=2020-06-14T10:00:00
|
||
|
||
---
|
||
|
||
### Response
|
||
|
||
The service returns:
|
||
- product identifier
|
||
- brand identifier
|
||
- applicable price list
|
||
- start date
|
||
- end date
|
||
- final price
|
||
|
||
---
|
||
|
||
## Running the Application
|
||
|
||
To start the application locally:
|
||
|
||
```bash
|
||
mvn spring-boot:run
|
||
```
|
||
|
||
The service will be available on port 8080.
|
||
|
||
---
|
||
|
||
## Running Tests
|
||
|
||
The project includes integration tests that validate the scenarios described in the exercise.
|
||
|
||
To execute the tests:
|
||
|
||
```bash
|
||
mvn test
|
||
```
|
||
|
||
The tests:
|
||
- Load the Spring context
|
||
- Initialize the in-memory H2 database via Liquibase
|
||
- Validate the REST endpoint responses
|
||
|
||
---
|
||
|
||
## Notes
|
||
|
||
The database is fully in-memory and requires no external setup.
|
||
|
||
Liquibase is used to manage database schema and initial data.
|