Skip to content

Instantly share code, notes, and snippets.

@compwron
Created May 11, 2017 13:11
Show Gist options
  • Save compwron/3692a8c3ef7ad1459a1a4ba6863fa5b9 to your computer and use it in GitHub Desktop.
Save compwron/3692a8c3ef7ad1459a1a4ba6863fa5b9 to your computer and use it in GitHub Desktop.
hamcrest matcher for http status
private Matcher<ResponseEntity<String>> httpStatus(final HttpStatus httpStatus) {
return new BaseMatcher<ResponseEntity<String>>() {
@Override
public boolean matches(final Object item) {
final ResponseEntity<String> responseEntity = (ResponseEntity<String>) item;
return httpStatus.equals(responseEntity.getStatusCode());
}
@Override
public void describeTo(final Description description) {
description.appendText("Status code should be ").appendValue(httpStatus);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment