Created
October 25, 2020 22:36
-
-
Save danielsiwiec/68c188b4f0698cb3564d876065c5ae9c to your computer and use it in GitHub Desktop.
End to End Test (synchronous)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrderProcessingTest { | |
@Autowired | |
RestTemplate restTemplate; | |
@Test | |
public void shouldProcessValidOrder() { | |
var validOrder = Order.withItems(Item.id("2fa2ac")).withCustomerId("123"); | |
// submit Order | |
var response = restTemplate.postForEntity("/processOrder", validOrder); | |
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); | |
assertThat(response.getBody().getStatus()).isEqualTo("PROCESSED"); | |
// validate Payment | |
var paymentTransactionId = response.getBody().getPaymentTranscationId(); | |
var paymentStatus = restTemplate.getForEntity("http://externalPaymentGateway/paymentStatus/" + paymentTransactionId); | |
assertThat(paymentStatus).isEqualTo("PAYMENT_PROCESSED"); | |
// validate Shipment | |
var shipmentId = response.getBody().getShipmentId(); | |
var shipmentStatus = restTemplate.getForEntity("http://externalShipmentService/shipmentStatus/" + shipmentId); | |
assertThat(shipmentStatus).isEqualTo("QUEUED_FOR_SHIPMENT"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment