クラス PayloadMatcher< T >

java.lang.ObjectSE
org.hamcrest.BaseMatcher<Message<?>>
org.hamcrest.TypeSafeMatcher<Message<?>>
org.springframework.integration.test.matcher.PayloadMatcher<T>
実装済みのインターフェース一覧:
org.hamcrest.Matcher<Message<?>>, org.hamcrest.SelfDescribing

public final class PayloadMatcher<T> extends org.hamcrest.TypeSafeMatcher<Message<?>>
Message のペイロードは指定された値に等しいですか、それとも指定されたマッチャーと一致していますか?

MatcherAssert.assertThat(Object, Matcher) を使用した JUnit の例は、ペイロード値をテストするために次のようになります。


ANY_PAYLOAD = new BigDecimal("1.123");
Message<BigDecimal> message = MessageBuilder.withPayload(ANY_PAYLOAD).build();
assertThat(message, hasPayload(ANY_PAYLOAD));

別の Matcher に委譲する MatcherAssert.assertThat(Object, Matcher) を使用する例。


ANY_PAYLOAD = new BigDecimal("1.123");
Message<BigDecimal> message = MessageBuilder.withPayload(ANY_PAYLOAD).build();
assertThat(message, PayloadMatcher.hasPayload(is(BigDecimal.class)));
assertThat(message, PayloadMatcher.hasPayload(notNullValue()));
assertThat(message, not((PayloadMatcher.hasPayload(is(String.class))))); *

AssertJ を使用する場合、HamcrestCondition を使用して AssertJ API と Hamcrest マッチャーを組み合わせることができます。


ANY_PAYLOAD = new BigDecimal("1.123");
Message<BigDecimal> message = MessageBuilder.withPayload(ANY_PAYLOAD).build();
assertThat(message).is(matching(hasPayload(ANY_PAYLOAD)));
assertThat(message).has(matching(hasPayload(notNullValue())));
assertThat(message).isNot(matching(hasPayload(is(String.class))));

作成者:
Alex Peters, Iwein Fuld, Artem Bilan, Gary Russell
  • 方法の概要

    修飾子と型
    メソッド
    説明
    void
    describeTo(org.hamcrest.Description description)
    static <P> PayloadMatcher<P>
    hasPayload(org.hamcrest.Matcher<P> payloadMatcher)
    static <P> PayloadMatcher<P>
    hasPayload(P payload)
    boolean

    クラス org.hamcrest.TypeSafeMatcher から継承されたメソッド

    describeMismatch, describeMismatchSafely, matches

    クラス org.hamcrest.BaseMatcher から継承されたメソッド

    _dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString

    クラス ObjectSE から継承されたメソッド

    clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, wait, waitSE, waitSE
  • 方法の詳細

    • matchesSafely

      public boolean matchesSafely(Message<?> message)
      次で指定:
      クラス org.hamcrest.TypeSafeMatcher<Message<?>> の matchesSafely 
    • describeTo

      public void describeTo(org.hamcrest.Description description)
    • hasPayload

      public static <P> PayloadMatcher<P> hasPayload(P payload)
    • hasPayload

      public static <P> PayloadMatcher<P> hasPayload(org.hamcrest.Matcher<P> payloadMatcher)