DATAGRAPH-1354 - Use same check style import conventions as Spring Boot.
This avoids mostly star and static imports. It allows the CypherDSL elements to be imported statically.
This commit is contained in:
3
.mvn/wrapper/MavenWrapperDownloader.java
vendored
3
.mvn/wrapper/MavenWrapperDownloader.java
vendored
@@ -17,9 +17,6 @@ specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenWrapperDownloader {
|
||||
|
||||
@@ -56,6 +56,11 @@
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck" />
|
||||
|
||||
<!-- Imports -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck" />
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStaticImportCheck">
|
||||
<property name="excludes"
|
||||
value="org.neo4j.cypherdsl.core.Cypher.*, org.neo4j.cypherdsl.core.Functions.*, org.neo4j.cypherdsl.core.Conditions.*, org.neo4j.cypherdsl.core.Predicates.*, org.apiguardian.api.API.Status.*, org.assertj.core.api.Assertions.*, org.assertj.core.api.Assumptions.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.mockito.Mockito.*, org.mockito.ArgumentMatchers.*" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
||||
<property name="regexp" value="true" />
|
||||
<property name="illegalPkgs"
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.springframework.data.neo4j.core.Neo4jClient.*;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
@@ -30,6 +27,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.neo4j.driver.Driver;
|
||||
import org.neo4j.driver.QueryRunner;
|
||||
@@ -203,7 +201,7 @@ class DefaultNeo4jClient implements Neo4jClient {
|
||||
@Override
|
||||
public RunnableSpecTightToDatabase in(@SuppressWarnings("HiddenField") String targetDatabase) {
|
||||
|
||||
this.targetDatabase = verifyDatabaseName(targetDatabase);
|
||||
this.targetDatabase = Neo4jClient.verifyDatabaseName(targetDatabase);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -317,7 +315,7 @@ class DefaultNeo4jClient implements Neo4jClient {
|
||||
|
||||
try (AutoCloseableQueryRunner statementRunner = getQueryRunner(this.targetDatabase)) {
|
||||
Result result = runnableStatement.runWith(statementRunner);
|
||||
return result.stream().map(partialMappingFunction(typeSystem)).collect(toList());
|
||||
return result.stream().map(partialMappingFunction(typeSystem)).collect(Collectors.toList());
|
||||
} catch (RuntimeException e) {
|
||||
throw potentiallyConvertRuntimeException(e, persistenceExceptionTranslator);
|
||||
}
|
||||
@@ -350,7 +348,7 @@ class DefaultNeo4jClient implements Neo4jClient {
|
||||
@Override
|
||||
public RunnableDelegation in(@Nullable @SuppressWarnings("HiddenField") String targetDatabase) {
|
||||
|
||||
this.targetDatabase = verifyDatabaseName(targetDatabase);
|
||||
this.targetDatabase = Neo4jClient.verifyDatabaseName(targetDatabase);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apiguardian.api.API;
|
||||
import org.neo4j.cypherdsl.core.Cypher;
|
||||
@@ -78,7 +77,7 @@ final class NamedParameters {
|
||||
@Override
|
||||
public String toString() {
|
||||
return parameters.entrySet().stream().map(e -> String.format("%s: %s", e.getKey(), formatValue(e.getValue())))
|
||||
.collect(joining(", ", ":params {", "}"));
|
||||
.collect(Collectors.joining(", ", ":params {", "}"));
|
||||
}
|
||||
|
||||
private static Object formatValue(Object value) {
|
||||
@@ -88,9 +87,11 @@ final class NamedParameters {
|
||||
return Cypher.quote((String) value);
|
||||
} else if (value instanceof Map) {
|
||||
return ((Map<?, ?>) value).entrySet().stream()
|
||||
.map(e -> String.format("%s: %s", e.getKey(), formatValue(e.getValue()))).collect(joining(", ", "{", "}"));
|
||||
.map(e -> String.format("%s: %s", e.getKey(), formatValue(e.getValue()))).collect(
|
||||
Collectors.joining(", ", "{", "}"));
|
||||
} else if (value instanceof Collection) {
|
||||
return ((Collection) value).stream().map(NamedParameters::formatValue).collect(joining(", ", "[", "]"));
|
||||
return ((Collection) value).stream().map(NamedParameters::formatValue).collect(
|
||||
Collectors.joining(", ", "[", "]"));
|
||||
}
|
||||
|
||||
return value.toString();
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.asterisk;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.parameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -26,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apiguardian.api.API;
|
||||
@@ -116,7 +116,7 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware {
|
||||
|
||||
@Override
|
||||
public long count(Statement statement) {
|
||||
return count(statement, emptyMap());
|
||||
return count(statement, Collections.emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,7 +126,7 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware {
|
||||
|
||||
@Override
|
||||
public long count(String cypherQuery) {
|
||||
return count(cypherQuery, emptyMap());
|
||||
return count(cypherQuery, Collections.emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,7 +182,8 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware {
|
||||
Statement statement = cypherGenerator
|
||||
.prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().isEqualTo(parameter(Constants.NAME_OF_ID)))
|
||||
.returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)).build();
|
||||
return createExecutableQuery(domainType, statement, singletonMap(Constants.NAME_OF_ID, convertIdValues(id)))
|
||||
return createExecutableQuery(domainType, statement, Collections
|
||||
.singletonMap(Constants.NAME_OF_ID, convertIdValues(id)))
|
||||
.getSingleResult();
|
||||
}
|
||||
|
||||
@@ -193,7 +194,8 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware {
|
||||
.prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().in((parameter(Constants.NAME_OF_IDS))))
|
||||
.returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)).build();
|
||||
|
||||
return createExecutableQuery(domainType, statement, singletonMap(Constants.NAME_OF_IDS, convertIdValues(ids)))
|
||||
return createExecutableQuery(domainType, statement, Collections
|
||||
.singletonMap(Constants.NAME_OF_IDS, convertIdValues(ids)))
|
||||
.getResults();
|
||||
}
|
||||
|
||||
@@ -282,14 +284,14 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware {
|
||||
if (entityMetaData.isUsingInternalIds() || entityMetaData.hasVersionProperty()) {
|
||||
log.debug("Saving entities using single statements.");
|
||||
|
||||
return entities.stream().map(e -> saveImpl(e, databaseName)).collect(toList());
|
||||
return entities.stream().map(e -> saveImpl(e, databaseName)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<T> entitiesToBeSaved = entities.stream().map(eventSupport::maybeCallBeforeBind).collect(toList());
|
||||
List<T> entitiesToBeSaved = entities.stream().map(eventSupport::maybeCallBeforeBind).collect(Collectors.toList());
|
||||
|
||||
// Save roots
|
||||
Function<T, Map<String, Object>> binderFunction = neo4jMappingContext.getRequiredBinderFunctionFor(domainClass);
|
||||
List<Map<String, Object>> entityList = entitiesToBeSaved.stream().map(binderFunction).collect(toList());
|
||||
List<Map<String, Object>> entityList = entitiesToBeSaved.stream().map(binderFunction).collect(Collectors.toList());
|
||||
ResultSummary resultSummary = neo4jClient
|
||||
.query(() -> renderer.render(cypherGenerator.prepareSaveOfMultipleInstancesOf(entityMetaData))).in(databaseName)
|
||||
.bind(entityList).to(Constants.NAME_OF_ENTITY_LIST_PARAM).run();
|
||||
@@ -509,7 +511,7 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware {
|
||||
}
|
||||
|
||||
public List<T> getResults() {
|
||||
return fetchSpec.all().stream().collect(toList());
|
||||
return fetchSpec.all().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Optional<T> getSingleResult() {
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.asterisk;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.parameter;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -30,6 +29,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apiguardian.api.API;
|
||||
@@ -114,7 +114,7 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea
|
||||
|
||||
@Override
|
||||
public Mono<Long> count(Statement statement) {
|
||||
return count(statement, emptyMap());
|
||||
return count(statement, Collections.emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +124,7 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea
|
||||
|
||||
@Override
|
||||
public Mono<Long> count(String cypherQuery) {
|
||||
return count(cypherQuery, emptyMap());
|
||||
return count(cypherQuery, Collections.emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,7 +184,8 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea
|
||||
.prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().isEqualTo(parameter(Constants.NAME_OF_ID)))
|
||||
.returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)).build();
|
||||
|
||||
return createExecutableQuery(domainType, statement, singletonMap(Constants.NAME_OF_ID, convertIdValues(id)))
|
||||
return createExecutableQuery(domainType, statement, Collections
|
||||
.singletonMap(Constants.NAME_OF_ID, convertIdValues(id)))
|
||||
.flatMap(ExecutableQuery::getSingleResult);
|
||||
}
|
||||
|
||||
@@ -196,7 +197,8 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea
|
||||
.prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().in((parameter(Constants.NAME_OF_IDS))))
|
||||
.returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)).build();
|
||||
|
||||
return createExecutableQuery(domainType, statement, singletonMap(Constants.NAME_OF_IDS, convertIdValues(ids)))
|
||||
return createExecutableQuery(domainType, statement, Collections
|
||||
.singletonMap(Constants.NAME_OF_IDS, convertIdValues(ids)))
|
||||
.flatMapMany(ExecutableQuery::getResults);
|
||||
}
|
||||
|
||||
@@ -306,7 +308,7 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea
|
||||
// flux
|
||||
// completes
|
||||
List<Map<String, Object>> boundedEntityList = entitiesToBeSaved.stream().map(binderFunction)
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return neo4jClient
|
||||
.query(() -> renderer.render(cypherGenerator.prepareSaveOfMultipleInstancesOf(entityMetaData)))
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.convert;
|
||||
|
||||
import static org.springframework.data.convert.ConverterBuilder.*;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
@@ -41,6 +39,7 @@ import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.ConditionalConverter;
|
||||
import org.springframework.core.convert.converter.ConverterRegistry;
|
||||
import org.springframework.core.convert.converter.GenericConverter;
|
||||
import org.springframework.data.convert.ConverterBuilder;
|
||||
import org.springframework.data.convert.ReadingConverter;
|
||||
import org.springframework.data.convert.WritingConverter;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -61,33 +60,33 @@ final class AdditionalTypes {
|
||||
static {
|
||||
|
||||
List<Object> hlp = new ArrayList<>();
|
||||
hlp.add(reading(Value.class, boolean[].class, AdditionalTypes::asBooleanArray).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, Byte.class, AdditionalTypes::asByte).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, byte.class, AdditionalTypes::asByte).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, Character.class, AdditionalTypes::asCharacter).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, char.class, AdditionalTypes::asCharacter).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, char[].class, AdditionalTypes::asCharArray).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, Date.class, AdditionalTypes::asDate).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, double[].class, AdditionalTypes::asDoubleArray).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, boolean[].class, AdditionalTypes::asBooleanArray).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Byte.class, AdditionalTypes::asByte).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, byte.class, AdditionalTypes::asByte).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Character.class, AdditionalTypes::asCharacter).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, char.class, AdditionalTypes::asCharacter).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, char[].class, AdditionalTypes::asCharArray).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Date.class, AdditionalTypes::asDate).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, double[].class, AdditionalTypes::asDoubleArray).andWriting(Values::value));
|
||||
hlp.add(new EnumConverter());
|
||||
hlp.add(reading(Value.class, Float.class, AdditionalTypes::asFloat).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, float.class, AdditionalTypes::asFloat).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, float[].class, AdditionalTypes::asFloatArray).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, Integer.class, Value::asInt).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, int.class, Value::asInt).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, int[].class, AdditionalTypes::asIntArray).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, Locale.class, AdditionalTypes::asLocale).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, long[].class, AdditionalTypes::asLongArray).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, Short.class, AdditionalTypes::asShort).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, short.class, AdditionalTypes::asShort).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, short[].class, AdditionalTypes::asShortArray).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, String[].class, AdditionalTypes::asStringArray).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, BigDecimal.class, AdditionalTypes::asBigDecimal).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, BigInteger.class, AdditionalTypes::asBigInteger).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, TemporalAmount.class, AdditionalTypes::asTemporalAmount)
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Float.class, AdditionalTypes::asFloat).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, float.class, AdditionalTypes::asFloat).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, float[].class, AdditionalTypes::asFloatArray).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Integer.class, Value::asInt).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, int.class, Value::asInt).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, int[].class, AdditionalTypes::asIntArray).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Locale.class, AdditionalTypes::asLocale).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, long[].class, AdditionalTypes::asLongArray).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Short.class, AdditionalTypes::asShort).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, short.class, AdditionalTypes::asShort).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, short[].class, AdditionalTypes::asShortArray).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, String[].class, AdditionalTypes::asStringArray).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, BigDecimal.class, AdditionalTypes::asBigDecimal).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, BigInteger.class, AdditionalTypes::asBigInteger).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, TemporalAmount.class, AdditionalTypes::asTemporalAmount)
|
||||
.andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, Instant.class, AdditionalTypes::asInstant).andWriting(AdditionalTypes::value));
|
||||
hlp.add(reading(Value.class, UUID.class, AdditionalTypes::asUUID).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Instant.class, AdditionalTypes::asInstant).andWriting(AdditionalTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, UUID.class, AdditionalTypes::asUUID).andWriting(AdditionalTypes::value));
|
||||
|
||||
CONVERTERS = Collections.unmodifiableList(hlp);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.convert;
|
||||
|
||||
import static org.springframework.data.convert.ConverterBuilder.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
@@ -30,6 +28,7 @@ import org.neo4j.driver.Value;
|
||||
import org.neo4j.driver.Values;
|
||||
import org.neo4j.driver.types.IsoDuration;
|
||||
import org.neo4j.driver.types.Point;
|
||||
import org.springframework.data.convert.ConverterBuilder;
|
||||
|
||||
/**
|
||||
* Conversions for all known Cypher types, directly supported by the driver. See
|
||||
@@ -44,24 +43,24 @@ final class CypherTypes {
|
||||
|
||||
static {
|
||||
|
||||
List<ConverterAware> hlp = new ArrayList<>();
|
||||
hlp.add(reading(Value.class, Void.class, v -> null).andWriting(v -> Values.NULL));
|
||||
hlp.add(reading(Value.class, void.class, v -> null).andWriting(v -> Values.NULL));
|
||||
hlp.add(reading(Value.class, Boolean.class, Value::asBoolean).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, boolean.class, Value::asBoolean).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, Long.class, Value::asLong).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, long.class, Value::asLong).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, Double.class, Value::asDouble).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, double.class, Value::asDouble).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, String.class, Value::asString).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, byte[].class, Value::asByteArray).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, LocalDate.class, Value::asLocalDate).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, OffsetTime.class, Value::asOffsetTime).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, LocalTime.class, Value::asLocalTime).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, ZonedDateTime.class, Value::asZonedDateTime).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, LocalDateTime.class, Value::asLocalDateTime).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, IsoDuration.class, Value::asIsoDuration).andWriting(Values::value));
|
||||
hlp.add(reading(Value.class, Point.class, Value::asPoint).andWriting(Values::value));
|
||||
List<ConverterBuilder.ConverterAware> hlp = new ArrayList<>();
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Void.class, v -> null).andWriting(v -> Values.NULL));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, void.class, v -> null).andWriting(v -> Values.NULL));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Boolean.class, Value::asBoolean).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, boolean.class, Value::asBoolean).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Long.class, Value::asLong).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, long.class, Value::asLong).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Double.class, Value::asDouble).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, double.class, Value::asDouble).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, String.class, Value::asString).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, byte[].class, Value::asByteArray).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, LocalDate.class, Value::asLocalDate).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, OffsetTime.class, Value::asOffsetTime).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, LocalTime.class, Value::asLocalTime).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, ZonedDateTime.class, Value::asZonedDateTime).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, LocalDateTime.class, Value::asLocalDateTime).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, IsoDuration.class, Value::asIsoDuration).andWriting(Values::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Point.class, Value::asPoint).andWriting(Values::value));
|
||||
|
||||
CONVERTERS = Collections.unmodifiableList(hlp);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.convert;
|
||||
|
||||
import static org.springframework.data.convert.ConverterBuilder.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -60,10 +58,10 @@ final class SpatialTypes {
|
||||
static {
|
||||
|
||||
List<ConverterBuilder.ConverterAware> hlp = new ArrayList<>();
|
||||
hlp.add(reading(Value.class, Point.class, SpatialTypes::asSpringDataPoint).andWriting(SpatialTypes::value));
|
||||
hlp.add(reading(Value.class, Point[].class, SpatialTypes::asPointArray).andWriting(SpatialTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Point.class, SpatialTypes::asSpringDataPoint).andWriting(SpatialTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Point[].class, SpatialTypes::asPointArray).andWriting(SpatialTypes::value));
|
||||
|
||||
hlp.add(reading(Value.class, Neo4jPoint.class, SpatialTypes::asNeo4jPoint).andWriting(SpatialTypes::value));
|
||||
hlp.add(ConverterBuilder.reading(Value.class, Neo4jPoint.class, SpatialTypes::asNeo4jPoint).andWriting(SpatialTypes::value));
|
||||
|
||||
CONVERTERS = Collections.unmodifiableList(hlp);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.mapping;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.springframework.core.CollectionFactory.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -32,6 +29,7 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -42,6 +40,7 @@ import org.neo4j.driver.types.MapAccessor;
|
||||
import org.neo4j.driver.types.Node;
|
||||
import org.neo4j.driver.types.Relationship;
|
||||
import org.neo4j.driver.types.TypeSystem;
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.ConfigurableConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
@@ -148,7 +147,8 @@ final class DefaultNeo4jConverter implements Neo4jConverter {
|
||||
Class<?> rawType = type.getType();
|
||||
|
||||
if (!valueIsLiteralNullOrNullValue && isCollection(type)) {
|
||||
Collection<Object> target = createCollection(rawType, type.getComponentType().getType(), value.size());
|
||||
Collection<Object> target = CollectionFactory
|
||||
.createCollection(rawType, type.getComponentType().getType(), value.size());
|
||||
value.values()
|
||||
.forEach(element -> target.add(conversionService.convert(element, type.getComponentType().getType())));
|
||||
return target;
|
||||
@@ -163,7 +163,7 @@ final class DefaultNeo4jConverter implements Neo4jConverter {
|
||||
|
||||
private Collection<String> createDynamicLabelsProperty(TypeInformation<?> type, Collection<String> dynamicLabels) {
|
||||
|
||||
Collection<String> target = createCollection(type.getType(), String.class, dynamicLabels.size());
|
||||
Collection<String> target = CollectionFactory.createCollection(type.getType(), String.class, dynamicLabels.size());
|
||||
target.addAll(dynamicLabels);
|
||||
return target;
|
||||
}
|
||||
@@ -391,7 +391,7 @@ final class DefaultNeo4jConverter implements Neo4jConverter {
|
||||
TypeInformation<?> actualType = persistentProperty.getTypeInformation().getRequiredActualType();
|
||||
mappedObjectHandler = (type, mappedObject) -> {
|
||||
List<Object> bucket = (List<Object>) dynamicValue.computeIfAbsent(keyTransformer.apply(type),
|
||||
s -> createCollection(actualType.getType(), persistentProperty.getAssociationTargetType(), values.size()));
|
||||
s -> CollectionFactory.createCollection(actualType.getType(), persistentProperty.getAssociationTargetType(), values.size()));
|
||||
bucket.add(mappedObject);
|
||||
};
|
||||
} else if (persistentProperty.isDynamicAssociation()) {
|
||||
@@ -419,11 +419,11 @@ final class DefaultNeo4jConverter implements Neo4jConverter {
|
||||
List<Relationship> allMatchingTypeRelationshipsInResult = StreamSupport
|
||||
.stream(values.values().spliterator(), false).filter(isList.and(containsOnlyRelationships))
|
||||
.flatMap(entry -> entry.asList(Value::asRelationship).stream()).filter(r -> r.type().equals(relationshipType))
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Node> allNodesWithMatchingLabelInResult = StreamSupport.stream(values.values().spliterator(), false)
|
||||
.filter(isList.and(containsOnlyNodes)).flatMap(entry -> entry.asList(Value::asNode).stream())
|
||||
.filter(n -> n.hasLabel(targetLabel)).collect(toList());
|
||||
.filter(n -> n.hasLabel(targetLabel)).collect(Collectors.toList());
|
||||
|
||||
if (allNodesWithMatchingLabelInResult.isEmpty() && allMatchingTypeRelationshipsInResult.isEmpty()) {
|
||||
return Optional.empty();
|
||||
|
||||
@@ -15,17 +15,33 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.mapping;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.springframework.util.StringUtils.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.data.mapping.Association;
|
||||
import org.springframework.data.mapping.PropertyHandler;
|
||||
import org.springframework.data.mapping.model.BasicPersistentEntity;
|
||||
import org.springframework.data.neo4j.core.schema.*;
|
||||
import org.springframework.data.neo4j.core.schema.DynamicLabels;
|
||||
import org.springframework.data.neo4j.core.schema.GeneratedValue;
|
||||
import org.springframework.data.neo4j.core.schema.GraphPropertyDescription;
|
||||
import org.springframework.data.neo4j.core.schema.IdDescription;
|
||||
import org.springframework.data.neo4j.core.schema.IdGenerator;
|
||||
import org.springframework.data.neo4j.core.schema.Node;
|
||||
import org.springframework.data.neo4j.core.schema.NodeDescription;
|
||||
import org.springframework.data.neo4j.core.schema.Property;
|
||||
import org.springframework.data.neo4j.core.schema.Relationship;
|
||||
import org.springframework.data.neo4j.core.schema.RelationshipDescription;
|
||||
import org.springframework.data.support.IsNewStrategy;
|
||||
import org.springframework.data.util.Lazy;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
@@ -231,7 +247,7 @@ class DefaultNeo4jPersistentEntity<T> extends BasicPersistentEntity<T, Neo4jPers
|
||||
Node nodeAnnotation = this.findAnnotation(Node.class);
|
||||
if (nodeAnnotation == null || hasEmptyLabelInformation(nodeAnnotation)) {
|
||||
return this.getType().getSimpleName();
|
||||
} else if (hasText(nodeAnnotation.primaryLabel())) {
|
||||
} else if (StringUtils.hasText(nodeAnnotation.primaryLabel())) {
|
||||
return nodeAnnotation.primaryLabel();
|
||||
} else {
|
||||
return nodeAnnotation.labels()[0];
|
||||
@@ -262,8 +278,8 @@ class DefaultNeo4jPersistentEntity<T> extends BasicPersistentEntity<T, Neo4jPers
|
||||
private List<String> computeOwnAdditionalLabels() {
|
||||
Node nodeAnnotation = this.findAnnotation(Node.class);
|
||||
if (nodeAnnotation == null || hasEmptyLabelInformation(nodeAnnotation)) {
|
||||
return emptyList();
|
||||
} else if (hasText(nodeAnnotation.primaryLabel())) {
|
||||
return Collections.emptyList();
|
||||
} else if (StringUtils.hasText(nodeAnnotation.primaryLabel())) {
|
||||
return Arrays.asList(nodeAnnotation.labels());
|
||||
} else {
|
||||
return Arrays.asList(Arrays.copyOfRange(nodeAnnotation.labels(), 1, nodeAnnotation.labels().length));
|
||||
@@ -283,7 +299,7 @@ class DefaultNeo4jPersistentEntity<T> extends BasicPersistentEntity<T, Neo4jPers
|
||||
}
|
||||
|
||||
private static boolean hasEmptyLabelInformation(Node nodeAnnotation) {
|
||||
return nodeAnnotation.labels().length < 1 && !hasText(nodeAnnotation.primaryLabel());
|
||||
return nodeAnnotation.labels().length < 1 && !StringUtils.hasText(nodeAnnotation.primaryLabel());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.schema;
|
||||
|
||||
import static org.apiguardian.api.API.Status.*;
|
||||
|
||||
import org.apiguardian.api.API;
|
||||
import org.apiguardian.api.API.Status;
|
||||
import org.neo4j.cypherdsl.core.Cypher;
|
||||
import org.neo4j.cypherdsl.core.SymbolicName;
|
||||
|
||||
@@ -28,7 +27,7 @@ import org.neo4j.cypherdsl.core.SymbolicName;
|
||||
* @soundtrack Milky Chance - Sadnecessary
|
||||
* @since 1.0
|
||||
*/
|
||||
@API(status = INTERNAL, since = "1.0")
|
||||
@API(status = Status.INTERNAL, since = "1.0")
|
||||
public final class Constants {
|
||||
|
||||
public static final SymbolicName NAME_OF_ROOT_NODE = Cypher.name("n");
|
||||
|
||||
@@ -15,8 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.schema;
|
||||
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.springframework.data.neo4j.core.schema.RelationshipDescription.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.anyNode;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.listBasedOn;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.literalOf;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.match;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.node;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.optionalMatch;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.parameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -26,10 +31,19 @@ import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import org.apiguardian.api.API;
|
||||
import org.neo4j.cypherdsl.core.*;
|
||||
import org.neo4j.cypherdsl.core.Condition;
|
||||
import org.neo4j.cypherdsl.core.Conditions;
|
||||
import org.neo4j.cypherdsl.core.Cypher;
|
||||
import org.neo4j.cypherdsl.core.Expression;
|
||||
import org.neo4j.cypherdsl.core.Functions;
|
||||
import org.neo4j.cypherdsl.core.MapProjection;
|
||||
import org.neo4j.cypherdsl.core.Node;
|
||||
import org.neo4j.cypherdsl.core.Parameter;
|
||||
import org.neo4j.cypherdsl.core.Relationship;
|
||||
import org.neo4j.cypherdsl.core.Statement;
|
||||
import org.neo4j.cypherdsl.core.StatementBuilder;
|
||||
import org.neo4j.cypherdsl.core.StatementBuilder.OngoingMatchAndUpdate;
|
||||
import org.neo4j.cypherdsl.core.SymbolicName;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity;
|
||||
@@ -426,7 +440,8 @@ public enum CypherGenerator {
|
||||
|
||||
addMapProjection(relationshipTargetName,
|
||||
listBasedOn(relationship).returning(projectAllPropertiesAndRelationships(endNodeDescription,
|
||||
relationshipFieldName, new ArrayList<>(processedRelationships)).and(NAME_OF_RELATIONSHIP_TYPE,
|
||||
relationshipFieldName, new ArrayList<>(processedRelationships)).and(
|
||||
RelationshipDescription.NAME_OF_RELATIONSHIP_TYPE,
|
||||
Functions.type(relationship))),
|
||||
mapProjectionLists);
|
||||
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.support;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -46,7 +45,8 @@ public final class Relationships {
|
||||
if (property.isDynamicAssociation()) {
|
||||
if (property.isDynamicOneToManyAssociation()) {
|
||||
unifiedValue = ((Map<String, Collection<?>>) rawValue).entrySet().stream()
|
||||
.flatMap(e -> e.getValue().stream().map(v -> new SimpleEntry(e.getKey(), v))).collect(toList());
|
||||
.flatMap(e -> e.getValue().stream().map(v -> new SimpleEntry(e.getKey(), v))).collect(
|
||||
Collectors.toList());
|
||||
} else {
|
||||
unifiedValue = ((Map<String, Object>) rawValue).entrySet();
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.transaction;
|
||||
|
||||
import static org.springframework.data.neo4j.core.transaction.Neo4jTransactionUtils.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.neo4j.driver.Bookmark;
|
||||
@@ -62,7 +60,7 @@ final class Neo4jTransactionHolder extends ResourceHolderSupport {
|
||||
*/
|
||||
@Nullable
|
||||
Transaction getTransaction(String inDatabase) {
|
||||
return namesMapToTheSameDatabase(this.context.getDatabaseName(), inDatabase) ? transaction : null;
|
||||
return Neo4jTransactionUtils.namesMapToTheSameDatabase(this.context.getDatabaseName(), inDatabase) ? transaction : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.transaction;
|
||||
|
||||
import static org.springframework.data.neo4j.core.transaction.Neo4jTransactionUtils.*;
|
||||
|
||||
import org.apiguardian.api.API;
|
||||
import org.neo4j.driver.Bookmark;
|
||||
import org.neo4j.driver.Driver;
|
||||
@@ -100,11 +98,12 @@ public class Neo4jTransactionManager extends AbstractPlatformTransactionManager
|
||||
}
|
||||
|
||||
throw new IllegalStateException(
|
||||
formatOngoingTxInAnotherDbErrorMessage(connectionHolder.getDatabaseName(), targetDatabase));
|
||||
Neo4jTransactionUtils
|
||||
.formatOngoingTxInAnotherDbErrorMessage(connectionHolder.getDatabaseName(), targetDatabase));
|
||||
}
|
||||
|
||||
// Otherwise we open a session and synchronize it.
|
||||
Session session = driver.session(defaultSessionConfig(targetDatabase));
|
||||
Session session = driver.session(Neo4jTransactionUtils.defaultSessionConfig(targetDatabase));
|
||||
Transaction transaction = session.beginTransaction(TransactionConfig.empty());
|
||||
// Manually create a new synchronization
|
||||
connectionHolder = new Neo4jTransactionHolder(new Neo4jTransactionContext(targetDatabase), session, transaction);
|
||||
@@ -149,7 +148,7 @@ public class Neo4jTransactionManager extends AbstractPlatformTransactionManager
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
|
||||
Neo4jTransactionObject transactionObject = extractNeo4jTransaction(transaction);
|
||||
|
||||
TransactionConfig transactionConfig = createTransactionConfigFrom(definition);
|
||||
TransactionConfig transactionConfig = Neo4jTransactionUtils.createTransactionConfigFrom(definition);
|
||||
boolean readOnly = definition.isReadOnly();
|
||||
|
||||
TransactionSynchronizationManager.setCurrentTransactionReadOnly(readOnly);
|
||||
@@ -160,7 +159,8 @@ public class Neo4jTransactionManager extends AbstractPlatformTransactionManager
|
||||
databaseSelectionProvider.getDatabaseSelection().getValue(), bookmarkManager.getBookmarks());
|
||||
|
||||
// Configure and open session together with a native transaction
|
||||
Session session = this.driver.session(sessionConfig(readOnly, context.getBookmarks(), context.getDatabaseName()));
|
||||
Session session = this.driver.session(
|
||||
Neo4jTransactionUtils.sessionConfig(readOnly, context.getBookmarks(), context.getDatabaseName()));
|
||||
Transaction nativeTransaction = session.beginTransaction(transactionConfig);
|
||||
|
||||
// Synchronize on that
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.config;
|
||||
|
||||
import static org.springframework.data.neo4j.repository.config.ReactiveNeo4jRepositoryConfigurationExtension.*;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
@@ -88,17 +86,17 @@ public @interface EnableReactiveNeo4jRepositories {
|
||||
/**
|
||||
* Configures the name of the {@link Neo4jMappingContext} bean to be used with the repositories detected.
|
||||
*/
|
||||
String neo4jMappingContextRef() default DEFAULT_MAPPING_CONTEXT_BEAN_NAME;
|
||||
String neo4jMappingContextRef() default ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_MAPPING_CONTEXT_BEAN_NAME;
|
||||
|
||||
/**
|
||||
* Configures the name of the {@link ReactiveNeo4jTemplate} bean to be used with the repositories detected.
|
||||
*/
|
||||
String neo4jTemplateRef() default DEFAULT_NEO4J_TEMPLATE_BEAN_NAME;
|
||||
String neo4jTemplateRef() default ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME;
|
||||
|
||||
/**
|
||||
* Configures the name of the {@link ReactiveNeo4jTransactionManager} bean to be used with the repositories detected.
|
||||
*/
|
||||
String transactionManagerRef() default DEFAULT_TRANSACTION_MANAGER_BEAN_NAME;
|
||||
String transactionManagerRef() default ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME;
|
||||
|
||||
/**
|
||||
* Specifies which types are eligible for component scanning. Further narrows the set of candidate components from
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.query;
|
||||
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.springframework.data.neo4j.core.schema.Constants.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.property;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -26,6 +25,7 @@ import org.neo4j.cypherdsl.core.SortItem;
|
||||
import org.neo4j.cypherdsl.core.StatementBuilder;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.neo4j.core.schema.Constants;
|
||||
import org.springframework.data.neo4j.core.schema.GraphPropertyDescription;
|
||||
import org.springframework.data.neo4j.core.schema.NodeDescription;
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class CypherAdapterUtils {
|
||||
String property = nodeDescription.getGraphProperty(order.getProperty())
|
||||
.map(GraphPropertyDescription::getPropertyName).orElseThrow(() -> new IllegalStateException(
|
||||
String.format("Cannot order by the unknown graph property: '%s'", order.getProperty())));
|
||||
SortItem sortItem = Cypher.sort(property(NAME_OF_ROOT_NODE, property));
|
||||
SortItem sortItem = Cypher.sort(property(Constants.NAME_OF_ROOT_NODE, property));
|
||||
|
||||
// Spring's Sort.Order defaults to ascending, so we just need to change this if we have descending order.
|
||||
if (order.isDescending()) {
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.query;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.neo4j.cypherdsl.core.Functions.*;
|
||||
import static org.springframework.data.neo4j.core.schema.Constants.*;
|
||||
import static org.neo4j.cypherdsl.core.Functions.point;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -29,9 +27,23 @@ import java.util.Queue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.neo4j.cypherdsl.core.*;
|
||||
import org.neo4j.cypherdsl.core.Condition;
|
||||
import org.neo4j.cypherdsl.core.Conditions;
|
||||
import org.neo4j.cypherdsl.core.Cypher;
|
||||
import org.neo4j.cypherdsl.core.ExposesRelationships;
|
||||
import org.neo4j.cypherdsl.core.ExposesReturning;
|
||||
import org.neo4j.cypherdsl.core.Expression;
|
||||
import org.neo4j.cypherdsl.core.Functions;
|
||||
import org.neo4j.cypherdsl.core.Node;
|
||||
import org.neo4j.cypherdsl.core.Predicates;
|
||||
import org.neo4j.cypherdsl.core.Property;
|
||||
import org.neo4j.cypherdsl.core.RelationshipPattern;
|
||||
import org.neo4j.cypherdsl.core.SortItem;
|
||||
import org.neo4j.cypherdsl.core.Statement;
|
||||
import org.neo4j.cypherdsl.core.StatementBuilder;
|
||||
import org.neo4j.cypherdsl.core.StatementBuilder.OngoingMatchAndReturnWithOrder;
|
||||
import org.neo4j.cypherdsl.core.renderer.Renderer;
|
||||
import org.neo4j.driver.types.Point;
|
||||
@@ -47,6 +59,7 @@ import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.PersistentPropertyPath;
|
||||
import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext;
|
||||
import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty;
|
||||
import org.springframework.data.neo4j.core.schema.Constants;
|
||||
import org.springframework.data.neo4j.core.schema.CypherGenerator;
|
||||
import org.springframework.data.neo4j.core.schema.NodeDescription;
|
||||
import org.springframework.data.neo4j.core.schema.RelationshipDescription;
|
||||
@@ -124,7 +137,7 @@ final class CypherQueryCreator extends AbstractQueryCreator<QueryAndParameters,
|
||||
propertyPathWrappers = tree.getParts().stream()
|
||||
.map(part -> new PropertyPathWrapper(symbolicNameIndex.getAndIncrement(),
|
||||
mappingContext.getPersistentPropertyPath(part.getProperty())))
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@@ -236,7 +249,7 @@ final class CypherQueryCreator extends AbstractQueryCreator<QueryAndParameters,
|
||||
Statement statement = createStatement(condition, sort);
|
||||
|
||||
Map<String, Object> convertedParameters = this.boundedParameters.stream()
|
||||
.collect(toMap(p -> p.nameOrIndex, p -> parameterConversion.apply(p.value)));
|
||||
.collect(Collectors.toMap(p -> p.nameOrIndex, p -> parameterConversion.apply(p.value)));
|
||||
|
||||
return new QueryAndParameters(Renderer.getDefaultRenderer().render(statement), convertedParameters);
|
||||
}
|
||||
@@ -247,7 +260,7 @@ final class CypherQueryCreator extends AbstractQueryCreator<QueryAndParameters,
|
||||
|
||||
// all the ways we could query for
|
||||
Node startNode = Cypher.node(nodeDescription.getPrimaryLabel(), nodeDescription.getAdditionalLabels())
|
||||
.named(NAME_OF_ROOT_NODE);
|
||||
.named(Constants.NAME_OF_ROOT_NODE);
|
||||
|
||||
ExposesReturning matchAndCondition = Cypher.match(startNode)
|
||||
.where(Optional.ofNullable(condition).orElseGet(Conditions::noCondition));
|
||||
@@ -505,7 +518,7 @@ final class CypherQueryCreator extends AbstractQueryCreator<QueryAndParameters,
|
||||
|
||||
private Property toCypherProperty(Neo4jPersistentProperty persistentProperty) {
|
||||
|
||||
return Cypher.property(NAME_OF_ROOT_NODE, persistentProperty.getPropertyName());
|
||||
return Cypher.property(Constants.NAME_OF_ROOT_NODE, persistentProperty.getPropertyName());
|
||||
}
|
||||
|
||||
private Expression toCypherProperty(Neo4jPersistentProperty persistentProperty, boolean addToLower) {
|
||||
@@ -514,7 +527,7 @@ final class CypherQueryCreator extends AbstractQueryCreator<QueryAndParameters,
|
||||
Expression expression;
|
||||
|
||||
if (owner.equals(this.nodeDescription)) {
|
||||
expression = Cypher.property(NAME_OF_ROOT_NODE, persistentProperty.getPropertyName());
|
||||
expression = Cypher.property(Constants.NAME_OF_ROOT_NODE, persistentProperty.getPropertyName());
|
||||
} else {
|
||||
PropertyPathWrapper propertyPathWrapper = propertyPathWrappers.stream()
|
||||
.filter(rp -> rp.getLeafProperty().equals(persistentProperty)).findFirst().get();
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.query;
|
||||
|
||||
import static java.lang.String.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -121,9 +119,9 @@ class Neo4jQueryMethod extends QueryMethod {
|
||||
public String getPlaceholder() {
|
||||
|
||||
if (isNamedParameter()) {
|
||||
return format(NAMED_PARAMETER_TEMPLATE, getName().get());
|
||||
return String.format(NAMED_PARAMETER_TEMPLATE, getName().get());
|
||||
} else {
|
||||
return format(POSITION_PARAMETER_TEMPLATE, getIndex());
|
||||
return String.format(POSITION_PARAMETER_TEMPLATE, getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.query;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -28,6 +26,7 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.neo4j.driver.types.Point;
|
||||
import org.springframework.data.repository.query.parser.Part;
|
||||
@@ -112,7 +111,7 @@ class PartValidator {
|
||||
}
|
||||
|
||||
private static String formatTypes(Collection<Part.Type> types) {
|
||||
return types.stream().flatMap(t -> t.getKeywords().stream()).collect(joining(", ", "[", "]"));
|
||||
return types.stream().flatMap(t -> t.getKeywords().stream()).collect(Collectors.joining(", ", "[", "]"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.query;
|
||||
|
||||
import static org.springframework.data.repository.util.ClassUtils.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
@@ -54,7 +52,7 @@ final class ReactiveNeo4jQueryMethod extends Neo4jQueryMethod {
|
||||
ReactiveNeo4jQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
|
||||
super(method, metadata, factory);
|
||||
|
||||
if (hasParameterOfType(method, Pageable.class)) {
|
||||
if (org.springframework.data.repository.util.ClassUtils.hasParameterOfType(method, Pageable.class)) {
|
||||
|
||||
TypeInformation<?> returnType = ClassTypeInformation.fromReturnTypeOf(method);
|
||||
|
||||
|
||||
@@ -23,7 +23,18 @@ import java.util.function.BiFunction;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apiguardian.api.API;
|
||||
import org.neo4j.driver.exceptions.*;
|
||||
import org.neo4j.driver.exceptions.AuthenticationException;
|
||||
import org.neo4j.driver.exceptions.ClientException;
|
||||
import org.neo4j.driver.exceptions.DatabaseException;
|
||||
import org.neo4j.driver.exceptions.DiscoveryException;
|
||||
import org.neo4j.driver.exceptions.FatalDiscoveryException;
|
||||
import org.neo4j.driver.exceptions.Neo4jException;
|
||||
import org.neo4j.driver.exceptions.ProtocolException;
|
||||
import org.neo4j.driver.exceptions.ResultConsumedException;
|
||||
import org.neo4j.driver.exceptions.ServiceUnavailableException;
|
||||
import org.neo4j.driver.exceptions.SessionExpiredException;
|
||||
import org.neo4j.driver.exceptions.TransactionNestingException;
|
||||
import org.neo4j.driver.exceptions.TransientException;
|
||||
import org.neo4j.driver.exceptions.value.ValueException;
|
||||
import org.springframework.core.log.LogAccessor;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.support;
|
||||
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.springframework.data.neo4j.core.schema.Constants.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.literalOf;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.parameter;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.property;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.data.neo4j.core.convert.Neo4jConverter;
|
||||
import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext;
|
||||
import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity;
|
||||
import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty;
|
||||
import org.springframework.data.neo4j.core.schema.Constants;
|
||||
import org.springframework.data.neo4j.core.schema.GraphPropertyDescription;
|
||||
import org.springframework.data.neo4j.core.schema.NodeDescription;
|
||||
import org.springframework.data.support.ExampleMatcherAccessor;
|
||||
@@ -85,7 +87,7 @@ final class Predicate {
|
||||
|
||||
if (!optionalValue.isPresent()) {
|
||||
if (!internalId && matcherAccessor.getNullHandler().equals(ExampleMatcher.NullHandler.INCLUDE)) {
|
||||
predicate.add(mode, property(NAME_OF_ROOT_NODE, propertyName).isNull());
|
||||
predicate.add(mode, property(Constants.NAME_OF_ROOT_NODE, propertyName).isNull());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -98,7 +100,7 @@ final class Predicate {
|
||||
predicate.add(mode,
|
||||
predicate.neo4jPersistentEntity.getIdExpression().isEqualTo(literalOf(optionalValue.get())));
|
||||
} else {
|
||||
Expression property = property(NAME_OF_ROOT_NODE, propertyName);
|
||||
Expression property = property(Constants.NAME_OF_ROOT_NODE, propertyName);
|
||||
Expression parameter = parameter(propertyName);
|
||||
Condition condition = property.isEqualTo(parameter);
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.support;
|
||||
|
||||
import static org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactorySupport.*;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
@@ -66,7 +64,7 @@ final class ReactiveNeo4jRepositoryFactory extends ReactiveRepositoryFactorySupp
|
||||
protected Object getTargetRepository(RepositoryInformation metadata) {
|
||||
|
||||
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||
assertIdentifierType(metadata.getIdType(), entityInformation.getIdType());
|
||||
Neo4jRepositoryFactorySupport.assertIdentifierType(metadata.getIdType(), entityInformation.getIdType());
|
||||
return getTargetRepositoryViaReflection(metadata, neo4jOperations, entityInformation);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.support;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.LongSupplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.apiguardian.api.API;
|
||||
@@ -165,7 +164,7 @@ public class SimpleNeo4jRepository<T, ID> implements PagingAndSortingRepository<
|
||||
public void deleteAll(Iterable<? extends T> entities) {
|
||||
|
||||
List<Object> ids = StreamSupport.stream(entities.spliterator(), false).map(this.entityInformation::getId)
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
|
||||
this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.support;
|
||||
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.asterisk;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.support;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.apiguardian.api.API;
|
||||
@@ -197,7 +196,7 @@ public class SimpleReactiveNeo4jRepository<T, ID> implements ReactiveSortingRepo
|
||||
|
||||
Assert.notNull(entities, "The given Iterable of entities must not be null!");
|
||||
List<ID> ids = StreamSupport.stream(entities.spliterator(), false).map(this.entityInformation::getId)
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
return this.neo4jOperations.deleteAllById(ids, this.entityInformation.getJavaType());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.support;
|
||||
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.springframework.data.neo4j.repository.query.CypherAdapterUtils.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.asterisk;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -28,6 +27,7 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.neo4j.core.ReactiveNeo4jOperations;
|
||||
import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext;
|
||||
import org.springframework.data.neo4j.core.schema.CypherGenerator;
|
||||
import org.springframework.data.neo4j.repository.query.CypherAdapterUtils;
|
||||
import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor;
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ class SimpleReactiveQueryByExampleExecutor<T> implements ReactiveQueryByExampleE
|
||||
|
||||
Predicate predicate = Predicate.create(mappingContext, example);
|
||||
Statement statement = predicate.useWithReadingFragment(cypherGenerator::prepareMatchOf).returning(asterisk())
|
||||
.orderBy(toSortItems(predicate.getNeo4jPersistentEntity(), sort)).build();
|
||||
.orderBy(CypherAdapterUtils.toSortItems(predicate.getNeo4jPersistentEntity(), sort)).build();
|
||||
|
||||
return this.neo4jOperations.findAll(statement, predicate.getParameters(), example.getProbeType());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.neo4j.driver.Record;
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@@ -116,7 +117,7 @@ class NamedParametersTest {
|
||||
|
||||
Map<String, Object> outer = new TreeMap<>();
|
||||
outer.put("oma", "Something");
|
||||
outer.put("omb", singletonMap("ims", "Something else"));
|
||||
outer.put("omb", Collections.singletonMap("ims", "Something else"));
|
||||
|
||||
NamedParameters p = new NamedParameters();
|
||||
p.add("aKey", outer);
|
||||
@@ -129,8 +130,8 @@ class NamedParametersTest {
|
||||
|
||||
Map<String, Object> outer = new TreeMap<>();
|
||||
outer.put("oma", "Something");
|
||||
outer.put("omb", singletonMap("ims", singletonMap("imi", "Embedded Thing")));
|
||||
outer.put("omc", singletonMap("ims", "Something else"));
|
||||
outer.put("omb", Collections.singletonMap("ims", Collections.singletonMap("imi", "Embedded Thing")));
|
||||
outer.put("omc", Collections.singletonMap("ims", "Something else"));
|
||||
|
||||
NamedParameters p = new NamedParameters();
|
||||
p.add("aKey", outer);
|
||||
@@ -145,7 +146,8 @@ class NamedParametersTest {
|
||||
NamedParameters p = new NamedParameters();
|
||||
p.add("a", Arrays.asList("Something", "Else"));
|
||||
p.add("l", Arrays.asList(1L, 2L, 3L));
|
||||
p.add("m", Arrays.asList(singletonMap("a", "av"), singletonMap("b", Arrays.asList("A", "b"))));
|
||||
p.add("m", Arrays.asList(
|
||||
Collections.singletonMap("a", "av"), Collections.singletonMap("b", Arrays.asList("A", "b"))));
|
||||
|
||||
assertThat(p.toString())
|
||||
.isEqualTo(":params {a: ['Something', 'Else'], l: [1, 2, 3], m: [{a: 'av'}, {b: ['A', 'b']}]}");
|
||||
|
||||
@@ -15,9 +15,16 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyMap;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
@@ -40,6 +47,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.hamcrest.MockitoHamcrest;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.neo4j.driver.Driver;
|
||||
import org.neo4j.driver.Record;
|
||||
@@ -116,7 +124,7 @@ class Neo4jClientTest {
|
||||
expectedParameters.putAll(parameters);
|
||||
expectedParameters.put("name", "michael");
|
||||
expectedParameters.put("aDate", LocalDate.of(2019, 1, 1));
|
||||
verify(session).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(session).run(eq(cypher), MockitoHamcrest.argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
|
||||
verify(result).stream();
|
||||
verify(record1).asMap();
|
||||
@@ -146,7 +154,7 @@ class Neo4jClientTest {
|
||||
Map<String, Object> expectedParameters = new HashMap<>();
|
||||
expectedParameters.put("name", "Someone.*");
|
||||
|
||||
verify(session).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(session).run(eq(cypher), MockitoHamcrest.argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(result).stream();
|
||||
verify(record1).asMap();
|
||||
verify(session).close();
|
||||
@@ -236,7 +244,7 @@ class Neo4jClientTest {
|
||||
Map<String, Object> expectedParameters = new HashMap<>();
|
||||
expectedParameters.put("name", "michael");
|
||||
|
||||
verify(session).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(session).run(eq(cypher), MockitoHamcrest.argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(result).stream();
|
||||
verify(record1).get("name");
|
||||
verify(session).close();
|
||||
@@ -264,7 +272,7 @@ class Neo4jClientTest {
|
||||
|
||||
verifyDatabaseSelection(null);
|
||||
|
||||
verify(session).run(eq("MATCH (n) RETURN n"), argThat(new MapAssertionMatcher(Collections.emptyMap())));
|
||||
verify(session).run(eq("MATCH (n) RETURN n"), MockitoHamcrest.argThat(new MapAssertionMatcher(Collections.emptyMap())));
|
||||
verify(result).stream();
|
||||
verify(record1).get("name");
|
||||
verify(session).close();
|
||||
@@ -290,7 +298,7 @@ class Neo4jClientTest {
|
||||
Map<String, Object> expectedParameters = new HashMap<>();
|
||||
expectedParameters.put("name", "Michael");
|
||||
|
||||
verify(session).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(session).run(eq(cypher), MockitoHamcrest.argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(result).consume();
|
||||
verify(session).close();
|
||||
}
|
||||
@@ -343,7 +351,7 @@ class Neo4jClientTest {
|
||||
Map<String, Object> expectedParameters = new HashMap<>();
|
||||
expectedParameters.put("name", "fixie");
|
||||
|
||||
verify(session).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(session).run(eq(cypher), MockitoHamcrest.argThat(new MapAssertionMatcher(expectedParameters)));
|
||||
verify(result).consume();
|
||||
verify(session).close();
|
||||
}
|
||||
|
||||
@@ -15,10 +15,15 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.hamcrest.MockitoHamcrest.argThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyMap;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -37,6 +42,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.hamcrest.MockitoHamcrest;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.neo4j.driver.Driver;
|
||||
import org.neo4j.driver.Record;
|
||||
@@ -117,7 +123,7 @@ class ReactiveNeo4jClientTest {
|
||||
expectedParameters.putAll(parameters);
|
||||
expectedParameters.put("name", "michael");
|
||||
expectedParameters.put("aDate", LocalDate.of(2019, 1, 1));
|
||||
verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(transaction).run(eq(cypher), MockitoHamcrest.argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
|
||||
verify(result).records();
|
||||
verify(record1).asMap();
|
||||
@@ -149,7 +155,7 @@ class ReactiveNeo4jClientTest {
|
||||
Map<String, Object> expectedParameters = new HashMap<>();
|
||||
expectedParameters.put("name", "Someone.*");
|
||||
|
||||
verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(transaction).run(eq(cypher), MockitoHamcrest.argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(result).records();
|
||||
verify(record1).asMap();
|
||||
verify(transaction).commit();
|
||||
@@ -250,7 +256,7 @@ class ReactiveNeo4jClientTest {
|
||||
Map<String, Object> expectedParameters = new HashMap<>();
|
||||
expectedParameters.put("name", "michael");
|
||||
|
||||
verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(transaction).run(eq(cypher), MockitoHamcrest.argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(result).records();
|
||||
verify(record1).get("name");
|
||||
verify(transaction).commit();
|
||||
@@ -283,7 +289,7 @@ class ReactiveNeo4jClientTest {
|
||||
verifyDatabaseSelection(null);
|
||||
|
||||
verify(transaction).run(eq("MATCH (n) RETURN n"),
|
||||
argThat(new Neo4jClientTest.MapAssertionMatcher(Collections.emptyMap())));
|
||||
MockitoHamcrest.argThat(new Neo4jClientTest.MapAssertionMatcher(Collections.emptyMap())));
|
||||
verify(result).records();
|
||||
verify(record1).get("name");
|
||||
verify(transaction).commit();
|
||||
@@ -318,7 +324,7 @@ class ReactiveNeo4jClientTest {
|
||||
Map<String, Object> expectedParameters = new HashMap<>();
|
||||
expectedParameters.put("name", "Michael");
|
||||
|
||||
verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(transaction).run(eq(cypher), MockitoHamcrest.argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(result).consume();
|
||||
verify(transaction).commit();
|
||||
verify(transaction).rollback();
|
||||
@@ -377,7 +383,7 @@ class ReactiveNeo4jClientTest {
|
||||
Map<String, Object> expectedParameters = new HashMap<>();
|
||||
expectedParameters.put("name", "fixie");
|
||||
|
||||
verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(transaction).run(eq(cypher), MockitoHamcrest.argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters)));
|
||||
verify(result).consume();
|
||||
verify(transaction).commit();
|
||||
verify(transaction).rollback();
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
|
||||
@@ -15,9 +15,15 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.convert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.neo4j.driver.types.Point;
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.convert;
|
||||
|
||||
import static java.time.temporal.ChronoUnit.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.neo4j.driver.Values;
|
||||
@@ -45,7 +45,7 @@ class TemporalAmountAdapterTest {
|
||||
public void durationsShouldStayDurations() {
|
||||
final TemporalAmountAdapter adapter = new TemporalAmountAdapter();
|
||||
|
||||
Duration duration = MONTHS.getDuration().multipliedBy(13).plus(DAYS.getDuration().multipliedBy(32)).plusHours(25)
|
||||
Duration duration = ChronoUnit.MONTHS.getDuration().multipliedBy(13).plus(ChronoUnit.DAYS.getDuration().multipliedBy(32)).plusHours(25)
|
||||
.plusMinutes(120);
|
||||
|
||||
assertThat(adapter.apply(Values.value(duration).asIsoDuration())).isEqualTo(duration);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.mapping;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -163,7 +165,7 @@ class Neo4jMappingContextTest {
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
// in the real world this should also define the opposite way
|
||||
return singleton(new ConvertiblePair(ConvertibleType.class, StringValue.class));
|
||||
return Collections.singleton(new ConvertiblePair(ConvertibleType.class, StringValue.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,7 +176,7 @@ class Neo4jMappingContextTest {
|
||||
}
|
||||
|
||||
Neo4jMappingContext schema = new Neo4jMappingContext(
|
||||
new Neo4jConversions(singleton(new ConvertibleTypeConverter())));
|
||||
new Neo4jConversions(Collections.singleton(new ConvertibleTypeConverter())));
|
||||
Neo4jPersistentEntity<?> entity = schema.getPersistentEntity(EntityWithConvertibleProperty.class);
|
||||
|
||||
Assertions.assertThat(entity.getPersistentProperty("convertibleType").isRelationship()).isFalse();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.schema;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.schema;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.transaction;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -34,7 +35,7 @@ class Neo4jBookmarkManagerTest {
|
||||
|
||||
@Test
|
||||
void updatesPreviouslyEmptyBookmarks() {
|
||||
BookmarkForTesting bookmark = new BookmarkForTesting(singleton("a"));
|
||||
BookmarkForTesting bookmark = new BookmarkForTesting(Collections.singleton("a"));
|
||||
bookmarkManager.updateBookmarks(new HashSet<>(), bookmark);
|
||||
|
||||
assertThat(bookmarkManager.getBookmarks()).containsExactly(bookmark);
|
||||
@@ -42,7 +43,7 @@ class Neo4jBookmarkManagerTest {
|
||||
|
||||
@Test
|
||||
void returnsUnmodifiableCopyOfBookmarks() {
|
||||
BookmarkForTesting bookmark = new BookmarkForTesting(singleton("a"));
|
||||
BookmarkForTesting bookmark = new BookmarkForTesting(Collections.singleton("a"));
|
||||
bookmarkManager.updateBookmarks(new HashSet<>(), bookmark);
|
||||
|
||||
Collection<Bookmark> bookmarks = bookmarkManager.getBookmarks();
|
||||
@@ -51,20 +52,20 @@ class Neo4jBookmarkManagerTest {
|
||||
|
||||
@Test
|
||||
void updatesPreviouslySetBookmarks() {
|
||||
BookmarkForTesting oldBookmark = new BookmarkForTesting(singleton("a"));
|
||||
BookmarkForTesting oldBookmark = new BookmarkForTesting(Collections.singleton("a"));
|
||||
bookmarkManager.updateBookmarks(new HashSet<>(), oldBookmark);
|
||||
|
||||
BookmarkForTesting newBookmark = new BookmarkForTesting(singleton("b"));
|
||||
bookmarkManager.updateBookmarks(singleton(oldBookmark), newBookmark);
|
||||
BookmarkForTesting newBookmark = new BookmarkForTesting(Collections.singleton("b"));
|
||||
bookmarkManager.updateBookmarks(Collections.singleton(oldBookmark), newBookmark);
|
||||
|
||||
assertThat(bookmarkManager.getBookmarks()).containsExactly(newBookmark);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updatesPreviouslyUnknownBookmarks() {
|
||||
BookmarkForTesting oldBookmark = new BookmarkForTesting(singleton("a"));
|
||||
BookmarkForTesting newBookmark = new BookmarkForTesting(singleton("b"));
|
||||
bookmarkManager.updateBookmarks(singleton(oldBookmark), newBookmark);
|
||||
BookmarkForTesting oldBookmark = new BookmarkForTesting(Collections.singleton("a"));
|
||||
BookmarkForTesting newBookmark = new BookmarkForTesting(Collections.singleton("b"));
|
||||
bookmarkManager.updateBookmarks(Collections.singleton(oldBookmark), newBookmark);
|
||||
|
||||
assertThat(bookmarkManager.getBookmarks()).containsExactly(newBookmark);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,19 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.transaction;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyCollection;
|
||||
import static org.mockito.Mockito.anyMap;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -15,9 +15,14 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.core.transaction;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyCollection;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import io.r2dbc.h2.H2ConnectionConfiguration;
|
||||
import io.r2dbc.h2.H2ConnectionFactory;
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.neo4j.documentation.domain;
|
||||
|
||||
// tag::mapping.annotations[]
|
||||
|
||||
import static org.springframework.data.neo4j.core.schema.Relationship.Direction.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -28,6 +26,7 @@ import org.springframework.data.neo4j.core.schema.Id;
|
||||
import org.springframework.data.neo4j.core.schema.Node;
|
||||
import org.springframework.data.neo4j.core.schema.Property;
|
||||
import org.springframework.data.neo4j.core.schema.Relationship;
|
||||
import org.springframework.data.neo4j.core.schema.Relationship.Direction;
|
||||
|
||||
// end::mapping.annotations[]
|
||||
|
||||
@@ -44,12 +43,12 @@ public class MovieEntity {
|
||||
@Property("tagline") // <.>
|
||||
private final String description;
|
||||
|
||||
@Relationship(type = "ACTED_IN", direction = INCOMING) // <.>
|
||||
@Relationship(type = "ACTED_IN", direction = Direction.INCOMING) // <.>
|
||||
// tag::mapping.relationship.properties[]
|
||||
private Map<PersonEntity, Roles> actorsAndRoles = new HashMap<>();
|
||||
// end::mapping.relationship.properties[]
|
||||
|
||||
@Relationship(type = "DIRECTED", direction = INCOMING) private List<PersonEntity> directors = new ArrayList<>();
|
||||
@Relationship(type = "DIRECTED", direction = Direction.INCOMING) private List<PersonEntity> directors = new ArrayList<>();
|
||||
|
||||
public MovieEntity(String title, String description) { // <.>
|
||||
this.title = title;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.documentation.repositories.domain_events;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.documentation.repositories.populators;
|
||||
|
||||
import static org.springframework.data.neo4j.core.schema.Relationship.Direction.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.data.neo4j.core.schema.Id;
|
||||
import org.springframework.data.neo4j.core.schema.Node;
|
||||
import org.springframework.data.neo4j.core.schema.Property;
|
||||
import org.springframework.data.neo4j.core.schema.Relationship;
|
||||
import org.springframework.data.neo4j.core.schema.Relationship.Direction;
|
||||
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
@@ -35,9 +34,9 @@ public class MovieEntity {
|
||||
|
||||
@Property("tagline") private final String description;
|
||||
|
||||
@Relationship(type = "ACTED_IN", direction = INCOMING) private Set<PersonEntity> actors;
|
||||
@Relationship(type = "ACTED_IN", direction = Direction.INCOMING) private Set<PersonEntity> actors;
|
||||
|
||||
@Relationship(type = "DIRECTED", direction = INCOMING) private Set<PersonEntity> directors;
|
||||
@Relationship(type = "DIRECTED", direction = Direction.INCOMING) private Set<PersonEntity> directors;
|
||||
|
||||
public MovieEntity(String title, String description) {
|
||||
this.title = title;
|
||||
|
||||
@@ -17,10 +17,10 @@ package org.springframework.data.neo4j.documentation.spring_boot;
|
||||
|
||||
// tag::faq.template-reactive[]
|
||||
|
||||
import static java.util.Collections.*;
|
||||
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.neo4j.core.ReactiveNeo4jTemplate;
|
||||
import org.springframework.data.neo4j.documentation.Test;
|
||||
@@ -59,8 +59,8 @@ class ReactiveTemplateExampleTest {
|
||||
"A movie that follows the adventures of Herbie, Herbie's driver, "
|
||||
+ "Jim Douglas (Dean Jones), and Jim's love interest, " + "Carole Bennett (Michele Lee)");
|
||||
|
||||
movie.getActorsAndRoles().put(new PersonEntity(1931, "Dean Jones"), new Roles(singletonList("Didi")));
|
||||
movie.getActorsAndRoles().put(new PersonEntity(1942, "Michele Lee"), new Roles(singletonList("Michi")));
|
||||
movie.getActorsAndRoles().put(new PersonEntity(1931, "Dean Jones"), new Roles(Collections.singletonList("Didi")));
|
||||
movie.getActorsAndRoles().put(new PersonEntity(1942, "Michele Lee"), new Roles(Collections.singletonList("Michi")));
|
||||
|
||||
StepVerifier.create(neo4jTemplate.save(movie)).expectNextCount(1L).verifyComplete();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.neo4j.documentation.spring_boot;
|
||||
|
||||
// tag::testing.reactivedataneo4jtest[]
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -17,9 +17,9 @@ package org.springframework.data.neo4j.documentation.spring_boot;
|
||||
|
||||
// tag::faq.template-imperative[]
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -46,8 +46,8 @@ public class TemplateExampleTest {
|
||||
"A movie that follows the adventures of Herbie, Herbie's driver, "
|
||||
+ "Jim Douglas (Dean Jones), and Jim's love interest, " + "Carole Bennett (Michele Lee)");
|
||||
|
||||
movie.getActorsAndRoles().put(new PersonEntity(1931, "Dean Jones"), new Roles(singletonList("Didi")));
|
||||
movie.getActorsAndRoles().put(new PersonEntity(1942, "Michele Lee"), new Roles(singletonList("Michi")));
|
||||
movie.getActorsAndRoles().put(new PersonEntity(1931, "Dean Jones"), new Roles(Collections.singletonList("Didi")));
|
||||
movie.getActorsAndRoles().put(new PersonEntity(1942, "Michele Lee"), new Roles(Collections.singletonList("Michi")));
|
||||
|
||||
neo4jTemplate.save(movie);
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.DynamicTest.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
@@ -70,10 +69,11 @@ class Neo4jConversionsIT extends Neo4jConversionsITBase {
|
||||
return supportedTypes.entrySet().stream().map(types -> {
|
||||
|
||||
DynamicContainer reads = DynamicContainer.dynamicContainer("read", types.getValue().entrySet().stream().map(
|
||||
a -> dynamicTest(a.getKey(), () -> Neo4jConversionsIT.assertRead(types.getKey(), a.getKey(), a.getValue()))));
|
||||
a -> DynamicTest
|
||||
.dynamicTest(a.getKey(), () -> Neo4jConversionsIT.assertRead(types.getKey(), a.getKey(), a.getValue()))));
|
||||
|
||||
DynamicContainer writes = DynamicContainer.dynamicContainer("write",
|
||||
types.getValue().entrySet().stream().map(a -> dynamicTest(a.getKey(),
|
||||
types.getValue().entrySet().stream().map(a -> DynamicTest.dynamicTest(a.getKey(),
|
||||
() -> Neo4jConversionsIT.assertWrite(types.getKey(), a.getKey(), a.getValue()))));
|
||||
|
||||
return DynamicContainer.dynamicContainer(types.getKey(), Arrays.asList(reads, writes));
|
||||
@@ -109,10 +109,10 @@ class Neo4jConversionsIT extends Neo4jConversionsITBase {
|
||||
new Neo4jConversions(converterAware.getConverters()).registerConvertersIn(customConversionService);
|
||||
|
||||
return Stream.of(
|
||||
dynamicTest("read",
|
||||
DynamicTest.dynamicTest("read",
|
||||
() -> assertThat(customConversionService.convert(Values.value("gestern"), LocalDate.class))
|
||||
.isEqualTo(LocalDate.now().minusDays(1))),
|
||||
dynamicTest("write",
|
||||
DynamicTest.dynamicTest("write",
|
||||
() -> assertThat(customConversionService.convert(LocalDate.now().plusDays(1), TYPE_DESCRIPTOR_OF_VALUE))
|
||||
.isEqualTo(Values.value("morgen"))));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -27,6 +25,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -75,7 +74,7 @@ class CausalClusterLoadTestIT {
|
||||
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
List<Future<ThingWithSequence>> executedWrites = executor
|
||||
.invokeAll(IntStream.range(0, numberOfRequests).mapToObj(i -> createAndRead).collect(toList()));
|
||||
.invokeAll(IntStream.range(0, numberOfRequests).mapToObj(i -> createAndRead).collect(Collectors.toList()));
|
||||
try {
|
||||
executedWrites.forEach(request -> {
|
||||
try {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -36,6 +35,7 @@ import org.springframework.data.neo4j.core.schema.Property;
|
||||
import org.springframework.data.neo4j.core.schema.Relationship;
|
||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@@ -47,7 +47,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@Neo4jIntegrationTest
|
||||
class DefaultNeo4jConverterIT {
|
||||
|
||||
protected static Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
|
||||
@Test
|
||||
void itShouldReturnsAllTheRelatedEntities(@Autowired Entity2Repository entity2Repository) {
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.neo4j.cypherdsl.core.Conditions.not;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.neo4j.cypherdsl.core.Predicates.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.parameter;
|
||||
import static org.neo4j.cypherdsl.core.Predicates.exists;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -44,7 +44,16 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
|
||||
import org.springframework.data.neo4j.core.Neo4jTemplate;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.*;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.DynamicLabelsWithMultipleNodeLabels;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.DynamicLabelsWithNodeLabel;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.ExtendedBaseClass1;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.InheritedSimpleDynamicLabels;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabels;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabelsCtor;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessId;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessIdAndVersion;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithVersion;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SuperNode;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.springframework.data.neo4j.core.schema.Node;
|
||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@@ -52,7 +53,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@Neo4jIntegrationTest
|
||||
class ExceptionTranslationIT {
|
||||
|
||||
protected static Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
|
||||
@BeforeAll
|
||||
static void createConstraints(@Autowired Driver driver) {
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@@ -73,14 +73,14 @@ class IdGeneratorsIT extends IdGeneratorsITBase {
|
||||
void idGenerationWithNewEntitiesShouldWork(@Autowired ThingWithGeneratedIdRepository repository) {
|
||||
|
||||
List<ThingWithGeneratedId> things = IntStream.rangeClosed(1, 10).mapToObj(i -> new ThingWithGeneratedId("name" + i))
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Iterable<ThingWithGeneratedId> savedThings = repository.saveAll(things);
|
||||
assertThat(savedThings).hasSize(things.size()).extracting(ThingWithGeneratedId::getTheId)
|
||||
.allMatch(s -> s.matches("thingWithGeneratedId-\\d+"));
|
||||
|
||||
Set<String> distinctIds = StreamSupport.stream(savedThings.spliterator(), false).map(ThingWithGeneratedId::getTheId)
|
||||
.collect(toSet());
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertThat(distinctIds).hasSize(things.size());
|
||||
}
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -131,7 +130,7 @@ class Neo4jOperationsIT {
|
||||
Statement statement = Cypher.match(node).where(node.property("name").isEqualTo(Cypher.parameter("name")))
|
||||
.returning(Functions.count(node)).build();
|
||||
|
||||
assertThat(neo4jOperations.count(statement, singletonMap("name", TEST_PERSON1_NAME))).isEqualTo(1);
|
||||
assertThat(neo4jOperations.count(statement, Collections.singletonMap("name", TEST_PERSON1_NAME))).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,7 +144,7 @@ class Neo4jOperationsIT {
|
||||
void countWithCypherQueryAndParameters() {
|
||||
String cypherQuery = "MATCH (p:PersonWithAllConstructor) WHERE p.name = $name return count(p)";
|
||||
|
||||
assertThat(neo4jOperations.count(cypherQuery, singletonMap("name", TEST_PERSON1_NAME))).isEqualTo(1);
|
||||
assertThat(neo4jOperations.count(cypherQuery, Collections.singletonMap("name", TEST_PERSON1_NAME))).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,9 +168,9 @@ class Neo4jOperationsIT {
|
||||
Statement statement = Cypher.match(node).where(node.property("name").isEqualTo(Cypher.parameter("name")))
|
||||
.returning(node).build();
|
||||
|
||||
List<PersonWithAllConstructor> people = neo4jOperations
|
||||
.findAll(statement, singletonMap("name", TEST_PERSON1_NAME),
|
||||
PersonWithAllConstructor.class);
|
||||
List<PersonWithAllConstructor> people = neo4jOperations.findAll(statement, Collections
|
||||
.singletonMap("name", TEST_PERSON1_NAME),
|
||||
PersonWithAllConstructor.class);
|
||||
|
||||
assertThat(people).hasSize(1);
|
||||
}
|
||||
@@ -183,7 +182,7 @@ class Neo4jOperationsIT {
|
||||
.returning(node).build();
|
||||
|
||||
Optional<PersonWithAllConstructor> person = neo4jOperations.findOne(statement,
|
||||
singletonMap("name", TEST_PERSON1_NAME), PersonWithAllConstructor.class);
|
||||
Collections.singletonMap("name", TEST_PERSON1_NAME), PersonWithAllConstructor.class);
|
||||
|
||||
assertThat(person).isPresent();
|
||||
}
|
||||
@@ -201,7 +200,7 @@ class Neo4jOperationsIT {
|
||||
String cypherQuery = "MATCH (p:PersonWithAllConstructor) WHERE p.name = $name return p";
|
||||
|
||||
List<PersonWithAllConstructor> people = neo4jOperations.findAll(cypherQuery,
|
||||
singletonMap("name", TEST_PERSON1_NAME), PersonWithAllConstructor.class);
|
||||
Collections.singletonMap("name", TEST_PERSON1_NAME), PersonWithAllConstructor.class);
|
||||
|
||||
assertThat(people).hasSize(1);
|
||||
}
|
||||
@@ -211,7 +210,7 @@ class Neo4jOperationsIT {
|
||||
String cypherQuery = "MATCH (p:PersonWithAllConstructor) WHERE p.name = $name return p";
|
||||
|
||||
Optional<PersonWithAllConstructor> person = neo4jOperations.findOne(cypherQuery,
|
||||
singletonMap("name", TEST_PERSON1_NAME), PersonWithAllConstructor.class);
|
||||
Collections.singletonMap("name", TEST_PERSON1_NAME), PersonWithAllConstructor.class);
|
||||
|
||||
assertThat(person).isPresent();
|
||||
}
|
||||
@@ -347,12 +346,12 @@ class Neo4jOperationsIT {
|
||||
@Bean
|
||||
@Override
|
||||
public Neo4jConversions neo4jConversions() {
|
||||
return new Neo4jConversions(singletonList(new PersonWithCustomId.CustomPersonIdConverter()));
|
||||
return new Neo4jConversions(Collections.singletonList(new PersonWithCustomId.CustomPersonIdConverter()));
|
||||
}
|
||||
|
||||
@Override // needed here because there is no implicit registration of entities upfront some methods under test
|
||||
protected Collection<String> getMappingBasePackages() {
|
||||
return singletonList(PersonWithAllConstructor.class.getPackage().getName());
|
||||
return Collections.singletonList(PersonWithAllConstructor.class.getPackage().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -97,7 +98,7 @@ class OptimisticLockingIT {
|
||||
VersionedThing parentThing = new VersionedThing("Thing1");
|
||||
VersionedThing childThing = new VersionedThing("Thing2");
|
||||
|
||||
parentThing.setOtherVersionedThings(singletonList(childThing));
|
||||
parentThing.setOtherVersionedThings(Collections.singletonList(childThing));
|
||||
|
||||
VersionedThing thing = repository.save(parentThing);
|
||||
|
||||
@@ -137,7 +138,7 @@ class OptimisticLockingIT {
|
||||
void shouldFailIncrementVersionsOnRelatedEntities(@Autowired VersionedThingRepository repository) {
|
||||
VersionedThing parentThing = new VersionedThing("Thing1");
|
||||
VersionedThing childThing = new VersionedThing("Thing2");
|
||||
parentThing.setOtherVersionedThings(singletonList(childThing));
|
||||
parentThing.setOtherVersionedThings(Collections.singletonList(childThing));
|
||||
|
||||
VersionedThing thing = repository.save(parentThing);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,16 +15,26 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.domain.Range.Bound.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.Assertions.tuple;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@@ -69,7 +79,28 @@ import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
|
||||
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
|
||||
import org.springframework.data.neo4j.integration.imperative.repositories.PersonRepository;
|
||||
import org.springframework.data.neo4j.integration.imperative.repositories.ThingRepository;
|
||||
import org.springframework.data.neo4j.integration.shared.*;
|
||||
import org.springframework.data.neo4j.integration.shared.AnotherThingWithAssignedId;
|
||||
import org.springframework.data.neo4j.integration.shared.BidirectionalEnd;
|
||||
import org.springframework.data.neo4j.integration.shared.BidirectionalStart;
|
||||
import org.springframework.data.neo4j.integration.shared.Club;
|
||||
import org.springframework.data.neo4j.integration.shared.DeepRelationships;
|
||||
import org.springframework.data.neo4j.integration.shared.EntityWithConvertedId;
|
||||
import org.springframework.data.neo4j.integration.shared.Hobby;
|
||||
import org.springframework.data.neo4j.integration.shared.ImmutablePerson;
|
||||
import org.springframework.data.neo4j.integration.shared.Inheritance;
|
||||
import org.springframework.data.neo4j.integration.shared.KotlinPerson;
|
||||
import org.springframework.data.neo4j.integration.shared.LikesHobbyRelationship;
|
||||
import org.springframework.data.neo4j.integration.shared.MultipleLabels;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithNoConstructor;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithRelationship;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithRelationshipWithProperties;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithWither;
|
||||
import org.springframework.data.neo4j.integration.shared.Pet;
|
||||
import org.springframework.data.neo4j.integration.shared.SimilarThing;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithCustomTypes;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithGeneratedId;
|
||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.repository.query.BoundingBox;
|
||||
@@ -152,7 +183,7 @@ class RepositoryIT {
|
||||
person1 = new PersonWithAllConstructor(id1, TEST_PERSON1_NAME, TEST_PERSON1_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, createdAt.toInstant());
|
||||
person2 = new PersonWithAllConstructor(id2, TEST_PERSON2_NAME, TEST_PERSON2_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
false, 2L, TEST_PERSON2_BORN_ON, null, emptyList(), SFO, null);
|
||||
false, 2L, TEST_PERSON2_BORN_ON, null, Collections.emptyList(), SFO, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -219,7 +250,7 @@ class RepositoryIT {
|
||||
|
||||
AnotherThingWithAssignedId anotherThing = new AnotherThingWithAssignedId(4711L);
|
||||
anotherThing.setName("Bart");
|
||||
assertThat(optionalThing).map(ThingWithAssignedId::getThings).contains(singletonList(anotherThing));
|
||||
assertThat(optionalThing).map(ThingWithAssignedId::getThings).contains(Collections.singletonList(anotherThing));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -239,7 +270,7 @@ class RepositoryIT {
|
||||
session.run("CREATE (:EntityWithConvertedId{identifyingEnum:'A'})");
|
||||
}
|
||||
|
||||
List<EntityWithConvertedId> entities = repository.findAllById(singleton(EntityWithConvertedId.IdentifyingEnum.A));
|
||||
List<EntityWithConvertedId> entities = repository.findAllById(Collections.singleton(EntityWithConvertedId.IdentifyingEnum.A));
|
||||
|
||||
assertThat(entities).hasSize(1);
|
||||
assertThat(entities.get(0).getIdentifyingEnum()).isEqualTo(EntityWithConvertedId.IdentifyingEnum.A);
|
||||
@@ -1085,7 +1116,7 @@ class RepositoryIT {
|
||||
void saveAll(@Autowired PersonRepository repository) {
|
||||
|
||||
PersonWithAllConstructor newPerson = new PersonWithAllConstructor(null, "Mercury", "Freddie", "Queen", true,
|
||||
1509L, LocalDate.of(1946, 9, 15), null, emptyList(), null, null);
|
||||
1509L, LocalDate.of(1946, 9, 15), null, Collections.emptyList(), null, null);
|
||||
|
||||
PersonWithAllConstructor existingPerson = repository.findById(id1).get();
|
||||
existingPerson.setFirstName("Updated first name");
|
||||
@@ -1095,7 +1126,7 @@ class RepositoryIT {
|
||||
|
||||
List<Long> ids = StreamSupport
|
||||
.stream(repository.saveAll(Arrays.asList(existingPerson, newPerson)).spliterator(), false)
|
||||
.map(PersonWithAllConstructor::getId).collect(toList());
|
||||
.map(PersonWithAllConstructor::getId).collect(Collectors.toList());
|
||||
|
||||
assertThat(repository.count()).isEqualTo(2);
|
||||
|
||||
@@ -1118,7 +1149,7 @@ class RepositoryIT {
|
||||
originalPerson.setFirstName("Updated first name");
|
||||
originalPerson.setNullable("Updated nullable field");
|
||||
assertThat(originalPerson.getThings()).isNotEmpty();
|
||||
originalPerson.setThings(emptyList());
|
||||
originalPerson.setThings(Collections.emptyList());
|
||||
|
||||
PersonWithAllConstructor savedPerson = repository.save(originalPerson);
|
||||
try (Session session = createSession()) {
|
||||
@@ -1259,7 +1290,7 @@ class RepositoryIT {
|
||||
Pet pet2 = new Pet("Tom");
|
||||
Hobby petHobby = new Hobby();
|
||||
petHobby.setName("sleeping");
|
||||
pet1.setHobbies(singleton(petHobby));
|
||||
pet1.setHobbies(Collections.singleton(petHobby));
|
||||
person.setPets(Arrays.asList(pet1, pet2));
|
||||
|
||||
PersonWithRelationship savedPerson = repository.save(person);
|
||||
@@ -1283,11 +1314,13 @@ class RepositoryIT {
|
||||
pets.put(petWithHobbies.get(0), ((List<Node>) petWithHobbies.get(1)));
|
||||
}
|
||||
|
||||
assertThat(pets.keySet().stream().map(pet -> ((Node) pet).get("name").asString()).collect(toList()))
|
||||
assertThat(pets.keySet().stream().map(pet -> ((Node) pet).get("name").asString()).collect(
|
||||
Collectors.toList()))
|
||||
.containsExactlyInAnyOrder("Jerry", "Tom");
|
||||
|
||||
assertThat(pets.values().stream()
|
||||
.flatMap(petHobbies -> petHobbies.stream().map(node -> node.get("name").asString())).collect(toList()))
|
||||
.flatMap(petHobbies -> petHobbies.stream().map(node -> node.get("name").asString())).collect(
|
||||
Collectors.toList()))
|
||||
.containsExactlyInAnyOrder("sleeping");
|
||||
|
||||
assertThat(record.get("hobbies").asList(entry -> entry.asNode().get("name").asString()))
|
||||
@@ -1311,7 +1344,7 @@ class RepositoryIT {
|
||||
Pet pet2 = new Pet("Tom");
|
||||
Hobby petHobby = new Hobby();
|
||||
petHobby.setName("sleeping");
|
||||
pet1.setHobbies(singleton(petHobby));
|
||||
pet1.setHobbies(Collections.singleton(petHobby));
|
||||
person.setPets(Arrays.asList(pet1, pet2));
|
||||
|
||||
PersonWithRelationship savedPerson = repository.save(person);
|
||||
@@ -1339,11 +1372,13 @@ class RepositoryIT {
|
||||
pets.put(petWithHobbies.get(0), ((List<Node>) petWithHobbies.get(1)));
|
||||
}
|
||||
|
||||
assertThat(pets.keySet().stream().map(pet -> ((Node) pet).get("name").asString()).collect(toList()))
|
||||
assertThat(pets.keySet().stream().map(pet -> ((Node) pet).get("name").asString()).collect(
|
||||
Collectors.toList()))
|
||||
.containsExactlyInAnyOrder("Jerry", "Tom");
|
||||
|
||||
assertThat(pets.values().stream()
|
||||
.flatMap(petHobbies -> petHobbies.stream().map(node -> node.get("name").asString())).collect(toList()))
|
||||
.flatMap(petHobbies -> petHobbies.stream().map(node -> node.get("name").asString())).collect(
|
||||
Collectors.toList()))
|
||||
.containsExactlyInAnyOrder("sleeping");
|
||||
|
||||
assertThat(record.get("hobbies").asList(entry -> entry.asNode().get("name").asString()))
|
||||
@@ -1456,16 +1491,16 @@ class RepositoryIT {
|
||||
Pet petOfChildPet = new Pet("Mucki");
|
||||
Pet petOfGrandChildPet = new Pet("Blacky");
|
||||
|
||||
rootPet.setFriends(singletonList(petOfRootPet));
|
||||
petOfRootPet.setFriends(singletonList(petOfChildPet));
|
||||
petOfChildPet.setFriends(singletonList(petOfGrandChildPet));
|
||||
rootPet.setFriends(Collections.singletonList(petOfRootPet));
|
||||
petOfRootPet.setFriends(Collections.singletonList(petOfChildPet));
|
||||
petOfChildPet.setFriends(Collections.singletonList(petOfGrandChildPet));
|
||||
|
||||
repository.save(rootPet);
|
||||
|
||||
try (Session session = createSession()) {
|
||||
Record record = session.run("MATCH (rootPet:Pet)-[:Has]->(petOfRootPet:Pet)-[:Has]->(petOfChildPet:Pet)"
|
||||
+ "-[:Has]->(petOfGrandChildPet:Pet) " + "RETURN rootPet, petOfRootPet, petOfChildPet, petOfGrandChildPet",
|
||||
emptyMap()).single();
|
||||
Collections.emptyMap()).single();
|
||||
|
||||
assertThat(record.get("rootPet").asNode().get("name").asString()).isEqualTo("Luna");
|
||||
assertThat(record.get("petOfRootPet").asNode().get("name").asString()).isEqualTo("Daphne");
|
||||
@@ -1479,8 +1514,8 @@ class RepositoryIT {
|
||||
Pet luna = new Pet("Luna");
|
||||
Pet daphne = new Pet("Daphne");
|
||||
|
||||
luna.setFriends(singletonList(daphne));
|
||||
daphne.setFriends(singletonList(luna));
|
||||
luna.setFriends(Collections.singletonList(daphne));
|
||||
daphne.setFriends(Collections.singletonList(luna));
|
||||
|
||||
repository.save(luna);
|
||||
|
||||
@@ -1521,7 +1556,7 @@ class RepositoryIT {
|
||||
thing.setName("That's the thing.");
|
||||
AnotherThingWithAssignedId anotherThing = new AnotherThingWithAssignedId(4711L);
|
||||
anotherThing.setName("AnotherThing");
|
||||
thing.setThings(singletonList(anotherThing));
|
||||
thing.setThings(Collections.singletonList(anotherThing));
|
||||
thing = repository.save(thing);
|
||||
|
||||
try (Session session = createSession()) {
|
||||
@@ -1548,8 +1583,8 @@ class RepositoryIT {
|
||||
thing.setName("That's the thing.");
|
||||
AnotherThingWithAssignedId anotherThing = new AnotherThingWithAssignedId(4711L);
|
||||
anotherThing.setName("AnotherThing");
|
||||
thing.setThings(singletonList(anotherThing));
|
||||
repository.saveAll(singletonList(thing));
|
||||
thing.setThings(Collections.singletonList(anotherThing));
|
||||
repository.saveAll(Collections.singletonList(thing));
|
||||
|
||||
try (Session session = createSession()) {
|
||||
Record record = session.run("MATCH (n:Thing)-[:Has]->(t:Thing2) WHERE n.theId = $id RETURN n, t",
|
||||
@@ -1685,7 +1720,7 @@ class RepositoryIT {
|
||||
person1 = new PersonWithAllConstructor(id1, TEST_PERSON1_NAME, TEST_PERSON1_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, createdAt.toInstant());
|
||||
person2 = new PersonWithAllConstructor(id2, TEST_PERSON2_NAME, TEST_PERSON2_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
false, 2L, TEST_PERSON2_BORN_ON, null, emptyList(), SFO, null);
|
||||
false, 2L, TEST_PERSON2_BORN_ON, null, Collections.emptyList(), SFO, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1820,7 +1855,7 @@ class RepositoryIT {
|
||||
person1 = new PersonWithAllConstructor(id1, TEST_PERSON1_NAME, TEST_PERSON1_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, createdAt.toInstant());
|
||||
person2 = new PersonWithAllConstructor(id2, TEST_PERSON2_NAME, TEST_PERSON2_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
false, 2L, TEST_PERSON2_BORN_ON, null, emptyList(), SFO, null);
|
||||
false, 2L, TEST_PERSON2_BORN_ON, null, Collections.emptyList(), SFO, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1955,22 +1990,22 @@ class RepositoryIT {
|
||||
void findByBetweenRange(@Autowired PersonRepository repository) {
|
||||
|
||||
List<PersonWithAllConstructor> persons;
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(inclusive(1L)).to(inclusive(2L)));
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(Bound.inclusive(1L)).to(Bound.inclusive(2L)));
|
||||
assertThat(persons).containsExactlyInAnyOrder(person1, person2);
|
||||
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(inclusive(1L)).to(exclusive(2L)));
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(Bound.inclusive(1L)).to(Bound.exclusive(2L)));
|
||||
assertThat(persons).hasSize(1).contains(person1);
|
||||
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(inclusive(1L)).to(unbounded()));
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(Bound.inclusive(1L)).to(Bound.unbounded()));
|
||||
assertThat(persons).containsExactlyInAnyOrder(person1, person2);
|
||||
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(exclusive(1L)).to(unbounded()));
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(Bound.exclusive(1L)).to(Bound.unbounded()));
|
||||
assertThat(persons).hasSize(1).contains(person2);
|
||||
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(Bound.<Long>unbounded()).to(inclusive(2L)));
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(Bound.<Long>unbounded()).to(Bound.inclusive(2L)));
|
||||
assertThat(persons).containsExactlyInAnyOrder(person1, person2);
|
||||
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(Bound.<Long>unbounded()).to(exclusive(2L)));
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.from(Bound.<Long>unbounded()).to(Bound.exclusive(2L)));
|
||||
assertThat(persons).hasSize(1).contains(person1);
|
||||
|
||||
persons = repository.findAllByPersonNumberIsBetween(Range.unbounded());
|
||||
@@ -2081,7 +2116,7 @@ class RepositoryIT {
|
||||
persons = repository.findAllByPlaceNear(SFO);
|
||||
assertThat(persons).containsExactly(person2, person1);
|
||||
|
||||
persons = repository.findAllByPlaceNearAndFirstNameIn(SFO, singletonList(TEST_PERSON1_FIRST_NAME));
|
||||
persons = repository.findAllByPlaceNearAndFirstNameIn(SFO, Collections.singletonList(TEST_PERSON1_FIRST_NAME));
|
||||
assertThat(persons).containsExactly(person1);
|
||||
|
||||
Distance distance = new Distance(200.0 / 1000.0, Metrics.KILOMETERS);
|
||||
@@ -2099,8 +2134,8 @@ class RepositoryIT {
|
||||
Distance.between(100.0 / 1000.0, Metrics.KILOMETERS, 200.0 / 1000.0, Metrics.KILOMETERS));
|
||||
assertThat(persons).isEmpty();
|
||||
|
||||
final Range<Distance> distanceRange = Range.of(inclusive(new Distance(100.0 / 1000.0, Metrics.KILOMETERS)),
|
||||
unbounded());
|
||||
final Range<Distance> distanceRange = Range.of(Bound.inclusive(new Distance(100.0 / 1000.0, Metrics.KILOMETERS)),
|
||||
Bound.unbounded());
|
||||
persons = repository.findAllByPlaceNear(MINC, distanceRange);
|
||||
assertThat(persons).hasSize(1).contains(person2);
|
||||
|
||||
@@ -2281,7 +2316,7 @@ class RepositoryIT {
|
||||
|
||||
@Test
|
||||
void createAllNodesWithMultipleLabels(@Autowired MultipleLabelRepository multipleLabelRepository) {
|
||||
multipleLabelRepository.saveAll(singletonList(new MultipleLabels.MultipleLabelsEntity()));
|
||||
multipleLabelRepository.saveAll(Collections.singletonList(new MultipleLabels.MultipleLabelsEntity()));
|
||||
|
||||
try (Session session = createSession()) {
|
||||
Node node = session.run("MATCH (n:A) return n").single().get("n").asNode();
|
||||
@@ -2360,7 +2395,7 @@ class RepositoryIT {
|
||||
|
||||
@Test
|
||||
void createAllNodesWithMultipleLabels(@Autowired MultipleLabelWithAssignedIdRepository multipleLabelRepository) {
|
||||
multipleLabelRepository.saveAll(singletonList(new MultipleLabels.MultipleLabelsEntityWithAssignedId(4711L)));
|
||||
multipleLabelRepository.saveAll(Collections.singletonList(new MultipleLabels.MultipleLabelsEntityWithAssignedId(4711L)));
|
||||
|
||||
try (Session session = createSession()) {
|
||||
Node node = session.run("MATCH (n:X) return n").single().get("n").asNode();
|
||||
@@ -2828,7 +2863,7 @@ class RepositoryIT {
|
||||
|
||||
@Override
|
||||
protected Collection<String> getMappingBasePackages() {
|
||||
return singletonList(PersonWithAllConstructor.class.getPackage().getName());
|
||||
return Collections.singletonList(PersonWithAllConstructor.class.getPackage().getName());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -15,21 +15,20 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.neo4j.driver.Session;
|
||||
import org.neo4j.driver.SessionConfig;
|
||||
import org.springframework.data.neo4j.core.DatabaseSelection;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(COMMERCIAL_EDITION_ONLY)
|
||||
@Tag(REQUIRES + "4.0.0")
|
||||
@Tag(Neo4jExtension.COMMERCIAL_EDITION_ONLY)
|
||||
@Tag(Neo4jExtension.REQUIRES + "4.0.0")
|
||||
@DirtiesContext
|
||||
class RepositoryWithADifferentDatabaseIT extends RepositoryIT {
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -15,8 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.imperative;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.DynamicTest.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -29,6 +29,7 @@ import java.util.stream.Stream;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.DynamicContainer;
|
||||
import org.junit.jupiter.api.DynamicNode;
|
||||
import org.junit.jupiter.api.DynamicTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestFactory;
|
||||
import org.neo4j.driver.Driver;
|
||||
@@ -139,11 +140,12 @@ class TypeConversionIT extends Neo4jConversionsITBase {
|
||||
}
|
||||
|
||||
DynamicContainer reads = DynamicContainer.dynamicContainer("read",
|
||||
entry.getValue().entrySet().stream().map(a -> dynamicTest(a.getKey(),
|
||||
entry.getValue().entrySet().stream().map(a -> DynamicTest.dynamicTest(a.getKey(),
|
||||
() -> assertThat(ReflectionTestUtils.getField(thing, a.getKey())).isEqualTo(a.getValue()))));
|
||||
|
||||
DynamicContainer writes = DynamicContainer.dynamicContainer("write", entry.getValue().entrySet().stream()
|
||||
.map(a -> dynamicTest(a.getKey(), () -> assertWrite(copyOfThing, a.getKey(), defaultConversionService))));
|
||||
.map(a -> DynamicTest
|
||||
.dynamicTest(a.getKey(), () -> assertWrite(copyOfThing, a.getKey(), defaultConversionService))));
|
||||
|
||||
return DynamicContainer.dynamicContainer(entry.getKey(), Arrays.asList(reads, writes));
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.kotlin;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -40,6 +39,7 @@ import org.springframework.data.neo4j.integration.shared.ImmutableAuditableThing
|
||||
import org.springframework.data.neo4j.integration.shared.ImmutableAuditableThingWithGeneratedId;
|
||||
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.transaction.ReactiveTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
@@ -47,7 +47,7 @@ import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveAuditingIT extends AuditingITBase {
|
||||
|
||||
private final ReactiveTransactionManager transactionManager;
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -45,7 +43,7 @@ import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveCallbacksIT extends CallbacksITBase {
|
||||
|
||||
private static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -30,6 +28,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -80,7 +79,7 @@ class ReactiveCausalClusterLoadTestIT {
|
||||
|
||||
ExecutorService executor = Executors.newCachedThreadPool();
|
||||
List<Future<ThingWithSequence>> executedWrites = executor
|
||||
.invokeAll(IntStream.range(0, numberOfRequests).mapToObj(i -> createAndRead).collect(toList()));
|
||||
.invokeAll(IntStream.range(0, numberOfRequests).mapToObj(i -> createAndRead).collect(Collectors.toList()));
|
||||
try {
|
||||
executedWrites.forEach(request -> {
|
||||
try {
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.neo4j.cypherdsl.core.Conditions.not;
|
||||
import static org.neo4j.cypherdsl.core.Predicates.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.neo4j.cypherdsl.core.Predicates.exists;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -47,7 +46,16 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
|
||||
import org.springframework.data.neo4j.core.ReactiveNeo4jTemplate;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.*;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.DynamicLabelsWithMultipleNodeLabels;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.DynamicLabelsWithNodeLabel;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.ExtendedBaseClass1;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.InheritedSimpleDynamicLabels;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabels;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabelsCtor;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessId;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessIdAndVersion;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithVersion;
|
||||
import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.SuperNode;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@@ -56,7 +64,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
@ExtendWith(Neo4jExtension.class)
|
||||
public class ReactiveDynamicLabelsIT {
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -43,13 +42,14 @@ import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.Typ
|
||||
import org.springframework.data.neo4j.integration.shared.Pet;
|
||||
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveDynamicRelationshipsIT extends DynamicRelationshipsITBase<PersonWithRelatives> {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -45,6 +43,7 @@ import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator;
|
||||
import org.springframework.data.neo4j.repository.support.ReactivePersistenceExceptionTranslationPostProcessor;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@@ -53,10 +52,10 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Neo4jIntegrationTest
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveExceptionTranslationIT {
|
||||
|
||||
protected static Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
|
||||
// @formatter:off
|
||||
private final Predicate<Throwable> aTranslatedException = ex -> ex instanceof DataIntegrityViolationException && //
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -26,6 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.jupiter.api.Tag;
|
||||
@@ -40,6 +39,7 @@ import org.springframework.data.neo4j.integration.shared.IdGeneratorsITBase;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithGeneratedId;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithIdGeneratedByBean;
|
||||
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.transaction.ReactiveTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@@ -48,7 +48,7 @@ import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveIdGeneratorsIT extends IdGeneratorsITBase {
|
||||
|
||||
private final ReactiveTransactionManager transactionManager;
|
||||
@@ -94,7 +94,7 @@ class ReactiveIdGeneratorsIT extends IdGeneratorsITBase {
|
||||
void idGenerationWithNewEntitiesShouldWork(@Autowired ThingWithGeneratedIdRepository repository) {
|
||||
|
||||
List<ThingWithGeneratedId> things = IntStream.rangeClosed(1, 10).mapToObj(i -> new ThingWithGeneratedId("name" + i))
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Set<String> generatedIds = new HashSet<>();
|
||||
TransactionalOperator transactionalOperator = TransactionalOperator.create(transactionManager);
|
||||
|
||||
@@ -15,10 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.neo4j.cypherdsl.core.Cypher.parameter;
|
||||
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -59,8 +57,9 @@ import org.springframework.data.neo4j.core.convert.Neo4jConversions;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithCustomId;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithGeneratedId;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension.Neo4jConnectionSupport;
|
||||
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
@@ -68,7 +67,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Neo4jIntegrationTest
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveNeo4jOperationsIT {
|
||||
private static final String TEST_PERSON1_NAME = "Test";
|
||||
private static final String TEST_PERSON2_NAME = "Test2";
|
||||
@@ -138,7 +137,7 @@ class ReactiveNeo4jOperationsIT {
|
||||
Statement statement = Cypher.match(node).where(node.property("name").isEqualTo(parameter("name")))
|
||||
.returning(Functions.count(node)).build();
|
||||
|
||||
StepVerifier.create(neo4jOperations.count(statement, singletonMap("name", TEST_PERSON1_NAME)))
|
||||
StepVerifier.create(neo4jOperations.count(statement, Collections.singletonMap("name", TEST_PERSON1_NAME)))
|
||||
.assertNext(count -> assertThat(count).isEqualTo(1)).verifyComplete();
|
||||
}
|
||||
|
||||
@@ -155,7 +154,7 @@ class ReactiveNeo4jOperationsIT {
|
||||
void countWithCypherQueryAndParameters() {
|
||||
String cypherQuery = "MATCH (p:PersonWithAllConstructor) WHERE p.name = $name return count(p)";
|
||||
|
||||
StepVerifier.create(neo4jOperations.count(cypherQuery, singletonMap("name", TEST_PERSON1_NAME)))
|
||||
StepVerifier.create(neo4jOperations.count(cypherQuery, Collections.singletonMap("name", TEST_PERSON1_NAME)))
|
||||
.assertNext(count -> assertThat(count).isEqualTo(1)).verifyComplete();
|
||||
}
|
||||
|
||||
@@ -354,12 +353,12 @@ class ReactiveNeo4jOperationsIT {
|
||||
@Bean
|
||||
@Override
|
||||
public Neo4jConversions neo4jConversions() {
|
||||
return new Neo4jConversions(singletonList(new PersonWithCustomId.CustomPersonIdConverter()));
|
||||
return new Neo4jConversions(Collections.singletonList(new PersonWithCustomId.CustomPersonIdConverter()));
|
||||
}
|
||||
|
||||
@Override // needed here because there is no implicit registration of entities upfront some methods under test
|
||||
protected Collection<String> getMappingBasePackages() {
|
||||
return singletonList(PersonWithAllConstructor.class.getPackage().getName());
|
||||
return Collections.singletonList(PersonWithAllConstructor.class.getPackage().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -49,7 +48,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
* @author Gerrit Meier
|
||||
*/
|
||||
@Neo4jIntegrationTest
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveOptimisticLockingIT {
|
||||
|
||||
private static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
@@ -101,7 +100,7 @@ class ReactiveOptimisticLockingIT {
|
||||
VersionedThing parentThing = new VersionedThing("Thing1");
|
||||
VersionedThing childThing = new VersionedThing("Thing2");
|
||||
|
||||
parentThing.setOtherVersionedThings(singletonList(childThing));
|
||||
parentThing.setOtherVersionedThings(Collections.singletonList(childThing));
|
||||
|
||||
StepVerifier.create(repository.save(parentThing))
|
||||
.assertNext(
|
||||
@@ -139,7 +138,7 @@ class ReactiveOptimisticLockingIT {
|
||||
|
||||
VersionedThing thing = new VersionedThing("Thing1");
|
||||
VersionedThing childThing = new VersionedThing("Thing2");
|
||||
thing.setOtherVersionedThings(singletonList(childThing));
|
||||
thing.setOtherVersionedThings(Collections.singletonList(childThing));
|
||||
VersionedThing savedThing = repository.save(thing).block();
|
||||
savedThing.getOtherVersionedThings().get(0).setMyVersion(1L); // Version in DB is 0
|
||||
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -45,7 +44,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
* @author Gerrit Meier
|
||||
*/
|
||||
@Neo4jIntegrationTest
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveProjectionIT {
|
||||
|
||||
private static final String FIRST_NAME = "Hans";
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -36,6 +35,7 @@ import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
|
||||
import org.springframework.data.neo4j.integration.shared.MultipleRelationshipsThing;
|
||||
import org.springframework.data.neo4j.integration.shared.RelationshipsITBase;
|
||||
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
*
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveRelationshipsIT extends RelationshipsITBase {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -15,18 +15,26 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.neo4j.driver.Values.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.tuple;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.assertj.core.data.MapEntry;
|
||||
@@ -62,7 +70,25 @@ import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider;
|
||||
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
|
||||
import org.springframework.data.neo4j.integration.reactive.repositories.ReactivePersonRepository;
|
||||
import org.springframework.data.neo4j.integration.reactive.repositories.ReactiveThingRepository;
|
||||
import org.springframework.data.neo4j.integration.shared.*;
|
||||
import org.springframework.data.neo4j.integration.shared.AltHobby;
|
||||
import org.springframework.data.neo4j.integration.shared.AnotherThingWithAssignedId;
|
||||
import org.springframework.data.neo4j.integration.shared.BidirectionalEnd;
|
||||
import org.springframework.data.neo4j.integration.shared.BidirectionalStart;
|
||||
import org.springframework.data.neo4j.integration.shared.Club;
|
||||
import org.springframework.data.neo4j.integration.shared.DeepRelationships;
|
||||
import org.springframework.data.neo4j.integration.shared.EntityWithConvertedId;
|
||||
import org.springframework.data.neo4j.integration.shared.Hobby;
|
||||
import org.springframework.data.neo4j.integration.shared.ImmutablePerson;
|
||||
import org.springframework.data.neo4j.integration.shared.LikesHobbyRelationship;
|
||||
import org.springframework.data.neo4j.integration.shared.MultipleLabels;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithRelationship;
|
||||
import org.springframework.data.neo4j.integration.shared.PersonWithRelationshipWithProperties;
|
||||
import org.springframework.data.neo4j.integration.shared.Pet;
|
||||
import org.springframework.data.neo4j.integration.shared.SimilarThing;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithCustomTypes;
|
||||
import org.springframework.data.neo4j.integration.shared.ThingWithGeneratedId;
|
||||
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.repository.query.Query;
|
||||
@@ -85,7 +111,7 @@ import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
@ExtendWith(Neo4jExtension.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveRepositoryIT {
|
||||
|
||||
protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
@@ -126,20 +152,21 @@ class ReactiveRepositoryIT {
|
||||
id1 = transaction.run("" + "CREATE (n:PersonWithAllConstructor) "
|
||||
+ " SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.nullable = 'something', n.things = ['a', 'b'], n.place = $place "
|
||||
+ "RETURN id(n)",
|
||||
parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON1_FIRST_NAME, "cool", true, "personNumber", 1, "bornOn", TEST_PERSON1_BORN_ON, "place",
|
||||
NEO4J_HQ))
|
||||
.next().get(0).asLong();
|
||||
|
||||
id2 = transaction.run(
|
||||
"CREATE (n:PersonWithAllConstructor) SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.things = [], n.place = $place return id(n)",
|
||||
parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON2_FIRST_NAME, "cool", false, "personNumber", 2, "bornOn", TEST_PERSON2_BORN_ON, "place", SFO))
|
||||
.next().get(0).asLong();
|
||||
|
||||
transaction.run("CREATE (a:Thing {theId: 'anId', name: 'Homer'})-[:Has]->(b:Thing2{theId: 4711, name: 'Bart'})");
|
||||
IntStream.rangeClosed(1, 20).forEach(i -> transaction
|
||||
.run("CREATE (a:Thing {theId: 'id' + $i, name: 'name' + $i})", parameters("i", String.format("%02d", i))));
|
||||
.run("CREATE (a:Thing {theId: 'id' + $i, name: 'name' + $i})", Values
|
||||
.parameters("i", String.format("%02d", i))));
|
||||
|
||||
person1 = new PersonWithAllConstructor(id1, TEST_PERSON1_NAME, TEST_PERSON1_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, null);
|
||||
@@ -447,7 +474,7 @@ class ReactiveRepositoryIT {
|
||||
session.run("CREATE (:EntityWithConvertedId{identifyingEnum:'A'})");
|
||||
}
|
||||
|
||||
StepVerifier.create(repository.findAllById(singleton(EntityWithConvertedId.IdentifyingEnum.A)))
|
||||
StepVerifier.create(repository.findAllById(Collections.singleton(EntityWithConvertedId.IdentifyingEnum.A)))
|
||||
.assertNext(
|
||||
entity -> assertThat(entity.getIdentifyingEnum()).isEqualTo(EntityWithConvertedId.IdentifyingEnum.A))
|
||||
.verifyComplete();
|
||||
@@ -465,20 +492,21 @@ class ReactiveRepositoryIT {
|
||||
id1 = transaction.run("" + "CREATE (n:PersonWithAllConstructor) "
|
||||
+ " SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.nullable = 'something', n.things = ['a', 'b'], n.place = $place "
|
||||
+ "RETURN id(n)",
|
||||
parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON1_FIRST_NAME, "cool", true, "personNumber", 1, "bornOn", TEST_PERSON1_BORN_ON, "place",
|
||||
NEO4J_HQ))
|
||||
.next().get(0).asLong();
|
||||
|
||||
id2 = transaction.run(
|
||||
"CREATE (n:PersonWithAllConstructor) SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.things = [], n.place = $place return id(n)",
|
||||
parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON2_FIRST_NAME, "cool", false, "personNumber", 2, "bornOn", TEST_PERSON2_BORN_ON, "place", SFO))
|
||||
.next().get(0).asLong();
|
||||
|
||||
transaction.run("CREATE (a:Thing {theId: 'anId', name: 'Homer'})-[:Has]->(b:Thing2{theId: 4711, name: 'Bart'})");
|
||||
IntStream.rangeClosed(1, 20).forEach(i -> transaction
|
||||
.run("CREATE (a:Thing {theId: 'id' + $i, name: 'name' + $i})", parameters("i", String.format("%02d", i))));
|
||||
.run("CREATE (a:Thing {theId: 'id' + $i, name: 'name' + $i})", Values
|
||||
.parameters("i", String.format("%02d", i))));
|
||||
|
||||
person1 = new PersonWithAllConstructor(id1, TEST_PERSON1_NAME, TEST_PERSON1_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, null);
|
||||
@@ -1141,20 +1169,21 @@ class ReactiveRepositoryIT {
|
||||
id1 = transaction.run("" + "CREATE (n:PersonWithAllConstructor) "
|
||||
+ " SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.nullable = 'something', n.things = ['a', 'b'], n.place = $place "
|
||||
+ "RETURN id(n)",
|
||||
parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON1_FIRST_NAME, "cool", true, "personNumber", 1, "bornOn", TEST_PERSON1_BORN_ON, "place",
|
||||
NEO4J_HQ))
|
||||
.next().get(0).asLong();
|
||||
|
||||
id2 = transaction.run(
|
||||
"CREATE (n:PersonWithAllConstructor) SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.things = [], n.place = $place return id(n)",
|
||||
parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON2_FIRST_NAME, "cool", false, "personNumber", 2, "bornOn", TEST_PERSON2_BORN_ON, "place", SFO))
|
||||
.next().get(0).asLong();
|
||||
|
||||
transaction.run("CREATE (a:Thing {theId: 'anId', name: 'Homer'})-[:Has]->(b:Thing2{theId: 4711, name: 'Bart'})");
|
||||
IntStream.rangeClosed(1, 20).forEach(i -> transaction
|
||||
.run("CREATE (a:Thing {theId: 'id' + $i, name: 'name' + $i})", parameters("i", String.format("%02d", i))));
|
||||
.run("CREATE (a:Thing {theId: 'id' + $i, name: 'name' + $i})", Values
|
||||
.parameters("i", String.format("%02d", i))));
|
||||
|
||||
person1 = new PersonWithAllConstructor(id1, TEST_PERSON1_NAME, TEST_PERSON1_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
||||
true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, null);
|
||||
@@ -1178,7 +1207,8 @@ class ReactiveRepositoryIT {
|
||||
.expectNextCount(1L).verifyComplete();
|
||||
|
||||
Flux.usingWhen(Mono.fromSupplier(() -> createRxSession()),
|
||||
s -> s.run("MATCH (n:PersonWithAllConstructor) WHERE id(n) in $ids RETURN n", parameters("ids", ids))
|
||||
s -> s.run("MATCH (n:PersonWithAllConstructor) WHERE id(n) in $ids RETURN n", Values
|
||||
.parameters("ids", ids))
|
||||
.records(),
|
||||
RxSession::close).map(r -> r.get("n").asNode().get("first_name").asString()).as(StepVerifier::create)
|
||||
.expectNext("Freddie").verifyComplete();
|
||||
@@ -1206,7 +1236,7 @@ class ReactiveRepositoryIT {
|
||||
|
||||
Flux.usingWhen(Mono.fromSupplier(() -> createRxSession()),
|
||||
s -> s.run("MATCH (n:PersonWithAllConstructor) WHERE id(n) in $ids RETURN n ORDER BY n.name ASC",
|
||||
parameters("ids", ids)).records(),
|
||||
Values.parameters("ids", ids)).records(),
|
||||
RxSession::close).map(r -> r.get("n").asNode().get("name").asString()).as(StepVerifier::create)
|
||||
.expectNext("Mercury").expectNext(TEST_PERSON1_NAME).verifyComplete();
|
||||
}
|
||||
@@ -1226,7 +1256,7 @@ class ReactiveRepositoryIT {
|
||||
|
||||
Flux.usingWhen(Mono.fromSupplier(() -> createRxSession()),
|
||||
s -> s.run("MATCH (n:PersonWithAllConstructor) WHERE id(n) in $ids RETURN n ORDER BY n.name ASC",
|
||||
parameters("ids", ids)).records(),
|
||||
Values.parameters("ids", ids)).records(),
|
||||
RxSession::close).map(r -> r.get("n").asNode().get("name").asString()).as(StepVerifier::create)
|
||||
.expectNext("Mercury").verifyComplete();
|
||||
}
|
||||
@@ -1245,7 +1275,7 @@ class ReactiveRepositoryIT {
|
||||
.verifyComplete();
|
||||
|
||||
Flux.usingWhen(Mono.fromSupplier(() -> createRxSession()), s -> {
|
||||
Value parameters = parameters("id", id1);
|
||||
Value parameters = Values.parameters("id", id1);
|
||||
return s.run("MATCH (n:PersonWithAllConstructor) WHERE id(n) = $id RETURN n", parameters).records();
|
||||
}, RxSession::close).map(r -> r.get("n").asNode()).as(StepVerifier::create)
|
||||
.expectNextMatches(node -> node.get("first_name").asString().equals("Updated first name")
|
||||
@@ -1267,7 +1297,7 @@ class ReactiveRepositoryIT {
|
||||
.verifyComplete();
|
||||
|
||||
Flux.usingWhen(Mono.fromSupplier(() -> createRxSession()),
|
||||
s -> s.run("MATCH (n:Thing) WHERE n.theId = $id RETURN n", parameters("id", "aaBB")).records(),
|
||||
s -> s.run("MATCH (n:Thing) WHERE n.theId = $id RETURN n", Values.parameters("id", "aaBB")).records(),
|
||||
RxSession::close).map(r -> r.get("n").asNode().get("name").asString()).as(StepVerifier::create)
|
||||
.expectNext("That's the thing.").verifyComplete();
|
||||
|
||||
@@ -1293,7 +1323,7 @@ class ReactiveRepositoryIT {
|
||||
.verifyComplete();
|
||||
|
||||
Flux.usingWhen(Mono.fromSupplier(() -> createRxSession()), s -> {
|
||||
Value parameters = parameters("ids", Arrays.asList("anId", "aaBB"));
|
||||
Value parameters = Values.parameters("ids", Arrays.asList("anId", "aaBB"));
|
||||
return s.run("MATCH (n:Thing) WHERE n.theId IN ($ids) RETURN n.name as name ORDER BY n.name ASC", parameters)
|
||||
.records();
|
||||
}, RxSession::close).map(r -> r.get("name").asString()).as(StepVerifier::create).expectNext("That's the thing.")
|
||||
@@ -1320,7 +1350,7 @@ class ReactiveRepositoryIT {
|
||||
.verifyComplete();
|
||||
|
||||
Flux.usingWhen(Mono.fromSupplier(() -> createRxSession()), s -> {
|
||||
Value parameters = parameters("ids", Arrays.asList("anId", "aaBB"));
|
||||
Value parameters = Values.parameters("ids", Arrays.asList("anId", "aaBB"));
|
||||
return s.run("MATCH (n:Thing) WHERE n.theId IN ($ids) RETURN n.name as name ORDER BY n.name ASC", parameters)
|
||||
.records();
|
||||
}, RxSession::close).map(r -> r.get("name").asString()).as(StepVerifier::create).expectNext("That's the thing.")
|
||||
@@ -1352,7 +1382,7 @@ class ReactiveRepositoryIT {
|
||||
.verifyComplete();
|
||||
|
||||
Flux.usingWhen(Mono.fromSupplier(() -> createRxSession()), s -> {
|
||||
Value parameters = parameters("ids", Arrays.asList("id07", "id15"));
|
||||
Value parameters = Values.parameters("ids", Arrays.asList("id07", "id15"));
|
||||
return s.run("MATCH (n:Thing) WHERE n.theId IN ($ids) RETURN n.name as name ORDER BY n.name ASC", parameters)
|
||||
.records();
|
||||
}, RxSession::close).map(r -> r.get("name").asString()).as(StepVerifier::create)
|
||||
@@ -1404,7 +1434,7 @@ class ReactiveRepositoryIT {
|
||||
Pet pet2 = new Pet("Tom");
|
||||
Hobby petHobby = new Hobby();
|
||||
petHobby.setName("sleeping");
|
||||
pet1.setHobbies(singleton(petHobby));
|
||||
pet1.setHobbies(Collections.singleton(petHobby));
|
||||
person.setPets(Arrays.asList(pet1, pet2));
|
||||
|
||||
List<Long> ids = new ArrayList<>();
|
||||
@@ -1432,11 +1462,13 @@ class ReactiveRepositoryIT {
|
||||
pets.put(petWithHobbies.get(0), ((List<Node>) petWithHobbies.get(1)));
|
||||
}
|
||||
|
||||
assertThat(pets.keySet().stream().map(pet -> ((Node) pet).get("name").asString()).collect(toList()))
|
||||
assertThat(pets.keySet().stream().map(pet -> ((Node) pet).get("name").asString()).collect(
|
||||
Collectors.toList()))
|
||||
.containsExactlyInAnyOrder("Jerry", "Tom");
|
||||
|
||||
assertThat(pets.values().stream()
|
||||
.flatMap(petHobbies -> petHobbies.stream().map(node -> node.get("name").asString())).collect(toList()))
|
||||
.flatMap(petHobbies -> petHobbies.stream().map(node -> node.get("name").asString())).collect(
|
||||
Collectors.toList()))
|
||||
.containsExactlyInAnyOrder("sleeping");
|
||||
|
||||
assertThat(record.get("hobbies").asList(entry -> entry.asNode().get("name").asString()))
|
||||
@@ -1460,7 +1492,7 @@ class ReactiveRepositoryIT {
|
||||
Pet pet2 = new Pet("Tom");
|
||||
Hobby petHobby = new Hobby();
|
||||
petHobby.setName("sleeping");
|
||||
pet1.setHobbies(singleton(petHobby));
|
||||
pet1.setHobbies(Collections.singleton(petHobby));
|
||||
person.setPets(Arrays.asList(pet1, pet2));
|
||||
|
||||
List<Long> ids = new ArrayList<>();
|
||||
@@ -1496,11 +1528,13 @@ class ReactiveRepositoryIT {
|
||||
pets.put(petWithHobbies.get(0), ((List<Node>) petWithHobbies.get(1)));
|
||||
}
|
||||
|
||||
assertThat(pets.keySet().stream().map(pet -> ((Node) pet).get("name").asString()).collect(toList()))
|
||||
assertThat(pets.keySet().stream().map(pet -> ((Node) pet).get("name").asString()).collect(
|
||||
Collectors.toList()))
|
||||
.containsExactlyInAnyOrder("Jerry", "Tom");
|
||||
|
||||
assertThat(pets.values().stream()
|
||||
.flatMap(petHobbies -> petHobbies.stream().map(node -> node.get("name").asString())).collect(toList()))
|
||||
.flatMap(petHobbies -> petHobbies.stream().map(node -> node.get("name").asString())).collect(
|
||||
Collectors.toList()))
|
||||
.containsExactlyInAnyOrder("sleeping");
|
||||
|
||||
assertThat(record.get("hobbies").asList(entry -> entry.asNode().get("name").asString()))
|
||||
@@ -1568,16 +1602,16 @@ class ReactiveRepositoryIT {
|
||||
Pet petOfChildPet = new Pet("Mucki");
|
||||
Pet petOfGrandChildPet = new Pet("Blacky");
|
||||
|
||||
rootPet.setFriends(singletonList(petOfRootPet));
|
||||
petOfRootPet.setFriends(singletonList(petOfChildPet));
|
||||
petOfChildPet.setFriends(singletonList(petOfGrandChildPet));
|
||||
rootPet.setFriends(Collections.singletonList(petOfRootPet));
|
||||
petOfRootPet.setFriends(Collections.singletonList(petOfChildPet));
|
||||
petOfChildPet.setFriends(Collections.singletonList(petOfGrandChildPet));
|
||||
|
||||
StepVerifier.create(repository.save(rootPet)).expectNextCount(1).verifyComplete();
|
||||
|
||||
try (Session session = createSession()) {
|
||||
Record record = session.run("MATCH (rootPet:Pet)-[:Has]->(petOfRootPet:Pet)-[:Has]->(petOfChildPet:Pet)"
|
||||
+ "-[:Has]->(petOfGrandChildPet:Pet) " + "RETURN rootPet, petOfRootPet, petOfChildPet, petOfGrandChildPet",
|
||||
emptyMap()).single();
|
||||
Collections.emptyMap()).single();
|
||||
|
||||
assertThat(record.get("rootPet").asNode().get("name").asString()).isEqualTo("Luna");
|
||||
assertThat(record.get("petOfRootPet").asNode().get("name").asString()).isEqualTo("Daphne");
|
||||
@@ -1625,8 +1659,8 @@ class ReactiveRepositoryIT {
|
||||
Pet luna = new Pet("Luna");
|
||||
Pet daphne = new Pet("Daphne");
|
||||
|
||||
luna.setFriends(singletonList(daphne));
|
||||
daphne.setFriends(singletonList(luna));
|
||||
luna.setFriends(Collections.singletonList(daphne));
|
||||
daphne.setFriends(Collections.singletonList(luna));
|
||||
|
||||
StepVerifier.create(repository.save(luna)).expectNextCount(1).verifyComplete();
|
||||
|
||||
@@ -1652,14 +1686,14 @@ class ReactiveRepositoryIT {
|
||||
id1 = transaction.run("" + "CREATE (n:PersonWithAllConstructor) "
|
||||
+ " SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.nullable = 'something', n.things = ['a', 'b'], n.place = $place "
|
||||
+ "RETURN id(n)",
|
||||
parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON1_FIRST_NAME, "cool", true, "personNumber", 1, "bornOn", TEST_PERSON1_BORN_ON, "place",
|
||||
NEO4J_HQ))
|
||||
.next().get(0).asLong();
|
||||
|
||||
id2 = transaction.run(
|
||||
"CREATE (n:PersonWithAllConstructor) SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.things = [], n.place = $place return id(n)",
|
||||
parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON2_FIRST_NAME, "cool", false, "personNumber", 2, "bornOn", TEST_PERSON2_BORN_ON, "place", SFO))
|
||||
.next().get(0).asLong();
|
||||
|
||||
@@ -1760,14 +1794,14 @@ class ReactiveRepositoryIT {
|
||||
transaction.run("" + "CREATE (n:PersonWithAllConstructor) "
|
||||
+ " SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.nullable = 'something', n.things = ['a', 'b'], n.place = $place "
|
||||
+ "RETURN id(n)",
|
||||
parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON1_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON1_FIRST_NAME, "cool", true, "personNumber", 1, "bornOn", TEST_PERSON1_BORN_ON, "place",
|
||||
NEO4J_HQ))
|
||||
.next().get(0).asLong();
|
||||
|
||||
transaction.run(
|
||||
"CREATE (n:PersonWithAllConstructor) SET n.name = $name, n.sameValue = $sameValue, n.first_name = $firstName, n.cool = $cool, n.personNumber = $personNumber, n.bornOn = $bornOn, n.things = [], n.place = $place return id(n)",
|
||||
parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
Values.parameters("name", TEST_PERSON2_NAME, "sameValue", TEST_PERSON_SAMEVALUE, "firstName",
|
||||
TEST_PERSON2_FIRST_NAME, "cool", false, "personNumber", 2, "bornOn", TEST_PERSON2_BORN_ON, "place", SFO))
|
||||
.next().get(0).asLong();
|
||||
}
|
||||
@@ -1840,7 +1874,7 @@ class ReactiveRepositoryIT {
|
||||
|
||||
@Test
|
||||
void createAllNodesWithMultipleLabels(@Autowired ReactiveMultipleLabelRepository repository) {
|
||||
repository.saveAll(singletonList(new MultipleLabels.MultipleLabelsEntity())).collectList().block();
|
||||
repository.saveAll(Collections.singletonList(new MultipleLabels.MultipleLabelsEntity())).collectList().block();
|
||||
|
||||
try (Session session = createSession()) {
|
||||
Node node = session.run("MATCH (n:A) return n").single().get("n").asNode();
|
||||
@@ -1922,7 +1956,7 @@ class ReactiveRepositoryIT {
|
||||
@Test
|
||||
void createAllNodesWithMultipleLabels(@Autowired ReactiveMultipleLabelWithAssignedIdRepository repository) {
|
||||
|
||||
repository.saveAll(singletonList(new MultipleLabels.MultipleLabelsEntityWithAssignedId(4711L))).collectList()
|
||||
repository.saveAll(Collections.singletonList(new MultipleLabels.MultipleLabelsEntityWithAssignedId(4711L))).collectList()
|
||||
.block();
|
||||
|
||||
try (Session session = createSession()) {
|
||||
@@ -2181,7 +2215,7 @@ class ReactiveRepositoryIT {
|
||||
|
||||
@Override
|
||||
protected Collection<String> getMappingBasePackages() {
|
||||
return singletonList(PersonWithAllConstructor.class.getPackage().getName());
|
||||
return Collections.singletonList(PersonWithAllConstructor.class.getPackage().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,21 +15,20 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.neo4j.driver.Session;
|
||||
import org.neo4j.driver.SessionConfig;
|
||||
import org.springframework.data.neo4j.core.DatabaseSelection;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(COMMERCIAL_EDITION_ONLY)
|
||||
@Tag(REQUIRES + "4.0.0")
|
||||
@Tag(Neo4jExtension.COMMERCIAL_EDITION_ONLY)
|
||||
@Tag(Neo4jExtension.REQUIRES + "4.0.0")
|
||||
@DirtiesContext
|
||||
class ReactiveRepositoryWithADifferentDatabaseIT extends ReactiveRepositoryIT {
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assumptions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -41,13 +40,14 @@ import org.springframework.data.neo4j.integration.shared.PersonWithStringlyTyped
|
||||
import org.springframework.data.neo4j.integration.shared.Pet;
|
||||
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.test.Neo4jExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* @author Michael J. Simons
|
||||
*/
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveStringlyTypeDynamicRelationshipsIT extends DynamicRelationshipsITBase<PersonWithStringlyTypedRelatives> {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.reactive;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.neo4j.test.Neo4jExtension.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -51,7 +50,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@ExtendWith(Neo4jExtension.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
@Tag(NEEDS_REACTIVE_SUPPORT)
|
||||
@Tag(Neo4jExtension.NEEDS_REACTIVE_SUPPORT)
|
||||
class ReactiveTypeConversionIT {
|
||||
|
||||
protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.shared;
|
||||
|
||||
import static org.springframework.data.neo4j.core.schema.Relationship.Direction.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -34,7 +32,7 @@ public class AltHobby {
|
||||
|
||||
private String name;
|
||||
|
||||
@Relationship(type = "LIKES", direction = INCOMING)
|
||||
@Relationship(type = "LIKES", direction = Relationship.Direction.INCOMING)
|
||||
private Map<AltPerson, AltLikedByPersonRelationship> likedBy = new HashMap<>();
|
||||
|
||||
public Long getId() {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.shared;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.shared;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -60,9 +60,9 @@ public abstract class CallbacksITBase {
|
||||
protected void verifyDatabase(Iterable<ThingWithAssignedId> expectedValues) {
|
||||
|
||||
List<String> ids = StreamSupport.stream(expectedValues.spliterator(), false).map(ThingWithAssignedId::getTheId)
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
List<String> names = StreamSupport.stream(expectedValues.spliterator(), false).map(ThingWithAssignedId::getName)
|
||||
.collect(toList());
|
||||
.collect(Collectors.toList());
|
||||
try (Session session = driver.session()) {
|
||||
Record record = session
|
||||
.run("MATCH (n:Thing) WHERE n.theId in $ids RETURN COLLECT(n) as things", Values.parameters("ids", ids))
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.shared;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.neo4j.driver.Driver;
|
||||
|
||||
@@ -19,8 +19,26 @@ import lombok.Builder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.time.*;
|
||||
import java.util.*;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.OffsetTime;
|
||||
import java.time.Period;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.neo4j.driver.Session;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user