Search in sources :

Example 1 with ResponseBodyMatchers

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());
}
Also used : JsonPaths(org.springframework.cloud.contract.verifier.util.JsonPaths) TimestampMatcher(au.com.dius.pact.core.model.matchingrules.TimestampMatcher) JsonToJsonPathsConverter(org.springframework.cloud.contract.verifier.util.JsonToJsonPathsConverter) Category(au.com.dius.pact.core.model.matchingrules.Category) RegexMatcher(au.com.dius.pact.core.model.matchingrules.RegexMatcher) MaxTypeMatcher(au.com.dius.pact.core.model.matchingrules.MaxTypeMatcher) MessagePact(au.com.dius.pact.core.model.messaging.MessagePact) StringUtils(org.apache.commons.lang3.StringUtils) Contract(org.springframework.cloud.contract.spec.Contract) Message(au.com.dius.pact.core.model.messaging.Message) MinMaxTypeMatcher(au.com.dius.pact.core.model.matchingrules.MinMaxTypeMatcher) MinTypeMatcher(au.com.dius.pact.core.model.matchingrules.MinTypeMatcher) NumberTypeMatcher(au.com.dius.pact.core.model.matchingrules.NumberTypeMatcher) Collection(java.util.Collection) TypeMatcher(au.com.dius.pact.core.model.matchingrules.TypeMatcher) TimeMatcher(au.com.dius.pact.core.model.matchingrules.TimeMatcher) ResponseBodyMatchers(org.springframework.cloud.contract.spec.internal.ResponseBodyMatchers) Collectors(java.util.stream.Collectors) NullMatcher(au.com.dius.pact.core.model.matchingrules.NullMatcher) DateMatcher(au.com.dius.pact.core.model.matchingrules.DateMatcher) RuleLogic(au.com.dius.pact.core.model.matchingrules.RuleLogic) List(java.util.List) MatchingRule(au.com.dius.pact.core.model.matchingrules.MatchingRule) RegexPatterns(org.springframework.cloud.contract.spec.internal.RegexPatterns) Collections(java.util.Collections) Headers(org.springframework.cloud.contract.spec.internal.Headers) Category(au.com.dius.pact.core.model.matchingrules.Category)

Aggregations

Category (au.com.dius.pact.core.model.matchingrules.Category)1 DateMatcher (au.com.dius.pact.core.model.matchingrules.DateMatcher)1 MatchingRule (au.com.dius.pact.core.model.matchingrules.MatchingRule)1 MaxTypeMatcher (au.com.dius.pact.core.model.matchingrules.MaxTypeMatcher)1 MinMaxTypeMatcher (au.com.dius.pact.core.model.matchingrules.MinMaxTypeMatcher)1 MinTypeMatcher (au.com.dius.pact.core.model.matchingrules.MinTypeMatcher)1 NullMatcher (au.com.dius.pact.core.model.matchingrules.NullMatcher)1 NumberTypeMatcher (au.com.dius.pact.core.model.matchingrules.NumberTypeMatcher)1 RegexMatcher (au.com.dius.pact.core.model.matchingrules.RegexMatcher)1 RuleLogic (au.com.dius.pact.core.model.matchingrules.RuleLogic)1 TimeMatcher (au.com.dius.pact.core.model.matchingrules.TimeMatcher)1 TimestampMatcher (au.com.dius.pact.core.model.matchingrules.TimestampMatcher)1 TypeMatcher (au.com.dius.pact.core.model.matchingrules.TypeMatcher)1 Message (au.com.dius.pact.core.model.messaging.Message)1 MessagePact (au.com.dius.pact.core.model.messaging.MessagePact)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1