Created
July 19, 2019 07:42
-
-
Save rafaroca/5aca21c79d4676b5ea28d005884976d1 to your computer and use it in GitHub Desktop.
Consumer-driven asynchronous contract tests
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
@Pact(consumer = "fulfillment-service", provider = "order-service") | |
fun exportAnOrderTo(builder: MessagePactBuilder): MessagePact = builder.hasPactWith("order-service") | |
.given("An order with three items") | |
.expectsToReceive("an order to export") | |
.withContent( | |
newJsonBody { o -> | |
o.stringType("customerId", testCustomerId) | |
o.array("items") { a -> | |
a.newObject { item -> | |
item.stringType("name", "A Teddy Bear") | |
item.numberType("price", 1295) | |
} | |
a.newObject { item -> | |
item.stringType("name", "Googly Eyes") | |
item.numberType("price", 59) | |
} | |
a.newObject { item -> | |
item.stringType("name", "Goofy Socks") | |
item.numberType("price", 100) | |
} | |
} | |
}.build() | |
) | |
.toPact() |
Author
rafaroca
commented
Nov 15, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment