### Question:
EnforcerFilter implements Filter { @Override public Promise<Response, NeverThrowsException> filter(final Context context, final Request request, final Handler next) { if (!isConditionVerified(bindings(context, request))) { return newResultPromise(Responses.newInternalServerError( "Cannot satisfy the enforcement expression")); } return delegate.filter(context, request, next); } EnforcerFilter(final Expression<Boolean> enforcement, final Filter delegate); @Override Promise<Response, NeverThrowsException> filter(final Context context,
                                                          final Request request,
                                                          final Handler next);  }### Answer:
@Test public void shouldDelegateToTheRealFilter() throws Exception { EnforcerFilter enforcer = new EnforcerFilter(Expression.valueOf("${true}", Boolean.class), delegate); Context context = new RootContext(); enforcer.filter(context, null, handler); verify(delegate).filter(context, null, handler); }
@Test(dataProvider = "conditionsEvaluatingToFalse") public void shouldReturnAnInternalServerErrorForInvalidOrEvaluatedToFalseConditions(String condition) throws Exception { EnforcerFilter enforcer = new EnforcerFilter(Expression.valueOf(condition, Boolean.class), delegate); Response response = enforcer.filter(new AttributesContext(new RootContext()), null, handler).get(); assertThat(response.getStatus()).isEqualTo(Status.INTERNAL_SERVER_ERROR); }