Bumping versions

This commit is contained in:
buildmaster
2020-09-17 00:23:53 +00:00
parent 3a1e3c9640
commit ffd6574532
460 changed files with 3789 additions and 6477 deletions

View File

@@ -393,29 +393,24 @@ public class Contract {
}
Contract contract = (Contract) o;
return ignored == contract.ignored && Objects.equals(priority, contract.priority)
&& Objects.equals(request, contract.request)
&& Objects.equals(response, contract.response)
&& Objects.equals(label, contract.label)
&& Objects.equals(description, contract.description)
&& Objects.equals(name, contract.name)
&& Objects.equals(input, contract.input)
&& Objects.equals(metadata, contract.metadata)
&& Objects.equals(outputMessage, contract.outputMessage);
&& Objects.equals(request, contract.request) && Objects.equals(response, contract.response)
&& Objects.equals(label, contract.label) && Objects.equals(description, contract.description)
&& Objects.equals(name, contract.name) && Objects.equals(input, contract.input)
&& Objects.equals(metadata, contract.metadata) && Objects.equals(outputMessage, contract.outputMessage);
}
@Override
public int hashCode() {
return Objects.hash(priority, request, response, label, description, name, input,
outputMessage, metadata, ignored);
return Objects.hash(priority, request, response, label, description, name, input, outputMessage, metadata,
ignored);
}
@Override
public String toString() {
return "Contract{" + "\npriority=" + priority + ", \n\trequest=" + request
+ ", \n\tresponse=" + response + ", \n\tlabel='" + label + '\''
+ ", \n\tdescription='" + description + '\'' + ", \n\tname='" + name
+ '\'' + ", \n\tinput=" + input + ", \n\toutputMessage=" + outputMessage
+ ", \n\tignored=" + ignored + '}';
return "Contract{" + "\npriority=" + priority + ", \n\trequest=" + request + ", \n\tresponse=" + response
+ ", \n\tlabel='" + label + '\'' + ", \n\tdescription='" + description + '\'' + ", \n\tname='" + name
+ '\'' + ", \n\tinput=" + input + ", \n\toutputMessage=" + outputMessage + ", \n\tignored=" + ignored
+ '}';
}
}

View File

@@ -31,20 +31,16 @@ import java.util.stream.Collectors;
public class Body extends DslProperty {
public Body(Map<String, DslProperty> body) {
super(extractValue(body, ContractUtils.CLIENT_VALUE),
extractValue(body, ContractUtils.SERVER_VALUE));
super(extractValue(body, ContractUtils.CLIENT_VALUE), extractValue(body, ContractUtils.SERVER_VALUE));
}
public Body(List<DslProperty> bodyAsList) {
super(bodyAsList.stream().map(DslProperty::getClientValue)
.collect(Collectors.toList()),
bodyAsList.stream().map(DslProperty::getServerValue)
.collect(Collectors.toList()));
super(bodyAsList.stream().map(DslProperty::getClientValue).collect(Collectors.toList()),
bodyAsList.stream().map(DslProperty::getServerValue).collect(Collectors.toList()));
}
public Body(Object value) {
super(ContractUtils.CLIENT_VALUE.apply(value),
ContractUtils.SERVER_VALUE.apply(value));
super(ContractUtils.CLIENT_VALUE.apply(value), ContractUtils.SERVER_VALUE.apply(value));
}
public Body(Byte[] bodyAsValue) {
@@ -71,8 +67,7 @@ public class Body extends DslProperty {
super(matchingStrategy, matchingStrategy);
}
private static Map<String, Object> extractValue(Map<String, DslProperty> body,
final Function valueProvider) {
private static Map<String, Object> extractValue(Map<String, DslProperty> body, final Function valueProvider) {
final Map<String, Object> map = new LinkedHashMap<String, Object>();
body.forEach((key, value) -> map.put(key, valueProvider.apply(value)));
return map;

View File

@@ -143,8 +143,7 @@ public class BodyMatchers {
* @param consumer function to manipulate the output message
* @return matching type
*/
public MatchingTypeValue byType(
@DelegatesTo(MatchingTypeValueHolder.class) Closure consumer) {
public MatchingTypeValue byType(@DelegatesTo(MatchingTypeValueHolder.class) Closure consumer) {
MatchingTypeValueHolder matchingTypeValue = new MatchingTypeValueHolder();
consumer.setDelegate(matchingTypeValue);
consumer.call();

View File

@@ -39,12 +39,11 @@ import java.util.stream.Collectors;
*/
public class Common {
public Map<String, DslProperty> convertObjectsToDslProperties(
Map<String, Object> body) {
return body.entrySet().stream().collect(Collectors.toMap(
(Function<Map.Entry, String>) t -> t.getKey().toString(),
(Function<Map.Entry, DslProperty>) t -> toDslProperty(t.getValue()),
throwingMerger(), LinkedHashMap::new));
public Map<String, DslProperty> convertObjectsToDslProperties(Map<String, Object> body) {
return body.entrySet().stream()
.collect(Collectors.toMap((Function<Map.Entry, String>) t -> t.getKey().toString(),
(Function<Map.Entry, DslProperty>) t -> toDslProperty(t.getValue()), throwingMerger(),
LinkedHashMap::new));
}
private static <T> BinaryOperator<T> throwingMerger() {
@@ -77,8 +76,7 @@ public class Common {
return new NamedProperty(name, value);
}
public NamedProperty named(DslProperty name, DslProperty value,
DslProperty contentType) {
public NamedProperty named(DslProperty name, DslProperty value, DslProperty contentType) {
return new NamedProperty(name, value, contentType);
}
@@ -241,8 +239,7 @@ public class Common {
* @return file contents as an array of bytes
*/
private File fileLocation(String relativePath) {
URL resource = Thread.currentThread().getContextClassLoader()
.getResource(relativePath);
URL resource = Thread.currentThread().getContextClassLoader().getResource(relativePath);
if (resource == null) {
throw new IllegalStateException("File [" + relativePath + "] is not present");
}
@@ -278,48 +275,38 @@ public class Common {
if (secondSide == null) {
return;
}
assertThat(
secondSide.toString()
.matches(((OptionalProperty) firstSide).optionalPattern()),
"Pattern [" + ((OptionalProperty) firstSide).optionalPattern()
+ "] is not matched by [" + secondSide.toString() + "]");
assertThat(secondSide.toString().matches(((OptionalProperty) firstSide).optionalPattern()),
"Pattern [" + ((OptionalProperty) firstSide).optionalPattern() + "] is not matched by ["
+ secondSide.toString() + "]");
}
else if ((firstSide instanceof Pattern || firstSide instanceof RegexProperty)
&& secondSide instanceof String) {
else if ((firstSide instanceof Pattern || firstSide instanceof RegexProperty) && secondSide instanceof String) {
Pattern pattern = firstSide instanceof Pattern ? (Pattern) firstSide
: ((RegexProperty) firstSide).getPattern();
assertThat(((String) secondSide).toString().matches(pattern.pattern()),
"Pattern [" + pattern.pattern() + "] is not matched by ["
+ secondSide.toString() + "]");
"Pattern [" + pattern.pattern() + "] is not matched by [" + secondSide.toString() + "]");
}
else if ((secondSide instanceof Pattern || secondSide instanceof RegexProperty)
&& firstSide instanceof String) {
Pattern pattern = secondSide instanceof Pattern ? (Pattern) secondSide
: ((RegexProperty) secondSide).getPattern();
assertThat(((String) firstSide).matches(pattern.pattern()),
"Pattern [" + pattern.pattern() + "] is not matched by ["
+ firstSide.toString() + "]");
"Pattern [" + pattern.pattern() + "] is not matched by [" + firstSide.toString() + "]");
}
else if (firstSide instanceof MatchingStrategy
&& secondSide instanceof MatchingStrategy) {
if (((MatchingStrategy) firstSide).getType()
.equals(MatchingStrategy.Type.ABSENT)
&& !((MatchingStrategy) secondSide).getType()
.equals(MatchingStrategy.Type.ABSENT)) {
else if (firstSide instanceof MatchingStrategy && secondSide instanceof MatchingStrategy) {
if (((MatchingStrategy) firstSide).getType().equals(MatchingStrategy.Type.ABSENT)
&& !((MatchingStrategy) secondSide).getType().equals(MatchingStrategy.Type.ABSENT)) {
throwAbsentError();
}
}
else if (firstSide instanceof MatchingStrategy) {
if (((MatchingStrategy) firstSide).getType()
.equals(MatchingStrategy.Type.ABSENT)) {
if (((MatchingStrategy) firstSide).getType().equals(MatchingStrategy.Type.ABSENT)) {
throwAbsentError();
}
}
else if (secondSide instanceof MatchingStrategy) {
if (((MatchingStrategy) secondSide).getType()
.equals(MatchingStrategy.Type.ABSENT)) {
if (((MatchingStrategy) secondSide).getType().equals(MatchingStrategy.Type.ABSENT)) {
throwAbsentError();
}

View File

@@ -20,10 +20,8 @@ import java.util.function.Function;
final class ContractUtils {
static final Function CLIENT_VALUE = o -> o instanceof DslProperty
? ((DslProperty) o).getClientValue() : o;
static final Function SERVER_VALUE = o -> o instanceof DslProperty
? ((DslProperty) o).getServerValue() : o;
static final Function CLIENT_VALUE = o -> o instanceof DslProperty ? ((DslProperty) o).getClientValue() : o;
static final Function SERVER_VALUE = o -> o instanceof DslProperty ? ((DslProperty) o).getServerValue() : o;
private ContractUtils() {
throw new IllegalStateException("Can't instantiate an utility class");

View File

@@ -39,8 +39,7 @@ public class Cookie extends DslProperty {
}
public Cookie(String key, Object value) {
super(ContractUtils.CLIENT_VALUE.apply(value),
ContractUtils.SERVER_VALUE.apply(value));
super(ContractUtils.CLIENT_VALUE.apply(value), ContractUtils.SERVER_VALUE.apply(value));
this.key = key;
}

View File

@@ -86,8 +86,7 @@ public class Cookies {
*/
public Map<String, Object> asStubSideMap() {
final Map<String, Object> map = new LinkedHashMap<>();
entries.forEach(cookie -> map.put(cookie.getKey(),
ContractUtils.convertStubSideRecursively(cookie)));
entries.forEach(cookie -> map.put(cookie.getKey(), ContractUtils.convertStubSideRecursively(cookie)));
return map;
}
@@ -98,8 +97,7 @@ public class Cookies {
*/
public Map<String, Object> asTestSideMap() {
final Map<String, Object> map = new HashMap<String, Object>();
entries.forEach(cookie -> map.put(cookie.getKey(),
ContractUtils.convertTestSideRecursively(cookie)));
entries.forEach(cookie -> map.put(cookie.getKey(), ContractUtils.convertTestSideRecursively(cookie)));
return map;
}

View File

@@ -42,8 +42,7 @@ public class DslProperty<T> implements Serializable {
}
public boolean isSingleValue() {
return this.clientValue.equals(this.serverValue)
|| (this.clientValue != null && this.serverValue == null)
return this.clientValue.equals(this.serverValue) || (this.clientValue != null && this.serverValue == null)
|| (this.serverValue != null && this.clientValue == null);
}
@@ -60,8 +59,7 @@ public class DslProperty<T> implements Serializable {
Object thatClientValue = stringPatternIfPattern(that.clientValue);
Object thisServerValue = stringPatternIfPattern(serverValue);
Object thatServerValue = stringPatternIfPattern(that.serverValue);
return Objects.equals(thisClientValue, thatClientValue)
&& Objects.equals(thisServerValue, thatServerValue);
return Objects.equals(thisClientValue, thatClientValue) && Objects.equals(thisServerValue, thatServerValue);
}
private Object stringPatternIfPattern(Object value) {
@@ -70,14 +68,13 @@ public class DslProperty<T> implements Serializable {
@Override
public int hashCode() {
return Objects.hash(stringPatternIfPattern(clientValue),
stringPatternIfPattern(serverValue));
return Objects.hash(stringPatternIfPattern(clientValue), stringPatternIfPattern(serverValue));
}
@Override
public String toString() {
return getClass().getSimpleName() + "{" + "\nclientValue=" + clientValue
+ ", \n\tserverValue=" + serverValue + '}';
return getClass().getSimpleName() + "{" + "\nclientValue=" + clientValue + ", \n\tserverValue=" + serverValue
+ '}';
}
public final T getClientValue() {

View File

@@ -48,8 +48,7 @@ public interface DslPropertyConverter {
if (INSTANCE != null) {
return INSTANCE;
}
List<DslPropertyConverter> converters = SpringFactoriesLoader
.loadFactories(DslPropertyConverter.class, null);
List<DslPropertyConverter> converters = SpringFactoriesLoader.loadFactories(DslPropertyConverter.class, null);
if (converters.isEmpty()) {
return DEFAULT;
}

View File

@@ -119,8 +119,7 @@ public class HandlebarsContractTemplate implements ContractTemplate {
@Override
public String escapedQuery(String key, int index) {
return escapedWrapped(
"request.query." + key + ".[" + String.valueOf(index) + "]");
return escapedWrapped("request.query." + key + ".[" + String.valueOf(index) + "]");
}
@Override
@@ -140,8 +139,7 @@ public class HandlebarsContractTemplate implements ContractTemplate {
@Override
public String escapedHeader(String key, int index) {
return escapedWrapped(
"request.headers." + key + ".[" + String.valueOf(index) + "]");
return escapedWrapped("request.headers." + key + ".[" + String.valueOf(index) + "]");
}
@Override

View File

@@ -38,8 +38,7 @@ public class Header extends DslProperty {
}
public Header(String name, Object value) {
super(ContractUtils.CLIENT_VALUE.apply(value),
ContractUtils.SERVER_VALUE.apply(value));
super(ContractUtils.CLIENT_VALUE.apply(value), ContractUtils.SERVER_VALUE.apply(value));
this.name = name;
}

View File

@@ -36,11 +36,11 @@ import java.util.regex.Pattern;
*/
public class Headers {
private static final BiFunction<String, Header, Object> CLIENT_SIDE = (s,
header) -> ContractUtils.convertStubSideRecursively(header);
private static final BiFunction<String, Header, Object> CLIENT_SIDE = (s, header) -> ContractUtils
.convertStubSideRecursively(header);
private static final BiFunction<String, Header, Object> SERVER_SIDE = (s,
header) -> ContractUtils.convertTestSideRecursively(header);
private static final BiFunction<String, Header, Object> SERVER_SIDE = (s, header) -> ContractUtils
.convertTestSideRecursively(header);
private Set<Header> entries = new LinkedHashSet<>();
@@ -95,8 +95,7 @@ public class Headers {
public Map<String, Object> asMap(final BiFunction<String, Header, Object> consumer) {
final Map<String, Object> map = new LinkedHashMap<>();
entries.forEach(header -> map.put(header.getName(),
consumer.apply(header.getName(), header)));
entries.forEach(header -> map.put(header.getName(), consumer.apply(header.getName(), header)));
return map;
}

View File

@@ -31,8 +31,7 @@ public final class HttpMethods {
private static final Log log = LogFactory.getLog(HttpMethods.class);
public HttpMethods() {
log.warn(
"WARNING: HttpMethods shouldn't be instantiated. Use its static methods instead.");
log.warn("WARNING: HttpMethods shouldn't be instantiated. Use its static methods instead.");
}
/**
@@ -149,10 +148,8 @@ public final class HttpMethods {
public enum HttpMethod {
GET(HttpMethods.GET), HEAD(HttpMethods.HEAD), POST(HttpMethods.POST), PUT(
HttpMethods.PUT), PATCH(HttpMethods.PATCH), DELETE(
HttpMethods.DELETE), OPTIONS(
HttpMethods.OPTIONS), TRACE(HttpMethods.TRACE),;
GET(HttpMethods.GET), HEAD(HttpMethods.HEAD), POST(HttpMethods.POST), PUT(HttpMethods.PUT), PATCH(
HttpMethods.PATCH), DELETE(HttpMethods.DELETE), OPTIONS(HttpMethods.OPTIONS), TRACE(HttpMethods.TRACE),;
private final String methodName;

View File

@@ -31,8 +31,7 @@ public final class HttpStatus {
private static final Log log = LogFactory.getLog(HttpStatus.class);
public HttpStatus() {
log.warn(
"WARNING: HttpStatus shouldn't be instantiated. Use its static methods instead.");
log.warn("WARNING: HttpStatus shouldn't be instantiated. Use its static methods instead.");
}
/**

View File

@@ -357,26 +357,22 @@ public class Input extends Common implements RegexCreatingProperty<ClientDslProp
return false;
}
Input input = (Input) o;
return Objects.equals(messageFrom, input.messageFrom)
&& Objects.equals(triggeredBy, input.triggeredBy)
return Objects.equals(messageFrom, input.messageFrom) && Objects.equals(triggeredBy, input.triggeredBy)
&& Objects.equals(messageHeaders, input.messageHeaders)
&& Objects.equals(messageBody, input.messageBody)
&& Objects.equals(assertThat, input.assertThat)
&& Objects.equals(messageBody, input.messageBody) && Objects.equals(assertThat, input.assertThat)
&& Objects.equals(bodyMatchers, input.bodyMatchers);
}
@Override
public int hashCode() {
return Objects.hash(messageFrom, triggeredBy, messageHeaders, messageBody,
assertThat, bodyMatchers);
return Objects.hash(messageFrom, triggeredBy, messageHeaders, messageBody, assertThat, bodyMatchers);
}
@Override
public String toString() {
return "Input{\n\tmessageFrom=" + messageFrom + ", \n\ttriggeredBy=" + triggeredBy
+ ", \n\tmessageHeaders=" + messageHeaders + ", \n\tmessageBody="
+ messageBody + ", \n\tassertThat=" + assertThat + ", \n\tbodyMatchers="
+ bodyMatchers + "} \n\t" + super.toString();
return "Input{\n\tmessageFrom=" + messageFrom + ", \n\ttriggeredBy=" + triggeredBy + ", \n\tmessageHeaders="
+ messageHeaders + ", \n\tmessageBody=" + messageBody + ", \n\tassertThat=" + assertThat
+ ", \n\tbodyMatchers=" + bodyMatchers + "} \n\t" + super.toString();
}
public static class BodyType extends DslProperty {
@@ -391,12 +387,10 @@ public class Input extends Common implements RegexCreatingProperty<ClientDslProp
}
private class ClientPatternValueDslProperty
extends PatternValueDslProperty<ClientDslProperty> {
private class ClientPatternValueDslProperty extends PatternValueDslProperty<ClientDslProperty> {
@Override
protected ClientDslProperty createProperty(Pattern pattern,
Object generatedValue) {
protected ClientDslProperty createProperty(Pattern pattern, Object generatedValue) {
return new ClientDslProperty(pattern, generatedValue);
}

View File

@@ -43,8 +43,7 @@ public class MatchingStrategy extends DslProperty {
this(value, type, null);
}
public MatchingStrategy(DslProperty value, Type type,
JSONCompareMode jsonCompareMode) {
public MatchingStrategy(DslProperty value, Type type, JSONCompareMode jsonCompareMode) {
super(value.getClientValue(), value.getServerValue());
this.type = type;
this.jsonCompareMode = jsonCompareMode;
@@ -68,8 +67,7 @@ public class MatchingStrategy extends DslProperty {
@Override
public String toString() {
return "MatchingStrategy{" + "type=" + type + ", jsonCompareMode="
+ jsonCompareMode + '}';
return "MatchingStrategy{" + "type=" + type + ", jsonCompareMode=" + jsonCompareMode + '}';
}
@Override

View File

@@ -62,8 +62,7 @@ public enum MatchingType {
NULL;
public static boolean regexRelated(MatchingType type) {
return !type.equals(EQUALITY) && !type.equals(TYPE) && !type.equals(COMMAND)
&& !type.equals(NULL);
return !type.equals(EQUALITY) && !type.equals(TYPE) && !type.equals(COMMAND) && !type.equals(NULL);
}
}

View File

@@ -58,8 +58,7 @@ public class MatchingTypeValue {
this.minTypeOccurrence = minTypeOccurrence;
}
MatchingTypeValue(MatchingType type, Object value, Integer minTypeOccurrence,
Integer maxTypeOccurrence) {
MatchingTypeValue(MatchingType type, Object value, Integer minTypeOccurrence, Integer maxTypeOccurrence) {
this.type = type;
this.value = value;
this.minTypeOccurrence = minTypeOccurrence;
@@ -119,9 +118,8 @@ public class MatchingTypeValue {
@Override
public String toString() {
return "MatchingTypeValue{" + "type=" + type + ", value=" + value
+ ", minTypeOccurrence=" + minTypeOccurrence + ", maxTypeOccurrence="
+ maxTypeOccurrence + '}';
return "MatchingTypeValue{" + "type=" + type + ", value=" + value + ", minTypeOccurrence=" + minTypeOccurrence
+ ", maxTypeOccurrence=" + maxTypeOccurrence + '}';
}
}

View File

@@ -31,8 +31,7 @@ public class MediaTypes {
private static final Log log = LogFactory.getLog(MediaTypes.class);
public MediaTypes() {
log.warn(
"WARNING: MediaTypes shouldn't be instantiated. Use its static methods instead.");
log.warn("WARNING: MediaTypes shouldn't be instantiated. Use its static methods instead.");
}
/**
@@ -58,8 +57,7 @@ public class MediaTypes {
/**
* Public constant for {@code application/json;charset=UTF-8}.
*/
public static final String APPLICATION_JSON_UTF8 = APPLICATION_JSON
+ ";charset=UTF-8";
public static final String APPLICATION_JSON_UTF8 = APPLICATION_JSON + ";charset=UTF-8";
/**
* Public constant for {@code application/octet-stream}.

View File

@@ -31,8 +31,7 @@ public class MessagingHeaders {
private static final Log log = LogFactory.getLog(MessagingHeaders.class);
public MessagingHeaders() {
log.warn(
"WARNING: MessagingHeaders shouldn't be instantiated. Use its static methods instead.");
log.warn("WARNING: MessagingHeaders shouldn't be instantiated. Use its static methods instead.");
}
/**

View File

@@ -25,20 +25,16 @@ import java.util.stream.Collectors;
public class Multipart extends DslProperty {
public Multipart(Map<String, DslProperty> multipart) {
super(extractValue(multipart, ContractUtils.CLIENT_VALUE),
extractValue(multipart, ContractUtils.SERVER_VALUE));
super(extractValue(multipart, ContractUtils.CLIENT_VALUE), extractValue(multipart, ContractUtils.SERVER_VALUE));
}
public Multipart(List<DslProperty> multipartAsList) {
super(multipartAsList.stream().map(DslProperty::getClientValue)
.collect(Collectors.toList()),
multipartAsList.stream().map(DslProperty::getServerValue)
.collect(Collectors.toList()));
super(multipartAsList.stream().map(DslProperty::getClientValue).collect(Collectors.toList()),
multipartAsList.stream().map(DslProperty::getServerValue).collect(Collectors.toList()));
}
public Multipart(Object value) {
super(ContractUtils.CLIENT_VALUE.apply(value),
ContractUtils.SERVER_VALUE.apply(value));
super(ContractUtils.CLIENT_VALUE.apply(value), ContractUtils.SERVER_VALUE.apply(value));
}
public Multipart(DslProperty multipartAsValue) {
@@ -56,11 +52,9 @@ public class Multipart extends DslProperty {
return new Multipart(value);
}
private static Map<String, Object> extractValue(Map<String, DslProperty> multipart,
final Function valueProvider) {
private static Map<String, Object> extractValue(Map<String, DslProperty> multipart, final Function valueProvider) {
final Map<String, Object> map = new LinkedHashMap<String, Object>();
multipart.forEach(
(s, dslProperty) -> map.put(s, valueProvider.apply(dslProperty)));
multipart.forEach((s, dslProperty) -> map.put(s, valueProvider.apply(dslProperty)));
return map;
}

View File

@@ -51,8 +51,7 @@ public class NamedProperty {
}
public NamedProperty(Map<String, DslProperty> namedMap) {
this(asDslProperty(value(namedMap, NAME)),
asDslProperty(value(namedMap, CONTENT)),
this(asDslProperty(value(namedMap, NAME)), asDslProperty(value(namedMap, CONTENT)),
asDslProperty(value(namedMap, CONTENT_TYPE)));
}
@@ -120,8 +119,7 @@ public class NamedProperty {
@Override
public String toString() {
return "NamedProperty{" + "name=" + name + ", value=" + value + ", contentType="
+ contentType + '}';
return "NamedProperty{" + "name=" + name + ", value=" + value + ", contentType=" + contentType + '}';
}
}

View File

@@ -33,8 +33,7 @@ import org.apache.commons.logging.LogFactory;
* @author Tim Ysewyn
* @since 1.0.0
*/
public class OutputMessage extends Common
implements RegexCreatingProperty<ServerDslProperty> {
public class OutputMessage extends Common implements RegexCreatingProperty<ServerDslProperty> {
private static final Log log = LogFactory.getLog(OutputMessage.class);
@@ -86,8 +85,7 @@ public class OutputMessage extends Common
*/
@Deprecated
public DslProperty value(ClientDslProperty clientDslProperty) {
return value(new ServerDslProperty(clientDslProperty.getServerValue(),
clientDslProperty.getClientValue()));
return value(new ServerDslProperty(clientDslProperty.getServerValue(), clientDslProperty.getClientValue()));
}
public DslProperty value(ServerDslProperty serverDslProperty) {
@@ -361,10 +359,8 @@ public class OutputMessage extends Common
return false;
}
OutputMessage that = (OutputMessage) o;
return Objects.equals(sentTo, that.sentTo)
&& Objects.equals(headers, that.headers)
&& Objects.equals(body, that.body)
&& Objects.equals(assertThat, that.assertThat)
return Objects.equals(sentTo, that.sentTo) && Objects.equals(headers, that.headers)
&& Objects.equals(body, that.body) && Objects.equals(assertThat, that.assertThat)
&& Objects.equals(bodyMatchers, that.bodyMatchers);
}
@@ -375,17 +371,14 @@ public class OutputMessage extends Common
@Override
public String toString() {
return "OutputMessage{" + "\n\tsentTo=" + sentTo + ", \n\theaders=" + headers
+ ", \n\tbody=" + body + ", \n\tassertThat=" + assertThat
+ ", \n\tbodyMatchers=" + bodyMatchers + "} \n\t" + super.toString();
return "OutputMessage{" + "\n\tsentTo=" + sentTo + ", \n\theaders=" + headers + ", \n\tbody=" + body
+ ", \n\tassertThat=" + assertThat + ", \n\tbodyMatchers=" + bodyMatchers + "} \n\t" + super.toString();
}
private class ServerPatternValueDslProperty
extends PatternValueDslProperty<ServerDslProperty> {
private class ServerPatternValueDslProperty extends PatternValueDslProperty<ServerDslProperty> {
@Override
protected ServerDslProperty createProperty(Pattern pattern,
Object generatedValue) {
protected ServerDslProperty createProperty(Pattern pattern, Object generatedValue) {
return new ServerDslProperty(pattern, generatedValue);
}

View File

@@ -66,8 +66,7 @@ public class PathBodyMatcher implements BodyMatcher {
return false;
}
PathBodyMatcher that = (PathBodyMatcher) o;
return Objects.equals(path, that.path)
&& Objects.equals(matchingTypeValue, that.matchingTypeValue);
return Objects.equals(path, that.path) && Objects.equals(matchingTypeValue, that.matchingTypeValue);
}
@Override
@@ -77,8 +76,7 @@ public class PathBodyMatcher implements BodyMatcher {
@Override
public String toString() {
return "PathBodyMatcher{" + "path='" + path + '\'' + ", matchingTypeValue="
+ matchingTypeValue + '}';
return "PathBodyMatcher{" + "path='" + path + '\'' + ", matchingTypeValue=" + matchingTypeValue + '}';
}
}

View File

@@ -26,8 +26,7 @@ import org.apache.commons.lang3.RandomStringUtils;
* @author Marcin Grzejszczak
* @author Tim Ysewyn
*/
abstract class PatternValueDslProperty<T extends DslProperty>
implements RegexCreatingProperty<T> {
abstract class PatternValueDslProperty<T extends DslProperty> implements RegexCreatingProperty<T> {
private final Random random = new Random();
@@ -61,14 +60,12 @@ abstract class PatternValueDslProperty<T extends DslProperty>
@Override
public T anyAlphaUnicode() {
return createAndValidateProperty(RegexPatterns.ONLY_ALPHA_UNICODE,
RandomStringGenerator.randomString(20));
return createAndValidateProperty(RegexPatterns.ONLY_ALPHA_UNICODE, RandomStringGenerator.randomString(20));
}
@Override
public T anyAlphaNumeric() {
return createAndValidateProperty(RegexPatterns.ALPHA_NUMERIC,
RandomStringUtils.randomAlphanumeric(20));
return createAndValidateProperty(RegexPatterns.ALPHA_NUMERIC, RandomStringUtils.randomAlphanumeric(20));
}
@Override
@@ -83,20 +80,17 @@ abstract class PatternValueDslProperty<T extends DslProperty>
@Override
public T anyPositiveInt() {
return createAndValidateProperty(RegexPatterns.POSITIVE_INT,
Math.abs(this.random.nextInt() + 1));
return createAndValidateProperty(RegexPatterns.POSITIVE_INT, Math.abs(this.random.nextInt() + 1));
}
@Override
public T anyDouble() {
return createAndValidateProperty(RegexPatterns.DOUBLE,
this.random.nextInt(100) + this.random.nextDouble());
return createAndValidateProperty(RegexPatterns.DOUBLE, this.random.nextInt(100) + this.random.nextDouble());
}
@Override
public T anyHex() {
return createAndValidateProperty(RegexPatterns.HEX,
RandomStringUtils.random(10, "0123456789abcdef"));
return createAndValidateProperty(RegexPatterns.HEX, RandomStringUtils.random(10, "0123456789abcdef"));
}
@Override
@@ -106,8 +100,7 @@ abstract class PatternValueDslProperty<T extends DslProperty>
@Override
public T anyIpAddress() {
return createAndValidateProperty(RegexPatterns.IP_ADDRESS,
"192.168.0." + this.random.nextInt(10));
return createAndValidateProperty(RegexPatterns.IP_ADDRESS, "192.168.0." + this.random.nextInt(10));
}
@Override
@@ -118,68 +111,59 @@ abstract class PatternValueDslProperty<T extends DslProperty>
@Override
public T anyEmail() {
return createAndValidateProperty(RegexPatterns.EMAIL,
"foo@bar" + this.random.nextInt() + ".com");
return createAndValidateProperty(RegexPatterns.EMAIL, "foo@bar" + this.random.nextInt() + ".com");
}
@Override
public T anyUrl() {
return createAndValidateProperty(RegexPatterns.URL,
"https://foo" + this.random.nextInt() + ".com");
return createAndValidateProperty(RegexPatterns.URL, "https://foo" + this.random.nextInt() + ".com");
}
@Override
public T anyHttpsUrl() {
return createAndValidateProperty(RegexPatterns.HTTPS_URL,
"https://baz" + this.random.nextInt() + ".com");
return createAndValidateProperty(RegexPatterns.HTTPS_URL, "https://baz" + this.random.nextInt() + ".com");
}
@Override
public T anyUuid() {
return createAndValidateProperty(RegexPatterns.UUID,
UUID.randomUUID().toString());
return createAndValidateProperty(RegexPatterns.UUID, UUID.randomUUID().toString());
}
@Override
public T anyDate() {
int d = this.random.nextInt(8) + 1;
return createAndValidateProperty(RegexPatterns.ANY_DATE, "201" + String.valueOf(d)
+ "-0" + String.valueOf(d) + "-1" + String.valueOf(d));
return createAndValidateProperty(RegexPatterns.ANY_DATE,
"201" + String.valueOf(d) + "-0" + String.valueOf(d) + "-1" + String.valueOf(d));
}
@Override
public T anyDateTime() {
final int d = this.random.nextInt(8) + 1;
return createAndValidateProperty(RegexPatterns.ANY_DATE_TIME,
"201" + String.valueOf(d) + "-0" + String.valueOf(d) + "-1"
+ String.valueOf(d) + "T12:23:34");
"201" + String.valueOf(d) + "-0" + String.valueOf(d) + "-1" + String.valueOf(d) + "T12:23:34");
}
@Override
public T anyTime() {
int d = this.random.nextInt(9);
return createAndValidateProperty(RegexPatterns.ANY_TIME,
"12:2" + String.valueOf(d) + ":3" + String.valueOf(d));
return createAndValidateProperty(RegexPatterns.ANY_TIME, "12:2" + String.valueOf(d) + ":3" + String.valueOf(d));
}
@Override
public T anyIso8601WithOffset() {
final int d = this.random.nextInt(8) + 1;
return createAndValidateProperty(RegexPatterns.ISO8601_WITH_OFFSET,
"201" + String.valueOf(d) + "-0" + String.valueOf(d) + "-1"
+ String.valueOf(d) + "T12:23:34.123Z");
"201" + String.valueOf(d) + "-0" + String.valueOf(d) + "-1" + String.valueOf(d) + "T12:23:34.123Z");
}
@Override
public T anyNonBlankString() {
return createAndValidateProperty(RegexPatterns.NON_BLANK,
RandomStringGenerator.randomString(20));
return createAndValidateProperty(RegexPatterns.NON_BLANK, RandomStringGenerator.randomString(20));
}
@Override
public T anyNonEmptyString() {
return createAndValidateProperty(RegexPatterns.NON_EMPTY,
RandomStringGenerator.randomString(20));
return createAndValidateProperty(RegexPatterns.NON_EMPTY, RandomStringGenerator.randomString(20));
}
@Override

View File

@@ -31,23 +31,19 @@ public class QueryParameter extends DslProperty {
public QueryParameter(String name, DslProperty dslProperty) {
super(dslProperty.getClientValue(), dslProperty.getServerValue());
ValidateUtils.validateServerValueIsAvailable(dslProperty.getServerValue(),
"Query parameter \'" + name + "\'");
ValidateUtils.validateServerValueIsAvailable(dslProperty.getServerValue(), "Query parameter \'" + name + "\'");
this.name = name;
}
public QueryParameter(String name, MatchingStrategy matchingStrategy) {
super(matchingStrategy);
ValidateUtils.validateServerValueIsAvailable(matchingStrategy,
"Query parameter \'" + name + "\'");
ValidateUtils.validateServerValueIsAvailable(matchingStrategy, "Query parameter \'" + name + "\'");
this.name = name;
}
public QueryParameter(String name, Object value) {
super(ContractUtils.CLIENT_VALUE.apply(value),
ContractUtils.SERVER_VALUE.apply(value));
ValidateUtils.validateServerValueIsAvailable(value,
"Query parameter \'" + name + "\'");
super(ContractUtils.CLIENT_VALUE.apply(value), ContractUtils.SERVER_VALUE.apply(value));
ValidateUtils.validateServerValueIsAvailable(value, "Query parameter \'" + name + "\'");
this.name = name;
}
@@ -56,8 +52,7 @@ public class QueryParameter extends DslProperty {
return new QueryParameter(key, (MatchingStrategy) value);
}
else if (value instanceof RegexProperty) {
return new QueryParameter(key,
((RegexProperty) value).dynamicClientEscapedConcreteProducer());
return new QueryParameter(key, ((RegexProperty) value).dynamicClientEscapedConcreteProducer());
}
return new QueryParameter(key, value);
}
@@ -92,8 +87,7 @@ public class QueryParameter extends DslProperty {
@Override
public String toString() {
return "QueryParameter{" + "name='" + name + '\'' + ", value=" + super.toString()
+ '}';
return "QueryParameter{" + "name='" + name + '\'' + ", value=" + super.toString() + '}';
}
}

View File

@@ -27,8 +27,7 @@ public class QueryParameters {
private List<QueryParameter> parameters = new LinkedList<QueryParameter>();
public void parameter(Map<String, Object> singleParameter) {
Iterator<Map.Entry<String, Object>> iterator = singleParameter.entrySet()
.iterator();
Iterator<Map.Entry<String, Object>> iterator = singleParameter.entrySet().iterator();
if (iterator.hasNext()) {
Map.Entry<String, Object> first = iterator.next();
if (first != null) {

View File

@@ -21,8 +21,7 @@ package org.springframework.cloud.contract.spec.internal;
*/
public class RegexMatchingTypeValue extends MatchingTypeValue {
RegexMatchingTypeValue(MatchingType type, Object value, Integer minTypeOccurrence,
Integer maxTypeOccurrence) {
RegexMatchingTypeValue(MatchingType type, Object value, Integer minTypeOccurrence, Integer maxTypeOccurrence) {
super(type, value, minTypeOccurrence, maxTypeOccurrence);
}
@@ -40,8 +39,7 @@ public class RegexMatchingTypeValue extends MatchingTypeValue {
}
RegexProperty regexProperty = (RegexProperty) this.getValue();
return new RegexMatchingTypeValue(this.getType(),
new RegexProperty(regexProperty.getClientValue(),
regexProperty.getServerValue(), clazz),
new RegexProperty(regexProperty.getClientValue(), regexProperty.getServerValue(), clazz),
this.getMinTypeOccurrence(), this.getMaxTypeOccurrence());
}

View File

@@ -35,8 +35,7 @@ public final class RegexPatterns {
private static final Log log = LogFactory.getLog(RegexPatterns.class);
public RegexPatterns() {
log.warn(
"WARNING: RegexPatterns shouldn't be instantiated. Use its static methods instead.");
log.warn("WARNING: RegexPatterns shouldn't be instantiated. Use its static methods instead.");
}
protected static final Pattern TRUE_OR_FALSE = Pattern.compile("(true|false)");
@@ -58,11 +57,9 @@ public final class RegexPatterns {
protected static final Pattern IP_ADDRESS = Pattern.compile(
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])");
protected static final Pattern HOSTNAME_PATTERN = Pattern
.compile("((http[s]?|ftp):/)/?([^:/\\s]+)(:[0-9]{1,5})?");
protected static final Pattern HOSTNAME_PATTERN = Pattern.compile("((http[s]?|ftp):/)/?([^:/\\s]+)(:[0-9]{1,5})?");
protected static final Pattern EMAIL = Pattern
.compile("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}");
protected static final Pattern EMAIL = Pattern.compile("[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}");
protected static final Pattern URL = UrlHelper.URL;
@@ -77,8 +74,7 @@ public final class RegexPatterns {
protected static final Pattern ANY_DATE_TIME = Pattern.compile(
"([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])");
protected static final Pattern ANY_TIME = Pattern
.compile("(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])");
protected static final Pattern ANY_TIME = Pattern.compile("(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])");
protected static final Pattern NON_EMPTY = Pattern.compile("[\\S\\s]+");
@@ -88,8 +84,7 @@ public final class RegexPatterns {
"([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\.\\d+)?(Z|[+-][01]\\d:[0-5]\\d)");
protected static Pattern anyOf(String... values) {
return Pattern.compile(Arrays.stream(values).map(it -> '^' + it + '$')
.collect(Collectors.joining("|")));
return Pattern.compile(Arrays.stream(values).map(it -> '^' + it + '$').collect(Collectors.joining("|")));
}
public static String multipartParam(Object name, Object value) {
@@ -98,13 +93,10 @@ public final class RegexPatterns {
+ value + "\r\n--\\1.*";
}
public static String multipartFile(Object name, Object filename, Object content,
Object contentType) {
return ".*--(.*)\r\nContent-Disposition: form-data; name=\"" + name
+ "\"; filename=\"" + filename + "\"\r\n(Content-Type: "
+ toContentType(contentType)
+ "\r\n)?(Content-Transfer-Encoding: .*\r\n)?(Content-Length: \\d+\r\n)?\r\n"
+ content + "\r\n--\\1.*";
public static String multipartFile(Object name, Object filename, Object content, Object contentType) {
return ".*--(.*)\r\nContent-Disposition: form-data; name=\"" + name + "\"; filename=\"" + filename
+ "\"\r\n(Content-Type: " + toContentType(contentType)
+ "\r\n)?(Content-Transfer-Encoding: .*\r\n)?(Content-Length: \\d+\r\n)?\r\n" + content + "\r\n--\\1.*";
}
private static String toContentType(Object contentType) {

View File

@@ -44,10 +44,8 @@ public class RegexProperty extends DslProperty implements CanBeDynamic {
public RegexProperty(Object client, Object server, Class clazz) {
super(client, server);
boolean clientDynamic = client instanceof Pattern
|| client instanceof RegexProperty;
boolean serverDynamic = server instanceof Pattern
|| server instanceof RegexProperty;
boolean clientDynamic = client instanceof Pattern || client instanceof RegexProperty;
boolean serverDynamic = server instanceof Pattern || server instanceof RegexProperty;
if (!clientDynamic && !serverDynamic) {
throw new IllegalStateException("Neither client not server side is dynamic");
}
@@ -80,38 +78,31 @@ public class RegexProperty extends DslProperty implements CanBeDynamic {
}
public RegexProperty asInteger() {
return new RegexProperty(this.getClientValue(), this.getServerValue(),
Integer.class);
return new RegexProperty(this.getClientValue(), this.getServerValue(), Integer.class);
}
public RegexProperty asDouble() {
return new RegexProperty(this.getClientValue(), this.getServerValue(),
Double.class);
return new RegexProperty(this.getClientValue(), this.getServerValue(), Double.class);
}
public RegexProperty asFloat() {
return new RegexProperty(this.getClientValue(), this.getServerValue(),
Float.class);
return new RegexProperty(this.getClientValue(), this.getServerValue(), Float.class);
}
public RegexProperty asLong() {
return new RegexProperty(this.getClientValue(), this.getServerValue(),
Long.class);
return new RegexProperty(this.getClientValue(), this.getServerValue(), Long.class);
}
public RegexProperty asShort() {
return new RegexProperty(this.getClientValue(), this.getServerValue(),
Short.class);
return new RegexProperty(this.getClientValue(), this.getServerValue(), Short.class);
}
public RegexProperty asString() {
return new RegexProperty(this.getClientValue(), this.getServerValue(),
String.class);
return new RegexProperty(this.getClientValue(), this.getServerValue(), String.class);
}
public RegexProperty asBooleanType() {
return new RegexProperty(this.getClientValue(), this.getServerValue(),
Boolean.class);
return new RegexProperty(this.getClientValue(), this.getServerValue(), Boolean.class);
}
public Object generate() {
@@ -171,13 +162,11 @@ public class RegexProperty extends DslProperty implements CanBeDynamic {
}
public RegexProperty concreteClientEscapedDynamicProducer() {
return new RegexProperty(generateAndEscapeJavaStringIfNeeded(), this.pattern,
this.clazz);
return new RegexProperty(generateAndEscapeJavaStringIfNeeded(), this.pattern, this.clazz);
}
public RegexProperty dynamicClientEscapedConcreteProducer() {
return new RegexProperty(this.pattern, generateAndEscapeJavaStringIfNeeded(),
this.clazz);
return new RegexProperty(this.pattern, generateAndEscapeJavaStringIfNeeded(), this.clazz);
}
@Override
@@ -189,8 +178,7 @@ public class RegexProperty extends DslProperty implements CanBeDynamic {
return false;
}
RegexProperty that = (RegexProperty) o;
return Objects.equals(stringPatternIfPresent(pattern),
stringPatternIfPresent(that.pattern))
return Objects.equals(stringPatternIfPresent(pattern), stringPatternIfPresent(that.pattern))
&& Objects.equals(clazz, that.clazz);
}

View File

@@ -277,8 +277,7 @@ public class Request extends Common implements RegexCreatingProperty<ClientDslPr
@Override
public void assertThatSidesMatch(Object stubSide, Object testSide) {
if (testSide instanceof OptionalProperty) {
throw new IllegalStateException(
"Optional can be used only for the stub side of the request!");
throw new IllegalStateException("Optional can be used only for the stub side of the request!");
}
super.assertThatSidesMatch(stubSide, testSide);
}
@@ -360,8 +359,7 @@ public class Request extends Common implements RegexCreatingProperty<ClientDslPr
@Override
public DslProperty value(ClientDslProperty client, ServerDslProperty server) {
if (server.getClientValue() instanceof RegexProperty) {
throw new IllegalStateException(
"You can't have a regular expression for the request on the server side");
throw new IllegalStateException("You can't have a regular expression for the request on the server side");
}
return super.value(client, server);
}
@@ -375,8 +373,7 @@ public class Request extends Common implements RegexCreatingProperty<ClientDslPr
@Override
public DslProperty value(ServerDslProperty server, ClientDslProperty client) {
if (server.getClientValue() instanceof RegexProperty) {
throw new IllegalStateException(
"You can't have a regular expression for the request on the server side");
throw new IllegalStateException("You can't have a regular expression for the request on the server side");
}
return super.value(server, client);
@@ -593,25 +590,20 @@ public class Request extends Common implements RegexCreatingProperty<ClientDslPr
}
Request request = (Request) o;
return Objects.equals(method, request.method) && Objects.equals(url, request.url)
&& Objects.equals(urlPath, request.urlPath)
&& Objects.equals(headers, request.headers)
&& Objects.equals(cookies, request.cookies)
&& Objects.equals(body, request.body)
&& Objects.equals(multipart, request.multipart)
&& Objects.equals(bodyMatchers, request.bodyMatchers);
&& Objects.equals(urlPath, request.urlPath) && Objects.equals(headers, request.headers)
&& Objects.equals(cookies, request.cookies) && Objects.equals(body, request.body)
&& Objects.equals(multipart, request.multipart) && Objects.equals(bodyMatchers, request.bodyMatchers);
}
@Override
public int hashCode() {
return Objects.hash(method, url, urlPath, headers, cookies, body, multipart,
bodyMatchers);
return Objects.hash(method, url, urlPath, headers, cookies, body, multipart, bodyMatchers);
}
@Override
public String toString() {
return "Request{" + "\nmethod=" + method + ", \n\turl=" + url + ", \n\turlPath="
+ urlPath + ", \n\theaders=" + headers + ", \n\tcookies=" + cookies
+ ", \n\tbody=" + body + ", \n\tmultipart=" + multipart
return "Request{" + "\nmethod=" + method + ", \n\turl=" + url + ", \n\turlPath=" + urlPath + ", \n\theaders="
+ headers + ", \n\tcookies=" + cookies + ", \n\tbody=" + body + ", \n\tmultipart=" + multipart
+ ", \n\tbodyMatchers=" + bodyMatchers + '}';
}
@@ -790,8 +782,8 @@ public class Request extends Common implements RegexCreatingProperty<ClientDslPr
@Override
public DslProperty matching(String value) {
return this.common.$(this.common.c(this.common
.regex(RegexpUtils.escapeSpecialRegexWithSingleEscape(value) + ".*")),
return this.common.$(
this.common.c(this.common.regex(RegexpUtils.escapeSpecialRegexWithSingleEscape(value) + ".*")),
this.common.p(value));
}
@@ -803,8 +795,8 @@ public class Request extends Common implements RegexCreatingProperty<ClientDslPr
@Override
public DslProperty matching(String value) {
return this.common.$(this.common.c(this.common
.regex(RegexpUtils.escapeSpecialRegexWithSingleEscape(value) + ".*")),
return this.common.$(
this.common.c(this.common.regex(RegexpUtils.escapeSpecialRegexWithSingleEscape(value) + ".*")),
this.common.p(value));
}
@@ -826,12 +818,10 @@ public class Request extends Common implements RegexCreatingProperty<ClientDslPr
}
private class ClientPatternValueDslProperty
extends PatternValueDslProperty<ClientDslProperty> {
private class ClientPatternValueDslProperty extends PatternValueDslProperty<ClientDslProperty> {
@Override
protected ClientDslProperty createProperty(Pattern pattern,
Object generatedValue) {
protected ClientDslProperty createProperty(Pattern pattern, Object generatedValue) {
return new ClientDslProperty(pattern, generatedValue);
}

View File

@@ -131,8 +131,7 @@ public class Response extends Common implements RegexCreatingProperty<ServerDslP
@Override
public void assertThatSidesMatch(Object stubSide, Object testSide) {
if (stubSide instanceof OptionalProperty) {
throw new IllegalStateException(
"Optional can be used only in the test side of the response!");
throw new IllegalStateException("Optional can be used only in the test side of the response!");
}
super.assertThatSidesMatch(stubSide, testSide);
}
@@ -218,8 +217,7 @@ public class Response extends Common implements RegexCreatingProperty<ServerDslP
@Override
public DslProperty value(ClientDslProperty client, ServerDslProperty server) {
if (client.getClientValue() instanceof RegexProperty) {
throw new IllegalStateException(
"You can't have a regular expression for the response on the client side");
throw new IllegalStateException("You can't have a regular expression for the response on the client side");
}
return super.value(client, server);
@@ -234,8 +232,7 @@ public class Response extends Common implements RegexCreatingProperty<ServerDslP
@Override
public DslProperty value(ServerDslProperty server, ClientDslProperty client) {
if (client.getClientValue() instanceof RegexProperty) {
throw new IllegalStateException(
"You can't have a regular expression for the response on the client side");
throw new IllegalStateException("You can't have a regular expression for the response on the client side");
}
return super.value(server, client);
@@ -699,10 +696,8 @@ public class Response extends Common implements RegexCreatingProperty<ServerDslP
}
Response response = (Response) o;
return async == response.async && Objects.equals(status, response.status)
&& Objects.equals(delay, response.delay)
&& Objects.equals(headers, response.headers)
&& Objects.equals(cookies, response.cookies)
&& Objects.equals(body, response.body)
&& Objects.equals(delay, response.delay) && Objects.equals(headers, response.headers)
&& Objects.equals(cookies, response.cookies) && Objects.equals(body, response.body)
&& Objects.equals(bodyMatchers, response.bodyMatchers);
}
@@ -713,10 +708,9 @@ public class Response extends Common implements RegexCreatingProperty<ServerDslP
@Override
public String toString() {
return "Response{" + "\nstatus=" + status + ", \n\tdelay=" + delay
+ ", \n\theaders=" + headers + ", \n\tcookies=" + cookies + ", \n\tbody="
+ body + ", \n\tasync=" + async + ", \n\tbodyMatchers=" + bodyMatchers
+ '}';
return "Response{" + "\nstatus=" + status + ", \n\tdelay=" + delay + ", \n\theaders=" + headers
+ ", \n\tcookies=" + cookies + ", \n\tbody=" + body + ", \n\tasync=" + async + ", \n\tbodyMatchers="
+ bodyMatchers + '}';
}
/**
@@ -804,8 +798,9 @@ public class Response extends Common implements RegexCreatingProperty<ServerDslP
@Override
public DslProperty matching(final String value) {
return this.common.$(this.common.p(notEscaped(Pattern.compile(
RegexpUtils.escapeSpecialRegexWithSingleEscape(value) + ".*"))),
return this.common.$(
this.common.p(
notEscaped(Pattern.compile(RegexpUtils.escapeSpecialRegexWithSingleEscape(value) + ".*"))),
this.common.c(value));
}
@@ -817,8 +812,8 @@ public class Response extends Common implements RegexCreatingProperty<ServerDslP
@Override
public DslProperty matching(final String value) {
return this.common.$(this.common.p(this.common
.regex(RegexpUtils.escapeSpecialRegexWithSingleEscape(value) + ".*")),
return this.common.$(
this.common.p(this.common.regex(RegexpUtils.escapeSpecialRegexWithSingleEscape(value) + ".*")),
this.common.c(value));
}
@@ -840,12 +835,10 @@ public class Response extends Common implements RegexCreatingProperty<ServerDslP
}
private class ServerPatternValueDslProperty
extends PatternValueDslProperty<ServerDslProperty> {
private class ServerPatternValueDslProperty extends PatternValueDslProperty<ServerDslProperty> {
@Override
protected ServerDslProperty createProperty(Pattern pattern,
Object generatedValue) {
protected ServerDslProperty createProperty(Pattern pattern, Object generatedValue) {
return new ServerDslProperty(pattern, generatedValue);
}

View File

@@ -78,8 +78,7 @@ public class Url extends DslProperty {
@Override
public String toString() {
return "Url{" + "\nqueryParameters=" + queryParameters + "} \n"
+ super.toString();
return "Url{" + "\nqueryParameters=" + queryParameters + "} \n" + super.toString();
}
/**

View File

@@ -39,8 +39,8 @@ final class UrlHelper {
private static final String REGEX_USERINFO = "(?:\\S+(?::\\S*)?@)?";
private static final String REGEX_HOST = "(?:"
+ "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
+ "|" + "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)"
+ "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" + "|"
+ "(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)"
+ "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*"
+ "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))|(?:localhost))";
@@ -48,13 +48,11 @@ final class UrlHelper {
private static final String REGEX_RESOURCE_PATH = "(?:/\\S*)?";
protected static final Pattern HTTPS_URL = Pattern.compile(
"^(?:" + HTTPS_REGEX_SCHEME + REGEX_AUTHORATIVE_DECLARATION + REGEX_USERINFO
+ REGEX_HOST + REGEX_PORT + REGEX_RESOURCE_PATH + ")$");
protected static final Pattern HTTPS_URL = Pattern.compile("^(?:" + HTTPS_REGEX_SCHEME
+ REGEX_AUTHORATIVE_DECLARATION + REGEX_USERINFO + REGEX_HOST + REGEX_PORT + REGEX_RESOURCE_PATH + ")$");
protected static final Pattern URL = Pattern.compile("^(?:(?:" + REGEX_SCHEME
+ REGEX_AUTHORATIVE_DECLARATION + ")?" + REGEX_USERINFO + REGEX_HOST
+ REGEX_PORT + REGEX_RESOURCE_PATH + ")$");
protected static final Pattern URL = Pattern.compile("^(?:(?:" + REGEX_SCHEME + REGEX_AUTHORATIVE_DECLARATION + ")?"
+ REGEX_USERINFO + REGEX_HOST + REGEX_PORT + REGEX_RESOURCE_PATH + ")$");
private UrlHelper() {
throw new IllegalStateException("Can't instantiate an utility class");

View File

@@ -37,7 +37,6 @@ public final class RegexpUtils {
return SPECIAL_REGEX_CHARS.matcher(str).replaceAll("\\\\$0");
}
private static final Pattern SPECIAL_REGEX_CHARS = Pattern
.compile("[{}()\\[\\].+*?^$\\\\|]");
private static final Pattern SPECIAL_REGEX_CHARS = Pattern.compile("[{}()\\[\\].+*?^$\\\\|]");
}

View File

@@ -73,12 +73,10 @@ public final class ValidateUtils {
throw new IllegalStateException(msg + " can\'t be a pattern for the server side");
}
public static void validateServerValue(MatchingStrategy matchingStrategy,
String msg) {
public static void validateServerValue(MatchingStrategy matchingStrategy, String msg) {
if (!ALLOWED_MATCHING_TYPES_ON_SERVER_SIDE.contains(matchingStrategy.getType())) {
throw new IllegalStateException(msg + " can\'t be of a matching type: "
+ String.valueOf(matchingStrategy.getType())
+ " for the server side");
+ String.valueOf(matchingStrategy.getType()) + " for the server side");
}
validateServerValue(matchingStrategy.getServerValue(), msg);

View File

@@ -63,10 +63,8 @@ public class Xeger {
.replace("\\s", "[ \t\r\n]"); // Used s="White"Space
this.automaton = new RegExp(pattern).toAutomaton();
this.random = random;
String generatedCharsSysProp = System
.getProperty("springCloudContractGeneratedCharsFromRegex");
String generatedCharsEnvVar = System
.getenv("SPRING_CLOUD_CONTRACT_GENERATED_CHARS_FROM_REGEX");
String generatedCharsSysProp = System.getProperty("springCloudContractGeneratedCharsFromRegex");
String generatedCharsEnvVar = System.getenv("SPRING_CLOUD_CONTRACT_GENERATED_CHARS_FROM_REGEX");
if (StringUtils.isNotEmpty(generatedCharsSysProp)) {
ITERATION_LIMIT = Integer.parseInt(generatedCharsSysProp);
}
@@ -130,8 +128,7 @@ public class Xeger {
}
private void appendChoice(StringBuilder builder, Transition transition) {
char c = (char) Xeger.getRandomInt(transition.getMin(), transition.getMax(),
this.random);
char c = (char) Xeger.getRandomInt(transition.getMin(), transition.getMax(), this.random);
builder.append(c);
}