Skip to content

Commit 306da48

Browse files
committed
Remove warnings from tests
1 parent 7bfd634 commit 306da48

11 files changed

+25
-23
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ private static void assertPhones(VertxTestContext context, Person person, String
442442
assertNotNull( person );
443443
String[] sortedExpected = Arrays.stream( expectedPhones ).sorted()
444444
.sorted( String.CASE_INSENSITIVE_ORDER )
445-
.collect( Collectors.toList() )
445+
.toList()
446446
.toArray( new String[expectedPhones.length] );
447447
List<String> sortedActual = person.getPhones().stream()
448448
.sorted( String.CASE_INSENSITIVE_ORDER )

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void test(VertxTestContext context) {
6363
}
6464

6565
private Book[] asBooks(String[] titles) {
66-
return Arrays.asList( titles ).stream().map( Book::new ).toArray( Book[]::new );
66+
return Arrays.stream( titles ).map( Book::new ).toArray( Book[]::new );
6767
}
6868

6969
@Entity(name = "Book")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private CompletionStage<?> populateDb() {
7070
return getSessionFactory()
7171
.withTransaction( (session, tx) -> session.persist( identities.toArray() ) )
7272
.thenAccept( ignore -> {
73-
Long assignedId = 0L;
73+
long assignedId = 0L;
7474
for ( EntityWithIdentity identity : identities ) {
7575
assertNotNull( identity.id );
7676
assertTrue( identity.id > assignedId );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private CompletionStage<?> populateDb() {
6868
return getSessionFactory()
6969
.withTransaction( (session, tx) -> session.persist( identities.toArray() ) )
7070
.thenAccept( ignore -> {
71-
Long assignedId = 0L;
71+
long assignedId = 0L;
7272
for ( EntityWithIdentity identity : identities ) {
7373
assertNotNull( identity.id );
7474
assertTrue( identity.id > assignedId );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private CompletionStage<?> populateDb() {
7272
return getSessionFactory()
7373
.withTransaction( (session, tx) -> session.persist( identities.toArray() ) )
7474
.thenAccept( ignore -> {
75-
Long assignedId = 0L;
75+
long assignedId = 0L;
7676
for ( EntityWithIdentity identity : identities ) {
7777
assertNotNull( identity.id );
7878
assertTrue( identity.id > assignedId );

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,14 @@ public void testLazyInitializationExceptionWithMutiny(VertxTestContext context)
7272

7373
@Test
7474
public void testLazyInitializationExceptionWithStage(VertxTestContext context) {
75-
test( context, assertThrown( LazyInitializationException.class, openSession()
76-
.thenCompose( ss -> ss.createSelectionQuery( "from Artist", Artist.class ).getSingleResult() )
77-
.thenAccept( artist -> artist.getPaintings().size() ) )
78-
.thenAccept( LazyInitializationExceptionTest::assertLazyInitialization )
75+
test(
76+
context, assertThrown(
77+
LazyInitializationException.class, openSession()
78+
.thenCompose( ss -> ss
79+
.createSelectionQuery( "from Artist", Artist.class )
80+
.getSingleResult() )
81+
.thenAccept( artist -> artist.getPaintings().size() )
82+
).thenAccept( LazyInitializationExceptionTest::assertLazyInitialization )
7983
);
8084
}
8185

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import jakarta.persistence.Table;
3838

3939
import static java.util.concurrent.TimeUnit.MINUTES;
40+
import static org.assertj.core.api.Assertions.fail;
4041
import static org.hibernate.cfg.AvailableSettings.SHOW_SQL;
4142
import static org.hibernate.reactive.BaseReactiveTest.setDefaultProperties;
4243
import static org.hibernate.reactive.provider.Settings.POOL_CONNECT_TIMEOUT;
@@ -233,11 +234,16 @@ public void reached() {
233234

234235
public void waitForEveryone() {
235236
try {
236-
countDownLatch.await( TIMEOUT_MINUTES, TimeUnit.MINUTES );
237-
prettyOut( "Everyone has now breached '" + label + "'" );
237+
boolean reachedZero = countDownLatch.await( TIMEOUT_MINUTES, MINUTES );
238+
if ( reachedZero ) {
239+
prettyOut( "Everyone has now breached '" + label + "'" );
240+
}
241+
else {
242+
fail( "Time out reached" );
243+
}
238244
}
239245
catch ( InterruptedException e ) {
240-
e.printStackTrace();
246+
fail( e );
241247
}
242248
}
243249
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ public User(Long id, String firstname, String lastname, Role... roles) {
111111
this.firstname = firstname;
112112
this.lastname = lastname;
113113
this.roles = new Role[roles.length];
114-
for ( int i = 0; i < roles.length; i++ ) {
115-
this.roles[i] = roles[i];
116-
}
114+
System.arraycopy( roles, 0, this.roles, 0, roles.length );
117115
}
118116

119117
public Long getId() {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ public void testPersistAll(VertxTestContext context) {
4545
Author author = new Author( "Iain M Banks" );
4646
author.books.add( book1 );
4747
author.books.add( book2 );
48-
final Book[] bookArray = new Book[2];
49-
bookArray[0] = book1;
50-
bookArray[1] = book2;
5148

5249
test( context, getMutinySessionFactory()
5350
.withTransaction( session -> session.persistAll( book1, book2, author ) )
@@ -67,9 +64,6 @@ public void testFetchJoinQueryGetSingleResult(VertxTestContext context) {
6764
Author author = new Author( "Iain M Banks" );
6865
author.books.add( book1 );
6966
author.books.add( book2 );
70-
final Book[] bookArray = new Book[2];
71-
bookArray[0] = book1;
72-
bookArray[1] = book2;
7367

7468
test( context, getMutinySessionFactory()
7569
.withTransaction( session -> session.persistAll( book1, book2, author ) )

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void testCriteriaEntityQuery(VertxTestContext context) {
138138
update.set( b.get( "title" ), "XXX" );
139139

140140
CriteriaDelete<Book> delete = builder.createCriteriaDelete( Book.class );
141-
b = delete.from( Book.class );
141+
delete.from( Book.class );
142142

143143
test(
144144
context,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private void testSoftDelete(
172172
} )
173173
)
174174
// Delete an entity
175-
.call( deleteEntity::get )
175+
.call( deleteEntity )
176176
// Test select all
177177
.call( () -> getMutinySessionFactory().withTransaction( s -> s
178178
.createSelectionQuery( "from " + entityClass.getSimpleName() + " order by id", Object.class )

0 commit comments

Comments
 (0)