microservices-patterns / ftgo-application

Example code for the book Microservice patterns
Other
3.35k stars 1.29k forks source link

Enhancement for testing - add more information to web responses #118

Open asn25 opened 3 years ago

asn25 commented 3 years ago

Hello,

please add more fields to web responses (in particular, in Order Service), f.e., such fields as:

Here is example how it may look like (done in my test version):

$ creordbulk {"consumerId":1}{"id":1} {"orderId":1,"state":"APPROVAL_PENDING","version":0,"positionsCount":1,"firstPositionPrice":"5.00","firstPositionQty":3,"total":"15.00"}

$ getord 1 {"orderId":1,"state":"APPROVED","version":1,"positionsCount":1,"firstPositionPrice":"5.00","firstPositionQty":3,"total":"15.00"}

$ revord 1 {"orderId":1,"state":"APPROVED","version":1,"positionsCount":1,"firstPositionPrice":"5.00","firstPositionQty":3,"total":"15.00"}

$ getord 1 {"orderId":1,"state":"APPROVED","version":3,"positionsCount":1,"firstPositionPrice":"5.00","firstPositionQty":14,"total":"70.00"}

$ cancord1 {"orderId":1,"state":"APPROVED","version":3,"positionsCount":1,"firstPositionPrice":"5.00","firstPositionQty":14,"total":"70.00"}

$ getord 1 {"orderId":1,"state":"CANCELLED","version":5,"positionsCount":1,"firstPositionPrice":"5.00","firstPositionQty":14,"total":"70.00"}

So it's easy to test Revise-operation and a lot of other stuff.

This extra information is very helpful for testing and saves a lot of time. F.e., you don't have to do additional lookup into DB on each operation (or have an extra monitor with DB-tables).

I propose to do it for GetOrderResponse and CreateOrderResponse of Orders at least (and maybe for Consumers and Restaurants too).