T - The type of the response.public abstract class ResponseAwareMatcher<T extends ResponseBody<T> & ResponseOptions<T>> extends Object
Matcher based on the contents of a response. For example imagine that a
resource "/x" returns the following JSON document:
{
"userId" : "my-id",
"href" : "http://localhost:8080/my-id"
}
you can then verify the href using:
get("/x").then().body("href", new ResponseAwareMatcher() {
public Matcher extends Object> matcher(Response response) {
return equalTo("http://localhost:8080/" + response.path("userId"));
}
});
ResponseAwareMatchers are also composable with other ResponseAwareMatchers and other Hamcrest matchers.
Note that you can also use some of the predefined methods in RestAssuredMatchers.
| Constructor and Description |
|---|
ResponseAwareMatcher() |
| Modifier and Type | Method and Description |
|---|---|
ResponseAwareMatcher<T> |
and(org.hamcrest.Matcher<? extends Object> matcher)
Compose this
ResponseAwareMatcher with a Matcher. |
ResponseAwareMatcher<T> |
and(ResponseAwareMatcher<T> responseAwareMatcher)
Compose this
ResponseAwareMatcher with another ResponseAwareMatcher. |
abstract org.hamcrest.Matcher<?> |
matcher(T response)
Create the matcher based on the content of the response.
|
ResponseAwareMatcher<T> |
or(org.hamcrest.Matcher<? extends Object> matcher)
Compose this
ResponseAwareMatcher with a Matcher. |
ResponseAwareMatcher<T> |
or(ResponseAwareMatcher<T> responseAwareMatcher)
Compose this
ResponseAwareMatcher with another ResponseAwareMatcher. |
public abstract org.hamcrest.Matcher<?> matcher(T response) throws Exception
response - The response.Exception - Throws any exception if neededpublic final ResponseAwareMatcher<T> and(ResponseAwareMatcher<T> responseAwareMatcher)
ResponseAwareMatcher with another ResponseAwareMatcher.responseAwareMatcher - The matcher.ResponseAwareMatcher.public final ResponseAwareMatcher<T> and(org.hamcrest.Matcher<? extends Object> matcher)
ResponseAwareMatcher with a Matcher.matcher - The matcher.ResponseAwareMatcher.public final ResponseAwareMatcher<T> or(ResponseAwareMatcher<T> responseAwareMatcher)
ResponseAwareMatcher with another ResponseAwareMatcher.responseAwareMatcher - The matcher.ResponseAwareMatcher.public final ResponseAwareMatcher<T> or(org.hamcrest.Matcher<? extends Object> matcher)
ResponseAwareMatcher with a Matcher.matcher - The matcher.ResponseAwareMatcher.Copyright © 2010–2014. All rights reserved.