Interface ContractTemplate
- All Known Implementing Classes:
CompositeContractTemplate, HandlebarsContractTemplate
public interface ContractTemplate
Contract 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
Modifier and TypeMethodDescriptionbody()Handlebars is using the Mustache template thus it looks like this {{ Mustache }}.default Stringdefault StringescapedBody(String jsonPath) default StringHandlebars 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 StringHandlebars is using the Mustache template thus it looks like this {{{ Mustache }}}.default Stringdefault StringescapedPath(int index) default StringescapedQuery(String key) default StringescapedQuery(String key, int index) default StringHandlebars is using the Mustache template thus it looks like this {{ Mustache }}.path()path(int index) default booleandefault booleanstartsWithTemplate(String text) url()
-
Method Details
-
startsWithTemplate
- Parameters:
text- text to assert- Returns:
- asserts whether the given text starts with proper opening template.
-
startsWithEscapedTemplate
- 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
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
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
-
query
-
path
String path()- Returns:
- the template for retrieving a URL path
-
path
- Parameters:
index- request path index- Returns:
- the template for retrieving nth value of a URL path (zero indexed) e.g. {{ request.path.[2] }}
-
header
-
header
-
cookie
-
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
-
escapedUrl
- Returns:
- the template for retrieving a escaped URL path and query from request
-
escapedQuery
-
escapedQuery
-
escapedPath
- Returns:
- the template for retrieving a escaped URL path
-
escapedPath
- Parameters:
index- path index- Returns:
- the template for retrieving escaped nth value of a URL path (zero indexed) e.g. {{{ request.path.[2] }}}
-
escapedHeader
-
escapedHeader
-
escapedCookie
-
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.
-
escapedBody
-