Upgraded pact code

This commit is contained in:
Marcin Grzejszczak
2021-07-16 18:02:16 +02:00
committed by Marcin Grzejszczak
parent d5a47e2514
commit 46331b7ffe
15 changed files with 32 additions and 32 deletions

View File

@@ -16,9 +16,9 @@
package org.springframework.cloud.contract.verifier.spec.pact;
import au.com.dius.pact.core.model.matchingrules.Category;
import au.com.dius.pact.core.model.matchingrules.DateMatcher;
import au.com.dius.pact.core.model.matchingrules.EqualsMatcher;
import au.com.dius.pact.core.model.matchingrules.MatchingRuleCategory;
import au.com.dius.pact.core.model.matchingrules.MaxTypeMatcher;
import au.com.dius.pact.core.model.matchingrules.MinMaxTypeMatcher;
import au.com.dius.pact.core.model.matchingrules.MinTypeMatcher;
@@ -43,12 +43,12 @@ final class MatchingRulesConverter {
private MatchingRulesConverter() {
}
static Category matchingRulesForBody(BodyMatchers bodyMatchers) {
static MatchingRuleCategory matchingRulesForBody(BodyMatchers bodyMatchers) {
return matchingRulesFor("body", bodyMatchers);
}
private static Category matchingRulesFor(String categoryName, BodyMatchers bodyMatchers) {
Category category = new Category(categoryName);
private static MatchingRuleCategory matchingRulesFor(String categoryName, BodyMatchers bodyMatchers) {
MatchingRuleCategory category = new MatchingRuleCategory(categoryName);
bodyMatchers.matchers().forEach((b) -> {
String key = getMatcherKey(b.path());
MatchingType matchingType = b.matchingType();

View File

@@ -51,7 +51,7 @@ class MessagePactCreator {
return null;
}
Names names = NamingUtil.name(contracts.get(0));
MessagePactBuilder pactBuilder = MessagePactBuilder.consumer(names.getConsumer())
MessagePactBuilder pactBuilder = new MessagePactBuilder().consumer(names.getConsumer())
.hasPactWith(names.getProducer());
for (Contract contract : contracts) {

View File

@@ -21,9 +21,9 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import au.com.dius.pact.core.model.matchingrules.Category;
import au.com.dius.pact.core.model.matchingrules.DateMatcher;
import au.com.dius.pact.core.model.matchingrules.MatchingRule;
import au.com.dius.pact.core.model.matchingrules.MatchingRuleCategory;
import au.com.dius.pact.core.model.matchingrules.MaxTypeMatcher;
import au.com.dius.pact.core.model.matchingrules.MinMaxTypeMatcher;
import au.com.dius.pact.core.model.matchingrules.MinTypeMatcher;
@@ -70,13 +70,13 @@ class MessagingSCContractCreator {
contract.outputMessage((outputMessage) -> {
if (message.getContents().isPresent()) {
outputMessage.body(BodyConverter.toSCCBody(message));
Category bodyRules = message.getMatchingRules().rulesForCategory("body");
MatchingRuleCategory bodyRules = message.getMatchingRules().rulesForCategory("body");
if (bodyRules != null && !bodyRules.getMatchingRules().isEmpty()) {
outputMessage.bodyMatchers((responseBodyMatchers) -> outputMessageBodyMatchers(message,
bodyRules, responseBodyMatchers));
}
}
if (!message.getMetaData().isEmpty()) {
if (!message.getMetadata().isEmpty()) {
outputMessage.headers((headers) -> outputMessageHeaders(message, headers));
}
String dest = findDestination(message);
@@ -88,7 +88,7 @@ class MessagingSCContractCreator {
}
private void outputMessageHeaders(Message message, Headers headers) {
message.getMetaData().forEach((key, value) -> {
message.getMetadata().forEach((key, value) -> {
String matchingRuleGroup = value.toString();
if (key.equalsIgnoreCase("contentType")) {
headers.messagingContentType(matchingRuleGroup);
@@ -99,7 +99,7 @@ class MessagingSCContractCreator {
});
}
private void outputMessageBodyMatchers(Message message, Category bodyRules,
private void outputMessageBodyMatchers(Message message, MatchingRuleCategory bodyRules,
ResponseBodyMatchers responseBodyMatchers) {
bodyRules.getMatchingRules().forEach((matchingRuleKey, matchingRuleGroup) -> {
if (matchingRuleGroup.getRuleLogic() != RuleLogic.AND) {
@@ -127,8 +127,8 @@ class MessagingSCContractCreator {
}
private String findDestination(Message message) {
return message.getMetaData().get(DESTINATION_KEY) != null
? message.getMetaData().get(DESTINATION_KEY).toString() : "";
return message.getMetadata().get(DESTINATION_KEY) != null
? message.getMetadata().get(DESTINATION_KEY).toString() : "";
}
void applyJsonPathToResponseBodyMatchers(MatchingRule matchingRule, String key,

View File

@@ -30,9 +30,9 @@ import au.com.dius.pact.core.model.Request;
import au.com.dius.pact.core.model.RequestResponseInteraction;
import au.com.dius.pact.core.model.RequestResponsePact;
import au.com.dius.pact.core.model.Response;
import au.com.dius.pact.core.model.matchingrules.Category;
import au.com.dius.pact.core.model.matchingrules.DateMatcher;
import au.com.dius.pact.core.model.matchingrules.MatchingRule;
import au.com.dius.pact.core.model.matchingrules.MatchingRuleCategory;
import au.com.dius.pact.core.model.matchingrules.MatchingRuleGroup;
import au.com.dius.pact.core.model.matchingrules.MaxTypeMatcher;
import au.com.dius.pact.core.model.matchingrules.MinMaxTypeMatcher;
@@ -92,7 +92,7 @@ class RequestResponseSCContractCreator {
if (pactRequest.getBody().getState() == OptionalBody.State.PRESENT) {
mapRequestBody(contractRequest, pactRequest);
}
Category bodyRules = pactRequest.getMatchingRules().rulesForCategory("body");
MatchingRuleCategory bodyRules = pactRequest.getMatchingRules().rulesForCategory("body");
if (!bodyRules.getMatchingRules().isEmpty()) {
mapRequestBodyRules(contractRequest, bodyRules);
}
@@ -111,7 +111,7 @@ class RequestResponseSCContractCreator {
mapResponseBody(contractResponse, pactResponse);
}
Category bodyRules = pactResponse.getMatchingRules().rulesForCategory("body");
MatchingRuleCategory bodyRules = pactResponse.getMatchingRules().rulesForCategory("body");
if (!bodyRules.getMatchingRules().isEmpty()) {
mapResponseBodyRules(contractResponse, pactResponse, bodyRules);
}
@@ -126,7 +126,7 @@ class RequestResponseSCContractCreator {
}
private void mapResponseBodyRules(org.springframework.cloud.contract.spec.internal.Response contractResponse,
Response pactResponse, Category bodyRules) {
Response pactResponse, MatchingRuleCategory bodyRules) {
contractResponse.bodyMatchers((bodyMatchers) -> {
bodyRules.getMatchingRules().forEach((key, matchindRuleGroup) -> {
if (matchindRuleGroup.getRuleLogic() != RuleLogic.AND) {
@@ -210,7 +210,7 @@ class RequestResponseSCContractCreator {
}
private void mapRequestBodyRules(org.springframework.cloud.contract.spec.internal.Request contractRequest,
Category bodyRules) {
MatchingRuleCategory bodyRules) {
contractRequest.bodyMatchers((bodyMatchers) -> {
bodyRules.getMatchingRules().forEach((key, matchingRuleGroup) -> {
if (matchingRuleGroup.getRuleLogic() != RuleLogic.AND) {
@@ -267,7 +267,7 @@ class RequestResponseSCContractCreator {
private void mapRequestCookies(org.springframework.cloud.contract.spec.internal.Request contractRequest,
Request pactRequest) {
Category headerRules = pactRequest.getMatchingRules().rulesForCategory("header");
MatchingRuleCategory headerRules = pactRequest.getMatchingRules().rulesForCategory("header");
String[] splitCookiesHeader = pactRequest.getHeaders().get("Cookie").get(0).split(";");
Map<String, String> foundCookies = Stream.of(splitCookiesHeader).map((cookieHeader) -> cookieHeader.split("="))
.collect(Collectors.toMap(splittedCookieHeader -> splittedCookieHeader[0],
@@ -300,7 +300,7 @@ class RequestResponseSCContractCreator {
private void mapResponseCookies(org.springframework.cloud.contract.spec.internal.Response contractResponse,
Response pactResponse) {
Category headerRules = pactResponse.getMatchingRules().rulesForCategory("header");
MatchingRuleCategory headerRules = pactResponse.getMatchingRules().rulesForCategory("header");
String[] splitCookiesHeader = pactResponse.getHeaders().get("Cookie").get(0).split(";");
Map<String, String> foundCookies = Stream.of(splitCookiesHeader).map((cookieHeader) -> cookieHeader.split("="))
.collect(Collectors.toMap(splittedCookieHeader -> splittedCookieHeader[0],
@@ -345,7 +345,7 @@ class RequestResponseSCContractCreator {
private void mapRequestHeaders(org.springframework.cloud.contract.spec.internal.Request contractRequest,
Request pactRequest) {
Category headerRules = pactRequest.getMatchingRules().rulesForCategory("header");
MatchingRuleCategory headerRules = pactRequest.getMatchingRules().rulesForCategory("header");
contractRequest.headers((headers) -> pactRequest.getHeaders().forEach((key, values) -> {
if (key.equalsIgnoreCase("Cookie")) {
return;
@@ -379,7 +379,7 @@ class RequestResponseSCContractCreator {
private void mapResponseHeaders(org.springframework.cloud.contract.spec.internal.Response contractResponse,
Response pactResponse) {
Category headerRules = pactResponse.getMatchingRules().rulesForCategory("header");
MatchingRuleCategory headerRules = pactResponse.getMatchingRules().rulesForCategory("header");
contractResponse.headers((headers) -> pactResponse.getHeaders().forEach((key, values) -> {
if (key.equalsIgnoreCase("Cookie")) {
return;

View File

@@ -133,7 +133,7 @@ final class ValueGeneratorConverter {
"We currently don't support a generator of type " + generator.getClass().getSimpleName());
}
else {
Object generatedValue = generator.generate(new HashMap<>());
Object generatedValue = generator.generate(new HashMap<>(), null);
return dslPropertyProvider.apply(pattern, generatedValue);
}
}
@@ -191,7 +191,7 @@ final class ValueGeneratorConverter {
generators.addGenerator(category, path, new RandomStringGenerator(10));
break;
case UUID_PATTERN:
generators.addGenerator(category, path, UuidGenerator.INSTANCE);
generators.addGenerator(category, path, new UuidGenerator());
break;
case ANY_DATE_PATTERN:
generators.addGenerator(category, path, new DateGenerator());

View File

@@ -347,7 +347,7 @@ class PactContractConverterSpec extends Specification {
],
"metadata": {
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}

View File

@@ -147,7 +147,7 @@
],
"metadata": {
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}

View File

@@ -290,7 +290,7 @@
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}

View File

@@ -98,7 +98,7 @@
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}

View File

@@ -90,7 +90,7 @@
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}

View File

@@ -70,7 +70,7 @@
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}

View File

@@ -39,7 +39,7 @@
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}

View File

@@ -38,7 +38,7 @@
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}

View File

@@ -22,7 +22,7 @@
"version": "3.0.0"
},
"pact-jvm": {
"version": "4.1.23"
"version": "4.3.6"
}
}
}