Interface ContractTemplate
-
- All Known Implementing Classes:
CompositeContractTemplate,HandlebarsContractTemplate
public interface ContractTemplateContract for defining templated responses.If no implementation is provided then Handlebars will be picked as a default implementation.
- Since:
- 1.1.0
- Author:
- Marcin Grzejszczak
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Stringbody()Stringbody(String jsonPath)StringclosingTemplate()Handlebars is using the Mustache template thus it looks like this {{ Mustache }}.Stringcookie(String key)default StringescapedBody()default StringescapedBody(String jsonPath)default StringescapedClosingTemplate()Handlebars is using the Mustache template thus it looks like this {{{ Mustache }}}.default StringescapedCookie(String key)default StringescapedHeader(String key)default StringescapedHeader(String key, int index)default StringescapedOpeningTemplate()Handlebars is using the Mustache template thus it looks like this {{{ Mustache }}}.default StringescapedPath()default StringescapedPath(int index)default StringescapedQuery(String key)default StringescapedQuery(String key, int index)default StringescapedUrl()Stringheader(String key)Stringheader(String key, int index)StringopeningTemplate()Handlebars is using the Mustache template thus it looks like this {{ Mustache }}.Stringpath()Stringpath(int index)Stringquery(String key)Stringquery(String key, int index)default booleanstartsWithEscapedTemplate(String text)default booleanstartsWithTemplate(String text)Stringurl()
-
-
-
Method Detail
-
startsWithTemplate
default boolean startsWithTemplate(String text)
- Parameters:
text- text to assert- Returns:
- asserts whether the given text starts with proper opening template.
-
startsWithEscapedTemplate
default boolean startsWithEscapedTemplate(String text)
- Parameters:
text- text to assert- Returns:
- asserts whether the given text starts with proper opening template for escaped value.
-
openingTemplate
String openingTemplate()
Handlebars is using the Mustache template thus it looks like this {{ Mustache }}. In this case the opening template would return {{- Returns:
- opening template for a variable
-
closingTemplate
String closingTemplate()
Handlebars is using the Mustache template thus it looks like this {{ Mustache }}. In this case the closing template would return }}- Returns:
- closing template for a variable
-
escapedOpeningTemplate
default String escapedOpeningTemplate()
Handlebars is using the Mustache template thus it looks like this {{{ Mustache }}}. In this case the opening template would return {{{- Returns:
- escaped opening template for a variable
-
escapedClosingTemplate
default String escapedClosingTemplate()
Handlebars is using the Mustache template thus it looks like this {{{ Mustache }}}. In this case the closing template would return }}}- Returns:
- escaped closing template for a variable
-
url
String url()
- Returns:
- returns the template for retrieving a URL path and query from request
-
query
String query(String key)
- Parameters:
key- query parameter key- Returns:
- the template for retrieving first value of a query parameter e.g. {{ request.query.search }}
-
query
String query(String key, int index)
- Parameters:
key- query parameter keyindex- query parameter index- Returns:
- the template for retrieving nth value of a query parameter (zero indexed) e.g. {{ request.query.search.[5] }}
-
path
String path()
- Returns:
- the template for retrieving a URL path
-
path
String path(int index)
- Parameters:
index- request path index- Returns:
- the template for retrieving nth value of a URL path (zero indexed) e.g. {{ request.path.[2] }}
-
header
String header(String key)
- Parameters:
key- headers key- Returns:
- the template for retrieving the first value of a request header e.g. {{ request.headers.X-Request-Id }}
-
header
String header(String key, int index)
- Parameters:
key- headers keyindex- headers index- Returns:
- the template for retrieving the nth value of a request header (zero indexed) e.g. {{ request.headers.X-Request-Id.[5] }}
-
cookie
String cookie(String key)
- Parameters:
key- cookie key- Returns:
- the template for retrieving the first value of a cookie with certain key
-
body
String body()
- Returns:
- 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.
-
body
String body(String jsonPath)
- Parameters:
jsonPath- json path value- Returns:
- request body text for the given JsonPath. e.g. {{ jsonPath request.body '$.a.b.c' }}
-
escapedUrl
default String escapedUrl()
- Returns:
- the template for retrieving a escaped URL path and query from request
-
escapedQuery
default String escapedQuery(String key)
- Parameters:
key- query parameter key- Returns:
- the template for retrieving escaped first value of a query parameter e.g. {{{ request.query.search }}}
-
escapedQuery
default String escapedQuery(String key, int index)
- Parameters:
key- query parameter keyindex- query parameter index- Returns:
- the template for retrieving esacped nth value of a query parameter (zero indexed) e.g. {{{ request.query.search.[5] }}}
-
escapedPath
default String escapedPath()
- Returns:
- the template for retrieving a escaped URL path
-
escapedPath
default String escapedPath(int index)
- Parameters:
index- path index- Returns:
- the template for retrieving escaped nth value of a URL path (zero indexed) e.g. {{{ request.path.[2] }}}
-
escapedHeader
default String escapedHeader(String key)
- Parameters:
key- headers key- Returns:
- the template for retrieving the escaped first value of a request header e.g. {{{ request.headers.X-Request-Id }}}
-
escapedHeader
default String escapedHeader(String key, int index)
- Parameters:
key- headers keyindex- headers index- Returns:
- the template for retrieving the esacaped nth value of a request header (zero indexed) e.g. {{{ request.headers.X-Request-Id.[5] }}}
-
escapedCookie
default String escapedCookie(String key)
- Parameters:
key- cookie key- Returns:
- the template for retrieving the escaped first value of a cookie with certain key
-
escapedBody
default String escapedBody()
- Returns:
- 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.
-
-