2323import com .rabbitmq .client .amqp .Message ;
2424import java .time .Duration ;
2525import java .util .List ;
26- import java .util .Objects ;
2726import java .util .concurrent .CountDownLatch ;
2827import java .util .concurrent .TimeUnit ;
2928import java .util .concurrent .atomic .AtomicReference ;
@@ -245,9 +244,7 @@ MessageAssert hasCorrelationId(Object id) {
245244 }
246245
247246 MessageAssert hasUserId (byte [] userId ) {
248- isNotNull ();
249- org .assertj .core .api .Assertions .assertThat (actual .userId ()).isEqualTo (userId );
250- return this ;
247+ return hasField ("user-id" , actual .userId (), userId );
251248 }
252249
253250 MessageAssert hasTo (String to ) {
@@ -317,11 +314,11 @@ MessageAssert hasProperty(String key, Object value) {
317314 }
318315 isNotNull ();
319316 hasProperty (key );
320- if (! value . equals (this .actual .property (key ))) {
321- fail (
322- "Message should have property '%s = %s' but has '%s = %s'" ,
323- key , value , key , this .actual .property (key ));
324- }
317+ org . assertj . core . api . Assertions . assertThat (this .actual .property (key ))
318+ . describedAs (
319+ "Message should have property '%s = %s' but has '%s = %s'" ,
320+ key , value , key , this .actual .property (key ))
321+ . isEqualTo ( value );
325322 return this ;
326323 }
327324
@@ -339,11 +336,11 @@ MessageAssert hasAnnotation(String key, Object value) {
339336 }
340337 isNotNull ();
341338 hasAnnotation (key );
342- if (! value . equals (this .actual .annotation (key ))) {
343- fail (
344- "Message should have annotation '%s = %s' but has '%s = %s'" ,
345- key , value , key , this .actual .annotation (key ));
346- }
339+ org . assertj . core . api . Assertions . assertThat (this .actual .annotation (key ))
340+ . describedAs (
341+ "Message should have annotation '%s = %s' but has '%s = %s'" ,
342+ key , value , key , this .actual .annotation (key ))
343+ . isEqualTo ( value );
347344 return this ;
348345 }
349346
@@ -357,9 +354,9 @@ MessageAssert doesNotHaveAnnotation(String key) {
357354
358355 private MessageAssert hasField (String fieldLabel , Object value , Object expected ) {
359356 isNotNull ();
360- if (! Objects . equals (value , expected )) {
361- fail ("Field '%s' should be '%s' but is '%s'" , fieldLabel , expected , value );
362- }
357+ org . assertj . core . api . Assertions . assertThat (value )
358+ . describedAs ("Field '%s' should be '%s' but is '%s'" , fieldLabel , expected , value )
359+ . isEqualTo ( expected );
363360 return this ;
364361 }
365362 }
0 commit comments