public final class HeaderMatcher<T> extends org.hamcrest.TypeSafeMatcher<Message<T>>
MessageHeaders
of a Message
containing any entry
or multiple that match?
For example using Assert.assertThat(Object, Matcher)
for a single
entry:
ANY_HEADER_KEY = "foo";
ANY_HEADER_VALUE = "bar";
assertThat(message, hasEntry(ANY_HEADER_KEY, ANY_HEADER_VALUE));
assertThat(message, hasEntry(ANY_HEADER_KEY, is(String.class)));
assertThat(message, hasEntry(ANY_HEADER_KEY, notNullValue()));
assertThat(message, hasEntry(ANY_HEADER_KEY, is(ANY_HEADER_VALUE)));
For multiple entries to match all:
Map<String, Object> expectedInHeaderMap = new HashMap<String, Object>();
expectedInHeaderMap.put(ANY_HEADER_KEY, ANY_HEADER_VALUE);
expectedInHeaderMap.put(OTHER_HEADER_KEY, is(OTHER_HEADER_VALUE));
assertThat(message, HeaderMatcher.hasAllEntries(expectedInHeaderMap));
For a single key:
ANY_HEADER_KEY = "foo"; assertThat(message, HeaderMatcher.hasKey(ANY_HEADER_KEY));
Modifier and Type | Method and Description |
---|---|
void |
describeTo(org.hamcrest.Description description) |
static <P> HeaderMatcher<P> |
hasAllHeaders(Map<String,?> entries) |
static <P,V> HeaderMatcher<P> |
hasCorrelationId(V value) |
static <P> HeaderMatcher<P> |
hasExpirationDate(Date value) |
static <P> HeaderMatcher<P> |
hasExpirationDate(org.hamcrest.Matcher<Long> matcher) |
static <P,V> HeaderMatcher<P> |
hasHeader(String key,
org.hamcrest.Matcher<V> valueMatcher) |
static <P,V> HeaderMatcher<P> |
hasHeader(String key,
V value) |
static <P> HeaderMatcher<P> |
hasHeaderKey(String key) |
static <P,V> HeaderMatcher<P> |
hasMessageId(V value) |
static <P> HeaderMatcher<P> |
hasSequenceNumber(Integer value) |
static <P> HeaderMatcher<P> |
hasSequenceNumber(org.hamcrest.Matcher<Integer> matcher) |
static <P> HeaderMatcher<P> |
hasSequenceSize(Integer value) |
static <P> HeaderMatcher<P> |
hasSequenceSize(org.hamcrest.Matcher<Integer> value) |
static <P> HeaderMatcher<P> |
hasTimestamp(Date value) |
static <P> HeaderMatcher<P> |
hasTimestamp(org.hamcrest.Matcher<Long> matcher) |
boolean |
matchesSafely(Message<T> item) |
describeMismatch, describeMismatchSafely, matches
public void describeTo(org.hamcrest.Description description)
public static <P,V> HeaderMatcher<P> hasHeader(String key, V value)
public static <P,V> HeaderMatcher<P> hasHeader(String key, org.hamcrest.Matcher<V> valueMatcher)
public static <P> HeaderMatcher<P> hasHeaderKey(String key)
public static <P> HeaderMatcher<P> hasAllHeaders(Map<String,?> entries)
public static <P,V> HeaderMatcher<P> hasMessageId(V value)
public static <P,V> HeaderMatcher<P> hasCorrelationId(V value)
public static <P> HeaderMatcher<P> hasSequenceNumber(Integer value)
public static <P> HeaderMatcher<P> hasSequenceNumber(org.hamcrest.Matcher<Integer> matcher)
public static <P> HeaderMatcher<P> hasSequenceSize(Integer value)
public static <P> HeaderMatcher<P> hasSequenceSize(org.hamcrest.Matcher<Integer> value)
public static <P> HeaderMatcher<P> hasExpirationDate(Date value)
public static <P> HeaderMatcher<P> hasExpirationDate(org.hamcrest.Matcher<Long> matcher)
public static <P> HeaderMatcher<P> hasTimestamp(Date value)
public static <P> HeaderMatcher<P> hasTimestamp(org.hamcrest.Matcher<Long> matcher)