### Question:
Validator implements Wrapper { @Override public Handler wrap(final Handler handler) { return request -> { final Collection<String> issues=rules.stream() .flatMap(rule -> rule.apply(request).stream()) .collect(toList()); return issues.isEmpty() ? handler.handle(request) : request.reply(new Failure() .status(Response.UnprocessableEntity) .error(Failure.DataInvalid) .trace(trace(issues.stream() .map(issue -> trace(issue)) .collect(toList()) )) ); }; } @SafeVarargs  Validator(final Function<Request, Collection<String>>... rules);  Validator(final Collection<Function<Request, Collection<String>>> rules); @Override Handler wrap(final Handler handler);  }### Answer:
@Test void testAcceptValidRequests() { exec(() -> new Validator(request -> emptyList()) .wrap(handler()) .handle(new Request()) .accept(response -> assertThat(response) .hasStatus(Response.OK) ) ); }
@Test void testRejectInvalidRequests() { exec(() -> new Validator(request -> asList("issue", "issue")) .wrap(handler()) .handle(new Request()) .accept(response -> assertThat(response) .hasStatus(Response.UnprocessableEntity) .hasBody(writer()) ) ); }