55 */
66package org .hibernate .reactive ;
77
8- import jakarta .persistence .GeneratedValue ;
9- import jakarta .persistence .ManyToOne ;
10- import jakarta .persistence .OneToMany ;
118import java .util .ArrayList ;
129import java .util .Collection ;
1310import java .util .List ;
2118import io .vertx .junit5 .Timeout ;
2219import io .vertx .junit5 .VertxTestContext ;
2320import jakarta .persistence .Entity ;
21+ import jakarta .persistence .GeneratedValue ;
2422import jakarta .persistence .Id ;
23+ import jakarta .persistence .ManyToOne ;
24+ import jakarta .persistence .OneToMany ;
2525import jakarta .persistence .Table ;
2626
2727import static jakarta .persistence .CascadeType .PERSIST ;
2828import static jakarta .persistence .FetchType .LAZY ;
2929import static java .util .concurrent .TimeUnit .MINUTES ;
3030import static org .assertj .core .api .Assertions .assertThat ;
3131import static org .junit .jupiter .api .Assertions .assertEquals ;
32- import static org .junit .jupiter .api .Assertions .assertNotNull ;
33- import static org .junit .jupiter .api .Assertions .assertTrue ;
3432
3533@ Timeout (value = 10 , timeUnit = MINUTES )
36-
3734public class HQLQueryTest extends BaseReactiveTest {
3835
3936 Flour spelt = new Flour ( 1 , "Spelt" , "An ancient grain, is a hexaploid species of wheat." , "Wheat flour" );
@@ -82,7 +79,7 @@ public void testAutoFlushOnResultList(VertxTestContext context) {
8279 public void testSelectScalarString (VertxTestContext context ) {
8380 test ( context , getSessionFactory ().withSession ( s -> {
8481 Stage .SelectionQuery <String > qr = s .createSelectionQuery ( "SELECT 'Prova' FROM Flour WHERE id = " + rye .getId (), String .class );
85- assertNotNull ( qr );
82+ assertThat ( qr ). isNotNull ( );
8683 return qr .getSingleResult ();
8784 } ).thenAccept ( found -> assertEquals ( "Prova" , found ) ) );
8885 }
@@ -91,19 +88,35 @@ public void testSelectScalarString(VertxTestContext context) {
9188 public void testSelectScalarCount (VertxTestContext context ) {
9289 test ( context , getSessionFactory ().withSession ( s -> {
9390 Stage .SelectionQuery <Long > qr = s .createSelectionQuery ( "SELECT count(*) FROM Flour" , Long .class );
94- assertNotNull ( qr );
91+ assertThat ( qr ). isNotNull ( );
9592 return qr .getSingleResult ();
9693 } ).thenAccept ( found -> assertEquals ( 3L , found ) ) );
9794 }
9895
9996 @ Test
10097 public void testSelectWithMultipleScalarValues (VertxTestContext context ) {
10198 test ( context , getSessionFactory ().withSession ( s -> {
102- Stage .SelectionQuery <?> qr = s .createSelectionQuery ( "SELECT 'Prova', f.id FROM Flour f WHERE f.id = " + rye .getId (), Object [].class );
103- assertNotNull ( qr );
99+ Stage .SelectionQuery <?> qr = s .createSelectionQuery (
100+ "SELECT 'Prova', f.id FROM Flour f WHERE f.id = " + rye .getId (),
101+ Object [].class
102+ );
103+ assertThat ( qr ).isNotNull ();
104+ return qr .getSingleResult ();
105+ } ).thenAccept ( found -> {
106+ assertThat ( found ).isInstanceOf ( Object [].class );
107+ assertEquals ( "Prova" , ( (Object []) found )[0 ] );
108+ assertEquals ( rye .getId (), ( (Object []) found )[1 ] );
109+ } )
110+ );
111+ test ( context , getSessionFactory ().withSession ( s -> {
112+ Stage .SelectionQuery <?> qr = s .createSelectionQuery (
113+ "SELECT 'Prova', f.id FROM Flour f WHERE f.id = " + rye .getId (),
114+ Object [].class
115+ );
116+ assertThat ( qr ).isNotNull ();
104117 return qr .getSingleResult ();
105118 } ).thenAccept ( found -> {
106- assertTrue ( found instanceof Object [] );
119+ assertThat ( found ). isInstanceOf ( Object []. class );
107120 assertEquals ( "Prova" , ( (Object []) found )[0 ] );
108121 assertEquals ( rye .getId (), ( (Object []) found )[1 ] );
109122 } )
@@ -114,7 +127,7 @@ public void testSelectWithMultipleScalarValues(VertxTestContext context) {
114127 public void testSingleResultQueryOnId (VertxTestContext context ) {
115128 test ( context , getSessionFactory ().withSession ( s -> {
116129 Stage .SelectionQuery <?> qr = s .createSelectionQuery ( "FROM Flour WHERE id = 1" , Flour .class );
117- assertNotNull ( qr );
130+ assertThat ( qr ). isNotNull ( );
118131 return qr .getSingleResult ();
119132 } ).thenAccept ( flour -> assertEquals ( spelt , flour ) )
120133 );
@@ -124,7 +137,7 @@ public void testSingleResultQueryOnId(VertxTestContext context) {
124137 public void testSingleResultQueryOnName (VertxTestContext context ) {
125138 test ( context , getSessionFactory ().withSession ( s -> {
126139 Stage .SelectionQuery <?> qr = s .createSelectionQuery ( "FROM Flour WHERE name = 'Almond'" , Flour .class );
127- assertNotNull ( qr );
140+ assertThat ( qr ). isNotNull ( );
128141 return qr .getSingleResult ();
129142 } ).thenAccept ( flour -> assertEquals ( almond , flour ) )
130143 );
@@ -135,7 +148,7 @@ public void testFromQuery(VertxTestContext context) {
135148 test ( context , getSessionFactory ()
136149 .withSession ( s -> {
137150 Stage .SelectionQuery <Flour > qr = s .createSelectionQuery ( "FROM Flour ORDER BY name" , Flour .class );
138- assertNotNull ( qr );
151+ assertThat ( qr ). isNotNull ( );
139152 return qr .getResultList ();
140153 } )
141154 .thenAccept ( results -> assertThat ( results ).containsExactly ( almond , rye , spelt ) )
0 commit comments