Skip to content

Commit 45a872b

Browse files
committed
chore: clean up HQLQueryTest class
* Code formattation * Replace Jupiter assertions with AssertJ ones
1 parent e43951a commit 45a872b

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryTest.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
*/
66
package org.hibernate.reactive;
77

8-
import jakarta.persistence.GeneratedValue;
9-
import jakarta.persistence.ManyToOne;
10-
import jakarta.persistence.OneToMany;
118
import java.util.ArrayList;
129
import java.util.Collection;
1310
import java.util.List;
@@ -21,19 +18,19 @@
2118
import io.vertx.junit5.Timeout;
2219
import io.vertx.junit5.VertxTestContext;
2320
import jakarta.persistence.Entity;
21+
import jakarta.persistence.GeneratedValue;
2422
import jakarta.persistence.Id;
23+
import jakarta.persistence.ManyToOne;
24+
import jakarta.persistence.OneToMany;
2525
import jakarta.persistence.Table;
2626

2727
import static jakarta.persistence.CascadeType.PERSIST;
2828
import static jakarta.persistence.FetchType.LAZY;
2929
import static java.util.concurrent.TimeUnit.MINUTES;
3030
import static org.assertj.core.api.Assertions.assertThat;
3131
import 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-
3734
public 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,30 +88,33 @@ 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 );
104-
return qr.getSingleResult();
105-
} ).thenAccept( found -> {
106-
assertTrue( found instanceof Object[] );
107-
assertEquals( "Prova", ( (Object[]) found )[0] );
108-
assertEquals( rye.getId(), ( (Object[]) found )[1] );
109-
} )
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+
} )
110110
);
111111
}
112112

113113
@Test
114114
public void testSingleResultQueryOnId(VertxTestContext context) {
115115
test( context, getSessionFactory().withSession( s -> {
116116
Stage.SelectionQuery<?> qr = s.createSelectionQuery( "FROM Flour WHERE id = 1", Flour.class );
117-
assertNotNull( qr );
117+
assertThat( qr ).isNotNull();
118118
return qr.getSingleResult();
119119
} ).thenAccept( flour -> assertEquals( spelt, flour ) )
120120
);
@@ -124,7 +124,7 @@ public void testSingleResultQueryOnId(VertxTestContext context) {
124124
public void testSingleResultQueryOnName(VertxTestContext context) {
125125
test( context, getSessionFactory().withSession( s -> {
126126
Stage.SelectionQuery<?> qr = s.createSelectionQuery( "FROM Flour WHERE name = 'Almond'", Flour.class );
127-
assertNotNull( qr );
127+
assertThat( qr ).isNotNull();
128128
return qr.getSingleResult();
129129
} ).thenAccept( flour -> assertEquals( almond, flour ) )
130130
);
@@ -135,7 +135,7 @@ public void testFromQuery(VertxTestContext context) {
135135
test( context, getSessionFactory()
136136
.withSession( s -> {
137137
Stage.SelectionQuery<Flour> qr = s.createSelectionQuery( "FROM Flour ORDER BY name", Flour.class );
138-
assertNotNull( qr );
138+
assertThat( qr ).isNotNull();
139139
return qr.getResultList();
140140
} )
141141
.thenAccept( results -> assertThat( results ).containsExactly( almond, rye, spelt ) )

0 commit comments

Comments
 (0)