Closed MattiaRiola closed 2 years ago
Tests are in function shopTickets()
inside OrdersTests
class. All the "bad requests" tests are now working.
The good one has some constraints:
1) The user has to be in the traveler database, otherwise 400 BAD_REQUEST 2) Kafka response that change the order status from PENDING -> COMPLETED is randomly working, so the test can't wait a fixed time.
My suggestion is to mock both the traveler and kafka calls
POST /shop/{ticket-id} →it accepts a json containing the number of tickets, ticketId, and payment information (credit card number, expiration date, cvv, card holder). Only authenticated users can perform this request. In case those tickets have age restrictions, it asks the TravellerService the user profile in order to check if the operation is permitted. In case it is, it saves the order in the database with the PENDING status, then it transmits the billing information and the total cost of the order to the payment service through a kafka topic, and it returns the orderId. When the Kafka listener receives the outcome of the transaction, the status of order is updated according to what the payment service has stated and, if the operation was successful, the purchased products are added to the list of acquired tickets in the TravellerService.
The client to check the order result, must do polling to check the outcome.