Skip to content

Commit 95a2a2d

Browse files
committed
Update
1 parent 6b072b8 commit 95a2a2d

14 files changed

+70
-70
lines changed

driver/src/main/java/org/neo4j/driver/internal/bolt/api/NotificationSeverity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public record NotificationSeverity(Type type, int level) implements Comparable<N
2424
public static final NotificationSeverity OFF =
2525
new NotificationSeverity(NotificationSeverity.Type.OFF, Integer.MAX_VALUE);
2626

27-
public static NotificationSeverity INFORMATION =
27+
public static final NotificationSeverity INFORMATION =
2828
new NotificationSeverity(NotificationSeverity.Type.INFORMATION, 800);
2929

30-
public static NotificationSeverity WARNING = new NotificationSeverity(NotificationSeverity.Type.WARNING, 900);
30+
public static final NotificationSeverity WARNING = new NotificationSeverity(NotificationSeverity.Type.WARNING, 900);
3131

3232
public NotificationSeverity {
3333
Objects.requireNonNull(type, "type must not be null");

driver/src/test/java/org/neo4j/driver/BookmarkManagersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
package org.neo4j.driver;
1818

19-
import static org.junit.jupiter.api.Assertions.assertTrue;
19+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2020

2121
import org.junit.jupiter.api.Test;
2222
import org.neo4j.driver.internal.Neo4jBookmarkManager;
@@ -31,6 +31,6 @@ void shouldCreateDefaultBookmarkManager() {
3131
var bookmarkManager = BookmarkManagers.defaultManager(config);
3232

3333
// THEN
34-
assertTrue(bookmarkManager instanceof Neo4jBookmarkManager);
34+
assertInstanceOf(Neo4jBookmarkManager.class, bookmarkManager);
3535
}
3636
}

driver/src/test/java/org/neo4j/driver/integration/GraphDatabaseAuthClusterIT.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
package org.neo4j.driver.integration;
1818

19+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
1920
import static org.junit.jupiter.api.Assertions.assertThrows;
20-
import static org.junit.jupiter.api.Assertions.assertTrue;
2121
import static org.reactivestreams.FlowAdapters.toPublisher;
2222

2323
import java.util.concurrent.CompletableFuture;
@@ -125,7 +125,7 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
125125
try (var driver = GraphDatabase.driver(clusterRule.getClusterUri(), manager);
126126
var session = driver.session()) {
127127
var exception = assertThrows(AuthTokenManagerExecutionException.class, () -> session.run("RETURN 1"));
128-
assertTrue(exception.getCause() instanceof NullPointerException);
128+
assertInstanceOf(NullPointerException.class, exception.getCause());
129129
}
130130
}
131131

@@ -197,7 +197,7 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
197197
var exception = assertThrows(
198198
CompletionException.class,
199199
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
200-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
200+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
201201
}
202202
}
203203

@@ -225,7 +225,7 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
225225
var exception = assertThrows(
226226
CompletionException.class,
227227
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
228-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
228+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
229229
}
230230
}
231231

@@ -253,7 +253,7 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
253253
var exception = assertThrows(
254254
CompletionException.class,
255255
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
256-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
256+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
257257
returnNull.set(false);
258258
session.runAsync("RETURN 1")
259259
.thenCompose(ResultCursor::consumeAsync)
@@ -280,8 +280,8 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
280280
var exception = assertThrows(
281281
CompletionException.class,
282282
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
283-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
284-
assertTrue(exception.getCause().getCause() instanceof NullPointerException);
283+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
284+
assertInstanceOf(NullPointerException.class, exception.getCause().getCause());
285285
}
286286
}
287287

@@ -311,8 +311,8 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
311311
var exception = assertThrows(
312312
CompletionException.class,
313313
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
314-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
315-
assertTrue(exception.getCause().getCause() instanceof NullPointerException);
314+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
315+
assertInstanceOf(NullPointerException.class, exception.getCause().getCause());
316316
}
317317
}
318318

@@ -342,8 +342,8 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
342342
var exception = assertThrows(
343343
CompletionException.class,
344344
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
345-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
346-
assertTrue(exception.getCause().getCause() instanceof NullPointerException);
345+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
346+
assertInstanceOf(NullPointerException.class, exception.getCause().getCause());
347347
returnNull.set(false);
348348
session.runAsync("RETURN 1")
349349
.thenCompose(ResultCursor::consumeAsync)

driver/src/test/java/org/neo4j/driver/integration/GraphDatabaseAuthDirectIT.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package org.neo4j.driver.integration;
1818

1919
import static java.util.concurrent.CompletableFuture.completedFuture;
20+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2021
import static org.junit.jupiter.api.Assertions.assertThrows;
21-
import static org.junit.jupiter.api.Assertions.assertTrue;
2222
import static org.reactivestreams.FlowAdapters.toPublisher;
2323

2424
import java.util.concurrent.CompletionException;
@@ -124,7 +124,7 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
124124
try (var driver = GraphDatabase.driver(neo4j.uri(), manager);
125125
var session = driver.session()) {
126126
var exception = assertThrows(AuthTokenManagerExecutionException.class, () -> session.run("RETURN 1"));
127-
assertTrue(exception.getCause() instanceof NullPointerException);
127+
assertInstanceOf(NullPointerException.class, exception.getCause());
128128
}
129129
}
130130

@@ -196,7 +196,7 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
196196
var exception = assertThrows(
197197
CompletionException.class,
198198
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
199-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
199+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
200200
}
201201
}
202202

@@ -224,7 +224,7 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
224224
var exception = assertThrows(
225225
CompletionException.class,
226226
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
227-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
227+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
228228
}
229229
}
230230

@@ -252,7 +252,7 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
252252
var exception = assertThrows(
253253
CompletionException.class,
254254
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
255-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
255+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
256256
returnNull.set(false);
257257
session.runAsync("RETURN 1")
258258
.thenCompose(ResultCursor::consumeAsync)
@@ -279,8 +279,8 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
279279
var exception = assertThrows(
280280
CompletionException.class,
281281
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
282-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
283-
assertTrue(exception.getCause().getCause() instanceof NullPointerException);
282+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
283+
assertInstanceOf(NullPointerException.class, exception.getCause().getCause());
284284
}
285285
}
286286

@@ -310,8 +310,8 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
310310
var exception = assertThrows(
311311
CompletionException.class,
312312
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
313-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
314-
assertTrue(exception.getCause().getCause() instanceof NullPointerException);
313+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
314+
assertInstanceOf(NullPointerException.class, exception.getCause().getCause());
315315
}
316316
}
317317

@@ -341,8 +341,8 @@ public boolean handleSecurityException(AuthToken authToken, SecurityException ex
341341
var exception = assertThrows(
342342
CompletionException.class,
343343
() -> session.runAsync("RETURN 1").toCompletableFuture().join());
344-
assertTrue(exception.getCause() instanceof AuthTokenManagerExecutionException);
345-
assertTrue(exception.getCause().getCause() instanceof NullPointerException);
344+
assertInstanceOf(AuthTokenManagerExecutionException.class, exception.getCause());
345+
assertInstanceOf(NullPointerException.class, exception.getCause().getCause());
346346
returnNull.set(false);
347347
session.runAsync("RETURN 1")
348348
.thenCompose(ResultCursor::consumeAsync)

driver/src/test/java/org/neo4j/driver/integration/ScalarTypeIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import static org.hamcrest.CoreMatchers.equalTo;
2020
import static org.hamcrest.MatcherAssert.assertThat;
21-
import static org.junit.jupiter.api.Assertions.assertTrue;
21+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2222
import static org.neo4j.driver.Values.parameters;
2323

2424
import java.util.Arrays;
@@ -162,7 +162,7 @@ static Stream<Arguments> listToTest() {
162162
@MethodSource("listToTest")
163163
void shouldEchoList(Value input) {
164164
// When & Then
165-
assertTrue(input instanceof ListValue);
165+
assertInstanceOf(ListValue.class, input);
166166
verifyCanEncodeAndDecode(input);
167167
}
168168

@@ -171,7 +171,7 @@ void shouldEchoNestedList() {
171171
var input = Values.value(toValueStream(listToTest()));
172172

173173
// When & Then
174-
assertTrue(input instanceof ListValue);
174+
assertInstanceOf(ListValue.class, input);
175175
verifyCanEncodeAndDecode(input);
176176
}
177177

@@ -188,7 +188,7 @@ static Stream<Arguments> mapToTest() {
188188
@ParameterizedTest
189189
@MethodSource("mapToTest")
190190
void shouldEchoMap(Value input) {
191-
assertTrue(input instanceof MapValue);
191+
assertInstanceOf(MapValue.class, input);
192192
// When & Then
193193
verifyCanEncodeAndDecode(input);
194194
}
@@ -205,7 +205,7 @@ void shouldEchoNestedMap() {
205205
private Stream<Value> toValueStream(Stream<Arguments> arguments) {
206206
return arguments.map(arg -> {
207207
var obj = arg.get()[0];
208-
assertTrue(obj instanceof Value);
208+
assertInstanceOf(Value.class, obj);
209209
return (Value) obj;
210210
});
211211
}

driver/src/test/java/org/neo4j/driver/internal/async/UnmanagedTransactionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static java.util.concurrent.CompletableFuture.completedFuture;
2020
import static org.junit.jupiter.api.Assertions.assertEquals;
2121
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2223
import static org.junit.jupiter.api.Assertions.assertNotNull;
2324
import static org.junit.jupiter.api.Assertions.assertNull;
2425
import static org.junit.jupiter.api.Assertions.assertSame;
@@ -622,7 +623,7 @@ void shouldReturnFailingStageOnConflictingCompletingAction(
622623
ExecutionException.class,
623624
() -> conflictingActionStage.toCompletableFuture().get())
624625
.getCause();
625-
assertTrue(throwable instanceof ClientException);
626+
assertInstanceOf(ClientException.class, throwable);
626627
assertEquals(expectedErrorMsg, throwable.getMessage());
627628
}
628629

driver/src/test/java/org/neo4j/driver/internal/bolt/basicimpl/async/connection/HandshakeCompletedListenerTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.neo4j.driver.internal.bolt.api.RoutingContext;
4141
import org.neo4j.driver.internal.bolt.basicimpl.async.inbound.InboundMessageDispatcher;
4242
import org.neo4j.driver.internal.bolt.basicimpl.handlers.HelloResponseHandler;
43-
import org.neo4j.driver.internal.bolt.basicimpl.messaging.Message;
4443
import org.neo4j.driver.internal.bolt.basicimpl.messaging.request.HelloMessage;
4544
import org.neo4j.driver.internal.bolt.basicimpl.messaging.v3.BoltProtocolV3;
4645
import org.neo4j.driver.internal.bolt.basicimpl.spi.ResponseHandler;
@@ -107,8 +106,6 @@ void shouldWriteInitializationMessageInBoltV3WhenHandshakeCompleted() {
107106
assertEquals(expectedMessage, outboundMessage);
108107
}
109108

110-
private void testWritingOfInitializationMessage(Message expectedMessage) {}
111-
112109
private static Map<String, Value> authToken() {
113110
return Map.of("neo4j", Values.value("secret"));
114111
}

driver/src/test/java/org/neo4j/driver/internal/bolt/basicimpl/async/inbound/InboundMessageDispatcherTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
import static java.util.Collections.emptyMap;
2020
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2122
import static org.junit.jupiter.api.Assertions.assertNull;
2223
import static org.junit.jupiter.api.Assertions.assertThrows;
23-
import static org.junit.jupiter.api.Assertions.assertTrue;
2424
import static org.junit.jupiter.api.Assertions.fail;
2525
import static org.mockito.ArgumentMatchers.any;
2626
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -309,8 +309,8 @@ void shouldCreateChannelActivityLoggerAndLogDebugMessageOnMessageHandling(Class<
309309
}
310310

311311
// THEN
312-
assertTrue(dispatcher.getLog() instanceof ChannelActivityLogger);
313-
assertTrue(dispatcher.getErrorLog() instanceof ChannelErrorLogger);
312+
assertInstanceOf(ChannelActivityLogger.class, dispatcher.getLog());
313+
assertInstanceOf(ChannelErrorLogger.class, dispatcher.getErrorLog());
314314
loggerVerification.run();
315315
}
316316

@@ -334,8 +334,8 @@ void shouldCreateChannelErrorLoggerAndLogDebugMessageOnChannelError() {
334334
dispatcher.handleChannelError(throwable);
335335

336336
// THEN
337-
assertTrue(dispatcher.getLog() instanceof ChannelActivityLogger);
338-
assertTrue(dispatcher.getErrorLog() instanceof ChannelErrorLogger);
337+
assertInstanceOf(ChannelActivityLogger.class, dispatcher.getLog());
338+
assertInstanceOf(ChannelErrorLogger.class, dispatcher.getErrorLog());
339339
verify(errorLogger)
340340
.log(
341341
eq(System.Logger.Level.DEBUG),

driver/src/test/java/org/neo4j/driver/internal/bolt/basicimpl/handlers/CommitTxResponseHandlerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static java.util.Collections.emptyMap;
2020
import static java.util.Collections.singletonMap;
2121
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNull;
2223
import static org.junit.jupiter.api.Assertions.assertThrows;
2324
import static org.neo4j.driver.Values.value;
2425
import static org.neo4j.driver.testutil.TestUtil.await;
@@ -35,7 +36,7 @@ class CommitTxResponseHandlerTest {
3536
void shouldHandleSuccessWithoutBookmark() {
3637
handler.onSuccess(emptyMap());
3738

38-
assertEquals(null, await(future));
39+
assertNull(await(future));
3940
}
4041

4142
@Test

driver/src/test/java/org/neo4j/driver/internal/bolt/pooledimpl/PooledBoltConnectionProviderTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,23 @@ class PooledBoltConnectionProviderTest {
9393
@Mock
9494
Supplier<CompletionStage<Map<String, Value>>> authMapStageSupplier;
9595

96-
int maxSize = 2;
97-
long acquisitionTimeout = 5000;
98-
long maxLifetime = 60000;
99-
long idleBeforeTest = 30000;
100-
BoltServerAddress address = BoltServerAddress.LOCAL_DEFAULT;
101-
RoutingContext context = RoutingContext.EMPTY;
102-
BoltAgent boltAgent = BoltAgentUtil.VALUE;
103-
String userAgent = "agent";
104-
int timeout = 1000;
105-
106-
SecurityPlan securityPlan = SecurityPlan.INSECURE;
107-
DatabaseName databaseName = DatabaseNameUtil.defaultDatabase();
108-
AccessMode mode = AccessMode.WRITE;
109-
Set<String> bookmarks = Set.of("bookmark1", "bookmark2");
110-
String impersonatedUser = null;
111-
BoltProtocolVersion minVersion = new BoltProtocolVersion(5, 6);
112-
NotificationConfig notificationConfig = NotificationConfig.defaultConfig();
96+
final int maxSize = 2;
97+
final long acquisitionTimeout = 5000;
98+
final long maxLifetime = 60000;
99+
final long idleBeforeTest = 30000;
100+
final BoltServerAddress address = BoltServerAddress.LOCAL_DEFAULT;
101+
final RoutingContext context = RoutingContext.EMPTY;
102+
final BoltAgent boltAgent = BoltAgentUtil.VALUE;
103+
final String userAgent = "agent";
104+
final int timeout = 1000;
105+
106+
final SecurityPlan securityPlan = SecurityPlan.INSECURE;
107+
final DatabaseName databaseName = DatabaseNameUtil.defaultDatabase();
108+
final AccessMode mode = AccessMode.WRITE;
109+
final Set<String> bookmarks = Set.of("bookmark1", "bookmark2");
110+
final String impersonatedUser = null;
111+
final BoltProtocolVersion minVersion = new BoltProtocolVersion(5, 6);
112+
final NotificationConfig notificationConfig = NotificationConfig.defaultConfig();
113113

114114
@BeforeEach
115115
@SuppressWarnings("resource")

driver/src/test/java/org/neo4j/driver/internal/cursor/ResultCursorImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ class ResultCursorImplTest {
6868
@Mock
6969
Supplier<Throwable> termSupplier;
7070

71-
Query query = new Query("query");
72-
long fetchSize = 1000;
71+
final Query query = new Query("query");
72+
final long fetchSize = 1000;
7373
boolean closeOnSummary;
7474

7575
@BeforeEach

driver/src/test/java/org/neo4j/driver/internal/metrics/MicrometerMetricsProviderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
package org.neo4j.driver.internal.metrics;
1818

19-
import static org.junit.jupiter.api.Assertions.assertTrue;
19+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2020

2121
import org.junit.jupiter.api.BeforeEach;
2222
import org.junit.jupiter.api.Test;
@@ -35,7 +35,7 @@ void shouldReturnMicrometerMetricsOnMetrics() {
3535
var metrics = provider.metrics();
3636

3737
// THEN
38-
assertTrue(metrics instanceof MicrometerMetrics);
38+
assertInstanceOf(MicrometerMetrics.class, metrics);
3939
}
4040

4141
@Test
@@ -44,6 +44,6 @@ void shouldReturnMicrometerMetricsOnMetricsListener() {
4444
var listener = provider.metricsListener();
4545

4646
// THEN
47-
assertTrue(listener instanceof MicrometerMetrics);
47+
assertInstanceOf(MicrometerMetrics.class, listener);
4848
}
4949
}

0 commit comments

Comments
 (0)