/** * Creates a filter matching messages whose header value contains the given * value. * * All to-compared Strings MUST BE converted to uppercase before doing so * (this also include the search value) * * @param headerName * name of the header whose value will be compared, not null * @param value * when null or empty the existance of the header will be * checked, otherwise contained value * @return <code>Criterion</code>, not null */ public static Criterion headerContains(String headerName, String value) { if (value == null || value.length() == 0) { return headerExists(headerName); } else { return new HeaderCriterion(headerName, new ContainsOperator(value)); } }
@Test public void filterConditionShouldMapWhenHeaderWithOneElement() { String headerName = "name"; SearchQuery expectedSearchQuery = new SearchQuery(); expectedSearchQuery.andCriteria(SearchQuery.headerExists(headerName)); SearchQuery searchQuery = new FilterToSearchQuery().convert(FilterCondition.builder() .header(Header.from(ImmutableList.of(headerName))) .build()); assertThat(searchQuery).isEqualTo(expectedSearchQuery); }
return SearchQuery.headerExists(key.getName()); } else { return SearchQuery.headerContains(key.getName(), value);
return SearchQuery.headerExists(key.getName()); } else { return SearchQuery.headerContains(key.getName(), value);