@Test public void onRequest() throws ExpressionException, HandlerException, IOException { AssignmentFilter filter = new AssignmentFilter(); AssignmentFilter.Binding binding = new AssignmentFilter.Binding(); binding.target = new Expression("${exchange.newAttr}"); binding.value = new Expression("${exchange.request.method}"); filter.onRequest.add(binding); Exchange exchange = new Exchange(); exchange.request = new Request(); exchange.request.method = "DELETE"; Chain chain = new Chain(); chain.filters.add(filter); StaticResponseHandler handler = new StaticResponseHandler(); handler.status = 200; chain.handler = handler; assertThat(binding.target.eval(exchange)).isNull(); chain.handle(exchange); assertThat(exchange.get("newAttr")).isEqualTo("DELETE"); }
private void eval(Binding binding, Exchange exchange) { if (binding.condition == null || Boolean.TRUE.equals(binding.condition.eval(exchange))) { binding.target.set(exchange, binding.value != null ? binding.value.eval(exchange) : null); } }
AssignmentFilter extends GenericFilter { private void eval(Binding binding, Exchange exchange) { if (binding.condition == null || Boolean.TRUE.equals(binding.condition.eval(exchange))) { binding.target.set(exchange, binding.value != null ? binding.value.eval(exchange) : null); } } }
AssignmentFilter extends GenericFilter { private void eval(Binding binding, Exchange exchange) { if (binding.condition == null || Boolean.TRUE.equals(binding.condition.eval(exchange))) { binding.target.set(exchange, binding.value != null ? binding.value.eval(exchange) : null); } }  }
AssignmentFilter extends GenericFilter { private void eval(Binding binding, Exchange exchange) { if (binding.condition == null || Boolean.TRUE.equals(binding.condition.eval(exchange))) { binding.target.set(exchange, binding.value != null ? binding.value.eval(exchange) : null); } }  @Override void filter(Exchange exchange, Handler next); }
AssignmentFilter extends GenericFilter { private void eval(Binding binding, Exchange exchange) { if (binding.condition == null || Boolean.TRUE.equals(binding.condition.eval(exchange))) { binding.target.set(exchange, binding.value != null ? binding.value.eval(exchange) : null); } }  @Override void filter(Exchange exchange, Handler next); final List<Binding> onRequest; final List<Binding> onResponse; }