I'm trying to refactor this old code that does not use ExpectedException
so that it does use it:
try {
//...
fail();
} catch (UniformInterfaceException e) {
assertEquals(404, e.getResponse().getStatus());
assertEquals("Could not find facility for aliasScope = DOESNTEXIST", e.getResponse().getEntity(String.class));
}
And I can't figure out how to do this because I don't know how to check the value of e.getResponse().getStatus()
or e.getResponse().getEntity(String.class)
in an ExpectedException
. I do see that ExpectedException
has an expect method that takes a hamcrest Matcher
. Maybe that's the key, but I'm not exactly sure how to use it.
How do I assert that the exception is in the state I want if that state only exists on the concrete exception?