Skip to content

Commit 6b541a1

Browse files
committed
Remove IntelliJ warnings in tests
1 parent 6261c35 commit 6b541a1

14 files changed

+26
-30
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private <T> CriteriaQuery<T> queryForDelete(Class<T> entityClass) {
174174

175175
@Before
176176
public void before(TestContext context) {
177-
test( context, setupSessionFactory( () -> constructConfiguration() ) );
177+
test( context, setupSessionFactory( this::constructConfiguration ) );
178178
}
179179

180180
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static class LoggedUserGeneratorWithStage extends StageValueGenerator<Str
4747

4848
@Override
4949
public CompletionStage<String> generateValue(Stage.Session session, Object owner) {
50-
Objects.nonNull( session );
50+
Objects.requireNonNull( session );
5151
String value = CurrentUser.INSTANCE.get();
5252
return completedFuture( value );
5353
}
@@ -57,7 +57,7 @@ public static class LoggedUserGeneratorWithMutiny extends MutinyValueGenerator<S
5757

5858
@Override
5959
public Uni<String> generateValue(Mutiny.Session session, Object owner) {
60-
Objects.nonNull( session );
60+
Objects.requireNonNull( session );
6161
String value = CurrentUser.INSTANCE.get();
6262
return Uni.createFrom().item( value );
6363
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public void setNewElementCollectionWithStageAPI(TestContext context) {
314314
.thenAccept( foundPerson -> {
315315
context.assertNotNull( foundPerson );
316316
context.assertFalse( foundPerson.getPhones().isEmpty() );
317-
foundPerson.setPhones( Arrays.asList( "555" ) );
317+
foundPerson.setPhones( List.of( "555" ) );
318318
} )
319319
)
320320
.thenCompose( v -> openSession() )
@@ -331,7 +331,7 @@ public void setNewElementCollectionWithMutinyAPI(TestContext context) {
331331
.invoke( foundPerson -> {
332332
context.assertNotNull( foundPerson );
333333
context.assertFalse( foundPerson.getPhones().isEmpty() );
334-
foundPerson.setPhones( Arrays.asList( "555" ) );
334+
foundPerson.setPhones( List.of( "555" ) );
335335
} )
336336
)
337337
.chain( this::openMutinySession )

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public void setNewElementCollectionWithStageAPI(TestContext context){
214214
.thenAccept( foundPerson -> {
215215
context.assertNotNull( foundPerson );
216216
context.assertFalse( foundPerson.getPhones().isEmpty() );
217-
foundPerson.setPhones( new HashSet<>( Arrays.asList( "555" ) ) );
217+
foundPerson.setPhones( new HashSet<>( List.of( "555" ) ) );
218218
} )
219219
.thenCompose( v -> session.flush() ) )
220220
.thenCompose( v -> openSession() )
@@ -231,7 +231,7 @@ public void setNewElementCollectionWithMutinyAPI(TestContext context) {
231231
.invoke( foundPerson -> {
232232
context.assertNotNull( foundPerson );
233233
context.assertFalse( foundPerson.getPhones().isEmpty() );
234-
foundPerson.setPhones( new HashSet<>( Arrays.asList( "555" ) ) );
234+
foundPerson.setPhones( new HashSet<>( List.of( "555" ) ) );
235235
} ) )
236236
.chain( this::openMutinySession )
237237
.chain( session -> session.find( Person.class, thePerson.getId() ) )

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public void setNewElementCollectionStageAPI(TestContext context) {
402402
.thenCompose( session -> session
403403
.find( Person.class, thePerson.getId() )
404404
// replace phones with list of 1 phone
405-
.thenAccept( foundPerson -> foundPerson.setPhones( Arrays.asList( new Phone( "000-000-0000" ) ) ) )
405+
.thenAccept( foundPerson -> foundPerson.setPhones( List.of( new Phone( "000-000-0000" ) ) ) )
406406
.thenCompose( v -> session.flush() ) )
407407
.thenCompose( v -> openSession() )
408408
.thenCompose( session -> session.find( Person.class, thePerson.getId() ) )
@@ -415,7 +415,7 @@ public void setNewElementCollectionMutinyAPI(TestContext context) {
415415
test( context, openMutinySession()
416416
.chain( session -> session.find( Person.class, thePerson.getId() )
417417
// replace phones with list of 1 phone
418-
.invoke( foundPerson -> foundPerson.setPhones( Arrays.asList( new Phone( "000-000-0000" ) ) ) )
418+
.invoke( foundPerson -> foundPerson.setPhones( List.of( new Phone( "000-000-0000" ) ) ) )
419419
.call( session::flush ) )
420420
.chain( this::openMutinySession )
421421
.chain( session -> session.find( Person.class, thePerson.getId() ) )

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ public void setNewElementCollectionStageAPI(TestContext context) {
417417
.thenCompose( session -> session.find( Person.class, thePerson.getId() )
418418
// replace phones with list of 1 phone
419419
.thenAccept( foundPerson -> foundPerson.getPhone()
420-
.setAlternativePhones( Arrays.asList( new AlternativePhone( MOBILE, "555" ) ) ) )
420+
.setAlternativePhones( List.of( new AlternativePhone( MOBILE, "555" ) ) ) )
421421
.thenCompose( v -> session.flush() ) )
422422
.thenCompose( v -> openSession() )
423423
.thenCompose( session -> session.find( Person.class, thePerson.getId() ) )
@@ -432,7 +432,7 @@ public void setNewElementCollectionMutinyAPI(TestContext context) {
432432
.find( Person.class, thePerson.getId())
433433
// replace phones with list of 1 phone
434434
.invoke( foundPerson -> foundPerson.getPhone()
435-
.setAlternativePhones( Arrays.asList( new AlternativePhone( MOBILE, "555" ) ) ) )
435+
.setAlternativePhones( List.of( new AlternativePhone( MOBILE, "555" ) ) ) )
436436
.call( session::flush ) )
437437
.chain( this::openMutinySession )
438438
.chain( session -> session.find( Person.class, thePerson.getId() ) )

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public void setNewElementCollectionStageAPI(TestContext context) {
401401
.withTransaction( (session, tx) -> session
402402
.find( Person.class, thePerson.getId() )
403403
// replace phones with list of 1 phone
404-
.thenAccept( foundPerson -> foundPerson.setPhones( Arrays.asList( new Phone( "000-000-0000" ) ) ) ) )
404+
.thenAccept( foundPerson -> foundPerson.setPhones( List.of( new Phone( "000-000-0000" ) ) ) ) )
405405
.thenCompose( s -> openSession() )
406406
.thenCompose( session -> session.find( Person.class, thePerson.getId() ) )
407407
.thenAccept( changedPerson -> assertPhones( context, changedPerson, "000-000-0000" ) )
@@ -414,7 +414,7 @@ public void setNewElementCollectionMutinyAPI(TestContext context) {
414414
.withTransaction( (session, tx) -> session
415415
.find( Person.class, thePerson.getId() )
416416
// replace phones with list of 1 phone
417-
.invoke( foundPerson -> foundPerson.setPhones( Arrays.asList( new Phone( "000-000-0000" ) ) ) ) )
417+
.invoke( foundPerson -> foundPerson.setPhones( List.of( new Phone( "000-000-0000" ) ) ) ) )
418418
.chain( this::openMutinySession )
419419
.chain( session -> session.find( Person.class, thePerson.getId() ) )
420420
.invoke( changedPerson -> assertPhones( context, changedPerson, "000-000-0000" ) )

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void testInsertQuery(TestContext context) {
8787
insertQueryBuilder.append( "'" ).append( chestnut.getName() ).append( "', " );
8888
insertQueryBuilder.append( "'" ).append( chestnut.getDescription() ).append( "', " );
8989
insertQueryBuilder.append( "'" ).append( chestnut.getType() ).append( "' " );
90-
insertQueryBuilder.append( " from Flour where id = " + rye.getId() );
90+
insertQueryBuilder.append( " from Flour where id = " ).append( rye.getId() );
9191
test(
9292
context,
9393
openSession()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public enum Tenant {
2222
TENANT_1( "dbtenant1" ),
2323
TENANT_2( "dbtenant2" );
2424

25-
private String dbName;
25+
private final String dbName;
2626

2727
Tenant(String dbName) {
2828
this.dbName = dbName;

hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/DB2Database.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class DB2Database implements TestableDatabase {
7373
expectedDBTypeForClass.put( char.class, "CHARACTER" );
7474
expectedDBTypeForClass.put( TextType.class, "VARCHAR" );
7575
expectedDBTypeForClass.put( String.class, "VARCHAR" );
76-
}};
76+
}}
7777

7878
/**
7979
* Holds configuration for the DB2 database container. If the build is run with <code>-Pdocker</code> then

hibernate-reactive-core/src/test/java/org/hibernate/reactive/containers/OracleDatabase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class OracleDatabase implements TestableDatabase {
4141

4242
public static final OracleDatabase INSTANCE = new OracleDatabase();
4343

44-
public static Map<Class<?>, String> expectedDBTypeForClass = new HashMap<>();
44+
public static final Map<Class<?>, String> expectedDBTypeForClass = new HashMap<>();
4545

4646
static {
4747
{
@@ -94,7 +94,7 @@ class OracleDatabase implements TestableDatabase {
9494
// See https://github.com/gvenzl/oci-oracle-xe/issues/64
9595
// I choose to limit it to "2 cpus": should be more than enough for any local testing needs,
9696
// and keeps things simple.
97-
.withCreateContainerCmdModifier( cmd -> cmd.getHostConfig().withCpuCount( 2l ) );
97+
.withCreateContainerCmdModifier( cmd -> cmd.getHostConfig().withCpuCount( 2L ) );
9898

9999
@Override
100100
public String getJdbcUrl() {
@@ -112,7 +112,7 @@ public String createJdbcUrl(String host, int port, String database, Map<String,
112112
params.forEach( (key, value) -> {
113113
paramsBuilder.append( jdbcParamDelimiter() );
114114
paramsBuilder.append( key );
115-
paramsBuilder.append( "=" );
115+
paramsBuilder.append( '=' );
116116
paramsBuilder.append( value );
117117
} );
118118
}
@@ -179,7 +179,7 @@ private static String addCredentialsToUri(String jdbcUrl) {
179179
// jdbc:oracle:thin:@localhost:49413/hreact
180180
String uri = jdbcUrl;
181181
if ( uri.startsWith( "jdbc:" ) ) {
182-
jdbcUrl.substring( "jdbc:".length() );
182+
uri = uri.substring( "jdbc:".length() );
183183
}
184184
uri = uri.replace( "thin:@", "thin:" + getCredentials() + "@" );
185185
return uri;

hibernate-reactive-core/src/test/java/org/hibernate/reactive/testing/SqlStatementTracker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ public SqlStatementTracker(Predicate<String> predicate, Properties properties) {
4848
}
4949

5050
private static boolean toBoolean(Object obj) {
51-
return Boolean.valueOf( (String) obj );
51+
return Boolean.parseBoolean( (String) obj );
5252
}
5353

5454
private static long toLong(Object obj) {
5555
if ( obj == null ) {
5656
return 0;
5757
}
58-
return Long.valueOf( (String) obj );
58+
return Long.parseLong( (String) obj );
5959
}
6060

6161
@Override

hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/BasicTypesAndCallbacksForAllDBsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public void testDuration(TestContext context) {
395395
basic.duration = Duration.ofMillis( 1894657L );
396396

397397
testField( context, basic, found -> {
398-
context.assertTrue( found.duration instanceof Duration );
398+
context.assertNotNull( found.duration );
399399
context.assertEquals( basic.duration, found.duration );
400400
} );
401401
}
@@ -406,7 +406,7 @@ public void testInstant(TestContext context) {
406406
basic.instant = Instant.now();
407407

408408
testField( context, basic, found -> {
409-
context.assertTrue( found.instant instanceof Instant );
409+
context.assertNotNull( found.instant );
410410
// Without the truncated it fails with JDK 15+
411411
context.assertEquals( basic.instant.truncatedTo( ChronoUnit.MILLIS ),
412412
found.instant.truncatedTo( ChronoUnit.MILLIS ) );

hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/LobTypeTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ protected Collection<Class<?>> annotatedEntities() {
4444
public void testStringLobType(TestContext context) {
4545
String text = "hello world once upon a time it was the best of times it was the worst of times goodbye";
4646
StringBuilder longText = new StringBuilder();
47-
for ( int i = 0; i < 1000; i++ ) {
48-
longText.append( text );
49-
}
47+
longText.append( text.repeat( 1000 ) );
5048
String book = longText.toString();
5149

5250
Basic basic = new Basic();
@@ -59,9 +57,7 @@ public void testStringLobType(TestContext context) {
5957
public void testBytesLobType(TestContext context) {
6058
String text = "hello world once upon a time it was the best of times it was the worst of times goodbye";
6159
StringBuilder longText = new StringBuilder();
62-
for ( int i = 0; i < 1000; i++ ) {
63-
longText.append( text );
64-
}
60+
longText.append( text.repeat( 1000 ) );
6561
byte[] pic = longText.toString().getBytes();
6662

6763
Basic basic = new Basic();

0 commit comments

Comments
 (0)