Language Injections
Various language injections are provided by the WireMocha plugin that extend the bundled configuration.
In general, injections require the IntelliLang plugin to be installed (bundled by default), while XPath injections require the XPathView + XSLT plugin,
and Handlebars injections require the Handlebars/Mustache plugin. All of these plugins are optional, but in case any of them is disabled or not installed, the corresponding functionality of WireMocha won’t be available.
Notes:
- Injecting multiple separate Handlebars fragments into the same literal is available since v1.0.2.
- Known issue: if a string literal contains a raw block (
{{{{
), although Handlebars is injected into it, subsequent Handlebars fragments in the same literal are highlighted as generic expressions and not actual helpers, and lack features like code completion. This happens via the IDE’s own language injection feature as well.
Java DSL
These are all enabled by default. Handlebars injection can be disabled under IDE Settings > Tools > WireMocha, while the rest can be disabled individually under IDE Settings > Editor > Language Injections. They are by default available since v1.0.0, unless stated otherwise.
Category | Location | Injected Language | Comment |
---|---|---|---|
WireMock URL Matchers | WireMock.urlMatching() WireMock.urlPathMatching() | RegExp | |
WireMock String Value Matchers | WireMock.matching() WireMock.notMatching() | RegExp | |
WireMock JSON Matchers | WireMock.equalToJson() | JSON | |
WireMock XML Matchers | WireMock.equalToXml() | XML | |
WireMock JSON Path Matchers | WireMock.matchingJsonPath() | JSONPath | |
WireMock XPath Matchers | WireMock.matchingXPath() WireMock.matchesXPathWithSubMatcher() | XPath | |
WireMock JSON Response Body | WireMock.okJson() WireMock.jsonResponse() | JSON | |
WireMock XML Response Body | WireMock.okXml() WireMock.okTextXml() | XML | |
Response definition | Following methods of ResponseDefinitionBuilder :withBody() withBodyFile() withBase64Body() withHeader() proxiedFrom() | Handlebars | |
WebhookDefinition | Following methods of WebhookDefinition :withUrl() withMethod() withBody() | Handlebars | |
WireMockContainer – TestContainers Java module | WireMockContainer.withMapping() | JSON | |
WireMockConfiguration Permitted Keys | WireMockConfiguration.withPermittedSystemKeys() | RegExp | |
WireMockGrpc JSON | WireMockGrpc.json() | JSON | |
WireMockGrpc Handlebars | WireMockGrpc.jsonTemplate() | Handlebars |
JSON DSL
Injections into JSON mapping files are generally available since v1.0.1. They cannot be disabled.
Property | Injected Language | Comments |
---|---|---|
matches doesNotMatch urlPattern urlPathPattern placeholderOpeningDelimiterRegex placeholderClosingDelimiterRegex | RegExp | |
equalToJson | JSON | |
equalToXml | XML | |
matchesJsonPath matchesJsonPath.expression | JSONPath | |
matchesXPath matchesXPath.expression | XPath | |
body bodyFileName base64Body proxyBaseUrl Literals within response.headers | Handlebars | Applied inside the `response` properties. |
body url method | Handlebars | Applied inside serveEventListeners.parameters properties when the listener name is webhook. |
The following properties under request.customMatcher when the matcher name is state-matcher:hasContext hasNotContext hasProperty hasNotProperty listSizeEqualTo listSizeLessThan listSizeMoreThan updateCountEqualTo updateCountLessThan updateCountMoreThan | Handlebars | For the wiremock-state-extension. |
Properties under serveEventListeners.parameters when the listener is recordState or deleteState . | Handlebars | For the wiremock-state-extension. |