use of org.springframework.cloud.contract.spec.internal.ResponseBodyMatchers in project spring-cloud-contract by spring-cloud.
the class MessagingSCContractCreator method convertFrom.
Collection<Contract> convertFrom(MessagePact pact) {
return pact.getMessages().stream().map(message -> Contract.make(contract -> {
contract.label(message.getDescription());
if (!message.getProviderStates().isEmpty()) {
contract.input(i -> i.triggeredBy(this.getTriggeredBy(message)));
}
contract.outputMessage((outputMessage) -> {
if (message.getContents().isPresent()) {
outputMessage.body(BodyConverter.toSCCBody(message));
Category bodyRules = message.getMatchingRules().rulesForCategory("body");
if (bodyRules != null && !bodyRules.getMatchingRules().isEmpty()) {
outputMessage.bodyMatchers((responseBodyMatchers) -> outputMessageBodyMatchers(message, bodyRules, responseBodyMatchers));
}
}
if (!message.getMetaData().isEmpty()) {
outputMessage.headers((headers) -> outputMessageHeaders(message, headers));
}
String dest = findDestination(message);
if (StringUtils.isNotBlank(dest)) {
outputMessage.sentTo(dest);
}
});
})).collect(Collectors.toList());
}
Aggregations