[TOC]
Request:
http :8080/orders id=11 name="pen" price=2.5
Response:
HTTP 201 Created
{
"id": 20,
"orderItems": [
{
"id": 31,
"price": 2.5,
"productId": 11
}
],
"price": 2.5,
"status": "CREATED"
}
Request:
http :8080/orders id=99 name="noprice"
Response:
HTTP 400 Bad Request
{
"errors": [
{
"code": "",
"description": "Price is mandatory"
}
],
"message": "Validation failed for arguments",
"status": 400,
"timestamp": "2021-09-20 11:03:33"
}
Request:
http :8080/orders/20/products id=22 name="headset" price=128.00
Response:
HTTP 200 OK
{
"id": 20,
"orderItems": [
{
"id": 31,
"price": 2.5,
"productId": 11
},
{
"id": 32,
"price": 128.0,
"productId": 22
}
],
"price": 130.5,
"status": "CREATED"
}
Request:
http :8080/orders/20
Response:
HTTP 200 OK
{
"id": 20,
"orderItems": [
{
"id": 31,
"price": 2.5,
"productId": 11
},
{
"id": 32,
"price": 128.0,
"productId": 22
}
],
"price": 130.5,
"status": "CREATED"
}
Request:
http :8080/orders/99
Response:
HTTP 400 NOT_FOUND
{
"errors": null,
"message": "Could not find order 99",
"status": 404,
"timestamp": "2021-09-20 11:04:57"
}
Request:
http DELETE :8080/orders/20/products?productId=22
Response:
HTTP 204 No Content
Request:
http POST :8080/orders/20/complete
Response:
HTTP 200 OK
{
"id": 20,
"orderItems": [
{
"id": 31,
"price": 2.5,
"productId": 11
}
],
"price": 2.5,
"status": "COMPLETED"
}
Request:
http :8080/orders/20/products id=33 name="book" price=45.00
Response:
HTTP 500 Internal Error
{
"errors": null,
"message": "The order is in completed state.",
"status": 500,
"timestamp": "2021-09-20 11:11:11"
}
- Map JPA entities to DTO // done
- Exception handling // done
- Unify response
- Use MongoDB for NoSQL example
- Health check
- Graceful shutdown // done
- Log to console/STDOUT // done
- Multiple application profiles
- Flyway data migration
- Unit Tests for domain layer
- Integration tests