23
23
import com .rabbitmq .client .amqp .Message ;
24
24
import java .time .Duration ;
25
25
import java .util .List ;
26
- import java .util .Objects ;
27
26
import java .util .concurrent .CountDownLatch ;
28
27
import java .util .concurrent .TimeUnit ;
29
28
import java .util .concurrent .atomic .AtomicReference ;
@@ -245,9 +244,7 @@ MessageAssert hasCorrelationId(Object id) {
245
244
}
246
245
247
246
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 );
251
248
}
252
249
253
250
MessageAssert hasTo (String to ) {
@@ -317,11 +314,11 @@ MessageAssert hasProperty(String key, Object value) {
317
314
}
318
315
isNotNull ();
319
316
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 );
325
322
return this ;
326
323
}
327
324
@@ -339,11 +336,11 @@ MessageAssert hasAnnotation(String key, Object value) {
339
336
}
340
337
isNotNull ();
341
338
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 );
347
344
return this ;
348
345
}
349
346
@@ -357,9 +354,9 @@ MessageAssert doesNotHaveAnnotation(String key) {
357
354
358
355
private MessageAssert hasField (String fieldLabel , Object value , Object expected ) {
359
356
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 );
363
360
return this ;
364
361
}
365
362
}
0 commit comments