FailureTypeUtil { public static boolean matches(final Class<? extends ClientErrorException> expectedException, final ClientErrorException actualException, final String reason) { if (!actualException.getClass() .isAssignableFrom(expectedException)) { return false; } else if (reason == null) { return true; } else { return FailureTypeUtil.getResponseEntity(actualException.getResponse()) .contains(reason); } } private  FailureTypeUtil(); static String getResponseEntity(final Response response); static boolean matches(final Class<? extends ClientErrorException> expectedException,
            final ClientErrorException actualException,
            final String reason);  }
@Test void differentException() { final ClientErrorException actual = new BadRequestException(); final Class<? extends ClientErrorException> expected = NotFoundException.class; assertThat(FailureTypeUtil.matches(expected, actual, null)).isFalse(); }
@Test void noExpectedReason() { final ClientErrorException actual = new BadRequestException(); final Class<? extends ClientErrorException> expected = actual.getClass(); assertThat(FailureTypeUtil.matches(expected, actual, null)).isTrue(); }
@Test void expectedReasonMatches() { final String reason = UUID.randomUUID() .toString(); final Response response = Response.status(400) .entity(reason) .build(); final ClientErrorException actual = new BadRequestException(response); final Class<? extends ClientErrorException> expected = actual.getClass(); assertThat(FailureTypeUtil.matches(expected, actual, reason)).isTrue(); }
@Test void expectedReasonDoesNotMatch() { final String reason = UUID.randomUUID() .toString(); final Response response = Response.status(400) .entity(reason) .build(); final ClientErrorException actual = new BadRequestException(response); final Class<? extends ClientErrorException> expected = actual.getClass(); assertThat(FailureTypeUtil.matches(expected, actual, UUID.randomUUID() .toString())).isFalse(); }