Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
End to End Test (synchronous)
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