Class HandlebarsContractTemplate
- java.lang.Object
-
- org.springframework.cloud.contract.spec.internal.HandlebarsContractTemplate
-
- All Implemented Interfaces:
ContractTemplate
public class HandlebarsContractTemplate extends Object implements ContractTemplate
Represents the structure of templates using Handlebars compatible with WireMock template model requirements.- Since:
- 1.1.0
- Author:
- Marcin Grzejszczak
-
-
Constructor Summary
Constructors Constructor Description HandlebarsContractTemplate()
-
Method Summary
All Methods Instance Methods Concrete 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)StringescapedBody()StringescapedBody(String jsonPath)StringescapedClosingTemplate()Handlebars is using the Mustache template thus it looks like this {{{ Mustache }}}.StringescapedCookie(String key)StringescapedHeader(String key)StringescapedHeader(String key, int index)StringescapedOpeningTemplate()Handlebars is using the Mustache template thus it looks like this {{{ Mustache }}}.StringescapedPath()StringescapedPath(int index)StringescapedQuery(String key)StringescapedQuery(String key, int index)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)Stringurl()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.cloud.contract.spec.ContractTemplate
startsWithEscapedTemplate, startsWithTemplate
-
-
-
-
Method Detail
-
openingTemplate
public String openingTemplate()
Description copied from interface:ContractTemplateHandlebars is using the Mustache template thus it looks like this {{ Mustache }}. In this case the opening template would return {{- Specified by:
openingTemplatein interfaceContractTemplate- Returns:
- opening template for a variable
-
closingTemplate
public String closingTemplate()
Description copied from interface:ContractTemplateHandlebars is using the Mustache template thus it looks like this {{ Mustache }}. In this case the closing template would return }}- Specified by:
closingTemplatein interfaceContractTemplate- Returns:
- closing template for a variable
-
escapedOpeningTemplate
public String escapedOpeningTemplate()
Description copied from interface:ContractTemplateHandlebars is using the Mustache template thus it looks like this {{{ Mustache }}}. In this case the opening template would return {{{- Specified by:
escapedOpeningTemplatein interfaceContractTemplate- Returns:
- escaped opening template for a variable
-
escapedClosingTemplate
public String escapedClosingTemplate()
Description copied from interface:ContractTemplateHandlebars is using the Mustache template thus it looks like this {{{ Mustache }}}. In this case the closing template would return }}}- Specified by:
escapedClosingTemplatein interfaceContractTemplate- Returns:
- escaped closing template for a variable
-
url
public String url()
- Specified by:
urlin interfaceContractTemplate- Returns:
- returns the template for retrieving a URL path and query from request
-
query
public String query(String key)
- Specified by:
queryin interfaceContractTemplate- Parameters:
key- query parameter key- Returns:
- the template for retrieving first value of a query parameter e.g. {{ request.query.search }}
-
query
public String query(String key, int index)
- Specified by:
queryin interfaceContractTemplate- 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
public String path()
- Specified by:
pathin interfaceContractTemplate- Returns:
- the template for retrieving a URL path
-
path
public String path(int index)
- Specified by:
pathin interfaceContractTemplate- Parameters:
index- request path index- Returns:
- the template for retrieving nth value of a URL path (zero indexed) e.g. {{ request.path.[2] }}
-
header
public String header(String key)
- Specified by:
headerin interfaceContractTemplate- Parameters:
key- headers key- Returns:
- the template for retrieving the first value of a request header e.g. {{ request.headers.X-Request-Id }}
-
header
public String header(String key, int index)
- Specified by:
headerin interfaceContractTemplate- 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
public String cookie(String key)
- Specified by:
cookiein interfaceContractTemplate- Parameters:
key- cookie key- Returns:
- the template for retrieving the first value of a cookie with certain key
-
body
public String body()
- Specified by:
bodyin interfaceContractTemplate- 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
public String escapedBody()
- Specified by:
escapedBodyin interfaceContractTemplate- 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
public String escapedBody(String jsonPath)
- Specified by:
escapedBodyin interfaceContractTemplate- Parameters:
jsonPath- json path value- Returns:
- request body text for the given JsonPath. e.g. {{{ jsonPath request.body '$.a.b.c' }}}
-
body
public String body(String jsonPath)
- Specified by:
bodyin interfaceContractTemplate- Parameters:
jsonPath- json path value- Returns:
- request body text for the given JsonPath. e.g. {{ jsonPath request.body '$.a.b.c' }}
-
escapedUrl
public String escapedUrl()
- Specified by:
escapedUrlin interfaceContractTemplate- Returns:
- the template for retrieving a escaped URL path and query from request
-
escapedQuery
public String escapedQuery(String key)
- Specified by:
escapedQueryin interfaceContractTemplate- Parameters:
key- query parameter key- Returns:
- the template for retrieving escaped first value of a query parameter e.g. {{{ request.query.search }}}
-
escapedQuery
public String escapedQuery(String key, int index)
- Specified by:
escapedQueryin interfaceContractTemplate- 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
public String escapedPath()
- Specified by:
escapedPathin interfaceContractTemplate- Returns:
- the template for retrieving a escaped URL path
-
escapedPath
public String escapedPath(int index)
- Specified by:
escapedPathin interfaceContractTemplate- Parameters:
index- path index- Returns:
- the template for retrieving escaped nth value of a URL path (zero indexed) e.g. {{{ request.path.[2] }}}
-
escapedHeader
public String escapedHeader(String key)
- Specified by:
escapedHeaderin interfaceContractTemplate- 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
public String escapedHeader(String key, int index)
- Specified by:
escapedHeaderin interfaceContractTemplate- 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
public String escapedCookie(String key)
- Specified by:
escapedCookiein interfaceContractTemplate- Parameters:
key- cookie key- Returns:
- the template for retrieving the escaped first value of a cookie with certain key
-
-