--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status.Family;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
/**
* This is a Hamcrest matcher that checks that a given Integer, representing an HTTP response status code, is in a
* certain response family.
*/
public class IsInFamily extends TypeSafeMatcher<Integer> {
Family family;
public IsInFamily(Family family) {
this.family = family;
}
@Override
public void describeTo(Description description) {
description.appendText("in response status code family " + family);
}
@Factory
public static Matcher<Integer> isInFamily(Response.Status.Family family) {
return new IsInFamily(family);
}
@Override
protected boolean matchesSafely(Integer item) {
return Response.Status.Family.familyOf(item).equals(family);
}