クラス PayloadMatcher< T >
- 実装済みのインターフェース一覧:
org.hamcrest.Matcher<Message<?>>, org.hamcrest.SelfDescribing
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
方法の概要
修飾子と型メソッド説明voiddescribeTo(org.hamcrest.Description description) static <P> PayloadMatcher<P> hasPayload(org.hamcrest.Matcher<P> payloadMatcher) static <P> PayloadMatcher<P> hasPayload(P payload) booleanmatchesSafely(Message<?> message) クラス org.hamcrest.TypeSafeMatcher から継承されたメソッド
describeMismatch, describeMismatchSafely, matchesクラス org.hamcrest.BaseMatcher から継承されたメソッド
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
方法の詳細
matchesSafely
describeTo
public void describeTo(org.hamcrest.Description description) hasPayload
hasPayload