Created
February 14, 2017 18:48
-
-
Save ramju/b19f562a5f7a954afd1cbf09b8597298 to your computer and use it in GitHub Desktop.
contract files
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
package doc.messaging | |
org.springframework.cloud.contract.spec.Contract.make { | |
description 'sample docnumber generation contract' | |
label 'label1' | |
input { | |
messageFrom('generateDoc') | |
messageBody([ | |
docId: 'D111' | |
]) | |
} | |
outputMessage { | |
sentTo('DocGenerated') | |
body([ | |
"docId" : value(consumer('D111'), producer(regex('.*'))), | |
"docNumber" : value(consumer('123'),producer(regex('.*'))) | |
]) | |
} | |
} |
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 MessagingTest extends DocMessagingBase { | |
@Inject ContractVerifierMessaging contractVerifierMessaging; | |
@Inject ContractVerifierObjectMapper contractVerifierObjectMapper; | |
@Test | |
public void validate_invoiceGenerated() throws Exception { | |
// given: | |
ContractVerifierMessage inputMessage = contractVerifierMessaging.create( | |
"{\"docId\":\"D111\"}" | |
); | |
// when: | |
contractVerifierMessaging.send(inputMessage, "generateDoc"); | |
// then: | |
ContractVerifierMessage response = contractVerifierMessaging.receive("DocGenerated"); | |
assertThat(response).isNotNull(); | |
DocumentContext parsedJson = JsonPath.parse(contractVerifierObjectMapper.writeValueAsString(response.getPayload())); | |
assertThatJson(parsedJson).field("docId").matches(".*"); | |
assertThatJson(parsedJson).field("docNumber").matches(".*"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment