48
48
import static org .hibernate .reactive .containers .DatabaseConfiguration .dbType ;
49
49
import static org .hibernate .reactive .testing .ReactiveAssertions .assertThrown ;
50
50
import static org .junit .jupiter .api .Assertions .assertEquals ;
51
+ import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
51
52
import static org .junit .jupiter .api .Assertions .assertNotNull ;
52
53
import static org .junit .jupiter .api .Assertions .assertNull ;
53
- import static org .junit .jupiter .api .Assertions .assertTrue ;
54
54
55
55
@ Timeout (value = 10 , timeUnit = MINUTES )
56
56
public class QueryTest extends BaseReactiveTest {
@@ -407,10 +407,10 @@ public void testNativeProjectionQuery(VertxTestContext context) {
407
407
.thenAccept ( books -> {
408
408
assertEquals ( 3 , books .size () );
409
409
books .forEach ( tuple -> {
410
- assertTrue ( tuple instanceof Object [] );
410
+ assertInstanceOf ( Object []. class , tuple );
411
411
assertEquals ( 2 , tuple .length );
412
- assertTrue ( tuple [0 ] instanceof String );
413
- assertTrue ( tuple [1 ] instanceof String );
412
+ assertInstanceOf ( String . class , tuple [0 ] );
413
+ assertInstanceOf ( String . class , tuple [1 ] );
414
414
} );
415
415
} )
416
416
.thenCompose ( v -> openSession () )
@@ -425,41 +425,40 @@ public void testNativeProjectionQuery(VertxTestContext context) {
425
425
.thenAccept ( list -> {
426
426
Object [] tuple = list .get ( 0 );
427
427
assertEquals ( 3 , tuple .length );
428
- assertTrue ( tuple [0 ] instanceof String );
428
+ assertInstanceOf ( String . class , tuple [0 ] );
429
429
} ) )
430
430
.thenCompose ( vv -> session
431
431
.createNativeQuery ( "select title from " + BOOK_TABLE )
432
432
.getResultList ()
433
- .thenAccept ( list -> assertTrue ( list .get ( 0 ) instanceof String ) )
434
- )
433
+ .thenAccept ( list -> assertInstanceOf ( String .class , list .get ( 0 ) ) ) )
435
434
.thenCompose ( vv -> session
436
435
.createNativeQuery ( "select title from " + BOOK_TABLE , String .class )
437
436
.getResultList ()
438
- .thenAccept ( list -> assertTrue ( list .get ( 0 ) instanceof String ) ) )
437
+ .thenAccept ( list -> assertInstanceOf ( String . class , list .get ( 0 ) ) ) )
439
438
.thenCompose ( vv -> session
440
439
.createNativeQuery ( "select title, isbn, id from " + BOOK_TABLE )
441
440
.getResultList ()
442
441
.thenAccept ( list -> {
443
442
Object [] tuple = (Object []) list .get ( 0 );
444
443
assertEquals ( 3 , tuple .length );
445
- assertTrue ( tuple [0 ] instanceof String );
444
+ assertInstanceOf ( String . class , tuple [0 ] );
446
445
} ) )
447
446
.thenCompose ( vv -> session
448
447
.createNativeQuery ( "select title, isbn, id from " + BOOK_TABLE , Object [].class )
449
448
.getResultList ()
450
449
.thenAccept ( list -> {
451
450
Object [] tuple = list .get ( 0 );
452
451
assertEquals ( 3 , tuple .length );
453
- assertTrue ( tuple [0 ] instanceof String );
452
+ assertInstanceOf ( String . class , tuple [0 ] );
454
453
} ) )
455
454
.thenCompose ( vv -> session
456
455
.createNativeQuery ( "select title, isbn, id from " + BOOK_TABLE , Tuple .class )
457
456
.getResultList ()
458
457
.thenAccept ( list -> {
459
458
Tuple tuple = list .get ( 0 );
460
459
assertEquals ( 3 , tuple .toArray ().length );
461
- assertTrue ( tuple .get ( 0 ) instanceof String );
462
- assertTrue ( tuple .get ( "isbn" ) instanceof String );
460
+ assertInstanceOf ( String . class , tuple .get ( 0 ) );
461
+ assertInstanceOf ( String . class , tuple .get ( "isbn" ) );
463
462
} ) )
464
463
)
465
464
);
@@ -488,10 +487,10 @@ public void testNamedHqlProjectionQuery(VertxTestContext context) {
488
487
.thenAccept ( books -> {
489
488
assertEquals ( 3 , books .size () );
490
489
books .forEach ( tuple -> {
491
- assertTrue ( tuple instanceof Object [] );
490
+ assertInstanceOf ( Object []. class , tuple );
492
491
assertEquals ( 2 , tuple .length );
493
- assertTrue ( tuple [0 ] instanceof String );
494
- assertTrue ( tuple [1 ] instanceof String );
492
+ assertInstanceOf ( String . class , tuple [0 ] );
493
+ assertInstanceOf ( String . class , tuple [1 ] );
495
494
} );
496
495
} )
497
496
@@ -527,10 +526,10 @@ public void testNamedNativeProjectionQuery(VertxTestContext context) {
527
526
.thenAccept ( books -> {
528
527
assertEquals ( 3 , books .size () );
529
528
books .forEach ( tuple -> {
530
- assertTrue ( tuple instanceof Object [] );
529
+ assertInstanceOf ( Object []. class , tuple );
531
530
assertEquals ( 2 , tuple .length );
532
- assertTrue ( tuple [0 ] instanceof String );
533
- assertTrue ( tuple [1 ] instanceof String );
531
+ assertInstanceOf ( String . class , tuple [0 ] );
532
+ assertInstanceOf ( String . class , tuple [1 ] );
534
533
} );
535
534
} )
536
535
);
@@ -573,7 +572,7 @@ public void testSingleResultQueryException(VertxTestContext context) {
573
572
574
573
} )
575
574
.handle ( (r , x ) -> {
576
- assertTrue ( x .getCause () instanceof NoResultException );
575
+ assertInstanceOf ( NoResultException . class , x .getCause () );
577
576
return null ;
578
577
} )
579
578
);
0 commit comments