Skip to content

Commit de8b2b3

Browse files
authored
Update Javadoc references deprecated javadocs
Replace deprecated `org.junit.Assert#assertThat` references with `org.hamcrest.MatcherAssert#assertThat` in test matcher documentation. This change updates documentation in `HeaderMatcher` and `PayloadMatcher` classes to reference the correct `assertThat` method location after JUnit Jupiter migration removed `Assert.assertThat` in favor of the Hamcrest implementation. * Add AssertJ integration example to `PayloadMatcher` Javadoc Extends the existing Javadoc for `PayloadMatcher` to include examples of how to use the matcher with AssertJ's `HamcrestCondition`.
1 parent e575220 commit de8b2b3

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

spring-integration-test-support/src/main/java/org/springframework/integration/test/matcher/HeaderMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Are the {@link MessageHeaders} of a {@link Message} containing any entry
3232
* or multiple that match?
3333
* <p>
34-
* For example using {@link org.junit.Assert#assertThat(Object, Matcher)} for a single
34+
* For example using {@link org.hamcrest.MatcherAssert#assertThat(Object, Matcher)} for a single
3535
* entry:
3636
*
3737
* <pre class="code">

spring-integration-test-support/src/main/java/org/springframework/integration/test/matcher/PayloadMatcher.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Is the payload of a {@link Message} equal to a given value or is matching
2828
* a given matcher?
2929
* <p>
30-
* A Junit example using {@link org.junit.Assert#assertThat(Object, Matcher)} could look
30+
* A Junit example using {@link org.hamcrest.MatcherAssert#assertThat(Object, Matcher)} could look
3131
* like this to test a payload value:
3232
*
3333
* <pre class="code">
@@ -39,7 +39,7 @@
3939
* </pre>
4040
*
4141
* <p>
42-
* An example using {@link org.junit.Assert#assertThat(Object, Matcher)} delegating to
42+
* An example using {@link org.hamcrest.MatcherAssert#assertThat(Object, Matcher)} delegating to
4343
* another {@link Matcher}.
4444
*
4545
* <pre class="code">
@@ -52,6 +52,20 @@
5252
* }
5353
* </pre>
5454
*
55+
* <p>
56+
* When using AssertJ, the {@link org.assertj.core.api.HamcrestCondition} can be used to combine the AssertJ API
57+
* with Hamcrest matchers:
58+
*
59+
* <pre class="code">
60+
* {@code
61+
* ANY_PAYLOAD = new BigDecimal("1.123");
62+
* Message<BigDecimal> message = MessageBuilder.withPayload(ANY_PAYLOAD).build();
63+
* assertThat(message).is(matching(hasPayload(ANY_PAYLOAD)));
64+
* assertThat(message).has(matching(hasPayload(notNullValue())));
65+
* assertThat(message).isNot(matching(hasPayload(is(String.class))));
66+
* }
67+
* </pre>
68+
*
5569
*
5670
*
5771
* @author Alex Peters

0 commit comments

Comments
 (0)