- * If no implementation is provided then Handlebars will be picked as a default implementation.
+ * If no implementation is provided then Handlebars will be picked as a default
+ * implementation.
*
* @author Marcin Grzejszczak
* @since 1.1.0
*/
public interface ContractTemplate {
+
/**
- * Asserts whether the given text starts with proper opening template
+ * @param text text to assert
+ * @return asserts whether the given text starts with proper opening template.
*/
default boolean startsWithTemplate(String text) {
return text.startsWith(openingTemplate());
}
/**
- * Asserts whether the given text starts with proper opening template for escaped value
+ * @param text text to assert
+ * @return asserts whether the given text starts with proper opening template for
+ * escaped value.
*/
default boolean startsWithEscapedTemplate(String text) {
return text.startsWith(escapedOpeningTemplate());
}
/**
- * Handlebars is using the Mustache template thus it looks like this
- * {{ Mustache }}. In this case the opening template would return {{
+ * Handlebars is using the Mustache template thus it looks like this {{ Mustache }}.
+ * In this case the opening template would return {{
+ * @return opening template for a variable
*/
String openingTemplate();
/**
- * Handlebars is using the Mustache template thus it looks like this
- * {{ Mustache }}. In this case the closing template would return }}
+ * Handlebars is using the Mustache template thus it looks like this {{ Mustache }}.
+ * In this case the closing template would return }}
+ * @return closing template for a variable
*/
String closingTemplate();
/**
- * Handlebars is using the Mustache template thus it looks like this
- * {{{ Mustache }}}. In this case the opening template would return {{{
+ * Handlebars is using the Mustache template thus it looks like this {{{ Mustache }}}.
+ * In this case the opening template would return {{{
+ * @return escaped opening template for a variable
*/
default String escapedOpeningTemplate() {
return openingTemplate();
}
/**
- * Handlebars is using the Mustache template thus it looks like this
- * {{{ Mustache }}}. In this case the closing template would return }}}
+ * Handlebars is using the Mustache template thus it looks like this {{{ Mustache }}}.
+ * In this case the closing template would return }}}
+ * @return escaped closing template for a variable
*/
default String escapedClosingTemplate() {
return closingTemplate();
}
/**
- * Returns the template for retrieving a URL path and query from request
+ * @return returns the template for retrieving a URL path and query from request
*/
String url();
/**
- * Returns the template for retrieving first value of a query parameter e.g. {{ request.query.search }}
- *
- * @param key
+ * @param key query parameter key
+ * @return the template for retrieving first value of a query parameter e.g. {{
+ * request.query.search }}
*/
String query(String key);
/**
- * Returns the template for retrieving nth value of a query parameter (zero indexed) e.g. {{ request.query.search.[5] }}
- *
- * @param key
- * @param index
+ * @param key query parameter key
+ * @param index query parameter index
+ * @return the template for retrieving nth value of a query parameter (zero indexed)
+ * e.g. {{ request.query.search.[5] }}
*/
String query(String key, int index);
/**
- * Returns the template for retrieving a URL path
+ * @return the template for retrieving a URL path
*/
String path();
/**
- * Returns the template for retrieving nth value of a URL path (zero indexed) e.g. {{ request.path.[2] }}
- *
- * @param index
+ * @param index request path index
+ * @return the template for retrieving nth value of a URL path (zero indexed) e.g. {{
+ * request.path.[2] }}
*/
String path(int index);
/**
- * Returns the template for retrieving the first value of a request header e.g. {{ request.headers.X-Request-Id }}
- *
- * @param key
+ * @param key headers key
+ * @return the template for retrieving the first value of a request header e.g. {{
+ * request.headers.X-Request-Id }}
*/
String header(String key);
/**
- * Returns the template for retrieving the nth value of a request header (zero indexed) e.g. {{ request.headers.X-Request-Id.[5] }}
- *
- * @param key
- * @param index
+ * @param key headers key
+ * @param index headers index
+ * @return the template for retrieving the nth value of a request header (zero
+ * indexed) e.g. {{ request.headers.X-Request-Id.[5] }}
*/
String header(String key, int index);
/**
- * Retruns the template for retrieving the first value of a cookie with certain key
- *
- * @param key
+ * @param key cookie key
+ * @return the template for retrieving the first value of a cookie with certain key
*/
String cookie(String key);
/**
- * Request body text (avoid for non-text bodies) e.g. {{ request.body }} . The body will not be escaped
- * so you won't be able to directly embed it in a JSON for example.
+ * @return request body text (avoid for non-text bodies) e.g. {{ request.body }} . The
+ * body will not be escaped so you won't be able to directly embed it in a JSON for
+ * example.
*/
String body();
/**
- * Request body text for the given JsonPath. e.g. {{ jsonPath request.body '$.a.b.c' }}
+ * @param jsonPath json path value
+ * @return request body text for the given JsonPath. e.g. {{ jsonPath request.body
+ * '$.a.b.c' }}
*/
String body(String jsonPath);
/**
- * Returns the template for retrieving a escaped URL path and query from request
+ * @return the template for retrieving a escaped URL path and query from request
*/
default String escapedUrl() {
return url();
}
/**
- * Returns the template for retrieving escaped first value of a query parameter e.g. {{{ request.query.search }}}
- *
- * @param key
+ * @param key query parameter key
+ * @return the template for retrieving escaped first value of a query parameter e.g.
+ * {{{ request.query.search }}}
*/
default String escapedQuery(String key) {
return query(key);
}
/**
- * Returns the template for retrieving esacped nth value of a query parameter (zero indexed) e.g. {{{ request.query.search.[5] }}}
- *
- * @param key
- * @param index
+ * @param key query parameter key
+ * @param index query parameter index
+ * @return the template for retrieving esacped nth value of a query parameter (zero
+ * indexed) e.g. {{{ request.query.search.[5] }}}
*/
default String escapedQuery(String key, int index) {
return query(key, index);
}
/**
- * Returns the template for retrieving a escaped URL path
+ * @return the template for retrieving a escaped URL path
*/
default String escapedPath() {
return path();
}
/**
- * Returns the template for retrieving escaped nth value of a URL path (zero indexed) e.g. {{{ request.path.[2] }}}
- *
- * @param index
+ * @param index path index
+ * @return the template for retrieving escaped nth value of a URL path (zero indexed)
+ * e.g. {{{ request.path.[2] }}}
*/
default String escapedPath(int index) {
return path(index);
}
/**
- * Returns the template for retrieving the escaped first value of a request header e.g. {{{ request.headers.X-Request-Id }}}
- *
- * @param key
+ * @param key headers key
+ * @return the template for retrieving the escaped first value of a request header
+ * e.g. {{{ request.headers.X-Request-Id }}}
*/
default String escapedHeader(String key) {
return header(key);
}
/**
- * Returns the template for retrieving the esacaped nth value of a request header (zero indexed) e.g. {{{ request.headers.X-Request-Id.[5] }}}
- *
- * @param key
- * @param index
+ * @param key headers key
+ * @param index headers index
+ * @return the template for retrieving the esacaped nth value of a request header
+ * (zero indexed) e.g. {{{ request.headers.X-Request-Id.[5] }}}
*/
default String escapedHeader(String key, int index) {
return header(key, index);
}
/**
- * Retruns the template for retrieving the escaped first value of a cookie with certain key
- *
- * @param key
+ * @param key cookie key
+ * @return the template for retrieving the escaped first value of a cookie with
+ * certain key
*/
default String escapedCookie(String key) {
return cookie(key);
}
/**
- * Request body text (avoid for non-text bodies) e.g. {{{ request.body }}} . The body will not be escaped
- * so you won't be able to directly embed it in a JSON for example.
+ * @return request body text (avoid for non-text bodies) e.g. {{{ request.body }}} .
+ * The body will not be escaped so you won't be able to directly embed it in a JSON
+ * for example.
*/
default String escapedBody() {
return body();
}
/**
- * Request body text for the given JsonPath. e.g. {{{ jsonPath request.body '$.a.b.c' }}}
+ * @param jsonPath json path value
+ * @return request body text for the given JsonPath. e.g. {{{ jsonPath request.body
+ * '$.a.b.c' }}}
*/
default String escapedBody(String jsonPath) {
return body(jsonPath);
diff --git a/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/ContractVerifierException.groovy b/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/ContractVerifierException.groovy
index 8c22210a52..f8131c94eb 100644
--- a/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/ContractVerifierException.groovy
+++ b/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/ContractVerifierException.groovy
@@ -1,17 +1,17 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * Copyright 2013-2019 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.springframework.cloud.contract.spec
diff --git a/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/internal/Body.groovy b/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/internal/Body.groovy
index 1a25fb0cb9..959113907e 100644
--- a/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/internal/Body.groovy
+++ b/spring-cloud-contract-spec/src/main/groovy/org/springframework/cloud/contract/spec/internal/Body.groovy
@@ -1,17 +1,17 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * Copyright 2013-2019 the original author or authors.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.springframework.cloud.contract.spec.internal
@@ -31,7 +31,8 @@ import groovy.transform.ToString
class Body extends DslProperty {
Body(Map