ResourceΒΆ
The following assertions can be performed on request
and response
variables offered by the Touchstone Rules-Engine.
They would validate the resource type within the payload.
assertResourceEquals(expectedValue)
Asserts that the resource type of the payload matches the provided expectedValue
Example:
response.assertResourceEquals("Bundle")
Equivalent to these:
assertResourceEquals("Bundle", response)
// expected resource type and operator can be passed as parameters from test script. assertResource("Bundle", "equals", response)
assert response.resource=="Bundle": "The actual value \""+response.resource +"\" did not match the expected value \"Bundle\" for resource type in response"
assert equals("Bundle", response.resource): "The actual value \""+response.resource +"\" did not match the expected value \"Bundle\" for resource type in response"
assertResourceNotEquals(expectedValue)
Asserts that the resource type of the payload does not match the provided expectedValue
Example:
response.assertResourceNotEquals("Patient")
Equivalent to these:
assertResourceNotEquals("Patient", response)
// expected resource type and operator can be passed as parameters from test script. assertResource("Patient", "notEquals", response)
assert response.resource!="Patient": "The actual value \""+response.resource +"\" matched the expected value \"Patient\" for resource type with operator 'notEquals' in response"
assert notEquals("Patient", response.resource): "The actual value \""+response.resource +"\" matched the expected value \"Patient\" for resource type with operator 'notEquals' in response"
assertResourceIn(expectedValues)
Asserts that the resource type of the payload is one of the provided expectedValues where each value is separated by a comma.
Example:
response.assertResourceIn("Bundle, Patient")
Equivalent to these:
assertResourceIn("Bundle, Patient", response)
// expected resource type and operator can be passed as parameters from test script. assertResource("Bundle, Patient", "in", response)
assert response.resource in ["Bundle", "Patient"]: "Expected one of the values in [Bundle, Patient] for resource type but encountered \""+response.resource+"\" in response"
assert isIn("Bundle, Patient", response.resource): "Expected one of the values in [Bundle, Patient] for resource type but encountered \""+response.resource+"\" in response"
assertResourceNotIn(expectedValues)
Asserts that the resource type of the payload is none of the provided expectedValues where each value is separated by a comma.
Example:
response.assertResourceNotIn("Bundle, Patient")
Equivalent to these:
assertResourceNotIn("Bundle, Patient", response)
// expected resource type and operator can be passed as parameters from test script. assertResource("Bundle, Patient", "notIn", response)
assert !(response.resource in ["Bundle", "Patient"]): "Expected none of the values in [Bundle, Patient] for resource type but encountered \""+response.resource+"\" with operator 'notIn' in response"
assert isNotIn("Bundle, Patient", response.resource): "Expected none of the values in [Bundle, Patient] for resource type but encountered \""+response.resource+"\" with operator 'notIn' in response"