use of io.restassured.filter.OrderedFilter in project rest-assured by rest-assured.
the class OrderedFilterITest method high_precedence_are_sorted_before_low_precedence.
@Test
public void high_precedence_are_sorted_before_low_precedence() {
List<String> list = new CopyOnWriteArrayList<>();
given().filter((requestSpec, responseSpec, ctx) -> {
list.add("Default");
return ctx.next(requestSpec, responseSpec);
}).filter(new OrderedFilter() {
@Override
public int getOrder() {
return 1002;
}
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
list.add("Custom");
return ctx.next(requestSpec, responseSpec);
}
}).filter(new OrderedFilter() {
@Override
public int getOrder() {
return LOWEST_PRECEDENCE;
}
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
list.add("Lowest");
return ctx.next(requestSpec, responseSpec);
}
}).filter(new OrderedFilter() {
@Override
public int getOrder() {
return HIGHEST_PRECEDENCE;
}
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
list.add("Highest");
return ctx.next(requestSpec, responseSpec);
}
}).when().get("/lotto");
assertThat(list, contains("Highest", "Default", "Custom", "Lowest"));
}
Aggregations