### Question:
Controller implements Wrapper { @Override public Handler wrap(final Handler handler) { return request -> { if ( roles.isEmpty() ) { return handler.handle(request); } else { final Collection<Object> roles=new HashSet<>(this.roles); roles.retainAll(request.roles()); return roles.isEmpty() ? request.reply(Response.Unauthorized) : handler.handle(request.roles(roles)); } }; } Controller(final Object... roles);  Controller(final Collection<Object> roles); @Override Handler wrap(final Handler handler);  }### Answer:
@Test void testAcceptedPublic() { exec(() -> new Controller() .wrap(handler()) .handle(request()) .accept(response -> assertThat(response).hasStatus(Response.OK)) ); }
@Test void testAcceptedControlled() { exec(() -> new Controller("x", "y") .wrap((Wrapper)handler -> request -> { assertThat(request.roles()).containsOnly("x"); return handler.handle(request); }) .wrap(handler()) .handle(request().roles("x")) .accept(response -> assertThat(response).hasStatus(Response.OK)) ); }
@Test void testUnauthorized() { exec(() -> new Controller("x", "y") .wrap(handler()) .handle(request().roles("z")) .accept(response -> assertThat(response).hasStatus(Response.Unauthorized)) ); }