- Java
- Spring Boot
- Maven
- Tomcat
- JUnit
- Mockito
- H2 database
- Lombok
- mvn test
- mvn clean package
Web port: 8090
Expose two endpoints.
- Endpoint with text body:
POST /order/order HTTP/1.1
Host: localhost:8090
10 VS5
14 MB11
13 CF
Response:
10 VS5 $8,99
2 x $8,99
14 MB11 $34,90
1 x $24,95
3 x $9,95
13 CF $15,90
2 x $9,95
1 x $5,95
- Endpoint with JSON objects of request and response:
POST /order/order-json HTTP/1.1
Host: localhost:8090
Content-Type: application/json
[
{
"productQuantity": "10",
"productCode": "VS5"
},
{
"productQuantity": "14",
"productCode": "MB11"
},
{
"productQuantity": "13",
"productCode": CF"
}
]
Response:
[
{
"productQuantity": 10,
"productCode": "VS5",
"productTotalCost": 8.99,
"packs": [
{
"packQuantity": 2,
"productQuantity": 5,
"packCost": 8.99
}
]
},
{
"productQuantity": 14,
"productCode": "MB11",
"productTotalCost": 34.9,
"packs": [
{
"packQuantity": 1,
"productQuantity": 8,
"packCost": 24.95
},
{
"packQuantity": 3,
"productQuantity": 2,
"packCost": 9.95
}
]
},
{
"productQuantity": 13,
"productCode": "CF",
"productTotalCost": 15.899999999999999,
"packs": [
{
"packQuantity": 2,
"productQuantity": 5,
"packCost": 9.95
},
{
"packQuantity": 1,
"productQuantity": 3,
"packCost": 5.95
}
]
}
]