@Test public void userAgentMatchesUserAgent() { Condition condition = condition("userAgent() == 'Mozilla Firefox 1.1.2' OR userAgent() =~ 'Safari.*'"); LiveHttpRequest request = get("/blah") .header(USER_AGENT, "Mozilla Firefox 1.1.2") .build(); assertThat(condition.evaluate(request, context), is(true)); request = get("/blah") .header(USER_AGENT, "Mozilla Firefox 1.1.25") .build(); assertThat(condition.evaluate(request, context), is(false)); request = get("/blah") .header(USER_AGENT, "Foxzilla x.y.z") .build(); assertThat(condition.evaluate(request, context), is(false)); request = get("/blah") .header(USER_AGENT, "Safari-XYZ") .build(); assertThat(condition.evaluate(request, context), is(true)); request = post("/blah") .build(); assertThat(condition.evaluate(request, context), is(false)); }
@Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); }
AntlrCondition implements Condition { @Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); } }
AntlrCondition implements Condition { @Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); } AntlrCondition(Expression<Boolean> expression); }
AntlrCondition implements Condition { @Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); } AntlrCondition(Expression<Boolean> expression); @Override boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context); }
AntlrCondition implements Condition { @Override public boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context) { return expression.evaluate(request, context); } AntlrCondition(Expression<Boolean> expression); @Override boolean evaluate(LiveHttpRequest request, HttpInterceptor.Context context);  }