Conditions { public static <T extends HttpMessage> Predicate<T> header(final String key, final String value) { return message -> message.getHeaders().getOrDefault(key, emptyList()).contains(value); } private  Conditions(); @SafeVarargs static Predicate<T> exclude(final Predicate<T>... predicates); static Predicate<T> exclude(final Collection<Predicate<T>> predicates); static Predicate<T> requestTo(final String pattern); static Predicate<T> contentType(final String contentType,
            final String... contentTypes); static Predicate<T> withoutContentType(); static Predicate<T> header(final String key, final String value); static Predicate<T> header(final String key, final Predicate<String> predicate); static Predicate<T> header(final BiPredicate<String, String> predicate);  }
@Test void headerShouldMatchNameAndValue() { final Predicate<HttpMessage> unit = header("X-Secret", "true"); assertThat(unit.test(request), is(true)); }
@Test void headerShouldNotMatchNameAndValue() { final Predicate<HttpMessage> unit = header("X-Secret", "false"); assertThat(unit.test(request), is(false)); }
@Test void headerShouldMatchNameAndValuePredicate() { final Predicate<HttpMessage> unit = header("X-Secret", asList("true", "1")::contains); assertThat(unit.test(request), is(true)); }
@Test void headerShouldNotMatchNameAndValuePredicate() { final Predicate<HttpMessage> unit = header("X-Secret", asList("yes", "1")::contains); assertThat(unit.test(request), is(false)); }
@Test void headerShouldMatchPredicate() { final Predicate<HttpMessage> unit = header((name, value) -> name.equalsIgnoreCase("X-Secret") && value.equalsIgnoreCase("true")); assertThat(unit.test(request), is(true)); }
@Test void headerShouldNotMatchPredicate() { final Predicate<HttpMessage> unit = header((name, value) -> name.equalsIgnoreCase("X-Secret") && value.equalsIgnoreCase("false")); assertThat(unit.test(request), is(false)); }
@Test void headerShouldNotMatchPredicateWhenHeaderIsAbsent() { final Predicate<HttpMessage> unit = header("X-Absent", v -> true); assertThat(unit.test(request), is(false)); }