Commit 0ee6f4fa authored by Administrator's avatar Administrator

Modifies HasHttpStatus matcher for a more descriptive message

The message showed currently by the HasHttpStatus when de expected
status didn't match the actual status was not very informative, as
the actual status was not shown in the message.

This commit modifies this behaviour to show both status (expected and
actual) in the message.
parent 3fd80931
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<groupId>es.uvigo.esei.daa</groupId> <groupId>es.uvigo.esei.daa</groupId>
<artifactId>example</artifactId> <artifactId>example</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>0.1.8</version> <version>0.1.9</version>
<name>DAA Example</name> <name>DAA Example</name>
<licenses> <licenses>
......
...@@ -48,6 +48,11 @@ public class HasHttpStatus extends TypeSafeMatcher<Response> { ...@@ -48,6 +48,11 @@ public class HasHttpStatus extends TypeSafeMatcher<Response> {
description.appendValue(this.expectedStatus); description.appendValue(this.expectedStatus);
} }
@Override
protected void describeMismatchSafely(Response item, Description mismatchDescription) {
mismatchDescription.appendText("was ").appendValue(item.getStatusInfo());
}
@Override @Override
protected boolean matchesSafely(Response item) { protected boolean matchesSafely(Response item) {
return item != null && expectedStatus.getStatusCode() == item.getStatusInfo().getStatusCode(); return item != null && expectedStatus.getStatusCode() == item.getStatusInfo().getStatusCode();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment