Use in memory storage. Do not use a database.
Create an application listening to port 8085, and:
The application should be able to receive a
POST http://localhost:8085/api/register with payload (store it as a shipment):
{
"reference":"ABCD123456",
"parcels" : [
{
"weight":1,
"width": 10,
"height": 10,
"lenght": 10
},
{
"weight":2,
"width": 20,
"height": 20,
"lenght": 20
}
]
}The application should be able to receive a
PUT http://localhost:8085/api/push with the following payload (tracking):
{
"status":"WAITING_IN_HUB",
"parcels":2,
"weight":null,
"reference":"ABCD123456"
}{
"status":"WAITING_IN_HUB",
"parcels":2,
"weight":2,
"reference":"ABCD123456"
}{
"status":"WAITING_IN_HUB",
"parcels":1,
"weight":15,
"reference":"ABCD123456"
}{
"status":"WAITING_IN_HUB",
"parcels":2,
"weight":30,
"reference":"ABCD123456"
}{
"status":"DELIVERED",
"parcels":2,
"weight":2,
"reference":"ABCD123456"
}{
"status":"DELIVERED",
"parcels":2,
"weight":30,
"reference":"ABCD123456"
}{
"status":"DELIVERED",
"parcels":2,
"weight":30,
"reference":"EFGH123456"
}{
"status":"DELIVERED",
"parcels":null,
"weight":30,
"reference":"ABCD123456"
}Using the above examples:
Given the provided shipment
When
shipmentreference should be equal totrackingreferenceshipmentparcel number should be equal totrackingparcel number.shipmenttotal weight should be less thantrackingweight.trackingstatus should beDELIVERED
Then dispatch an application event
{
"reference":"ABCD123456",
"status": "CONCILLIATION_REQUEST"
}AND print it into the console
Given the provided shipment
When
shipmentreference should be equal totrackingreference.shipmentparcel number should be equal totrackingparcel number.shipmenttotal weight should be greater or equal thantrackingweight.trackingstatus should beDELIVERED.
Then dispatch an application event
{
"reference":"ABCD123456",
"status": "NOT_NEEDED"
}AND print it into the console
Given the provided shipment
When
shipmentreference should be equal totrackingreferencetrackingstatus is notDELIVERED
Then dispatch an application event
{
"reference":"ABCD123456",
"status": "INCOMPLETE"
}AND print it into the console
Given the provided shipment
When
shipmentreference should be equal totrackingreference- any other
trackingfield is null
Then dispatch an application event
{
"reference":"ABCD123456",
"status": "INCOMPLETE"
}AND print it into the console
Given the provided shipment
When
trackingreference is not equal toshipmentreference
Then dispatch an application event
{
"reference":"EFGH123456",
"status": "NOT_FOUND"
}AND print it into the console