diff --git a/testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/NewSession.java b/testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/NewSession.java index 968ec77cd9..654f40df79 100644 --- a/testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/NewSession.java +++ b/testkit-backend/src/main/java/neo4j/org/testkit/backend/messages/requests/NewSession.java @@ -85,9 +85,12 @@ protected TestkitResponse createSessionStateAndResponse( TestkitState testkitState, BiFunction sessionStateProducer, Function addSessionHolder) { - DriverHolder driverHolder = testkitState.getDriverHolder(data.getDriverId()); - AccessMode formattedAccessMode = data.getAccessMode().equals("r") ? AccessMode.READ : AccessMode.WRITE; - SessionConfig.Builder builder = SessionConfig.builder().withDefaultAccessMode(formattedAccessMode); + var driverHolder = testkitState.getDriverHolder(data.getDriverId()); + + var builder = SessionConfig.builder(); + Optional.ofNullable(data.getAccessMode()) + .map(mode -> mode.equals("r") ? AccessMode.READ : AccessMode.WRITE) + .ifPresent(builder::withDefaultAccessMode); Optional.ofNullable(data.bookmarks) .map(bookmarks ->