The not
predicate negates its child predicate.
POST /imposters HTTP/1.1
Host: localhost:<%= port %>
Accept: application/json
Content-Type: application/json
{
"port": 4552,
"protocol": "tcp",
"mode": "text",
"stubs": [
{
"responses": [{ "is": { "data": "not test" } }],
"predicates": [{ "not": { "equals": { "data": "test\n" } } }]
},
{
"responses": [{ "is": { "data": "test" } }],
"predicates": [{ "equals": { "data": "test\n" } }]
}
]
}
The first stub matches if the is
sub-predicate does not match:
echo 'production' | nc localhost 4552
not test
As expected, the second stub matches if the is
sub-predicate does match:
echo 'test' | nc localhost 4552
test
DELETE /imposters/4552 HTTP/1.1
Host: localhost:<%= port %>
Accept: application/json