Verify requests received by WireMock mocks (stubs are defined in WireMock mapping files).
mock.service
Section titled “mock.service”Given the mocked {word} service with the following properties: | ... | ... |Register a WireMock server. The first mocked service registered in a scenario is the default one.
Properties: url (required; ${env:..}/${sys:..} are expanded).
Parameters: {word} (one word, no spaces)
Example:
Given the mocked addresses service with the following properties:mock.received
Section titled “mock.received”Then the mocked {word} request to {word} named {word} was received by {mockedService}Register a request pattern under a name (method + exact URL, including the query string) and verify WireMock received it at least once. Later steps refer to the pattern by name.
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario)
Example:
Then the mocked GET request to /v1/postcodes/DE/10115 named postcode-check was received by addressesmock.openapi.levels
Section titled “mock.openapi.levels”Given the OpenAPI validation levels for the mocked {mockedService} service are: | ... | ... |Relax, for this scenario, the mocked service’s OpenAPI contract: findings that would fail the checking mock step are reported at the level you set instead (key | level rows; WARN logs them, INFO and IGNORE drop them). A key also covers the keys below it: validation.response.body covers validation.response.body.schema.required. It applies to the calls this scenario’s mock steps check; a stub that is off-contract on purpose is better relaxed in its own metadata (openApiValidationLevels), which applies wherever it answers. This is the dependency’s contract: your own service’s is relaxed with the OpenAPI validation levels are:.
Parameters: {mockedService} (The name of a mocked service registered in the scenario)
Example:
Given the OpenAPI validation levels for the mocked addresses service are:mock.count.exactly
Section titled “mock.count.exactly”Then the mocked request named {word}[[ on {mockedService}]] was received exactly {int} time(s)Verify the named request pattern was received exactly the given number of times.
Variants (optional parts in [[...]] above):
the mocked request named {word} was received exactly {int} time(s)the mocked request named {word} on {mockedService} was received exactly {int} time(s)
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario), {int} (a 32-bit integer)
Example:
Then the mocked request named postcode-check was received exactly 1 timemock.count.atLeast
Section titled “mock.count.atLeast”Then the mocked request named {word}[[ on {mockedService}]] was received at least {int} time(s)Verify the named request pattern was received at least the given number of times.
Variants (optional parts in [[...]] above):
the mocked request named {word} was received at least {int} time(s)the mocked request named {word} on {mockedService} was received at least {int} time(s)
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario), {int} (a 32-bit integer)
Example:
Then the mocked request named postcode-check was received at least 1 timemock.count.atMost
Section titled “mock.count.atMost”Then the mocked request named {word}[[ on {mockedService}]] was received at most {int} time(s)Verify the named request pattern was received at most the given number of times.
Variants (optional parts in [[...]] above):
the mocked request named {word} was received at most {int} time(s)the mocked request named {word} on {mockedService} was received at most {int} time(s)
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario), {int} (a 32-bit integer)
Example:
Then the mocked request named postcode-check was received at most 1 timemock.notReceived
Section titled “mock.notReceived”Then the mocked {word} request to {word} named {word}[[ on {mockedService}]] was not receivedRegister a request pattern under a name and verify WireMock received no matching request.
Variants (optional parts in [[...]] above):
the mocked {word} request to {word} named {word} was not receivedthe mocked {word} request to {word} named {word} on {mockedService} was not received
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario)
Example:
Then the mocked GET request to /v1/postcodes/DE/12489 named skipped-check was not receivedmock.header.is
Section titled “mock.header.is”Then the header {word} for mocked request named {word}[[ on {mockedService}]] is {string}Verify the named request was received with a header equal to the value. The constraint is added to the named pattern.
Variants (optional parts in [[...]] above):
the header {word} for mocked request named {word} is {string}the header {word} for mocked request named {word} on {mockedService} is {string}
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario), {string} (text in single or double quotes; the quotes are removed)
Example:
Then the header X-Api-Key for mocked request named postcode-check is 'example-address-key'mock.headers.are
Section titled “mock.headers.are”Then the headers for mocked request named {word} on {mockedService} are: | ... | ... |Verify the named request was received with every header in the table (name | value).
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario)
Example:
Then the headers for mocked request named postcode-check on addresses are:mock.header.matches
Section titled “mock.header.matches”Then the header {word} for mocked request named {word} on {mockedService} matches {pattern}Verify the named request was received with a header matching the regular expression (evaluated by WireMock, full match).
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario), {pattern} (A regular expression (Java syntax) without whitespace. It must match the whole value)
Example:
Then the header Accept for mocked request named postcode-check on addresses matches ^application/json$mock.headers.match
Section titled “mock.headers.match”Then the headers for mocked request named {word} on {mockedService} match: | ... | ... |Verify the named request was received with headers matching each regular expression in the table (name | pattern).
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario)
Example:
Then the headers for mocked request named postcode-check on addresses match:mock.header.missing
Section titled “mock.header.missing”Then the header {word} for mocked request named {word} on {mockedService} is missingVerify the named request was received without the header.
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario)
Example:
Then the header Authorization for mocked request named postcode-check on addresses is missingmock.headers.missing
Section titled “mock.headers.missing”Then the headers for mocked request named {word} on {mockedService} are missing: | ... | ... |Verify the named request was received without any of the headers listed (one per row).
Parameters: {word} (one word, no spaces), {mockedService} (The name of a mocked service registered in the scenario)
Example:
Then the headers for mocked request named postcode-check on addresses are missing: