Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
injectives committed Jul 25, 2023
1 parent aee893b commit ed8bbf6
Show file tree
Hide file tree
Showing 42 changed files with 63 additions and 104 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ As a policy, patch versions will not be released except on rare occasions. Bug f

## Supported Driver Series

| Driver Series | Supported Java Runtime versions | Status | Changelog |
| --- | --- | --- | --- |
| 5.x | 17 | Primary development branch. | [link](https://github.com/neo4j/neo4j-java-driver/wiki/5.x-changelog) |
| 4.4 | 8, 11 | Maintenance. | [link](https://github.com/neo4j/neo4j-java-driver/wiki/4.4-changelog) |
| Driver Series | Supported Java Runtime versions | Status | Changelog |
|---------------|---------------------------------|-----------------------------|-----------------------------------------------------------------------|
| 5.x | 17 | Primary development branch. | [link](https://github.com/neo4j/neo4j-java-driver/wiki/5.x-changelog) |
| 4.4 | 8, 11 | Maintenance. | [link](https://github.com/neo4j/neo4j-java-driver/wiki/4.4-changelog) |

## Server Compatibility

Expand Down
2 changes: 1 addition & 1 deletion build/javadoc/overview.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HTML lang="en">
<HEAD>
<TITLE>API Overview</TITLE>
</HEAD>
Expand Down
5 changes: 2 additions & 3 deletions driver/src/main/java/org/neo4j/driver/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,8 @@ public ConfigBuilder withRoutingTablePurgeDelay(long delay, TimeUnit unit) {
* By default, the value is set to {@code 1000}.
* Use {@code -1} to disables back pressure and config client to pull all records at once after each run.
* <p>
* This config only applies to run result obtained via {@link Session} and {@link org.neo4j.driver.async.AsyncSession}.
* As with {@link org.neo4j.driver.reactive.RxSession}, the batch size is provided via
* {@link org.reactivestreams.Subscription#request(long)} instead.
* This config only applies to run results obtained via {@link Session} and {@link org.neo4j.driver.async.AsyncSession}.
* As with the reactive sessions the batch size is managed by the subscription requests instead.
*
* @param size the default record fetch size when pulling records in batches using Bolt V4.
* @return this builder
Expand Down
4 changes: 4 additions & 0 deletions driver/src/main/java/org/neo4j/driver/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ default Session session(SessionConfig sessionConfig) {
* @throws IllegalArgumentException for unsupported session types
* @since 5.2
*/
@SuppressWarnings("deprecation")
default <T extends BaseSession> T session(Class<T> sessionClass) {
return session(sessionClass, SessionConfig.defaultConfig());
}
Expand Down Expand Up @@ -176,6 +177,7 @@ default <T extends BaseSession> T session(Class<T> sessionClass) {
* @since 5.8
*/
@Preview(name = "AuthToken rotation and session auth support")
@SuppressWarnings("deprecation")
default <T extends BaseSession> T session(Class<T> sessionClass, AuthToken sessionAuthToken) {
return session(sessionClass, SessionConfig.defaultConfig(), sessionAuthToken);
}
Expand Down Expand Up @@ -208,6 +210,7 @@ default <T extends BaseSession> T session(Class<T> sessionClass, AuthToken sessi
* @throws IllegalArgumentException for unsupported session types
* @since 5.2
*/
@SuppressWarnings("deprecation")
default <T extends BaseSession> T session(Class<T> sessionClass, SessionConfig sessionConfig) {
return session(sessionClass, sessionConfig, null);
}
Expand Down Expand Up @@ -247,6 +250,7 @@ default <T extends BaseSession> T session(Class<T> sessionClass, SessionConfig s
* @since 5.8
*/
@Preview(name = "AuthToken rotation and session auth support")
@SuppressWarnings("deprecation")
<T extends BaseSession> T session(Class<T> sessionClass, SessionConfig sessionConfig, AuthToken sessionAuthToken);

/**
Expand Down
5 changes: 2 additions & 3 deletions driver/src/main/java/org/neo4j/driver/SessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import org.neo4j.driver.async.AsyncSession;
import org.neo4j.driver.exceptions.UnsupportedFeatureException;
import org.neo4j.driver.reactive.ReactiveSession;
import org.neo4j.driver.reactive.RxSession;
import org.reactivestreams.Subscription;

/**
* The session configurations used to configure a session.
Expand Down Expand Up @@ -339,7 +337,8 @@ public Builder withDatabase(String database) {
* Use {@code -1} to disables back pressure and config client to pull all records at once after each run.
* <p>
* This config only applies to run result obtained via {@link Session} and {@link AsyncSession}.
* As with {@link RxSession}, the batch size is provided via {@link Subscription#request(long)} instead.
* As with the reactive sessions the batch size is managed by the subscription requests instead.
*
* @param size the default record fetch size when pulling records in batches using Bolt V4.
* @return this builder
*/
Expand Down
6 changes: 2 additions & 4 deletions driver/src/main/java/org/neo4j/driver/TransactionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Map;
import java.util.Objects;
import org.neo4j.driver.async.AsyncSession;
import org.neo4j.driver.async.AsyncTransactionWork;
import org.neo4j.driver.internal.util.Extract;

/**
Expand All @@ -41,9 +40,8 @@
* <ul>
* <li>queries executed in auto-commit transactions - using various overloads of {@link Session#run(String, TransactionConfig)} and
* {@link AsyncSession#runAsync(String, TransactionConfig)}</li>
* <li>transactions started by transaction functions - using {@link Session#readTransaction(TransactionWork, TransactionConfig)},
* {@link Session#writeTransaction(TransactionWork, TransactionConfig)}, {@link AsyncSession#readTransactionAsync(AsyncTransactionWork, TransactionConfig)} and
* {@link AsyncSession#writeTransactionAsync(AsyncTransactionWork, TransactionConfig)}</li>
* <li>transactions started by transaction functions - using {@link Session#executeWrite(TransactionCallback, TransactionConfig)},
* {@link Session#executeRead(TransactionCallback, TransactionConfig)} and the other similar variants</li>
* <li>unmanaged transactions - using {@link Session#beginTransaction(TransactionConfig)} and {@link AsyncSession#beginTransactionAsync(TransactionConfig)}</li>
* </ul>
* <p>
Expand Down
3 changes: 1 addition & 2 deletions driver/src/main/java/org/neo4j/driver/Values.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ public static Value value(Object value) {
* @return the array of values
*/
public static Value[] values(final Object... input) {
var values = Arrays.stream(input).map(Values::value).toArray(Value[]::new);
return values;
return Arrays.stream(input).map(Values::value).toArray(Value[]::new);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,9 @@ private CompletionStage<ConnectionContextAndHandler> ensureDatabaseNameIsComplet
public Set<BoltServerAddress> allServers() {
// obviously we just had a snapshot of all servers in all routing tables
// after we read it, the set could already be changed.
var servers = routingTableHandlers.values().stream()
return routingTableHandlers.values().stream()
.flatMap(tableHandler -> tableHandler.servers().stream())
.collect(Collectors.toSet());
return servers;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void shouldRunParameterizedWithResult() {
assertThat(result.size(), equalTo(3));
}

@SuppressWarnings({"QueryWithEmptyBody", "ConstantConditions"})
@SuppressWarnings({"QueryWithEmptyBody"})
@Test
void shouldRunSimpleQuery() {
// When I run a simple write query
Expand All @@ -166,7 +166,6 @@ void shouldFailForIllegalQueries() {
}

@Test
@SuppressWarnings("deprecation")
void shouldBeAbleToLogSemanticWrongExceptions() {
try {
// When I run a query with the old syntax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ void beforeAll() {
}

@Test
@SuppressWarnings("resource")
void shouldSetTransactionMetadata() {
Map<String, Object> metadata = new HashMap<>();
metadata.put("a", "hello world");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -1257,10 +1256,9 @@ private void testExecuteReadTx(AccessMode sessionMode) {
driver.session(builder().withDefaultAccessMode(sessionMode).build())) {
var names = session.readTransaction(tx -> {
var records = tx.run("MATCH (p:Person) RETURN p.name AS name").list();
Set<String> names1 = records.stream()
return records.stream()
.map(record -> record.get("name").asString())
.collect(Collectors.toCollection(() -> new HashSet<>(records.size())));
return names1;
});

assertThat(names, containsInAnyOrder("Tony Stark", "Steve Rogers"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.junit.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
import static org.neo4j.driver.Values.parameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ void beforeAll() {
}

@Test
@SuppressWarnings("resource")
void shouldSetTransactionMetadata() {
Map<String, Object> metadata = new HashMap<>();
metadata.put("key1", "value1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class UnsupportedBoltV3IT {
.build();

@Test
@SuppressWarnings("resource")
void shouldNotSupportAutoCommitQueriesWithTransactionConfig() {
assertTxConfigNotSupported(() -> driver.session().run("RETURN 42", txConfig));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static java.util.Collections.singletonList;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ private Record createRecord() {
new RelationshipValue(rel),
Values.value(0.1F)
};
Record record = new InternalRecord(keys, values);
return record;
return new InternalRecord(keys, values);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.Arrays;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.Test;
import org.neo4j.driver.internal.util.Iterables;
import org.neo4j.driver.types.Node;
Expand Down Expand Up @@ -70,7 +69,7 @@ void shouldBeAbleToIterateOverPathAsSegments() {
var segments = Iterables.asList(path);

// Then
MatcherAssert.assertThat(
assertThat(
segments,
equalTo(Arrays.asList(
(Path.Segment) new InternalPath.SelfContainedSegment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,9 @@ private Result createResult(int numberOfRecords) {
}

private List<Value> values(Record record) {
List<Value> result = record.fields().stream()
return record.fields().stream()
.map(Pair::value)
.collect(Collectors.toCollection(
() -> new ArrayList<>(record.keys().size())));
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
package org.neo4j.driver.internal;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import static java.util.concurrent.CompletableFuture.completedFuture;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.junit.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
Expand Down Expand Up @@ -60,7 +60,6 @@
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;
import org.hamcrest.junit.MatcherAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -318,7 +317,7 @@ private void testTxIsRetriedUntilFailureWhenFunctionThrows(AccessMode mode) {

var e = assertThrows(Exception.class, () -> executeTransaction(asyncSession, mode, work));

MatcherAssert.assertThat(e, instanceOf(SessionExpiredException.class));
assertThat(e, instanceOf(SessionExpiredException.class));
assertEquals("Oh!", e.getMessage());
verifyInvocationCount(work, failures);
verifyCommitTx(connection, never());
Expand All @@ -338,7 +337,7 @@ private void testTxIsRetriedUntilFailureWhenCommitFails(AccessMode mode) {

var e = assertThrows(Exception.class, () -> executeTransaction(asyncSession, mode, work));

MatcherAssert.assertThat(e, instanceOf(ServiceUnavailableException.class));
assertThat(e, instanceOf(ServiceUnavailableException.class));
verifyInvocationCount(work, failures);
verifyCommitTx(connection, times(failures));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ void releasesOpenConnectionUsedForRunWhenSessionIsClosed() {
inOrder.verify(connection, atLeastOnce()).release();
}

@SuppressWarnings("deprecation")
@Test
void resetDoesNothingWhenNoTransactionAndNoConnection() {
await(session.resetAsync());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static java.util.concurrent.CompletableFuture.completedFuture;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.neo4j.driver.internal.cursor;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
package org.neo4j.driver.internal.cursor;

import static java.util.Arrays.asList;
import static junit.framework.TestCase.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.neo4j.driver.internal.handlers.pulln;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.neo4j.driver.internal.handlers.pulln;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
Expand Down
Loading

0 comments on commit ed8bbf6

Please sign in to comment.