The and
predicate matches if all of its sub-predicates match.
POST /imposters HTTP/1.1
Host: localhost:<%= port %>
Accept: application/json
Content-Type: application/json
{
"port": 4554,
"protocol": "tcp",
"mode": "text",
"stubs": [
{
"responses": [{ "is": { "data": "matches" } }],
"predicates": [
{
"and": [
{ "startsWith": { "data": "start" } },
{ "endsWith": { "data": "end\n" } },
{ "contains": { "data": "middle" } }
]
}
]
}
]
}
The first request matches all sub-predicates, triggering the stub response:
echo 'start middle end' | nc localhost 4554
matches
The stub matches two of the three sub-predicates, which is not enough to match
the and
predicate.
The stub does not match none of the sub-predicates match...
echo 'start end' | nc localhost 4554
No response is sent.
DELETE /imposters/4554 HTTP/1.1
Host: localhost:<%= port %>
Accept: application/json