diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/BodyMatchers.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/BodyMatchers.java index 1035394a17..c65bb62f88 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/BodyMatchers.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/BodyMatchers.java @@ -30,14 +30,13 @@ import groovy.lang.DelegatesTo; * * @author Marcin Grzejszczak * @author Olga Maciaszek-Sharma + * @author Tim Ysewyn * @since 1.0.3 */ public class BodyMatchers { protected final List matchers = new LinkedList<>(); - private final RegexPatterns regexPatterns = new RegexPatterns(); - public void jsonPath(String path, MatchingTypeValue matchingType) { this.matchers.add(new PathBodyMatcher(path, matchingType)); } @@ -71,16 +70,15 @@ public class BodyMatchers { } public MatchingTypeValue byDate() { - return new MatchingTypeValue(MatchingType.DATE, this.regexPatterns.isoDate()); + return new MatchingTypeValue(MatchingType.DATE, RegexPatterns.isoDate()); } public MatchingTypeValue byTime() { - return new MatchingTypeValue(MatchingType.TIME, this.regexPatterns.isoTime()); + return new MatchingTypeValue(MatchingType.TIME, RegexPatterns.isoTime()); } public MatchingTypeValue byTimestamp() { - return new MatchingTypeValue(MatchingType.TIMESTAMP, - this.regexPatterns.isoDateTime()); + return new MatchingTypeValue(MatchingType.TIMESTAMP, RegexPatterns.isoDateTime()); } public RegexMatchingTypeValue byRegex(String regex) { diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Common.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Common.java index 32a9acc6a1..b0e22c6be7 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Common.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Common.java @@ -32,12 +32,13 @@ import java.util.stream.Collectors; /** * Contains useful common methods for the DSL. * + * @author Marcin Grzejszczak + * @author Olga Maciaszek-Sharma + * @author Tim Ysewyn * @since 1.0.0 */ public class Common { - private final RegexPatterns regexPatterns = new RegexPatterns(); - public Map convertObjectsToDslProperties( Map body) { return body.entrySet().stream().collect(Collectors.toMap( @@ -324,79 +325,79 @@ public class Common { } public RegexProperty onlyAlphaUnicode() { - return regexPatterns.onlyAlphaUnicode(); + return RegexPatterns.onlyAlphaUnicode(); } public RegexProperty alphaNumeric() { - return regexPatterns.alphaNumeric(); + return RegexPatterns.alphaNumeric(); } public RegexProperty number() { - return regexPatterns.number(); + return RegexPatterns.number(); } public RegexProperty positiveInt() { - return regexPatterns.positiveInt(); + return RegexPatterns.positiveInt(); } public RegexProperty anyBoolean() { - return regexPatterns.anyBoolean(); + return RegexPatterns.anyBoolean(); } public RegexProperty anInteger() { - return regexPatterns.anInteger(); + return RegexPatterns.anInteger(); } public RegexProperty aDouble() { - return regexPatterns.aDouble(); + return RegexPatterns.aDouble(); } public RegexProperty ipAddress() { - return regexPatterns.ipAddress(); + return RegexPatterns.ipAddress(); } public RegexProperty hostname() { - return regexPatterns.hostname(); + return RegexPatterns.hostname(); } public RegexProperty email() { - return regexPatterns.email(); + return RegexPatterns.email(); } public RegexProperty url() { - return regexPatterns.url(); + return RegexPatterns.url(); } public RegexProperty httpsUrl() { - return regexPatterns.httpsUrl(); + return RegexPatterns.httpsUrl(); } public RegexProperty uuid() { - return regexPatterns.uuid(); + return RegexPatterns.uuid(); } public RegexProperty isoDate() { - return regexPatterns.isoDate(); + return RegexPatterns.isoDate(); } public RegexProperty isoDateTime() { - return regexPatterns.isoDateTime(); + return RegexPatterns.isoDateTime(); } public RegexProperty isoTime() { - return regexPatterns.isoTime(); + return RegexPatterns.isoTime(); } public RegexProperty iso8601WithOffset() { - return regexPatterns.iso8601WithOffset(); + return RegexPatterns.iso8601WithOffset(); } public RegexProperty nonEmpty() { - return regexPatterns.nonEmpty(); + return RegexPatterns.nonEmpty(); } public RegexProperty nonBlank() { - return regexPatterns.nonBlank(); + return RegexPatterns.nonBlank(); } } diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Headers.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Headers.java index 53bb457f66..4e004bc7d5 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Headers.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Headers.java @@ -29,6 +29,9 @@ import java.util.regex.Pattern; /** * Represents a set of headers of a request / response or a message. * + * @author Marcin Grzejszczak + * @author Olga Maciaszek-Sharma + * @author Tim Ysewyn * @since 1.0.0 */ public class Headers { @@ -41,8 +44,6 @@ public class Headers { private MediaTypes mediaTypes = new MediaTypes(); - private HttpHeaders httpHeaders = new HttpHeaders(); - private MessagingHeaders messagingHeaders = new MessagingHeaders(); private Set
entries = new LinkedHashSet<>(); @@ -74,7 +75,7 @@ public class Headers { } public void contentType(String contentType) { - header(httpHeaders.contentType(), matching(contentType)); + header(HttpHeaders.contentType(), matching(contentType)); } public void messagingContentType(String contentType) { @@ -151,14 +152,6 @@ public class Headers { this.mediaTypes = mediaTypes; } - public HttpHeaders getHttpHeaders() { - return httpHeaders; - } - - public void setHttpHeaders(HttpHeaders httpHeaders) { - this.httpHeaders = httpHeaders; - } - public MessagingHeaders getMessagingHeaders() { return messagingHeaders; } @@ -180,243 +173,243 @@ public class Headers { } public String accept() { - return httpHeaders.accept(); + return HttpHeaders.accept(); } public String acceptCharset() { - return httpHeaders.acceptCharset(); + return HttpHeaders.acceptCharset(); } public String acceptEncoding() { - return httpHeaders.acceptEncoding(); + return HttpHeaders.acceptEncoding(); } public String acceptLanguage() { - return httpHeaders.acceptLanguage(); + return HttpHeaders.acceptLanguage(); } public String acceptRanges() { - return httpHeaders.acceptRanges(); + return HttpHeaders.acceptRanges(); } public String accessControlAllowCredentials() { - return httpHeaders.accessControlAllowCredentials(); + return HttpHeaders.accessControlAllowCredentials(); } public String accessControlAllowHeaders() { - return httpHeaders.accessControlAllowHeaders(); + return HttpHeaders.accessControlAllowHeaders(); } public String accessControlAllowMethods() { - return httpHeaders.accessControlAllowMethods(); + return HttpHeaders.accessControlAllowMethods(); } public String accessControlAllowOrigin() { - return httpHeaders.accessControlAllowOrigin(); + return HttpHeaders.accessControlAllowOrigin(); } public String accessControlExposeHeaders() { - return httpHeaders.accessControlExposeHeaders(); + return HttpHeaders.accessControlExposeHeaders(); } public String accessControlMaxAge() { - return httpHeaders.accessControlMaxAge(); + return HttpHeaders.accessControlMaxAge(); } public String accessControlRequestHeaders() { - return httpHeaders.accessControlRequestHeaders(); + return HttpHeaders.accessControlRequestHeaders(); } public String accessControlRequestMethod() { - return httpHeaders.accessControlRequestMethod(); + return HttpHeaders.accessControlRequestMethod(); } public String age() { - return httpHeaders.age(); + return HttpHeaders.age(); } public String allow() { - return httpHeaders.allow(); + return HttpHeaders.allow(); } public String authorization() { - return httpHeaders.authorization(); + return HttpHeaders.authorization(); } public String cacheControl() { - return httpHeaders.cacheControl(); + return HttpHeaders.cacheControl(); } public String connection() { - return httpHeaders.connection(); + return HttpHeaders.connection(); } public String contentEncoding() { - return httpHeaders.contentEncoding(); + return HttpHeaders.contentEncoding(); } public String contentDisposition() { - return httpHeaders.contentDisposition(); + return HttpHeaders.contentDisposition(); } public String contentLanguage() { - return httpHeaders.contentLanguage(); + return HttpHeaders.contentLanguage(); } public String contentLength() { - return httpHeaders.contentLength(); + return HttpHeaders.contentLength(); } public String contentLocation() { - return httpHeaders.contentLocation(); + return HttpHeaders.contentLocation(); } public String contentRange() { - return httpHeaders.contentRange(); + return HttpHeaders.contentRange(); } public String contentType() { - return httpHeaders.contentType(); + return HttpHeaders.contentType(); } public String cookie() { - return httpHeaders.cookie(); + return HttpHeaders.cookie(); } public String date() { - return httpHeaders.date(); + return HttpHeaders.date(); } public String etag() { - return httpHeaders.etag(); + return HttpHeaders.etag(); } public String expect() { - return httpHeaders.expect(); + return HttpHeaders.expect(); } public String expires() { - return httpHeaders.expires(); + return HttpHeaders.expires(); } public String from() { - return httpHeaders.from(); + return HttpHeaders.from(); } public String host() { - return httpHeaders.host(); + return HttpHeaders.host(); } public String ifMatch() { - return httpHeaders.ifMatch(); + return HttpHeaders.ifMatch(); } public String ifModifiedSince() { - return httpHeaders.ifModifiedSince(); + return HttpHeaders.ifModifiedSince(); } public String ifNoneMatch() { - return httpHeaders.ifNoneMatch(); + return HttpHeaders.ifNoneMatch(); } public String ifRange() { - return httpHeaders.ifRange(); + return HttpHeaders.ifRange(); } public String ifUnmodifiedSince() { - return httpHeaders.ifUnmodifiedSince(); + return HttpHeaders.ifUnmodifiedSince(); } public String lastModified() { - return httpHeaders.lastModified(); + return HttpHeaders.lastModified(); } public String link() { - return httpHeaders.link(); + return HttpHeaders.link(); } public String location() { - return httpHeaders.location(); + return HttpHeaders.location(); } public String max_forwards() { - return httpHeaders.max_forwards(); + return HttpHeaders.max_forwards(); } public String origin() { - return httpHeaders.origin(); + return HttpHeaders.origin(); } public String pragma() { - return httpHeaders.pragma(); + return HttpHeaders.pragma(); } public String proxyAuthenticate() { - return httpHeaders.proxyAuthenticate(); + return HttpHeaders.proxyAuthenticate(); } public String proxyAuthorization() { - return httpHeaders.proxyAuthorization(); + return HttpHeaders.proxyAuthorization(); } public String range() { - return httpHeaders.range(); + return HttpHeaders.range(); } public String referer() { - return httpHeaders.referer(); + return HttpHeaders.referer(); } public String retryAfter() { - return httpHeaders.retryAfter(); + return HttpHeaders.retryAfter(); } public String server() { - return httpHeaders.server(); + return HttpHeaders.server(); } public String setCookie() { - return httpHeaders.setCookie(); + return HttpHeaders.setCookie(); } public String setCookie2() { - return httpHeaders.setCookie2(); + return HttpHeaders.setCookie2(); } public String te() { - return httpHeaders.te(); + return HttpHeaders.te(); } public String trailer() { - return httpHeaders.trailer(); + return HttpHeaders.trailer(); } public String transferEncoding() { - return httpHeaders.transferEncoding(); + return HttpHeaders.transferEncoding(); } public String upgrade() { - return httpHeaders.upgrade(); + return HttpHeaders.upgrade(); } public String user_agent() { - return httpHeaders.user_agent(); + return HttpHeaders.user_agent(); } public String vary() { - return httpHeaders.vary(); + return HttpHeaders.vary(); } public String via() { - return httpHeaders.via(); + return HttpHeaders.via(); } public String warning() { - return httpHeaders.warning(); + return HttpHeaders.warning(); } public String wwwAuthenticate() { - return httpHeaders.wwwAuthenticate(); + return HttpHeaders.wwwAuthenticate(); } public String allValue() { diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpHeaders.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpHeaders.java index 1a866789c6..a110b1dadf 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpHeaders.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpHeaders.java @@ -20,535 +20,541 @@ package org.springframework.cloud.contract.spec.internal; * Contains most commonly used http headers. * * @author Marcin Grzejszczak + * @author Tim Ysewyn * @since 1.0.2 */ -public class HttpHeaders { +public final class HttpHeaders { + + public HttpHeaders() { + System.out.println("WARNING: HttpHeaders shouldn't be instantiated"); + } /** - * The HTTP {@code Accept} header field name. - * @see Section 5.3.2 of + * @return The HTTP {@code Accept} header field name. + * @see Section 5.3.2 of * RFC 7231 */ - public String accept() { + public static String accept() { return "Accept"; } /** - * The HTTP {@code Accept-Charset} header field name. - * @see Section 5.3.3 of + * @return The HTTP {@code Accept-Charset} header field name. + * @see Section 5.3.3 of * RFC 7231 */ - public String acceptCharset() { + public static String acceptCharset() { return "Accept-Charset"; } /** - * The HTTP {@code Accept-Encoding} header field name. - * @see Section 5.3.4 of + * @return The HTTP {@code Accept-Encoding} header field name. + * @see Section 5.3.4 of * RFC 7231 */ - public String acceptEncoding() { + public static String acceptEncoding() { return "Accept-Encoding"; } /** - * The HTTP {@code Accept-Language} header field name. - * @see Section 5.3.5 of + * @return The HTTP {@code Accept-Language} header field name. + * @see Section 5.3.5 of * RFC 7231 */ - public String acceptLanguage() { + public static String acceptLanguage() { return "Accept-Language"; } /** - * The HTTP {@code Accept-Ranges} header field name. - * @see Section 5.3.5 of - * RFC 7233 + * @return The HTTP {@code Accept-Ranges} header field name. + * @see Section 5.3.5 of RFC + * 7233 */ - public String acceptRanges() { + public static String acceptRanges() { return "Accept-Ranges"; } /** - * The CORS {@code Access-Control-Allow-Credentials} response header field name. - * @see CORS W3C recommendation + * @return The CORS {@code Access-Control-Allow-Credentials} response header field + * name. + * @see CORS W3C recommendation */ - public String accessControlAllowCredentials() { + public static String accessControlAllowCredentials() { return "Access-Control-Allow-Credentials"; } /** - * The CORS {@code Access-Control-Allow-Headers} response header field name. - * @see CORS W3C recommendation + * @return The CORS {@code Access-Control-Allow-Headers} response header field name. + * @see CORS W3C recommendation */ - public String accessControlAllowHeaders() { + public static String accessControlAllowHeaders() { return "Access-Control-Allow-Headers"; } /** - * The CORS {@code Access-Control-Allow-Methods} response header field name. - * @see CORS W3C recommendation + * @return The CORS {@code Access-Control-Allow-Methods} response header field name. + * @see CORS W3C recommendation */ - public String accessControlAllowMethods() { + public static String accessControlAllowMethods() { return "Access-Control-Allow-Methods"; } /** - * The CORS {@code Access-Control-Allow-Origin} response header field name. - * @see CORS W3C recommendation + * @return The CORS {@code Access-Control-Allow-Origin} response header field name. + * @see CORS W3C recommendation */ - public String accessControlAllowOrigin() { + public static String accessControlAllowOrigin() { return "Access-Control-Allow-Origin"; } /** - * The CORS {@code Access-Control-Expose-Headers} response header field name. - * @see CORS W3C recommendation + * @return The CORS {@code Access-Control-Expose-Headers} response header field name. + * @see CORS W3C recommendation */ - public String accessControlExposeHeaders() { + public static String accessControlExposeHeaders() { return "Access-Control-Expose-Headers"; } /** - * The CORS {@code Access-Control-Max-Age} response header field name. - * @see CORS W3C recommendation + * @return The CORS {@code Access-Control-Max-Age} response header field name. + * @see CORS W3C recommendation */ - public String accessControlMaxAge() { + public static String accessControlMaxAge() { return "Access-Control-Max-Age"; } /** - * The CORS {@code Access-Control-Request-Headers} request header field name. - * @see CORS W3C recommendation + * @return The CORS {@code Access-Control-Request-Headers} request header field name. + * @see CORS W3C recommendation */ - public String accessControlRequestHeaders() { + public static String accessControlRequestHeaders() { return "Access-Control-Request-Headers"; } /** - * The CORS {@code Access-Control-Request-Method} request header field name. - * @see CORS W3C recommendation + * @return The CORS {@code Access-Control-Request-Method} request header field name. + * @see CORS W3C recommendation */ - public String accessControlRequestMethod() { + public static String accessControlRequestMethod() { return "Access-Control-Request-Method"; } /** - * The HTTP {@code Age} header field name. - * @see Section 5.1 of RFC + * @return The HTTP {@code Age} header field name. + * @see Section 5.1 of RFC * 7234 */ - public String age() { + public static String age() { return "Age"; } /** - * The HTTP {@code Allow} header field name. - * @see Section 7.4.1 of + * @return The HTTP {@code Allow} header field name. + * @see Section 7.4.1 of * RFC 7231 */ - public String allow() { + public static String allow() { return "Allow"; } /** - * The HTTP {@code Authorization} header field name. - * @see Section 4.2 of RFC + * @return The HTTP {@code Authorization} header field name. + * @see Section 4.2 of RFC * 7235 */ - public String authorization() { + public static String authorization() { return "Authorization"; } /** - * The HTTP {@code Cache-Control} header field name. - * @see Section 5.2 of RFC + * @return The HTTP {@code Cache-Control} header field name. + * @see Section 5.2 of RFC * 7234 */ - public String cacheControl() { + public static String cacheControl() { return "Cache-Control"; } /** - * The HTTP {@code Connection} header field name. - * @see Section 6.1 of RFC + * @return The HTTP {@code Connection} header field name. + * @see Section 6.1 of RFC * 7230 */ - public String connection() { + public static String connection() { return "Connection"; } /** - * The HTTP {@code Content-Encoding} header field name. - * @see Section 3.1.2.2 + * @return The HTTP {@code Content-Encoding} header field name. + * @see Section 3.1.2.2 * of RFC 7231 */ - public String contentEncoding() { + public static String contentEncoding() { return "Content-Encoding"; } /** - * The HTTP {@code Content-Disposition} header field name - * @see RFC 6266 + * @return The HTTP {@code Content-Disposition} header field name + * @see RFC 6266 */ - public String contentDisposition() { + public static String contentDisposition() { return "Content-Disposition"; } /** - * The HTTP {@code Content-Language} header field name. - * @see Section 3.1.3.2 + * @return The HTTP {@code Content-Language} header field name. + * @see Section 3.1.3.2 * of RFC 7231 */ - public String contentLanguage() { + public static String contentLanguage() { return "Content-Language"; } /** - * The HTTP {@code Content-Length} header field name. - * @see Section 3.3.2 of + * @return The HTTP {@code Content-Length} header field name. + * @see Section 3.3.2 of * RFC 7230 */ - public String contentLength() { + public static String contentLength() { return "Content-Length"; } /** - * The HTTP {@code Content-Location} header field name. - * @see Section 3.1.4.2 + * @return The HTTP {@code Content-Location} header field name. + * @see Section 3.1.4.2 * of RFC 7231 */ - public String contentLocation() { + public static String contentLocation() { return "Content-Location"; } /** - * The HTTP {@code Content-Range} header field name. - * @see Section 4.2 of RFC + * @return The HTTP {@code Content-Range} header field name. + * @see Section 4.2 of RFC * 7233 */ - public String contentRange() { + public static String contentRange() { return "Content-Range"; } /** - * The HTTP {@code Content-Type} header field name. - * @see Section 3.1.1.5 + * @return The HTTP {@code Content-Type} header field name. + * @see Section 3.1.1.5 * of RFC 7231 */ - public String contentType() { + public static String contentType() { return "Content-Type"; } /** - * The HTTP {@code Cookie} header field name. - * @see Section 4.3.4 of + * @return The HTTP {@code Cookie} header field name. + * @see Section 4.3.4 of * RFC 2109 */ - public String cookie() { + public static String cookie() { return "Cookie"; } /** - * The HTTP {@code Date} header field name. - * @see Section 7.1.1.2 + * @return The HTTP {@code Date} header field name. + * @see Section 7.1.1.2 * of RFC 7231 */ - public String date() { + public static String date() { return "Date"; } /** - * The HTTP {@code ETag} header field name. - * @see Section 2.3 of RFC + * @return The HTTP {@code ETag} header field name. + * @see Section 2.3 of RFC * 7232 */ - public String etag() { + public static String etag() { return "ETag"; } /** - * The HTTP {@code Expect} header field name. - * @see Section 5.1.1 of + * @return The HTTP {@code Expect} header field name. + * @see Section 5.1.1 of * RFC 7231 */ - public String expect() { + public static String expect() { return "Expect"; } /** - * The HTTP {@code Expires} header field name. - * @see Section 5.3 of RFC + * @return The HTTP {@code Expires} header field name. + * @see Section 5.3 of RFC * 7234 */ - public String expires() { + public static String expires() { return "Expires"; } /** - * The HTTP {@code From} header field name. - * @see Section 5.5.1 of + * @return The HTTP {@code From} header field name. + * @see Section 5.5.1 of * RFC 7231 */ - public String from() { + public static String from() { return "From"; } /** - * The HTTP {@code Host} header field name. - * @see Section 5.4 of RFC + * @return The HTTP {@code Host} header field name. + * @see Section 5.4 of RFC * 7230 */ - public String host() { + public static String host() { return "Host"; } /** - * The HTTP {@code If-Match} header field name. - * @see Section 3.1 of RFC + * @return The HTTP {@code If-Match} header field name. + * @see Section 3.1 of RFC * 7232 */ - public String ifMatch() { + public static String ifMatch() { return "If-Match"; } /** - * The HTTP {@code If-Modified-Since} header field name. - * @see Section 3.3 of RFC + * @return The HTTP {@code If-Modified-Since} header field name. + * @see Section 3.3 of RFC * 7232 */ - public String ifModifiedSince() { + public static String ifModifiedSince() { return "If-Modified-Since"; } /** - * The HTTP {@code If-None-Match} header field name. - * @see Section 3.2 of RFC + * @return The HTTP {@code If-None-Match} header field name. + * @see Section 3.2 of RFC * 7232 */ - public String ifNoneMatch() { + public static String ifNoneMatch() { return "If-None-Match"; } /** - * The HTTP {@code If-Range} header field name. - * @see Section 3.2 of RFC + * @return The HTTP {@code If-Range} header field name. + * @see Section 3.2 of RFC * 7233 */ - public String ifRange() { + public static String ifRange() { return "If-Range"; } /** - * The HTTP {@code If-Unmodified-Since} header field name. - * @see Section 3.4 of RFC + * @return The HTTP {@code If-Unmodified-Since} header field name. + * @see Section 3.4 of RFC * 7232 */ - public String ifUnmodifiedSince() { + public static String ifUnmodifiedSince() { return "If-Unmodified-Since"; } /** - * The HTTP {@code Last-Modified} header field name. - * @see Section 2.2 of RFC + * @return The HTTP {@code Last-Modified} header field name. + * @see Section 2.2 of RFC * 7232 */ - public String lastModified() { + public static String lastModified() { return "Last-Modified"; } /** - * The HTTP {@code Link} header field name. - * @see RFC 5988 + * @return The HTTP {@code Link} header field name. + * @see RFC 5988 */ - public String link() { + public static String link() { return "Link"; } /** - * The HTTP {@code Location} header field name. - * @see Section 7.1.2 of + * @return The HTTP {@code Location} header field name. + * @see Section 7.1.2 of * RFC 7231 */ - public String location() { + public static String location() { return "Location"; } /** - * The HTTP {@code Max-Forwards} header field name. - * @see Section 5.1.2 of + * @return The HTTP {@code Max-Forwards} header field name. + * @see Section 5.1.2 of * RFC 7231 */ - public String max_forwards() { + public static String max_forwards() { return "Max-Forwards"; } /** - * The HTTP {@code Origin} header field name. - * @see RFC 6454 + * @return The HTTP {@code Origin} header field name. + * @see RFC 6454 */ - public String origin() { + public static String origin() { return "Origin"; } /** - * The HTTP {@code Pragma} header field name. - * @see Section 5.4 of RFC + * @return The HTTP {@code Pragma} header field name. + * @see Section 5.4 of RFC * 7234 */ - public String pragma() { + public static String pragma() { return "Pragma"; } /** - * The HTTP {@code Proxy-Authenticate} header field name. - * @see Section 4.3 of RFC + * @return The HTTP {@code Proxy-Authenticate} header field name. + * @see Section 4.3 of RFC * 7235 */ - public String proxyAuthenticate() { + public static String proxyAuthenticate() { return "Proxy-Authenticate"; } /** - * The HTTP {@code Proxy-Authorization} header field name. - * @see Section 4.4 of RFC + * @return The HTTP {@code Proxy-Authorization} header field name. + * @see Section 4.4 of RFC * 7235 */ - public String proxyAuthorization() { + public static String proxyAuthorization() { return "Proxy-Authorization"; } /** - * The HTTP {@code Range} header field name. - * @see Section 3.1 of RFC + * @return The HTTP {@code Range} header field name. + * @see Section 3.1 of RFC * 7233 */ - public String range() { + public static String range() { return "Range"; } /** - * The HTTP {@code Referer} header field name. - * @see Section 5.5.2 of + * @return The HTTP {@code Referer} header field name. + * @see Section 5.5.2 of * RFC 7231 */ - public String referer() { + public static String referer() { return "Referer"; } /** - * The HTTP {@code Retry-After} header field name. - * @see Section 7.1.3 of + * @return The HTTP {@code Retry-After} header field name. + * @see Section 7.1.3 of * RFC 7231 */ - public String retryAfter() { + public static String retryAfter() { return "Retry-After"; } /** - * The HTTP {@code Server} header field name. - * @see Section 7.4.2 of + * @return The HTTP {@code Server} header field name. + * @see Section 7.4.2 of * RFC 7231 */ - public String server() { + public static String server() { return "Server"; } /** - * The HTTP {@code Set-Cookie} header field name. - * @see Section 4.2.2 of + * @return The HTTP {@code Set-Cookie} header field name. + * @see Section 4.2.2 of * RFC 2109 */ - public String setCookie() { + public static String setCookie() { return "Set-Cookie"; } /** - * The HTTP {@code Set-Cookie2} header field name. - * @see RFC 2965 + * @return The HTTP {@code Set-Cookie2} header field name. + * @see RFC 2965 */ - public String setCookie2() { + public static String setCookie2() { return "Set-Cookie2"; } /** - * The HTTP {@code TE} header field name. - * @see Section 4.3 of RFC + * @return The HTTP {@code TE} header field name. + * @see Section 4.3 of RFC * 7230 */ - public String te() { + public static String te() { return "TE"; } /** - * The HTTP {@code Trailer} header field name. - * @see Section 4.4 of RFC + * @return The HTTP {@code Trailer} header field name. + * @see Section 4.4 of RFC * 7230 */ - public String trailer() { + public static String trailer() { return "Trailer"; } /** - * The HTTP {@code Transfer-Encoding} header field name. - * @see Section 3.3.1 of + * @return The HTTP {@code Transfer-Encoding} header field name. + * @see Section 3.3.1 of * RFC 7230 */ - public String transferEncoding() { + public static String transferEncoding() { return "Transfer-Encoding"; } /** - * The HTTP {@code Upgrade} header field name. - * @see Section 6.7 of RFC + * @return The HTTP {@code Upgrade} header field name. + * @see Section 6.7 of RFC * 7230 */ - public String upgrade() { + public static String upgrade() { return "Upgrade"; } /** - * The HTTP {@code User-Agent} header field name. - * @see Section 5.5.3 of + * @return The HTTP {@code User-Agent} header field name. + * @see Section 5.5.3 of * RFC 7231 */ - public String user_agent() { + public static String user_agent() { return "User-Agent"; } /** - * The HTTP {@code Vary} header field name. - * @see Section 7.1.4 of + * @return The HTTP {@code Vary} header field name. + * @see Section 7.1.4 of * RFC 7231 */ - public String vary() { + public static String vary() { return "Vary"; } /** - * The HTTP {@code Via} header field name. - * @see Section 5.7.1 of + * @return The HTTP {@code Via} header field name. + * @see Section 5.7.1 of * RFC 7230 */ - public String via() { + public static String via() { return "Via"; } /** - * The HTTP {@code Warning} header field name. - * @see Section 5.5 of RFC + * @return The HTTP {@code Warning} header field name. + * @see Section 5.5 of RFC * 7234 */ - public String warning() { + public static String warning() { return "Warning"; } /** - * The HTTP {@code WWW-Authenticate} header field name. - * @see Section 4.1 of RFC + * @return The HTTP {@code WWW-Authenticate} header field name. + * @see Section 4.1 of RFC * 7235 */ - public String wwwAuthenticate() { + public static String wwwAuthenticate() { return "WWW-Authenticate"; } diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpMethods.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpMethods.java index 86b3ac1361..5a4b40e70c 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpMethods.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpMethods.java @@ -20,39 +20,68 @@ package org.springframework.cloud.contract.spec.internal; * Contains Http Methods. * * @author Marcin Grzejszczak + * @author Tim Ysewyn * @since 1.0.2 */ -public class HttpMethods { +public final class HttpMethods { - public HttpMethod GET() { + public HttpMethods() { + System.out.println("WARNING: HttpMethods shouldn't be instantiated"); + } + + /** + * @return {@code GET}. + */ + public static HttpMethod GET() { return HttpMethod.GET; } - public HttpMethod HEAD() { + /** + * @return {@code HEAD}. + */ + public static HttpMethod HEAD() { return HttpMethod.HEAD; } - public HttpMethod POST() { + /** + * @return {@code POST}. + */ + public static HttpMethod POST() { return HttpMethod.POST; } - public HttpMethod PUT() { + /** + * @return {@code PUT}. + */ + public static HttpMethod PUT() { return HttpMethod.PUT; } - public HttpMethod PATCH() { + /** + * @return {@code PATCH}. + */ + public static HttpMethod PATCH() { return HttpMethod.PATCH; } - public HttpMethod DELETE() { + /** + * @return {@code DELETE}. + */ + public static HttpMethod DELETE() { return HttpMethod.DELETE; } - public HttpMethod OPTIONS() { + /** + * @return {@code OPTIONS}. + */ + public static HttpMethod OPTIONS() { return HttpMethod.OPTIONS; } - public HttpMethod TRACE() { + /** + * @return {@code TRACE}. + */ + public static HttpMethod TRACE() { return HttpMethod.TRACE; } diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpStatus.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpStatus.java index 2ccdb3aae5..3d2b196c30 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpStatus.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/HttpStatus.java @@ -20,615 +20,620 @@ package org.springframework.cloud.contract.spec.internal; * Helper functions for HTTP statuses. * * @author Marcin Grzejszczak + * @author Tim Ysewyn * @since 2.0.0 */ -public class HttpStatus { +public final class HttpStatus { + + public HttpStatus() { + System.out.println("WARNING: HttpStatus shouldn't be instantiated"); + } /** - * {@code 100 Continue}. - * @see HTTP/1.1: + * @return {@code 100 Continue}. + * @see HTTP/1.1: * Semantics and Content, section 6.2.1 */ - public int CONTINUE() { + public static int CONTINUE() { return 100; } /** - * {@code 101 Switching Protocols}. - * @see HTTP/1.1: + * @return {@code 101 Switching Protocols}. + * @see HTTP/1.1: * Semantics and Content, section 6.2.2 */ - public int SWITCHING_PROTOCOLS() { + public static int SWITCHING_PROTOCOLS() { return 101; } /** - * {@code 102 Processing}. - * @see WebDAV + * @return {@code 102 Processing}. + * @see WebDAV */ - public int PROCESSING() { + public static int PROCESSING() { return 102; } /** - * {@code 103 Checkpoint}. - * @see + * @return {@code 103 Checkpoint}. + * @see * A proposal for supporting resumable POST/PUT HTTP requests in HTTP/1.0 */ - public int CHECKPOINT() { + public static int CHECKPOINT() { return 103; } /** - * {@code 200 OK}. - * @see HTTP/1.1: + * @return {@code 200 OK}. + * @see HTTP/1.1: * Semantics and Content, section 6.3.1 */ - public int OK() { + public static int OK() { return 200; } /** - * {@code 201 Created}. - * @see HTTP/1.1: + * @return {@code 201 Created}. + * @see HTTP/1.1: * Semantics and Content, section 6.3.2 */ - public int CREATED() { + public static int CREATED() { return 201; } /** - * {@code 202 Accepted}. - * @see HTTP/1.1: + * @return {@code 202 Accepted}. + * @see HTTP/1.1: * Semantics and Content, section 6.3.3 */ - public int ACCEPTED() { + public static int ACCEPTED() { return 202; } /** - * {@code 203 Non-Authoritative Information}. - * @see HTTP/1.1: + * @return {@code 203 Non-Authoritative Information}. + * @see HTTP/1.1: * Semantics and Content, section 6.3.4 */ - public int NON_AUTHORITATIVE_INFORMATION() { + public static int NON_AUTHORITATIVE_INFORMATION() { return 203; } /** - * {@code 204 No Content}. - * @see HTTP/1.1: + * @return {@code 204 No Content}. + * @see HTTP/1.1: * Semantics and Content, section 6.3.5 */ - public int NO_CONTENT() { + public static int NO_CONTENT() { return 204; } /** - * {@code 205 Reset Content}. - * @see HTTP/1.1: + * @return {@code 205 Reset Content}. + * @see HTTP/1.1: * Semantics and Content, section 6.3.6 */ - public int RESET_CONTENT() { + public static int RESET_CONTENT() { return 205; } /** - * {@code 206 Partial Content}. - * @see HTTP/1.1: Range + * @return {@code 206 Partial Content}. + * @see HTTP/1.1: Range * Requests, section 4.1 */ - public int PARTIAL_CONTENT() { + public static int PARTIAL_CONTENT() { return 206; } /** - * {@code 207 Multi-Status}. - * @see WebDAV + * @return {@code 207 Multi-Status}. + * @see WebDAV */ - public int MULTI_STATUS() { + public static int MULTI_STATUS() { return 207; } /** - * {@code 208 Already Reported}. - * @see WebDAV Binding + * @return {@code 208 Already Reported}. + * @see WebDAV Binding * Extensions */ - public int ALREADY_REPORTED() { + public static int ALREADY_REPORTED() { return 208; } /** - * {@code 226 IM Used}. - * @see Delta encoding - * in HTTP + * @return {@code 226 IM Used}. + * @see Delta encoding in + * HTTP */ - public int IM_USED() { + public static int IM_USED() { return 226; } /** - * {@code 300 Multiple Choices}. - * @see HTTP/1.1: + * @return {@code 300 Multiple Choices}. + * @see HTTP/1.1: * Semantics and Content, section 6.4.1 */ - public int MULTIPLE_CHOICES() { + public static int MULTIPLE_CHOICES() { return 300; } /** - * {@code 301 Moved Permanently}. - * @see HTTP/1.1: + * @return {@code 301 Moved Permanently}. + * @see HTTP/1.1: * Semantics and Content, section 6.4.2 */ - public int MOVED_PERMANENTLY() { + public static int MOVED_PERMANENTLY() { return 301; } /** - * {@code 302 Found}. - * @see HTTP/1.1: + * @return {@code 302 Found}. + * @see HTTP/1.1: * Semantics and Content, section 6.4.3 */ - public int FOUND() { + public static int FOUND() { return 302; } /** - * {@code 302 Moved Temporarily}. - * @see HTTP/1.0, section + * @return {@code 302 Moved Temporarily}. + * @see HTTP/1.0, section * 9.3 * @deprecated in favor of {@link #FOUND} which will be returned from - * {@code HttpStatus.valueOf(302)} */ @Deprecated - public int MOVED_TEMPORARILY() { + public static int MOVED_TEMPORARILY() { return 302; } /** - * {@code 303 See Other}. - * @see HTTP/1.1: + * @return {@code 303 See Other}. + * @see HTTP/1.1: * Semantics and Content, section 6.4.4 */ - public int SEE_OTHER() { + public static int SEE_OTHER() { return 303; } /** - * {@code 304 Not Modified}. - * @see HTTP/1.1: + * @return {@code 304 Not Modified}. + * @see HTTP/1.1: * Conditional Requests, section 4.1 */ - public int NOT_MODIFIED() { + public static int NOT_MODIFIED() { return 304; } /** - * {@code 305 Use Proxy}. - * @see HTTP/1.1: + * @return {@code 305 Use Proxy}. + * @see HTTP/1.1: * Semantics and Content, section 6.4.5 * @deprecated due to security concerns regarding in-band configuration of a proxy */ @Deprecated - public int USE_PROXY() { + public static int USE_PROXY() { return 305; } /** - * {@code 307 Temporary Redirect}. - * @see HTTP/1.1: + * @return {@code 307 Temporary Redirect}. + * @see HTTP/1.1: * Semantics and Content, section 6.4.7 */ - public int TEMPORARY_REDIRECT() { + public static int TEMPORARY_REDIRECT() { return 307; } /** - * {@code 308 Permanent Redirect}. - * @see RFC 7238 + * @return {@code 308 Permanent Redirect}. + * @see RFC 7238 */ - public int PERMANENT_REDIRECT() { + public static int PERMANENT_REDIRECT() { return 308; } /** - * {@code 400 Bad Request}. - * @see HTTP/1.1: + * @return {@code 400 Bad Request}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.1 */ - public int BAD_REQUEST() { + public static int BAD_REQUEST() { return 400; } /** - * {@code 401 Unauthorized}. - * @see HTTP/1.1: + * @return {@code 401 Unauthorized}. + * @see HTTP/1.1: * Authentication, section 3.1 */ - public int UNAUTHORIZED() { + public static int UNAUTHORIZED() { return 401; } /** - * {@code 402 Payment Required}. - * @see HTTP/1.1: + * @return {@code 402 Payment Required}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.2 */ - public int PAYMENT_REQUIRED() { + public static int PAYMENT_REQUIRED() { return 402; } /** - * {@code 403 Forbidden}. - * @see HTTP/1.1: + * @return {@code 403 Forbidden}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.3 */ - public int FORBIDDEN() { + public static int FORBIDDEN() { return 403; } /** - * {@code 404 Not Found}. - * @see HTTP/1.1: + * @return {@code 404 Not Found}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.4 */ - public int NOT_FOUND() { + public static int NOT_FOUND() { return 404; } /** - * {@code 405 Method Not Allowed}. - * @see HTTP/1.1: + * @return {@code 405 Method Not Allowed}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.5 */ - public int METHOD_NOT_ALLOWED() { + public static int METHOD_NOT_ALLOWED() { return 405; } /** - * {@code 406 Not Acceptable}. - * @see HTTP/1.1: + * @return {@code 406 Not Acceptable}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.6 */ - public int NOT_ACCEPTABLE() { + public static int NOT_ACCEPTABLE() { return 406; } /** - * {@code 407 Proxy Authentication Required}. - * @see HTTP/1.1: + * @return {@code 407 Proxy Authentication Required}. + * @see HTTP/1.1: * Authentication, section 3.2 */ - public int PROXY_AUTHENTICATION_REQUIRED() { + public static int PROXY_AUTHENTICATION_REQUIRED() { return 407; } /** - * {@code 408 Request Timeout}. - * @see HTTP/1.1: + * @return {@code 408 Request Timeout}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.7 */ - public int REQUEST_TIMEOUT() { + public static int REQUEST_TIMEOUT() { return 408; } /** - * {@code 409 Conflict}. - * @see HTTP/1.1: + * @return {@code 409 Conflict}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.8 */ - public int CONFLICT() { + public static int CONFLICT() { return 409; } /** - * {@code 410 Gone}. - * @see HTTP/1.1: + * @return {@code 410 Gone}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.9 */ - public int GONE() { + public static int GONE() { return 410; } /** - * {@code 411 Length Required}. - * @see HTTP/1.1: + * @return {@code 411 Length Required}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.10 */ - public int LENGTH_REQUIRED() { + public static int LENGTH_REQUIRED() { return 411; } /** - * {@code 412 Precondition failed}. - * @see HTTP/1.1: + * @return {@code 412 Precondition failed}. + * @see HTTP/1.1: * Conditional Requests, section 4.2 */ - public int PRECONDITION_FAILED() { + public static int PRECONDITION_FAILED() { return 412; } /** - * {@code 413 Payload Too Large}. - * @since 4.1* @see + * @return {@code 413 Payload Too Large}. + * @since 4.1* @see * HTTP/1.1: Semantics and Content, section 6.5.11 */ - public int PAYLOAD_TOO_LARGE() { + public static int PAYLOAD_TOO_LARGE() { return 413; } /** - * {@code 413 Request Entity Too Large}. - * @see HTTP/1.1, + * @return {@code 413 Request Entity Too Large}. + * @see HTTP/1.1, * section 10.4.14 * @deprecated in favor of {@link #PAYLOAD_TOO_LARGE} which will be returned from - * {@code HttpStatus.valueOf(413)} */ @Deprecated - public int REQUEST_ENTITY_TOO_LARGE() { + public static int REQUEST_ENTITY_TOO_LARGE() { return 413; } /** - * {@code 414 URI Too Long}. - * @since 4.1* @see + * @return {@code 414 URI Too Long}. + * @since 4.1* @see * HTTP/1.1: Semantics and Content, section 6.5.12 */ - public int URI_TOO_LONG() { + public static int URI_TOO_LONG() { return 414; } /** - * {@code 414 Request-URI Too Long}. - * @see HTTP/1.1, + * @return {@code 414 Request-URI Too Long}. + * @see HTTP/1.1, * section 10.4.15 * @deprecated in favor of {@link #URI_TOO_LONG} which will be returned from - * {@code HttpStatus.valueOf(414)} */ @Deprecated - public int REQUEST_URI_TOO_LONG() { + public static int REQUEST_URI_TOO_LONG() { return 414; } /** - * {@code 415 Unsupported Media Type}. - * @see HTTP/1.1: + * @return {@code 415 Unsupported Media Type}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.13 */ - public int UNSUPPORTED_MEDIA_TYPE() { + public static int UNSUPPORTED_MEDIA_TYPE() { return 415; } /** - * {@code 416 Requested Range Not Satisfiable}. - * @see HTTP/1.1: Range + * @return {@code 416 Requested Range Not Satisfiable}. + * @see HTTP/1.1: Range * Requests, section 4.4 */ - public int REQUESTED_RANGE_NOT_SATISFIABLE() { + public static int REQUESTED_RANGE_NOT_SATISFIABLE() { return 416; } /** - * {@code 417 Expectation Failed}. - * @see HTTP/1.1: + * @return {@code 417 Expectation Failed}. + * @see HTTP/1.1: * Semantics and Content, section 6.5.14 */ - public int EXPECTATION_FAILED() { + public static int EXPECTATION_FAILED() { return 417; } /** - * {@code 418 I'm a teapot}. - * @see HTCPCP/1.0 + * @return {@code 418 I'm a teapot}. + * @see HTCPCP/1.0 */ - public int I_AM_A_TEAPOT() { + public static int I_AM_A_TEAPOT() { return 418; } /** + * @return {@code 419 Insufficient Space}. * @deprecated See WebDAV * Draft Changes */ @Deprecated - public int INSUFFICIENT_SPACE_ON_RESOURCE() { + public static int INSUFFICIENT_SPACE_ON_RESOURCE() { return 419; } /** + * @return {@code 420 Method Failure}. * @deprecated See WebDAV * Draft Changes */ @Deprecated - public int METHOD_FAILURE() { + public static int METHOD_FAILURE() { return 420; } /** + * @return {@code 421 Destination Locked}. * @deprecated See WebDAV * Draft Changes */ @Deprecated - public int DESTINATION_LOCKED() { + public static int DESTINATION_LOCKED() { return 421; } /** - * {@code 422 Unprocessable Entity}. - * @see WebDAV + * @return {@code 422 Unprocessable Entity}. + * @see WebDAV */ - public int UNPROCESSABLE_ENTITY() { + public static int UNPROCESSABLE_ENTITY() { return 422; } /** - * {@code 423 Locked}. - * @see WebDAV + * @return {@code 423 Locked}. + * @see WebDAV */ - public int LOCKED() { + public static int LOCKED() { return 423; } /** - * {@code 424 Failed Dependency}. - * @see WebDAV + * @return {@code 424 Failed Dependency}. + * @see WebDAV */ - public int FAILED_DEPENDENCY() { + public static int FAILED_DEPENDENCY() { return 424; } /** - * {@code 426 Upgrade Required}. - * @see Upgrading to TLS + * @return {@code 426 Upgrade Required}. + * @see Upgrading to TLS * Within HTTP/1.1 */ - public int UPGRADE_REQUIRED() { + public static int UPGRADE_REQUIRED() { return 426; } /** - * {@code 428 Precondition Required}. - * @see Additional HTTP - * Status Codes + * @return {@code 428 Precondition Required}. + * @see Additional HTTP Status + * Codes */ - public int PRECONDITION_REQUIRED() { + public static int PRECONDITION_REQUIRED() { return 428; } /** - * {@code 429 Too Many Requests}. - * @see Additional HTTP - * Status Codes + * @return {@code 429 Too Many Requests}. + * @see Additional HTTP Status + * Codes */ - public int TOO_MANY_REQUESTS() { + public static int TOO_MANY_REQUESTS() { return 429; } /** - * {@code 431 Request Header Fields Too Large}. - * @see Additional HTTP - * Status Codes + * @return {@code 431 Request Header Fields Too Large}. + * @see Additional HTTP Status + * Codes */ - public int REQUEST_HEADER_FIELDS_TOO_LARGE() { + public static int REQUEST_HEADER_FIELDS_TOO_LARGE() { return 431; } /** - * {@code 451 Unavailable For Legal Reasons}. - * @see An HTTP Status Code to Report Legal Obstacles - * @since 4.3 + * @return {@code 451 Unavailable For Legal Reasons}. + * @see An + * HTTP Status Code to Report Legal Obstacles */ - public int UNAVAILABLE_FOR_LEGAL_REASONS() { + public static int UNAVAILABLE_FOR_LEGAL_REASONS() { return 451; } /** - * {@code 500 Internal Server Error}. - * @see HTTP/1.1: + * @return {@code 500 Internal Server Error}. + * @see HTTP/1.1: * Semantics and Content, section 6.6.1 */ - public int INTERNAL_SERVER_ERROR() { + public static int INTERNAL_SERVER_ERROR() { return 500; } /** - * {@code 501 Not Implemented}. - * @see HTTP/1.1: + * @return {@code 501 Not Implemented}. + * @see HTTP/1.1: * Semantics and Content, section 6.6.2 */ - public int NOT_IMPLEMENTED() { + public static int NOT_IMPLEMENTED() { return 501; } /** - * {@code 502 Bad Gateway}. - * @see HTTP/1.1: + * @return {@code 502 Bad Gateway}. + * @see HTTP/1.1: * Semantics and Content, section 6.6.3 */ - public int BAD_GATEWAY() { + public static int BAD_GATEWAY() { return 502; } /** - * {@code 503 Service Unavailable}. - * @see HTTP/1.1: + * @return {@code 503 Service Unavailable}. + * @see HTTP/1.1: * Semantics and Content, section 6.6.4 */ - public int SERVICE_UNAVAILABLE() { + public static int SERVICE_UNAVAILABLE() { return 503; } /** - * {@code 504 Gateway Timeout}. - * @see HTTP/1.1: + * @return {@code 504 Gateway Timeout}. + * @see HTTP/1.1: * Semantics and Content, section 6.6.5 */ - public int GATEWAY_TIMEOUT() { + public static int GATEWAY_TIMEOUT() { return 504; } /** - * {@code 505 HTTP Version Not Supported}. - * @see HTTP/1.1: + * @return {@code 505 HTTP Version Not Supported}. + * @see HTTP/1.1: * Semantics and Content, section 6.6.6 */ - public int HTTP_VERSION_NOT_SUPPORTED() { + public static int HTTP_VERSION_NOT_SUPPORTED() { return 505; } /** - * {@code 506 Variant Also Negotiates} - * @see Transparent Content + * @return {@code 506 Variant Also Negotiates} + * @see Transparent Content * Negotiation */ - public int VARIANT_ALSO_NEGOTIATES() { + public static int VARIANT_ALSO_NEGOTIATES() { return 506; } /** - * {@code 507 Insufficient Storage} - * @see WebDAV + * @return {@code 507 Insufficient Storage} + * @see WebDAV */ - public int INSUFFICIENT_STORAGE() { + public static int INSUFFICIENT_STORAGE() { return 507; } /** - * {@code 508 Loop Detected} - * @see WebDAV Binding + * @return {@code 508 Loop Detected} + * @see WebDAV Binding * Extensions */ - public int LOOP_DETECTED() { + public static int LOOP_DETECTED() { return 508; } /** - * {@code 509 Bandwidth Limit Exceeded} + * @return {@code 509 Bandwidth Limit Exceeded} */ - public int BANDWIDTH_LIMIT_EXCEEDED() { + public static int BANDWIDTH_LIMIT_EXCEEDED() { return 509; } /** - * {@code 510 Not Extended} - * @see HTTP Extension + * @return {@code 510 Not Extended} + * @see HTTP Extension * Framework */ - public int NOT_EXTENDED() { + public static int NOT_EXTENDED() { return 510; } /** - * {@code 511 Network Authentication Required}. - * @see Additional HTTP - * Status Codes + * @return {@code 511 Network Authentication Required}. + * @see Additional HTTP Status + * Codes */ - public int NETWORK_AUTHENTICATION_REQUIRED() { + public static int NETWORK_AUTHENTICATION_REQUIRED() { return 511; } diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/RegexPatterns.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/RegexPatterns.java index 1e6d3d8285..8ef63de339 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/RegexPatterns.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/RegexPatterns.java @@ -27,9 +27,12 @@ import java.util.stream.Collectors; * @author Tim Ysewyn * @since 1.0.0 */ -public class RegexPatterns { +public final class RegexPatterns { + + public RegexPatterns() { + System.out.println("WARNING: RegexPatterns shouldn't be instantiated"); + } - // tag::regexps[] protected static final Pattern TRUE_OR_FALSE = Pattern.compile("(true|false)"); protected static final Pattern ALPHA_NUMERIC = Pattern.compile("[a-zA-Z0-9]+"); @@ -108,82 +111,84 @@ public class RegexPatterns { return contentType.toString(); } - public RegexProperty onlyAlphaUnicode() { + // tag::regexps[] + + public static RegexProperty onlyAlphaUnicode() { return new RegexProperty(ONLY_ALPHA_UNICODE).asString(); } - public RegexProperty alphaNumeric() { + public static RegexProperty alphaNumeric() { return new RegexProperty(ALPHA_NUMERIC).asString(); } - public RegexProperty number() { + public static RegexProperty number() { return new RegexProperty(NUMBER).asDouble(); } - public RegexProperty positiveInt() { + public static RegexProperty positiveInt() { return new RegexProperty(POSITIVE_INT).asInteger(); } - public RegexProperty anyBoolean() { + public static RegexProperty anyBoolean() { return new RegexProperty(TRUE_OR_FALSE).asBooleanType(); } - public RegexProperty anInteger() { + public static RegexProperty anInteger() { return new RegexProperty(INTEGER).asInteger(); } - public RegexProperty aDouble() { + public static RegexProperty aDouble() { return new RegexProperty(DOUBLE).asDouble(); } - public RegexProperty ipAddress() { + public static RegexProperty ipAddress() { return new RegexProperty(IP_ADDRESS).asString(); } - public RegexProperty hostname() { + public static RegexProperty hostname() { return new RegexProperty(HOSTNAME_PATTERN).asString(); } - public RegexProperty email() { + public static RegexProperty email() { return new RegexProperty(EMAIL).asString(); } - public RegexProperty url() { + public static RegexProperty url() { return new RegexProperty(URL).asString(); } - public RegexProperty httpsUrl() { + public static RegexProperty httpsUrl() { return new RegexProperty(HTTPS_URL).asString(); } - public RegexProperty uuid() { + public static RegexProperty uuid() { return new RegexProperty(UUID).asString(); } - public RegexProperty isoDate() { + public static RegexProperty isoDate() { return new RegexProperty(ANY_DATE).asString(); } - public RegexProperty isoDateTime() { + public static RegexProperty isoDateTime() { return new RegexProperty(ANY_DATE_TIME).asString(); } - public RegexProperty isoTime() { + public static RegexProperty isoTime() { return new RegexProperty(ANY_TIME).asString(); } + public static RegexProperty iso8601WithOffset() { + return new RegexProperty(ISO8601_WITH_OFFSET).asString(); + } + + public static RegexProperty nonEmpty() { + return new RegexProperty(NON_EMPTY).asString(); + } + + public static RegexProperty nonBlank() { + return new RegexProperty(NON_BLANK).asString(); + } + // end::regexps[] - public RegexProperty iso8601WithOffset() { - return new RegexProperty(ISO8601_WITH_OFFSET).asString(); - } - - public RegexProperty nonEmpty() { - return new RegexProperty(NON_EMPTY).asString(); - } - - public RegexProperty nonBlank() { - return new RegexProperty(NON_BLANK).asString(); - } - } diff --git a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Request.java b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Request.java index 6972e5f428..ccc35f4acf 100644 --- a/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Request.java +++ b/specs/spring-cloud-contract-spec-java/src/main/java/org/springframework/cloud/contract/spec/internal/Request.java @@ -42,8 +42,6 @@ public class Request extends Common implements RegexCreatingProperty NON_HEADER_META_DATA = [DESTINATION_KEY] @@ -124,15 +122,15 @@ class MessagingSCContractCreator { switch (rule.numberType) { case NumberTypeMatcher.NumberType.NUMBER: jsonPath(key, - byRegex(regexPatterns.number())) + byRegex(RegexPatterns.number())) break case NumberTypeMatcher.NumberType.INTEGER: jsonPath(key, - byRegex(regexPatterns.anInteger())) + byRegex(RegexPatterns.anInteger())) break case NumberTypeMatcher.NumberType.DECIMAL: jsonPath(key, - byRegex(regexPatterns.aDouble())) + byRegex(RegexPatterns.aDouble())) break default: throw new RuntimeException("Unsupported number type!") diff --git a/spring-cloud-contract-tools/spring-cloud-contract-pact/src/main/groovy/org/springframework/cloud/contract/verifier/spec/pact/RequestResponseSCContractCreator.groovy b/spring-cloud-contract-tools/spring-cloud-contract-pact/src/main/groovy/org/springframework/cloud/contract/verifier/spec/pact/RequestResponseSCContractCreator.groovy index 3bed2775ea..ce5c90fe02 100644 --- a/spring-cloud-contract-tools/spring-cloud-contract-pact/src/main/groovy/org/springframework/cloud/contract/verifier/spec/pact/RequestResponseSCContractCreator.groovy +++ b/spring-cloud-contract-tools/spring-cloud-contract-pact/src/main/groovy/org/springframework/cloud/contract/verifier/spec/pact/RequestResponseSCContractCreator.groovy @@ -56,7 +56,6 @@ import org.springframework.cloud.contract.verifier.util.JsonToJsonPathsConverter class RequestResponseSCContractCreator { private static final String FULL_BODY = '$' - private static final RegexPatterns regexPatterns = new RegexPatterns() Collection convertFrom(RequestResponsePact pact) { return pact.interactions.collect { RequestResponseInteraction interaction -> @@ -147,15 +146,15 @@ class RequestResponseSCContractCreator { switch (rule.numberType) { case NumberTypeMatcher.NumberType.NUMBER: jsonPath(key, - byRegex(regexPatterns.number())) + byRegex(RegexPatterns.number())) break case NumberTypeMatcher.NumberType.INTEGER: - jsonPath(key, byRegex(regexPatterns. + jsonPath(key, byRegex(RegexPatterns. anInteger())) break case NumberTypeMatcher.NumberType.DECIMAL: jsonPath(key, - byRegex(regexPatterns.aDouble())) + byRegex(RegexPatterns.aDouble())) break default: throw new RuntimeException("Unsupported number type!") @@ -237,17 +236,17 @@ class RequestResponseSCContractCreator { switch (rule.numberType) { case NumberTypeMatcher.NumberType.NUMBER: jsonPath(key, - byRegex(regexPatterns. + byRegex(RegexPatterns. number())) break case NumberTypeMatcher.NumberType.INTEGER: jsonPath(key, - byRegex(regexPatterns. + byRegex(RegexPatterns. anInteger())) break case NumberTypeMatcher.NumberType.DECIMAL: jsonPath(key, - byRegex(regexPatterns. + byRegex(RegexPatterns. aDouble())) break default: diff --git a/spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/converter/YamlToContracts.groovy b/spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/converter/YamlToContracts.groovy index 5ac695948d..2dbbd318de 100644 --- a/spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/converter/YamlToContracts.groovy +++ b/spring-cloud-contract-verifier/src/main/groovy/org/springframework/cloud/contract/verifier/converter/YamlToContracts.groovy @@ -43,6 +43,7 @@ import static org.springframework.cloud.contract.verifier.util.ContentUtils.eval /** * @author Marcin Grzejszczak * @author Olga Maciaszek-Sharma + * @author Tim Ysewyn */ @PackageScope class YamlToContracts { @@ -721,38 +722,37 @@ class YamlToContracts { } protected Pattern predefinedToPattern(YamlContract.PredefinedRegex predefinedRegex) { - RegexPatterns patterns = new RegexPatterns() switch (predefinedRegex) { case YamlContract.PredefinedRegex.only_alpha_unicode: - return patterns.onlyAlphaUnicode().pattern + return RegexPatterns.onlyAlphaUnicode().pattern case YamlContract.PredefinedRegex.number: - return patterns.number().pattern + return RegexPatterns.number().pattern case YamlContract.PredefinedRegex.any_double: - return patterns.aDouble().pattern + return RegexPatterns.aDouble().pattern case YamlContract.PredefinedRegex.any_boolean: - return patterns.anyBoolean().pattern + return RegexPatterns.anyBoolean().pattern case YamlContract.PredefinedRegex.ip_address: - return patterns.ipAddress().pattern + return RegexPatterns.ipAddress().pattern case YamlContract.PredefinedRegex.hostname: - return patterns.hostname().pattern + return RegexPatterns.hostname().pattern case YamlContract.PredefinedRegex.email: - return patterns.email().pattern + return RegexPatterns.email().pattern case YamlContract.PredefinedRegex.url: - return patterns.url().pattern + return RegexPatterns.url().pattern case YamlContract.PredefinedRegex.uuid: - return patterns.uuid().pattern + return RegexPatterns.uuid().pattern case YamlContract.PredefinedRegex.iso_date: - return patterns.isoDate().pattern + return RegexPatterns.isoDate().pattern case YamlContract.PredefinedRegex.iso_date_time: - return patterns.isoDateTime().pattern + return RegexPatterns.isoDateTime().pattern case YamlContract.PredefinedRegex.iso_time: - return patterns.isoTime().pattern + return RegexPatterns.isoTime().pattern case YamlContract.PredefinedRegex.iso_8601_with_offset: - return patterns.iso8601WithOffset().pattern + return RegexPatterns.iso8601WithOffset().pattern case YamlContract.PredefinedRegex.non_empty: - return patterns.nonEmpty().pattern + return RegexPatterns.nonEmpty().pattern case YamlContract.PredefinedRegex.non_blank: - return patterns.nonBlank().pattern + return RegexPatterns.nonBlank().pattern default: throw new UnsupportedOperationException("The predefined regex [" + predefinedRegex + "] is unsupported. Use on of " + YamlContract.PredefinedRegex. diff --git a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/converter/YamlContractConverterSpec.groovy b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/converter/YamlContractConverterSpec.groovy index 181a8041d4..b262d219b2 100644 --- a/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/converter/YamlContractConverterSpec.groovy +++ b/spring-cloud-contract-verifier/src/test/groovy/org/springframework/cloud/contract/verifier/converter/YamlContractConverterSpec.groovy @@ -259,7 +259,6 @@ class YamlContractConverterSpec extends Specification { then: contracts.size() == 1 Contract contract = contracts.first() - RegexPatterns patterns = new RegexPatterns() contract.request.headers.entries.find { it.name == "Content-Type" && ((Pattern) it.clientValue).pattern == "application/json.*" && it.serverValue == "application/json" @@ -289,24 +288,24 @@ class YamlContractConverterSpec extends Specification { contract.request.bodyMatchers.matchers[1].matchingType() == EQUALITY contract.request.bodyMatchers.matchers[2].path() == '$.alpha' contract.request.bodyMatchers.matchers[2].matchingType() == REGEX - contract.request.bodyMatchers.matchers[2].value().pattern() == patterns.onlyAlphaUnicode().pattern() + contract.request.bodyMatchers.matchers[2].value().pattern() == RegexPatterns.onlyAlphaUnicode().pattern() contract.request.bodyMatchers.matchers[3].path() == '$.alpha' contract.request.bodyMatchers.matchers[3].matchingType() == EQUALITY contract.request.bodyMatchers.matchers[4].path() == '$.number' contract.request.bodyMatchers.matchers[4].matchingType() == REGEX - contract.request.bodyMatchers.matchers[4].value().pattern() == patterns.number().pattern() + contract.request.bodyMatchers.matchers[4].value().pattern() == RegexPatterns.number().pattern() contract.request.bodyMatchers.matchers[5].path() == '$.aBoolean' contract.request.bodyMatchers.matchers[5].matchingType() == REGEX - contract.request.bodyMatchers.matchers[5].value().pattern() == patterns.anyBoolean().pattern() + contract.request.bodyMatchers.matchers[5].value().pattern() == RegexPatterns.anyBoolean().pattern() contract.request.bodyMatchers.matchers[6].path() == '$.date' contract.request.bodyMatchers.matchers[6].matchingType() == DATE - contract.request.bodyMatchers.matchers[6].value().pattern() == patterns.isoDate().pattern() + contract.request.bodyMatchers.matchers[6].value().pattern() == RegexPatterns.isoDate().pattern() contract.request.bodyMatchers.matchers[7].path() == '$.dateTime' contract.request.bodyMatchers.matchers[7].matchingType() == TIMESTAMP - contract.request.bodyMatchers.matchers[7].value().pattern() == patterns.isoDateTime().pattern() + contract.request.bodyMatchers.matchers[7].value().pattern() == RegexPatterns.isoDateTime().pattern() contract.request.bodyMatchers.matchers[8].path() == '$.time' contract.request.bodyMatchers.matchers[8].matchingType() == TIME - contract.request.bodyMatchers.matchers[8].value().pattern() == patterns.isoTime().pattern() + contract.request.bodyMatchers.matchers[8].value().pattern() == RegexPatterns.isoTime().pattern() contract.request.bodyMatchers.matchers[9].path() == "\$.['key'].['complex.key']" contract.request.bodyMatchers.matchers[9].matchingType() == EQUALITY contract.request.bodyMatchers.matchers[10].path() == '$.valueWithMin' @@ -332,24 +331,24 @@ class YamlContractConverterSpec extends Specification { contract.response.bodyMatchers.matchers[1].matchingType() == EQUALITY contract.response.bodyMatchers.matchers[2].path() == '$.alpha' contract.response.bodyMatchers.matchers[2].matchingType() == REGEX - contract.response.bodyMatchers.matchers[2].value().pattern() == patterns.onlyAlphaUnicode().pattern() + contract.response.bodyMatchers.matchers[2].value().pattern() == RegexPatterns.onlyAlphaUnicode().pattern() contract.response.bodyMatchers.matchers[3].path() == '$.alpha' contract.response.bodyMatchers.matchers[3].matchingType() == EQUALITY contract.response.bodyMatchers.matchers[4].path() == '$.number' contract.response.bodyMatchers.matchers[4].matchingType() == REGEX - contract.response.bodyMatchers.matchers[4].value().pattern() == patterns.number().pattern() + contract.response.bodyMatchers.matchers[4].value().pattern() == RegexPatterns.number().pattern() contract.response.bodyMatchers.matchers[5].path() == '$.aBoolean' contract.response.bodyMatchers.matchers[5].matchingType() == REGEX - contract.response.bodyMatchers.matchers[5].value().pattern() == patterns.anyBoolean().pattern() + contract.response.bodyMatchers.matchers[5].value().pattern() == RegexPatterns.anyBoolean().pattern() contract.response.bodyMatchers.matchers[6].path() == '$.date' contract.response.bodyMatchers.matchers[6].matchingType() == DATE - contract.response.bodyMatchers.matchers[6].value().pattern() == patterns.isoDate().pattern() + contract.response.bodyMatchers.matchers[6].value().pattern() == RegexPatterns.isoDate().pattern() contract.response.bodyMatchers.matchers[7].path() == '$.dateTime' contract.response.bodyMatchers.matchers[7].matchingType() == TIMESTAMP - contract.response.bodyMatchers.matchers[7].value().pattern() == patterns.isoDateTime().pattern() + contract.response.bodyMatchers.matchers[7].value().pattern() == RegexPatterns.isoDateTime().pattern() contract.response.bodyMatchers.matchers[8].path() == '$.time' contract.response.bodyMatchers.matchers[8].matchingType() == TIME - contract.response.bodyMatchers.matchers[8].value().pattern() == patterns.isoTime().pattern() + contract.response.bodyMatchers.matchers[8].value().pattern() == RegexPatterns.isoTime().pattern() contract.response.bodyMatchers.matchers[9].path() == '$.valueWithTypeMatch' contract.response.bodyMatchers.matchers[9].matchingType() == TYPE contract.response.bodyMatchers.matchers[10].path() == '$.valueWithMin' @@ -395,7 +394,6 @@ class YamlContractConverterSpec extends Specification { then: contracts.size() == 1 Contract contract = contracts.first() - RegexPatterns patterns = new RegexPatterns() contract.input.messageHeaders.entries.find { it.name == "contentType" && ((Pattern) it.clientValue).pattern == "application/json.*" && it.serverValue == "application/json" @@ -407,24 +405,24 @@ class YamlContractConverterSpec extends Specification { contract.input.bodyMatchers.matchers[1].matchingType() == EQUALITY contract.input.bodyMatchers.matchers[2].path() == '$.alpha' contract.input.bodyMatchers.matchers[2].matchingType() == REGEX - contract.input.bodyMatchers.matchers[2].value().pattern() == patterns.onlyAlphaUnicode().pattern() + contract.input.bodyMatchers.matchers[2].value().pattern() == RegexPatterns.onlyAlphaUnicode().pattern() contract.input.bodyMatchers.matchers[3].path() == '$.alpha' contract.input.bodyMatchers.matchers[3].matchingType() == EQUALITY contract.input.bodyMatchers.matchers[4].path() == '$.number' contract.input.bodyMatchers.matchers[4].matchingType() == REGEX - contract.input.bodyMatchers.matchers[4].value().pattern() == patterns.number().pattern() + contract.input.bodyMatchers.matchers[4].value().pattern() == RegexPatterns.number().pattern() contract.input.bodyMatchers.matchers[5].path() == '$.aBoolean' contract.input.bodyMatchers.matchers[5].matchingType() == REGEX - contract.input.bodyMatchers.matchers[5].value().pattern() == patterns.anyBoolean().pattern() + contract.input.bodyMatchers.matchers[5].value().pattern() == RegexPatterns.anyBoolean().pattern() contract.input.bodyMatchers.matchers[6].path() == '$.date' contract.input.bodyMatchers.matchers[6].matchingType() == DATE - contract.input.bodyMatchers.matchers[6].value().pattern() == patterns.isoDate().pattern() + contract.input.bodyMatchers.matchers[6].value().pattern() == RegexPatterns.isoDate().pattern() contract.input.bodyMatchers.matchers[7].path() == '$.dateTime' contract.input.bodyMatchers.matchers[7].matchingType() == TIMESTAMP - contract.input.bodyMatchers.matchers[7].value().pattern() == patterns.isoDateTime().pattern() + contract.input.bodyMatchers.matchers[7].value().pattern() == RegexPatterns.isoDateTime().pattern() contract.input.bodyMatchers.matchers[8].path() == '$.time' contract.input.bodyMatchers.matchers[8].matchingType() == TIME - contract.input.bodyMatchers.matchers[8].value().pattern() == patterns.isoTime().pattern() + contract.input.bodyMatchers.matchers[8].value().pattern() == RegexPatterns.isoTime().pattern() contract.input.bodyMatchers.matchers[9].path() == "\$.['key'].['complex.key']" contract.input.bodyMatchers.matchers[9].matchingType() == EQUALITY and: @@ -435,24 +433,24 @@ class YamlContractConverterSpec extends Specification { contract.outputMessage.bodyMatchers.matchers[1].matchingType() == EQUALITY contract.outputMessage.bodyMatchers.matchers[2].path() == '$.alpha' contract.outputMessage.bodyMatchers.matchers[2].matchingType() == REGEX - contract.outputMessage.bodyMatchers.matchers[2].value().pattern() == patterns.onlyAlphaUnicode().pattern() + contract.outputMessage.bodyMatchers.matchers[2].value().pattern() == RegexPatterns.onlyAlphaUnicode().pattern() contract.outputMessage.bodyMatchers.matchers[3].path() == '$.alpha' contract.outputMessage.bodyMatchers.matchers[3].matchingType() == EQUALITY contract.outputMessage.bodyMatchers.matchers[4].path() == '$.number' contract.outputMessage.bodyMatchers.matchers[4].matchingType() == REGEX - contract.outputMessage.bodyMatchers.matchers[4].value().pattern() == patterns.number().pattern() + contract.outputMessage.bodyMatchers.matchers[4].value().pattern() == RegexPatterns.number().pattern() contract.outputMessage.bodyMatchers.matchers[5].path() == '$.aBoolean' contract.outputMessage.bodyMatchers.matchers[5].matchingType() == REGEX - contract.outputMessage.bodyMatchers.matchers[5].value().pattern() == patterns.anyBoolean().pattern() + contract.outputMessage.bodyMatchers.matchers[5].value().pattern() == RegexPatterns.anyBoolean().pattern() contract.outputMessage.bodyMatchers.matchers[6].path() == '$.date' contract.outputMessage.bodyMatchers.matchers[6].matchingType() == DATE - contract.outputMessage.bodyMatchers.matchers[6].value().pattern() == patterns.isoDate().pattern() + contract.outputMessage.bodyMatchers.matchers[6].value().pattern() == RegexPatterns.isoDate().pattern() contract.outputMessage.bodyMatchers.matchers[7].path() == '$.dateTime' contract.outputMessage.bodyMatchers.matchers[7].matchingType() == TIMESTAMP - contract.outputMessage.bodyMatchers.matchers[7].value().pattern() == patterns.isoDateTime().pattern() + contract.outputMessage.bodyMatchers.matchers[7].value().pattern() == RegexPatterns.isoDateTime().pattern() contract.outputMessage.bodyMatchers.matchers[8].path() == '$.time' contract.outputMessage.bodyMatchers.matchers[8].matchingType() == TIME - contract.outputMessage.bodyMatchers.matchers[8].value().pattern() == patterns.isoTime().pattern() + contract.outputMessage.bodyMatchers.matchers[8].value().pattern() == RegexPatterns.isoTime().pattern() contract.outputMessage.bodyMatchers.matchers[9].path() == '$.valueWithTypeMatch' contract.outputMessage.bodyMatchers.matchers[9].matchingType() == TYPE contract.outputMessage.bodyMatchers.matchers[10].path() == '$.valueWithMin' @@ -502,17 +500,16 @@ class YamlContractConverterSpec extends Specification { then: contracts.size() == 1 Contract contract = contracts.first() - RegexPatterns patterns = new RegexPatterns() def stubSide = MapConverter.getStubSideValues(contract.request.multipart) stubSide.formParameter.pattern() == ".+" - stubSide.someBooleanParameter.pattern() == patterns.anyBoolean().pattern() + stubSide.someBooleanParameter.pattern() == RegexPatterns.anyBoolean().pattern() def testSide = MapConverter.getTestSideValues(contract.request.multipart) testSide.formParameter == '"formParameterValue"' testSide.someBooleanParameter == "true" ((NamedProperty) testSide.file).name.serverValue == "filename.csv" - ((NamedProperty) testSide.file).name.clientValue.pattern() == patterns.nonEmpty().pattern() + ((NamedProperty) testSide.file).name.clientValue.pattern() == RegexPatterns.nonEmpty().pattern() ((NamedProperty) testSide.file).value.serverValue == "file content" - ((NamedProperty) testSide.file).value.clientValue.pattern() == patterns.nonEmpty().pattern() + ((NamedProperty) testSide.file).value.clientValue.pattern() == RegexPatterns.nonEmpty().pattern() and: contract.response.status.serverValue == 200 } @@ -1284,7 +1281,6 @@ ignored: false then: contracts.size() == 1 Contract contract = contracts.first() - RegexPatterns patterns = new RegexPatterns() contract.request.headers.entries.find({ it.name == 'Content-Type' && it.clientValue == "application/xml" && it.serverValue == "application/xml" }) @@ -1296,7 +1292,7 @@ ignored: false contract.request.bodyMatchers.matchers[2].path() == '/test/time/text()' contract.request.bodyMatchers.matchers[2].matchingType() == TIME contract.request.bodyMatchers.matchers[2] - .value().pattern() == patterns.isoTime().pattern() + .value().pattern() == RegexPatterns.isoTime().pattern() contract.request.body.clientValue.replaceAll("\n", ""). replaceAll(' ', '') == xmlContractBody.replaceAll("\n", ""). replaceAll(' ', '') @@ -1318,7 +1314,7 @@ ignored: false contract.response.bodyMatchers.matchers[4].path() == '/test/time/text()' contract.response.bodyMatchers.matchers[4].matchingType() == TIME contract.response.bodyMatchers.matchers[4] - .value().pattern() == patterns.isoTime().pattern() + .value().pattern() == RegexPatterns.isoTime().pattern() contract.response.body.clientValue.replaceAll("\n", "") .replaceAll(' ', '') == xmlContractBody .replaceAll("\n", "").replaceAll(' ', '') diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index e997e48975..fa5679883e 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -42,7 +42,8 @@ - - - + + + +