DATAGRAPH-1425 - Add strict entity support.

This commit is contained in:
Gerrit Meier
2020-11-09 13:47:58 +01:00
parent fa6a1aaede
commit 0a95db2ddd
128 changed files with 876 additions and 792 deletions

View File

@@ -25,9 +25,11 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -115,6 +117,8 @@ abstract class Neo4jConfigurationSupport {
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Node.class));
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
componentProvider.addIncludeFilter(new AnnotationTypeFilter(RelationshipProperties.class));
ClassLoader classLoader = Neo4jConfigurationSupport.class.getClassLoader();
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {

View File

@@ -29,6 +29,7 @@ import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.PropertyHandler;
import org.springframework.data.mapping.model.BasicPersistentEntity;
@@ -89,7 +90,7 @@ final class DefaultNeo4jPersistentEntity<T> extends BasicPersistentEntity<T, Neo
DefaultNeo4jPersistentEntity(TypeInformation<T> information) {
super(information);
this.isExplicitEntity = this.isAnnotationPresent(Node.class);
this.isExplicitEntity = this.isAnnotationPresent(Node.class) || this.isAnnotationPresent(Persistent.class);
this.primaryLabel = computePrimaryLabel();
this.additionalLabels = Lazy.of(this::computeAdditionalLabels);
this.graphProperties = Lazy.of(this::computeGraphProperties);

View File

@@ -23,6 +23,7 @@ import org.neo4j.driver.Values;
import org.springframework.data.mapping.Association;
import org.springframework.data.mapping.MappingException;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.SimpleTypeHolder;
@@ -95,31 +96,30 @@ final class DefaultNeo4jPersistentProperty extends AnnotationBasedPersistentProp
Class<?> type = getRelationshipPropertiesTargetType(getActualType());
obverseOwner = this.mappingContext.getPersistentEntity(type);
relationshipPropertiesClass = this.mappingContext.getPersistentEntity(getActualType());
} else if (dynamicAssociation) {
TypeInformation<?> mapValueType = this.getTypeInformation().getMapValueType();
boolean relationshipPropertiesCollection =
this.mappingContext.getPersistentEntity(mapValueType.getActualType().getType())
.isRelationshipPropertiesEntity();
boolean relationshipPropertiesScalar =
mapValueType.getType().isAnnotationPresent(RelationshipProperties.class);
if (relationshipPropertiesCollection) {
Class<?> type = getRelationshipPropertiesTargetType(mapValueType.getActualType().getType());
obverseOwner = this.mappingContext.getPersistentEntity(type);
relationshipPropertiesClass = this.mappingContext
.getPersistentEntity(mapValueType.getComponentType().getType());
} else if (relationshipPropertiesScalar) {
obverseOwner = this.mappingContext.getPersistentEntity(this.getAssociationTargetType());
relationshipPropertiesClass = this.mappingContext.getPersistentEntity(mapValueType.getType());
} else {
obverseOwner = this.mappingContext.getPersistentEntity(this.getAssociationTargetType());
}
} else {
obverseOwner = this.mappingContext.getPersistentEntity(this.getAssociationTargetType());
Class<?> associationTargetType = this.getAssociationTargetType();
obverseOwner = this.mappingContext.addPersistentEntity(associationTargetType).get();
if (dynamicAssociation) {
TypeInformation<?> mapValueType = this.getTypeInformation().getMapValueType();
boolean relationshipPropertiesCollection =
this.mappingContext.getPersistentEntity(mapValueType.getActualType().getType())
.isRelationshipPropertiesEntity();
boolean relationshipPropertiesScalar =
mapValueType.getType().isAnnotationPresent(RelationshipProperties.class);
if (relationshipPropertiesCollection) {
Class<?> type = getRelationshipPropertiesTargetType(mapValueType.getActualType().getType());
obverseOwner = this.mappingContext.getPersistentEntity(type);
relationshipPropertiesClass = this.mappingContext
.getPersistentEntity(mapValueType.getComponentType().getType());
} else if (relationshipPropertiesScalar) {
relationshipPropertiesClass = this.mappingContext.getPersistentEntity(mapValueType.getType());
}
}
}
Relationship outgoingRelationship = this.findAnnotation(Relationship.class);
@@ -154,12 +154,11 @@ final class DefaultNeo4jPersistentProperty extends AnnotationBasedPersistentProp
@NonNull
private Class<?> getRelationshipPropertiesTargetType(Class<?> relationshipPropertiesType) {
Neo4jPersistentProperty persistentProperty = this.mappingContext.getPersistentEntity(relationshipPropertiesType)
.getPersistentProperty(TargetNode.class);
if (persistentProperty == null) {
throw new MappingException("Missing @TargetNode declaration in " + relationshipPropertiesType);
}
return persistentProperty.getType();
return this.mappingContext.addPersistentEntity(relationshipPropertiesType)
.map(entity -> entity.getPersistentProperty(TargetNode.class))
.map(PersistentProperty::getType)
.orElseThrow(
() -> new MappingException("Missing @TargetNode declaration in " + relationshipPropertiesType));
}
@Override

View File

@@ -179,11 +179,11 @@ public final class Neo4jMappingContext extends AbstractMappingContext<Neo4jPersi
Class<? super T> superclass = typeInformation.getType().getSuperclass();
if (isValidParentNode(superclass)) {
Neo4jPersistentEntity<?> parentNodeDescription = getPersistentEntity(superclass);
if (parentNodeDescription != null) {
addPersistentEntity(superclass).ifPresent(parentNodeDescription -> {
parentNodeDescription.addChildNodeDescription(newEntity);
newEntity.setParentNodeDescription(parentNodeDescription);
}
});
}
return newEntity;

View File

@@ -16,13 +16,16 @@
package org.springframework.data.neo4j.repository.config;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import org.apiguardian.api.API;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactoryBean;
import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport;
@@ -83,7 +86,7 @@ public final class Neo4jRepositoryConfigurationExtension extends RepositoryConfi
@Override
protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() {
return Collections.singleton(Node.class);
return Arrays.asList(Node.class, RelationshipProperties.class, Persistent.class);
}
@Override

View File

@@ -16,13 +16,16 @@
package org.springframework.data.neo4j.repository.config;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import org.apiguardian.api.API;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.support.ReactiveNeo4jRepositoryFactoryBean;
import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport;
@@ -83,7 +86,7 @@ public final class ReactiveNeo4jRepositoryConfigurationExtension extends Reposit
@Override
protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() {
return Collections.singleton(Node.class);
return Arrays.asList(Node.class, RelationshipProperties.class, Persistent.class);
}
@Override

View File

@@ -74,7 +74,8 @@ class DtoInstantiatingConverter implements Converter<EntityInstanceWithSource, O
PersistentEntity<?, ?> sourceEntity = context.getRequiredPersistentEntity(entityInstance.getClass());
PersistentPropertyAccessor sourceAccessor = sourceEntity.getPropertyAccessor(entityInstance);
PersistentEntity<?, ?> targetEntity = context.getRequiredPersistentEntity(targetType);
PersistentEntity<?, ?> targetEntity = context.addPersistentEntity(targetType).get();
PreferredConstructor<?, ? extends PersistentProperty<?>> constructor = targetEntity
.getPersistenceConstructor();

View File

@@ -386,6 +386,7 @@ class DefaultNeo4jPersistentEntityTest {
private String name;
}
@Node
static class TypeWithInvalidDynamicRelationshipMappings1 {
@Id private String id;
@@ -395,6 +396,7 @@ class DefaultNeo4jPersistentEntityTest {
private Map<String, Neo4jMappingContextTest.BikeNode> bikes2;
}
@Node
static class TypeWithInvalidDynamicRelationshipMappings2 {
@Id private String id;
@@ -404,6 +406,7 @@ class DefaultNeo4jPersistentEntityTest {
private Map<String, List<Neo4jMappingContextTest.BikeNode>> bikes2;
}
@Node
static class TypeWithInvalidDynamicRelationshipMappings3 {
@Id private String id;
@@ -413,11 +416,13 @@ class DefaultNeo4jPersistentEntityTest {
private Map<String, List<Neo4jMappingContextTest.BikeNode>> bikes2;
}
@Node
static class EntityWithCorrectRelationshipProperties {
@Id private String id;
@Relationship HasTargetNodeRelationshipProperties rel;
}
@Node
static class EntityWithInCorrectRelationshipProperties {
@Id private String id;
@Relationship HasNoTargetNodeRelationshipProperties rel;

View File

@@ -298,6 +298,7 @@ class Neo4jMappingContextTest {
@Property(name = "firstName") String first_name;
}
@Node
static class SomeOtherClass {
}
@@ -318,6 +319,7 @@ class Neo4jMappingContextTest {
}
}
@Node
static class BikeNode {
@Id private String id;
@@ -334,6 +336,7 @@ class Neo4jMappingContextTest {
Map<String, Object> funnyDynamicProperties;
}
@Node
static class EnumRelNode {
@Id private String id;
@@ -343,6 +346,7 @@ class Neo4jMappingContextTest {
Map<ExtendedA, BikeNode> relEA;
}
@Node
static class TripNode {
@Id private String id;
@@ -350,11 +354,13 @@ class Neo4jMappingContextTest {
String name;
}
@Node
static class InvalidId {
@Id @GeneratedValue @Property("getMappingFunctionFor") private String id;
}
@Node
static class InvalidIdType {
@Id @GeneratedValue private String id;

View File

@@ -0,0 +1,214 @@
/*
* Copyright 2011-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.conversion_imperative;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.neo4j.driver.Driver;
import org.neo4j.driver.Result;
import org.neo4j.driver.Session;
import org.neo4j.driver.SessionConfig;
import org.neo4j.driver.TransactionWork;
import org.neo4j.driver.Values;
import org.neo4j.driver.summary.ResultSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.core.Neo4jOperations;
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
import org.springframework.data.neo4j.integration.shared.conversion.PersonWithCustomId;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCustomTypes;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.neo4j.test.Neo4jExtension.Neo4jConnectionSupport;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author Gerrit Meier
*/
@Neo4jIntegrationTest
public class CustomTypesIT {
protected static Neo4jConnectionSupport neo4jConnectionSupport;
private final AtomicLong customIdValueGenerator = new AtomicLong();
private final Driver driver;
private final Neo4jOperations neo4jOperations;
@Autowired
public CustomTypesIT(Driver driver, Neo4jOperations neo4jOperations) {
this.driver = driver;
this.neo4jOperations = neo4jOperations;
}
SessionConfig getSessionConfig() {
return SessionConfig.defaultConfig();
}
TransactionWork<ResultSummary> createPersonWithCustomId(PersonWithCustomId.PersonId assignedId) {
return tx -> tx.run("CREATE (n:PersonWithCustomId) SET n.id = $id ",
Values.parameters("id", assignedId.getId())).consume();
}
@BeforeEach
void setupData() {
try (Session session = driver.session()) {
session.writeTransaction(transaction -> {
transaction.run("MATCH (n) detach delete n").consume();
transaction.run("CREATE (:CustomTypes{customType:'XYZ'})").consume();
return null;
});
}
}
@Test
void deleteByCustomId() {
PersonWithCustomId.PersonId id = new PersonWithCustomId.PersonId(customIdValueGenerator.incrementAndGet());
try (Session session = driver.session(getSessionConfig())) {
session.writeTransaction(createPersonWithCustomId(id));
}
assertThat(neo4jOperations.count(PersonWithCustomId.class)).isEqualTo(1L);
neo4jOperations.deleteById(id, PersonWithCustomId.class);
try (Session session = driver.session(getSessionConfig())) {
Result result = session.run("MATCH (p:PersonWithCustomId) return count(p) as count");
assertThat(result.single().get("count").asLong()).isEqualTo(0);
}
}
@Test
void deleteAllByCustomId() {
List<PersonWithCustomId.PersonId> ids = Stream.generate(customIdValueGenerator::incrementAndGet)
.map(PersonWithCustomId.PersonId::new)
.limit(2)
.collect(Collectors.toList());
try (
Session session = driver.session(getSessionConfig());
) {
ids.forEach(id -> session.writeTransaction(createPersonWithCustomId(id)));
}
assertThat(neo4jOperations.count(PersonWithCustomId.class)).isEqualTo(2L);
neo4jOperations.deleteAllById(ids, PersonWithCustomId.class);
try (Session session = driver.session(getSessionConfig())) {
Result result = session.run("MATCH (p:PersonWithCustomId) return count(p) as count");
assertThat(result.single().get("count").asLong()).isEqualTo(0);
}
}
@Test
void findByConvertedCustomType(@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByCustomType(ThingWithCustomTypes.CustomType.of("XYZ"))).isNotNull();
}
@Test
void findByConvertedCustomTypeWithCustomQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByCustomTypeCustomQuery(ThingWithCustomTypes.CustomType.of("XYZ"))).isNotNull();
}
@Test
void findByConvertedCustomTypeWithSpELPropertyAccessQuery(
@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByCustomTypeCustomSpELPropertyAccessQuery(ThingWithCustomTypes.CustomType.of("XYZ")))
.isNotNull();
}
@Test
void findByConvertedCustomTypeWithSpELObjectQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByCustomTypeSpELObjectQuery(ThingWithCustomTypes.CustomType.of("XYZ"))).isNotNull();
}
@Test
void findByConvertedDifferentTypeWithSpELObjectQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByDifferentTypeCustomQuery(ThingWithCustomTypes.DifferentType.of("XYZ"))).isNotNull();
}
interface EntityWithCustomTypePropertyRepository extends Neo4jRepository<ThingWithCustomTypes, Long> {
ThingWithCustomTypes findByCustomType(ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = $customType return c")
ThingWithCustomTypes findByCustomTypeCustomQuery(@Param("customType") ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = $differentType return c")
ThingWithCustomTypes findByDifferentTypeCustomQuery(
@Param("differentType") ThingWithCustomTypes.DifferentType differentType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = :#{#customType.value} return c")
ThingWithCustomTypes findByCustomTypeCustomSpELPropertyAccessQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = :#{#customType} return c")
ThingWithCustomTypes findByCustomTypeSpELObjectQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
}
@Configuration
@EnableTransactionManagement
@EnableNeo4jRepositories(considerNestedRepositories = true)
static class Config extends AbstractNeo4jConfig {
@Bean
@Override
public Driver driver() {
return neo4jConnectionSupport.getDriver();
}
@Bean
@Override
public Neo4jConversions neo4jConversions() {
Set<GenericConverter> additionalConverters = new HashSet<>();
additionalConverters.add(new ThingWithCustomTypes.CustomTypeConverter());
additionalConverters.add(new ThingWithCustomTypes.DifferentTypeConverter());
additionalConverters.add(new PersonWithCustomId.CustomPersonIdConverter());
return new Neo4jConversions(additionalConverters);
}
@Override // needed here because there is no implicit registration of entities upfront some methods under test
protected Collection<String> getMappingBasePackages() {
return Collections.singletonList(ThingWithCustomTypes.class.getPackage().getName());
}
}
}

View File

@@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.imperative;
package org.springframework.data.neo4j.integration.conversion_imperative;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.neo4j.driver.Driver;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,15 +24,17 @@ 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.convert.Neo4jConversions;
import org.springframework.data.neo4j.integration.shared.CompositePropertiesITBase;
import org.springframework.data.neo4j.integration.shared.ThingWithCompositeProperties;
import org.springframework.data.neo4j.integration.shared.ThingWithCustomTypes;
import org.springframework.data.neo4j.integration.shared.conversion.CompositePropertiesITBase;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCompositeProperties;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCustomTypes;
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.transaction.annotation.EnableTransactionManagement;
import java.util.Collections;
/**
* @author Michael J. Simons
* @soundtrack Die Toten Hosen - Learning English, Lesson Two

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration;
package org.springframework.data.neo4j.integration.conversion_imperative;
import static org.assertj.core.api.Assertions.assertThat;
@@ -41,7 +41,7 @@ import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.data.convert.ConverterBuilder;
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
import org.springframework.data.neo4j.integration.shared.Neo4jConversionsITBase;
import org.springframework.data.neo4j.integration.shared.conversion.Neo4jConversionsITBase;
import org.springframework.data.neo4j.test.Neo4jExtension;
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.imperative;
package org.springframework.data.neo4j.integration.conversion_imperative;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -55,14 +55,14 @@ import org.springframework.data.mapping.MappingException;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.core.convert.ConvertWith;
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
import org.springframework.data.neo4j.integration.shared.Neo4jConversionsITBase;
import org.springframework.data.neo4j.integration.shared.ThingWithAllAdditionalTypes;
import org.springframework.data.neo4j.integration.shared.ThingWithAllCypherTypes;
import org.springframework.data.neo4j.integration.shared.ThingWithAllSpatialTypes;
import org.springframework.data.neo4j.integration.shared.ThingWithCompositeProperties;
import org.springframework.data.neo4j.integration.shared.ThingWithCustomTypes;
import org.springframework.data.neo4j.integration.shared.ThingWithNonExistingPrimitives;
import org.springframework.data.neo4j.integration.shared.ThingWithUUIDID;
import org.springframework.data.neo4j.integration.shared.conversion.Neo4jConversionsITBase;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithAllAdditionalTypes;
import org.springframework.data.neo4j.integration.shared.common.ThingWithAllCypherTypes;
import org.springframework.data.neo4j.integration.shared.common.ThingWithAllSpatialTypes;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCompositeProperties;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCustomTypes;
import org.springframework.data.neo4j.integration.shared.common.ThingWithNonExistingPrimitives;
import org.springframework.data.neo4j.integration.shared.common.ThingWithUUIDID;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;

View File

@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.reactive;
package org.springframework.data.neo4j.integration.conversion_reactive;
import static org.assertj.core.api.Assertions.assertThat;
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCustomTypes;
import reactor.test.StepVerifier;
import java.util.ArrayList;
@@ -30,10 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
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.convert.Neo4jConversions;
import org.springframework.data.neo4j.integration.shared.CompositePropertiesITBase;
import org.springframework.data.neo4j.integration.shared.ThingWithCompositeProperties;
import org.springframework.data.neo4j.integration.shared.ThingWithCustomTypes;
import org.springframework.data.neo4j.integration.shared.conversion.CompositePropertiesITBase;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCompositeProperties;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;
@@ -118,5 +118,6 @@ class ReactiveCompositePropertiesIT extends CompositePropertiesITBase {
public Neo4jConversions neo4jConversions() {
return new Neo4jConversions(Collections.singleton(new ThingWithCustomTypes.CustomTypeConverter()));
}
}
}

View File

@@ -0,0 +1,206 @@
/*
* Copyright 2011-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.conversion_reactive;
import static org.assertj.core.api.Assertions.assertThat;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.neo4j.driver.Driver;
import org.neo4j.driver.Result;
import org.neo4j.driver.Session;
import org.neo4j.driver.SessionConfig;
import org.neo4j.driver.TransactionWork;
import org.neo4j.driver.Values;
import org.neo4j.driver.summary.ResultSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.core.ReactiveNeo4jOperations;
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
import org.springframework.data.neo4j.integration.shared.conversion.PersonWithCustomId;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCustomTypes;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.neo4j.test.Neo4jExtension;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author Gerrit Meier
*/
@Neo4jIntegrationTest
public class ReactiveCustomTypesIT {
protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
private final AtomicLong customIdValueGenerator = new AtomicLong();
private final Driver driver;
private final ReactiveNeo4jOperations neo4jOperations;
@Autowired
public ReactiveCustomTypesIT(Driver driver, ReactiveNeo4jOperations neo4jOperations) {
this.driver = driver;
this.neo4jOperations = neo4jOperations;
}
@BeforeEach
void setup() {
try (Session session = driver.session()) {
session.writeTransaction(transaction -> {
transaction.run("MATCH (n) detach delete n");
transaction.run("CREATE (:CustomTypes{customType:'XYZ'})");
return null;
});
}
}
SessionConfig getSessionConfig() {
return SessionConfig.defaultConfig();
}
@Test
void findByConvertedCustomType(@Autowired EntityWithCustomTypePropertyRepository repository) {
StepVerifier.create(repository.findByCustomType(ThingWithCustomTypes.CustomType.of("XYZ"))).expectNextCount(1)
.verifyComplete();
}
@Test
void findByConvertedCustomTypeWithCustomQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
StepVerifier.create(repository.findByCustomTypeCustomQuery(ThingWithCustomTypes.CustomType.of("XYZ")))
.expectNextCount(1).verifyComplete();
}
@Test
void findByConvertedCustomTypeWithSpELPropertyAccessQuery(
@Autowired EntityWithCustomTypePropertyRepository repository) {
StepVerifier
.create(repository.findByCustomTypeCustomSpELPropertyAccessQuery(ThingWithCustomTypes.CustomType.of("XYZ")))
.expectNextCount(1).verifyComplete();
}
@Test
void findByConvertedCustomTypeWithSpELObjectQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
StepVerifier.create(repository.findByCustomTypeSpELObjectQuery(ThingWithCustomTypes.CustomType.of("XYZ")))
.expectNextCount(1).verifyComplete();
}
TransactionWork<ResultSummary> createPersonWithCustomId(PersonWithCustomId.PersonId assignedId) {
return tx -> tx.run("CREATE (n:PersonWithCustomId) SET n.id = $id ", Values.parameters("id", assignedId.getId()))
.consume();
}
@Test
void deleteByCustomId() {
PersonWithCustomId.PersonId id = new PersonWithCustomId.PersonId(customIdValueGenerator.incrementAndGet());
try (Session session = driver.session(getSessionConfig())) {
session.writeTransaction(createPersonWithCustomId(id));
}
StepVerifier.create(neo4jOperations.count(PersonWithCustomId.class)).expectNext(1L).verifyComplete();
StepVerifier.create(neo4jOperations.deleteById(id, PersonWithCustomId.class)).verifyComplete();
try (Session session = driver.session(getSessionConfig())) {
Result result = session.run("MATCH (p:PersonWithCustomId) return count(p) as count");
assertThat(result.single().get("count").asLong()).isEqualTo(0);
}
}
@Test
void deleteAllByCustomId() {
List<PersonWithCustomId.PersonId> ids = Stream.generate(customIdValueGenerator::incrementAndGet)
.map(PersonWithCustomId.PersonId::new).limit(2).collect(Collectors.toList());
try (Session session = driver.session(getSessionConfig());) {
ids.forEach(id -> session.writeTransaction(createPersonWithCustomId(id)));
}
StepVerifier.create(neo4jOperations.count(PersonWithCustomId.class)).expectNext(2L).verifyComplete();
StepVerifier.create(neo4jOperations.deleteAllById(ids, PersonWithCustomId.class)).verifyComplete();
try (Session session = driver.session(getSessionConfig())) {
Result result = session.run("MATCH (p:PersonWithCustomId) return count(p) as count");
assertThat(result.single().get("count").asLong()).isEqualTo(0);
}
}
interface EntityWithCustomTypePropertyRepository extends ReactiveNeo4jRepository<ThingWithCustomTypes, Long> {
Mono<ThingWithCustomTypes> findByCustomType(ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = $customType return c")
Mono<ThingWithCustomTypes> findByCustomTypeCustomQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = :#{#customType.value} return c")
Mono<ThingWithCustomTypes> findByCustomTypeCustomSpELPropertyAccessQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = :#{#customType} return c")
Mono<ThingWithCustomTypes> findByCustomTypeSpELObjectQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
}
@Configuration
@EnableReactiveNeo4jRepositories(considerNestedRepositories = true)
@EnableTransactionManagement
static class Config extends AbstractReactiveNeo4jConfig {
@Bean
public Driver driver() {
return neo4jConnectionSupport.getDriver();
}
@Override
protected Collection<String> getMappingBasePackages() {
return Collections.singletonList(ThingWithCustomTypes.class.getPackage().getName());
}
@Override
public Neo4jConversions neo4jConversions() {
Set<GenericConverter> additionalConverters = new HashSet<>();
additionalConverters.add(new ThingWithCustomTypes.CustomTypeConverter());
additionalConverters.add(new ThingWithCustomTypes.DifferentTypeConverter());
additionalConverters.add(new PersonWithCustomId.CustomPersonIdConverter());
return new Neo4jConversions(additionalConverters);
}
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.reactive;
package org.springframework.data.neo4j.integration.conversion_reactive;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,8 +33,8 @@ 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.convert.Neo4jConversions;
import org.springframework.data.neo4j.integration.shared.ThingWithCustomTypes;
import org.springframework.data.neo4j.integration.shared.ThingWithUUIDID;
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCustomTypes;
import org.springframework.data.neo4j.integration.shared.common.ThingWithUUIDID;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -17,6 +17,8 @@ package org.springframework.data.neo4j.integration.imperative;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import org.junit.jupiter.api.Test;
@@ -28,9 +30,9 @@ import org.springframework.data.auditing.DateTimeProvider;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.config.EnableNeo4jAuditing;
import org.springframework.data.neo4j.integration.shared.AuditingITBase;
import org.springframework.data.neo4j.integration.shared.ImmutableAuditableThing;
import org.springframework.data.neo4j.integration.shared.ImmutableAuditableThingWithGeneratedId;
import org.springframework.data.neo4j.integration.shared.common.AuditingITBase;
import org.springframework.data.neo4j.integration.shared.common.ImmutableAuditableThing;
import org.springframework.data.neo4j.integration.shared.common.ImmutableAuditableThingWithGeneratedId;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -136,6 +138,11 @@ class AuditingIT extends AuditingITBase {
return () -> Optional.of("A user");
}
@Override
protected Collection<String> getMappingBasePackages() {
return Collections.singleton(ImmutableAuditableThing.class.getPackage().getName());
}
@Bean
public DateTimeProvider fixedDateTimeProvider() {
return () -> Optional.of(DEFAULT_CREATION_AND_MODIFICATION_DATE);

View File

@@ -27,8 +27,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.integration.imperative.repositories.ThingRepository;
import org.springframework.data.neo4j.integration.shared.CallbacksITBase;
import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.CallbacksITBase;
import org.springframework.data.neo4j.integration.shared.common.ThingWithAssignedId;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.repository.event.BeforeBindCallback;
import org.springframework.transaction.annotation.EnableTransactionManagement;

View File

@@ -41,7 +41,7 @@ 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.Neo4jClient;
import org.springframework.data.neo4j.integration.shared.ThingWithSequence;
import org.springframework.data.neo4j.integration.shared.common.ThingWithSequence;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.test.CausalClusterIntegrationTest;

View File

@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.core.Neo4jOperations;
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.repository.support.Neo4jEntityInformation;

View File

@@ -1,145 +0,0 @@
/*
* Copyright 2011-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.imperative;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import org.junit.jupiter.api.Test;
import org.neo4j.driver.Driver;
import org.springframework.beans.factory.annotation.Autowired;
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.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.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;
/**
* @author Davide Fantuzzi
* @author Andrea Santurbano
*/
@Neo4jIntegrationTest
class DefaultNeo4jEntityConverterIT {
protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
@Test
void itShouldReturnsAllTheRelatedEntities(@Autowired Entity2Repository entity2Repository) {
Entity1 firstEntity1 = new Entity1("1-2-3");
Entity1 secondEntity1 = new Entity1("4-5-6");
Set<Entity1> entity1List = new HashSet<>(Arrays.asList(firstEntity1, secondEntity1));
Entity2 entity2 = new Entity2("7-8-9", entity1List);
entity2Repository.save(entity2);
Optional<Entity2> optionalEntity2 = entity2Repository.findById(entity2.id);
assertThat(optionalEntity2).isPresent();
assertThat(optionalEntity2).map(e -> e.entity1List).contains(entity1List);
}
@Node
private static class Entity1 {
@Id @Property("my_internal_id") private final String id;
Entity1(String id) {
this.id = id;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Entity1 entity1 = (Entity1) o;
return Objects.equals(id, entity1.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return "Entity1{" + "id='" + id + '\'' + '}';
}
}
@Node
private static class Entity2 {
@Id private final String id;
@Relationship(value = "REL", direction = Relationship.Direction.INCOMING) private final Set<Entity1> entity1List;
Entity2(String id, Set<Entity1> entity1List) {
this.id = id;
this.entity1List = entity1List;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Entity2 entity2 = (Entity2) o;
return Objects.equals(id, entity2.id) && Objects.equals(entity1List, entity2.entity1List);
}
@Override
public int hashCode() {
return Objects.hash(id, entity1List);
}
@Override
public String toString() {
return "Entity2{" + "id='" + id + '\'' + ", entity1List=" + entity1List + '}';
}
}
@Repository
interface Entity2Repository extends Neo4jRepository<Entity2, String> {}
@Configuration
@EnableNeo4jRepositories(considerNestedRepositories = true)
@EnableTransactionManagement
static class Config extends AbstractNeo4jConfig {
@Bean
public Driver driver() {
return neo4jConnectionSupport.getDriver();
}
}
}

View File

@@ -44,16 +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.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.integration.shared.common.EntitiesWithDynamicLabels.DynamicLabelsWithMultipleNodeLabels;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.DynamicLabelsWithNodeLabel;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.ExtendedBaseClass1;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.InheritedSimpleDynamicLabels;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabels;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsCtor;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessId;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessIdAndVersion;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithVersion;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SuperNode;
import org.springframework.data.neo4j.test.Neo4jExtension;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

View File

@@ -31,18 +31,18 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.Club;
import org.springframework.data.neo4j.integration.shared.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.DynamicRelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.Hobby;
import org.springframework.data.neo4j.integration.shared.HobbyRelationship;
import org.springframework.data.neo4j.integration.shared.Person;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.TypeOfClub;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.TypeOfHobby;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.TypeOfPet;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.TypeOfRelative;
import org.springframework.data.neo4j.integration.shared.Pet;
import org.springframework.data.neo4j.integration.shared.common.Club;
import org.springframework.data.neo4j.integration.shared.common.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.common.DynamicRelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.common.Hobby;
import org.springframework.data.neo4j.integration.shared.common.HobbyRelationship;
import org.springframework.data.neo4j.integration.shared.common.Person;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives.TypeOfClub;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives.TypeOfHobby;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives.TypeOfPet;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives.TypeOfRelative;
import org.springframework.data.neo4j.integration.shared.common.Pet;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.CrudRepository;

View File

@@ -36,9 +36,7 @@ import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.integration.shared.common.SimplePerson;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator;
@@ -110,22 +108,6 @@ class ExceptionTranslationIT {
"Node\\(\\d+\\) already exists with label `SimplePerson` and property `name` = '[\\w\\s]+'; Error code 'Neo.ClientError.Schema.ConstraintValidationFailed'");
}
@Node
static class SimplePerson {
@Id @GeneratedValue private Long id;
private String name;
SimplePerson(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
interface SimplePersonRepository extends Neo4jRepository<SimplePerson, Long> {}
@Repository

View File

@@ -30,9 +30,9 @@ 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.schema.IdGenerator;
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.integration.shared.common.IdGeneratorsITBase;
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.integration.shared.common.ThingWithIdGeneratedByBean;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.EnableTransactionManagement;

View File

@@ -24,10 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -41,19 +38,15 @@ import org.neo4j.driver.Result;
import org.neo4j.driver.Session;
import org.neo4j.driver.SessionConfig;
import org.neo4j.driver.Transaction;
import org.neo4j.driver.TransactionWork;
import org.neo4j.driver.Value;
import org.neo4j.driver.Values;
import org.neo4j.driver.summary.ResultSummary;
import org.springframework.beans.factory.annotation.Autowired;
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.Neo4jOperations;
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.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.test.Neo4jExtension.Neo4jConnectionSupport;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -73,7 +66,6 @@ class Neo4jOperationsIT {
private final Driver driver;
private final Neo4jOperations neo4jOperations;
private final AtomicLong customIdValueGenerator = new AtomicLong();
private Long person1Id;
private Long person2Id;
@@ -288,50 +280,6 @@ class Neo4jOperationsIT {
}
}
TransactionWork<ResultSummary> createPersonWithCustomId(PersonWithCustomId.PersonId assignedId) {
return tx -> tx.run("CREATE (n:PersonWithCustomId) SET n.id = $id ",
Values.parameters("id", assignedId.getId())).consume();
}
@Test
void deleteByCustomId() {
PersonWithCustomId.PersonId id = new PersonWithCustomId.PersonId(customIdValueGenerator.incrementAndGet());
try (Session session = driver.session(getSessionConfig())) {
session.writeTransaction(createPersonWithCustomId(id));
}
assertThat(neo4jOperations.count(PersonWithCustomId.class)).isEqualTo(1L);
neo4jOperations.deleteById(id, PersonWithCustomId.class);
try (Session session = driver.session(getSessionConfig())) {
Result result = session.run("MATCH (p:PersonWithCustomId) return count(p) as count");
assertThat(result.single().get("count").asLong()).isEqualTo(0);
}
}
@Test
void deleteAllByCustomId() {
List<PersonWithCustomId.PersonId> ids = Stream.generate(customIdValueGenerator::incrementAndGet)
.map(PersonWithCustomId.PersonId::new)
.limit(2)
.collect(Collectors.toList());
try (
Session session = driver.session(getSessionConfig());
) {
ids.forEach(id -> session.writeTransaction(createPersonWithCustomId(id)));
}
assertThat(neo4jOperations.count(PersonWithCustomId.class)).isEqualTo(2L);
neo4jOperations.deleteAllById(ids, PersonWithCustomId.class);
try (Session session = driver.session(getSessionConfig())) {
Result result = session.run("MATCH (p:PersonWithCustomId) return count(p) as count");
assertThat(result.single().get("count").asLong()).isEqualTo(0);
}
}
@Configuration
@EnableTransactionManagement
@@ -343,11 +291,11 @@ class Neo4jOperationsIT {
return neo4jConnectionSupport.getDriver();
}
@Bean
@Override
public Neo4jConversions neo4jConversions() {
return new Neo4jConversions(Collections.singletonList(new PersonWithCustomId.CustomPersonIdConverter()));
}
// @Bean
// @Override
// public Neo4jConversions neo4jConversions() {
// 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() {

View File

@@ -33,8 +33,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.VersionedThing;
import org.springframework.data.neo4j.integration.shared.VersionedThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.VersionedThing;
import org.springframework.data.neo4j.integration.shared.common.VersionedThingWithAssignedId;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -28,10 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.NamesOnly;
import org.springframework.data.neo4j.integration.shared.NamesOnlyDto;
import org.springframework.data.neo4j.integration.shared.Person;
import org.springframework.data.neo4j.integration.shared.PersonSummary;
import org.springframework.data.neo4j.integration.shared.common.NamesOnly;
import org.springframework.data.neo4j.integration.shared.common.NamesOnlyDto;
import org.springframework.data.neo4j.integration.shared.common.Person;
import org.springframework.data.neo4j.integration.shared.common.PersonSummary;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -29,7 +29,7 @@ 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.RelationshipsAsConstructorParametersEntities;
import org.springframework.data.neo4j.integration.shared.common.RelationshipsAsConstructorParametersEntities;
import org.springframework.data.neo4j.test.Neo4jExtension;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
import org.springframework.transaction.annotation.EnableTransactionManagement;

View File

@@ -31,9 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.Multiple1O1Relationships;
import org.springframework.data.neo4j.integration.shared.MultipleRelationshipsThing;
import org.springframework.data.neo4j.integration.shared.RelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.common.Multiple1O1Relationships;
import org.springframework.data.neo4j.integration.shared.common.MultipleRelationshipsThing;
import org.springframework.data.neo4j.integration.shared.common.RelationshipsITBase;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.EnableTransactionManagement;

View File

@@ -29,11 +29,9 @@ 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;
@@ -58,7 +56,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.ExampleMatcher.StringMatcher;
@@ -79,42 +76,42 @@ import org.springframework.data.neo4j.core.DatabaseSelection;
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
import org.springframework.data.neo4j.core.Neo4jTemplate;
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext;
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.AltHobby;
import org.springframework.data.neo4j.integration.shared.AltLikedByPersonRelationship;
import org.springframework.data.neo4j.integration.shared.AltPerson;
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.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.DeepRelationships;
import org.springframework.data.neo4j.integration.shared.DtoPersonProjection;
import org.springframework.data.neo4j.integration.shared.DtoPersonProjectionContainingAdditionalFields;
import org.springframework.data.neo4j.integration.shared.EntityWithConvertedId;
import org.springframework.data.neo4j.integration.shared.ExtendedParentNode;
import org.springframework.data.neo4j.integration.shared.Friend;
import org.springframework.data.neo4j.integration.shared.FriendshipRelationship;
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.ParentNode;
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.PersonWithRelationshipWithProperties2;
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.integration.shared.WorksInClubRelationship;
import org.springframework.data.neo4j.integration.shared.common.KotlinPerson;
import org.springframework.data.neo4j.integration.shared.common.AltHobby;
import org.springframework.data.neo4j.integration.shared.common.AltLikedByPersonRelationship;
import org.springframework.data.neo4j.integration.shared.common.AltPerson;
import org.springframework.data.neo4j.integration.shared.common.AnotherThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.BidirectionalEnd;
import org.springframework.data.neo4j.integration.shared.common.BidirectionalStart;
import org.springframework.data.neo4j.integration.shared.common.Club;
import org.springframework.data.neo4j.integration.shared.common.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.common.DeepRelationships;
import org.springframework.data.neo4j.integration.shared.common.DtoPersonProjection;
import org.springframework.data.neo4j.integration.shared.common.DtoPersonProjectionContainingAdditionalFields;
import org.springframework.data.neo4j.integration.shared.common.EntityWithConvertedId;
import org.springframework.data.neo4j.integration.shared.common.ExtendedParentNode;
import org.springframework.data.neo4j.integration.shared.common.Friend;
import org.springframework.data.neo4j.integration.shared.common.FriendshipRelationship;
import org.springframework.data.neo4j.integration.shared.common.Hobby;
import org.springframework.data.neo4j.integration.shared.common.ImmutablePerson;
import org.springframework.data.neo4j.integration.shared.common.Inheritance;
import org.springframework.data.neo4j.integration.shared.common.LikesHobbyRelationship;
import org.springframework.data.neo4j.integration.shared.common.MultipleLabels;
import org.springframework.data.neo4j.integration.shared.common.ParentNode;
import org.springframework.data.neo4j.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithNoConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelationship;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelationshipWithProperties;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelationshipWithProperties2;
import org.springframework.data.neo4j.integration.shared.common.PersonWithWither;
import org.springframework.data.neo4j.integration.shared.common.Pet;
import org.springframework.data.neo4j.integration.shared.common.SimilarThing;
import org.springframework.data.neo4j.integration.shared.common.ThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.integration.shared.common.WorksInClubRelationship;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.repository.query.BoundingBox;
@@ -3121,47 +3118,6 @@ class RepositoryIT {
}
}
@Nested
class Converter extends IntegrationTestBase {
@Override
void setupData(Transaction transaction) {
transaction.run("CREATE (:CustomTypes{customType:'XYZ'})");
}
@Test
void findByConvertedCustomType(@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByCustomType(ThingWithCustomTypes.CustomType.of("XYZ"))).isNotNull();
}
@Test
void findByConvertedCustomTypeWithCustomQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByCustomTypeCustomQuery(ThingWithCustomTypes.CustomType.of("XYZ"))).isNotNull();
}
@Test
void findByConvertedCustomTypeWithSpELPropertyAccessQuery(
@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByCustomTypeCustomSpELPropertyAccessQuery(ThingWithCustomTypes.CustomType.of("XYZ")))
.isNotNull();
}
@Test
void findByConvertedCustomTypeWithSpELObjectQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByCustomTypeSpELObjectQuery(ThingWithCustomTypes.CustomType.of("XYZ"))).isNotNull();
}
@Test
void findByConvertedDifferentTypeWithSpELObjectQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
assertThat(repository.findByDifferentTypeCustomQuery(ThingWithCustomTypes.DifferentType.of("XYZ"))).isNotNull();
}
}
/**
* The tests in this class ensure that in case of an inheritance scenario no DTO is projected but the extending class
* is used. If it wasn't the case, we wouldn't find the relationship nor the other attribute.
@@ -3283,26 +3239,6 @@ class RepositoryIT {
interface EntityWithConvertedIdRepository
extends Neo4jRepository<EntityWithConvertedId, EntityWithConvertedId.IdentifyingEnum> {}
interface EntityWithCustomTypePropertyRepository extends Neo4jRepository<ThingWithCustomTypes, Long> {
ThingWithCustomTypes findByCustomType(ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = $customType return c")
ThingWithCustomTypes findByCustomTypeCustomQuery(@Param("customType") ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = $differentType return c")
ThingWithCustomTypes findByDifferentTypeCustomQuery(
@Param("differentType") ThingWithCustomTypes.DifferentType differentType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = :#{#customType.value} return c")
ThingWithCustomTypes findByCustomTypeCustomSpELPropertyAccessQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = :#{#customType} return c")
ThingWithCustomTypes findByCustomTypeSpELObjectQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
}
interface HobbyWithRelationshipWithPropertiesRepository extends Neo4jRepository<AltHobby, Long> {
@Query("MATCH (p:AltPerson)-[l:LIKES]->(h:AltHobby) WHERE id(p) = $personId RETURN h, collect(l), collect(p)")
@@ -3378,17 +3314,18 @@ class RepositoryIT {
}
@Override
public Neo4jConversions neo4jConversions() {
Set<GenericConverter> additionalConverters = new HashSet<>();
additionalConverters.add(new ThingWithCustomTypes.CustomTypeConverter());
additionalConverters.add(new ThingWithCustomTypes.DifferentTypeConverter());
return new Neo4jConversions(additionalConverters);
protected Collection<String> getMappingBasePackages() {
return Arrays.asList(PersonWithAllConstructor.class.getPackage().getName());
}
@Override
protected Collection<String> getMappingBasePackages() {
return Collections.singletonList(PersonWithAllConstructor.class.getPackage().getName());
@Bean
public Neo4jMappingContext neo4jMappingContext(Neo4jConversions neo4JConversions) throws ClassNotFoundException {
Neo4jMappingContext mappingContext = new Neo4jMappingContext(neo4JConversions);
mappingContext.setInitialEntitySet(getInitialEntitySet());
mappingContext.setStrict(true);
return mappingContext;
}
@Bean

View File

@@ -31,14 +31,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.Club;
import org.springframework.data.neo4j.integration.shared.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.DynamicRelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.Hobby;
import org.springframework.data.neo4j.integration.shared.HobbyRelationship;
import org.springframework.data.neo4j.integration.shared.Person;
import org.springframework.data.neo4j.integration.shared.PersonWithStringlyTypedRelatives;
import org.springframework.data.neo4j.integration.shared.Pet;
import org.springframework.data.neo4j.integration.shared.common.Club;
import org.springframework.data.neo4j.integration.shared.common.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.common.DynamicRelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.common.Hobby;
import org.springframework.data.neo4j.integration.shared.common.HobbyRelationship;
import org.springframework.data.neo4j.integration.shared.common.Person;
import org.springframework.data.neo4j.integration.shared.common.PersonWithStringlyTypedRelatives;
import org.springframework.data.neo4j.integration.shared.common.Pet;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.CrudRepository;

View File

@@ -46,7 +46,7 @@ import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager;
import org.springframework.data.neo4j.integration.imperative.repositories.PersonRepository;
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.EnableTransactionManagement;

View File

@@ -30,13 +30,13 @@ import org.springframework.data.geo.Box;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Polygon;
import org.springframework.data.neo4j.integration.shared.DtoPersonProjection;
import org.springframework.data.neo4j.integration.shared.DtoPersonProjectionContainingAdditionalFields;
import org.springframework.data.neo4j.integration.shared.PersonProjection;
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.PersonWithNoConstructor;
import org.springframework.data.neo4j.integration.shared.PersonWithWither;
import org.springframework.data.neo4j.integration.shared.ThingWithGeneratedId;
import org.springframework.data.neo4j.integration.shared.common.DtoPersonProjection;
import org.springframework.data.neo4j.integration.shared.common.DtoPersonProjectionContainingAdditionalFields;
import org.springframework.data.neo4j.integration.shared.common.PersonProjection;
import org.springframework.data.neo4j.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithNoConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithWither;
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.BoundingBox;
import org.springframework.data.neo4j.repository.query.Query;

View File

@@ -17,7 +17,7 @@ package org.springframework.data.neo4j.integration.imperative.repositories;
import java.util.List;
import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.ThingWithAssignedId;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.CrudRepository;

View File

@@ -27,10 +27,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.KotlinClub;
import org.springframework.data.neo4j.integration.shared.KotlinClubRelationship;
import org.springframework.data.neo4j.integration.shared.KotlinPerson;
import org.springframework.data.neo4j.integration.shared.KotlinRepository;
import org.springframework.data.neo4j.integration.shared.common.KotlinClub;
import org.springframework.data.neo4j.integration.shared.common.KotlinClubRelationship;
import org.springframework.data.neo4j.integration.shared.common.KotlinPerson;
import org.springframework.data.neo4j.integration.shared.common.KotlinRepository;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension.Neo4jConnectionSupport;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;

View File

@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.core.ReactiveNeo4jOperations;
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.repository.support.Neo4jEntityInformation;

View File

@@ -34,9 +34,9 @@ import org.springframework.data.auditing.DateTimeProvider;
import org.springframework.data.domain.ReactiveAuditorAware;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.config.EnableReactiveNeo4jAuditing;
import org.springframework.data.neo4j.integration.shared.AuditingITBase;
import org.springframework.data.neo4j.integration.shared.ImmutableAuditableThing;
import org.springframework.data.neo4j.integration.shared.ImmutableAuditableThingWithGeneratedId;
import org.springframework.data.neo4j.integration.shared.common.AuditingITBase;
import org.springframework.data.neo4j.integration.shared.common.ImmutableAuditableThing;
import org.springframework.data.neo4j.integration.shared.common.ImmutableAuditableThingWithGeneratedId;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -31,8 +31,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.integration.reactive.repositories.ReactiveThingRepository;
import org.springframework.data.neo4j.integration.shared.CallbacksITBase;
import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.CallbacksITBase;
import org.springframework.data.neo4j.integration.shared.common.ThingWithAssignedId;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.repository.event.ReactiveBeforeBindCallback;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -44,7 +44,7 @@ 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.ReactiveNeo4jClient;
import org.springframework.data.neo4j.integration.shared.ThingWithSequence;
import org.springframework.data.neo4j.integration.shared.common.ThingWithSequence;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.CausalClusterIntegrationTest;

View File

@@ -46,16 +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.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.integration.shared.common.EntitiesWithDynamicLabels.DynamicLabelsWithMultipleNodeLabels;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.DynamicLabelsWithNodeLabel;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.ExtendedBaseClass1;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.InheritedSimpleDynamicLabels;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabels;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsCtor;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessId;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessIdAndVersion;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithVersion;
import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SuperNode;
import org.springframework.data.neo4j.test.Neo4jExtension;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

View File

@@ -18,12 +18,12 @@ package org.springframework.data.neo4j.integration.reactive;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assumptions.assumeThat;
import org.springframework.data.neo4j.integration.shared.Club;
import org.springframework.data.neo4j.integration.shared.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.Hobby;
import org.springframework.data.neo4j.integration.shared.HobbyRelationship;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.TypeOfClub;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.TypeOfHobby;
import org.springframework.data.neo4j.integration.shared.common.Club;
import org.springframework.data.neo4j.integration.shared.common.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.common.Hobby;
import org.springframework.data.neo4j.integration.shared.common.HobbyRelationship;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives.TypeOfClub;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives.TypeOfHobby;
import reactor.test.StepVerifier;
import java.util.ArrayList;
@@ -40,12 +40,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.DynamicRelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.Person;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.TypeOfPet;
import org.springframework.data.neo4j.integration.shared.PersonWithRelatives.TypeOfRelative;
import org.springframework.data.neo4j.integration.shared.Pet;
import org.springframework.data.neo4j.integration.shared.common.DynamicRelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.common.Person;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives.TypeOfPet;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelatives.TypeOfRelative;
import org.springframework.data.neo4j.integration.shared.common.Pet;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -36,9 +36,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.core.ReactiveNeo4jClient;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.integration.shared.common.SimplePerson;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator;
@@ -137,22 +135,6 @@ class ReactiveExceptionTranslationIT {
}
}
@Node
static class SimplePerson {
@Id @GeneratedValue private Long id;
private String name;
SimplePerson(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
interface SimplePersonRepository extends ReactiveNeo4jRepository<SimplePerson, Long> {}
@Repository

View File

@@ -35,9 +35,9 @@ 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.schema.IdGenerator;
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.integration.shared.common.IdGeneratorsITBase;
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.integration.shared.common.ThingWithIdGeneratedByBean;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;

View File

@@ -26,10 +26,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
@@ -44,19 +41,15 @@ import org.neo4j.driver.Result;
import org.neo4j.driver.Session;
import org.neo4j.driver.SessionConfig;
import org.neo4j.driver.Transaction;
import org.neo4j.driver.TransactionWork;
import org.neo4j.driver.Value;
import org.neo4j.driver.Values;
import org.neo4j.driver.summary.ResultSummary;
import org.springframework.beans.factory.annotation.Autowired;
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.ReactiveNeo4jOperations;
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.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.test.Neo4jExtension;
import org.springframework.data.neo4j.test.Neo4jExtension.Neo4jConnectionSupport;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
@@ -77,7 +70,6 @@ class ReactiveNeo4jOperationsIT {
private final Driver driver;
private final ReactiveNeo4jOperations neo4jOperations;
private final AtomicLong customIdValueGenerator = new AtomicLong();
private Long person1Id;
private Long person2Id;
@@ -275,33 +267,6 @@ class ReactiveNeo4jOperationsIT {
}
}
TransactionWork<ResultSummary> createPersonWithCustomId(PersonWithCustomId.PersonId assignedId) {
return tx -> tx.run("CREATE (n:PersonWithCustomId) SET n.id = $id ",
Values.parameters("id", assignedId.getId())).consume();
}
@Test
void deleteByCustomId() {
PersonWithCustomId.PersonId id = new PersonWithCustomId.PersonId(customIdValueGenerator.incrementAndGet());
try (Session session = driver.session(getSessionConfig())) {
session.writeTransaction(createPersonWithCustomId(id));
}
StepVerifier.create(neo4jOperations.count(PersonWithCustomId.class))
.expectNext(1L)
.verifyComplete();
StepVerifier.create(neo4jOperations.deleteById(id, PersonWithCustomId.class))
.verifyComplete();
try (Session session = driver.session(getSessionConfig())) {
Result result = session.run("MATCH (p:PersonWithCustomId) return count(p) as count");
assertThat(result.single().get("count").asLong()).isEqualTo(0);
}
}
@Test
void deleteAllById() {
@@ -315,32 +280,6 @@ class ReactiveNeo4jOperationsIT {
}
}
@Test
void deleteAllByCustomId() {
List<PersonWithCustomId.PersonId> ids = Stream.generate(customIdValueGenerator::incrementAndGet)
.map(PersonWithCustomId.PersonId::new)
.limit(2)
.collect(Collectors.toList());
try (
Session session = driver.session(getSessionConfig());
) {
ids.forEach(id -> session.writeTransaction(createPersonWithCustomId(id)));
}
StepVerifier.create(neo4jOperations.count(PersonWithCustomId.class))
.expectNext(2L)
.verifyComplete();
StepVerifier.create(neo4jOperations.deleteAllById(ids, PersonWithCustomId.class))
.verifyComplete();
try (Session session = driver.session(getSessionConfig())) {
Result result = session.run("MATCH (p:PersonWithCustomId) return count(p) as count");
assertThat(result.single().get("count").asLong()).isEqualTo(0);
}
}
@Configuration
@EnableTransactionManagement
static class Config extends AbstractReactiveNeo4jConfig {
@@ -350,12 +289,6 @@ class ReactiveNeo4jOperationsIT {
return neo4jConnectionSupport.getDriver();
}
@Bean
@Override
public Neo4jConversions neo4jConversions() {
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 Collections.singletonList(PersonWithAllConstructor.class.getPackage().getName());

View File

@@ -36,8 +36,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.VersionedThing;
import org.springframework.data.neo4j.integration.shared.VersionedThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.VersionedThing;
import org.springframework.data.neo4j.integration.shared.common.VersionedThingWithAssignedId;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -30,10 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.NamesOnly;
import org.springframework.data.neo4j.integration.shared.NamesOnlyDto;
import org.springframework.data.neo4j.integration.shared.Person;
import org.springframework.data.neo4j.integration.shared.PersonSummary;
import org.springframework.data.neo4j.integration.shared.common.NamesOnly;
import org.springframework.data.neo4j.integration.shared.common.NamesOnlyDto;
import org.springframework.data.neo4j.integration.shared.common.Person;
import org.springframework.data.neo4j.integration.shared.common.PersonSummary;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -32,8 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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.integration.shared.common.MultipleRelationshipsThing;
import org.springframework.data.neo4j.integration.shared.common.RelationshipsITBase;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;

View File

@@ -19,9 +19,6 @@ 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 org.springframework.data.neo4j.integration.shared.AltLikedByPersonRelationship;
import org.springframework.data.neo4j.integration.shared.AltPerson;
import org.springframework.data.neo4j.integration.shared.WorksInClubRelationship;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -32,11 +29,9 @@ 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;
@@ -61,7 +56,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.PageRequest;
@@ -69,28 +63,29 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.core.DatabaseSelection;
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.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.integration.shared.common.AltHobby;
import org.springframework.data.neo4j.integration.shared.common.AltLikedByPersonRelationship;
import org.springframework.data.neo4j.integration.shared.common.AltPerson;
import org.springframework.data.neo4j.integration.shared.common.AnotherThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.BidirectionalEnd;
import org.springframework.data.neo4j.integration.shared.common.BidirectionalStart;
import org.springframework.data.neo4j.integration.shared.common.Club;
import org.springframework.data.neo4j.integration.shared.common.DeepRelationships;
import org.springframework.data.neo4j.integration.shared.common.EntityWithConvertedId;
import org.springframework.data.neo4j.integration.shared.common.Hobby;
import org.springframework.data.neo4j.integration.shared.common.ImmutablePerson;
import org.springframework.data.neo4j.integration.shared.common.LikesHobbyRelationship;
import org.springframework.data.neo4j.integration.shared.common.MultipleLabels;
import org.springframework.data.neo4j.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelationship;
import org.springframework.data.neo4j.integration.shared.common.PersonWithRelationshipWithProperties;
import org.springframework.data.neo4j.integration.shared.common.Pet;
import org.springframework.data.neo4j.integration.shared.common.SimilarThing;
import org.springframework.data.neo4j.integration.shared.common.ThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.integration.shared.common.WorksInClubRelationship;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.repository.query.Query;
@@ -2202,52 +2197,6 @@ class ReactiveRepositoryIT {
}
@Nested
class Converter extends ReactiveIntegrationTestBase {
@Test
void findByConvertedCustomType(@Autowired EntityWithCustomTypePropertyRepository repository) {
try (Session session = createSession()) {
session.run("CREATE (:CustomTypes{customType:'XYZ'})");
}
StepVerifier.create(repository.findByCustomType(ThingWithCustomTypes.CustomType.of("XYZ"))).expectNextCount(1)
.verifyComplete();
}
@Test
void findByConvertedCustomTypeWithCustomQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
try (Session session = createSession()) {
session.run("CREATE (:CustomTypes{customType:'XYZ'})");
}
StepVerifier.create(repository.findByCustomTypeCustomQuery(ThingWithCustomTypes.CustomType.of("XYZ")))
.expectNextCount(1).verifyComplete();
}
@Test
void findByConvertedCustomTypeWithSpELPropertyAccessQuery(
@Autowired EntityWithCustomTypePropertyRepository repository) {
try (Session session = createSession()) {
session.run("CREATE (:CustomTypes{customType:'XYZ'})");
}
StepVerifier
.create(repository.findByCustomTypeCustomSpELPropertyAccessQuery(ThingWithCustomTypes.CustomType.of("XYZ")))
.expectNextCount(1).verifyComplete();
}
@Test
void findByConvertedCustomTypeWithSpELObjectQuery(@Autowired EntityWithCustomTypePropertyRepository repository) {
try (Session session = createSession()) {
session.run("CREATE (:CustomTypes{customType:'XYZ'})");
}
StepVerifier.create(repository.findByCustomTypeSpELObjectQuery(ThingWithCustomTypes.CustomType.of("XYZ")))
.expectNextCount(1).verifyComplete();
}
}
interface BidirectionalStartRepository extends ReactiveNeo4jRepository<BidirectionalStart, Long> {}
interface BidirectionalEndRepository extends ReactiveNeo4jRepository<BidirectionalEnd, Long> {}
@@ -2309,23 +2258,6 @@ class ReactiveRepositoryIT {
interface EntityWithConvertedIdRepository
extends ReactiveNeo4jRepository<EntityWithConvertedId, EntityWithConvertedId.IdentifyingEnum> {}
interface EntityWithCustomTypePropertyRepository extends ReactiveNeo4jRepository<ThingWithCustomTypes, Long> {
Mono<ThingWithCustomTypes> findByCustomType(ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = $customType return c")
Mono<ThingWithCustomTypes> findByCustomTypeCustomQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = :#{#customType.value} return c")
Mono<ThingWithCustomTypes> findByCustomTypeCustomSpELPropertyAccessQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
@Query("MATCH (c:CustomTypes) WHERE c.customType = :#{#customType} return c")
Mono<ThingWithCustomTypes> findByCustomTypeSpELObjectQuery(
@Param("customType") ThingWithCustomTypes.CustomType customType);
}
@SpringJUnitConfig(ReactiveRepositoryIT.Config.class)
static abstract class ReactiveIntegrationTestBase {
@@ -2373,14 +2305,6 @@ class ReactiveRepositoryIT {
return neo4jConnectionSupport.getDriver();
}
@Override
public Neo4jConversions neo4jConversions() {
Set<GenericConverter> additionalConverters = new HashSet<>();
additionalConverters.add(new ThingWithCustomTypes.CustomTypeConverter());
return new Neo4jConversions(additionalConverters);
}
@Override
protected Collection<String> getMappingBasePackages() {
return Collections.singletonList(PersonWithAllConstructor.class.getPackage().getName());

View File

@@ -18,10 +18,10 @@ package org.springframework.data.neo4j.integration.reactive;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assumptions.assumeThat;
import org.springframework.data.neo4j.integration.shared.Club;
import org.springframework.data.neo4j.integration.shared.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.Hobby;
import org.springframework.data.neo4j.integration.shared.HobbyRelationship;
import org.springframework.data.neo4j.integration.shared.common.Club;
import org.springframework.data.neo4j.integration.shared.common.ClubRelationship;
import org.springframework.data.neo4j.integration.shared.common.Hobby;
import org.springframework.data.neo4j.integration.shared.common.HobbyRelationship;
import reactor.test.StepVerifier;
import java.util.ArrayList;
@@ -38,10 +38,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig;
import org.springframework.data.neo4j.integration.shared.DynamicRelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.Person;
import org.springframework.data.neo4j.integration.shared.PersonWithStringlyTypedRelatives;
import org.springframework.data.neo4j.integration.shared.Pet;
import org.springframework.data.neo4j.integration.shared.common.DynamicRelationshipsITBase;
import org.springframework.data.neo4j.integration.shared.common.Person;
import org.springframework.data.neo4j.integration.shared.common.PersonWithStringlyTypedRelatives;
import org.springframework.data.neo4j.integration.shared.common.Pet;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.data.neo4j.test.Neo4jExtension;

View File

@@ -47,7 +47,7 @@ import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider;
import org.springframework.data.neo4j.core.ReactiveNeo4jClient;
import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager;
import org.springframework.data.neo4j.integration.reactive.repositories.ReactivePersonRepository;
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.EnableTransactionManagement;

View File

@@ -19,10 +19,10 @@ import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.data.domain.Pageable;
import org.springframework.data.neo4j.integration.shared.DtoPersonProjection;
import org.springframework.data.neo4j.integration.shared.PersonProjection;
import org.springframework.data.neo4j.integration.shared.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.ThingWithGeneratedId;
import org.springframework.data.neo4j.integration.shared.common.DtoPersonProjection;
import org.springframework.data.neo4j.integration.shared.common.PersonProjection;
import org.springframework.data.neo4j.integration.shared.common.PersonWithAllConstructor;
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.neo4j.types.GeographicPoint2d;

View File

@@ -17,7 +17,7 @@ package org.springframework.data.neo4j.integration.reactive.repositories;
import reactor.core.publisher.Mono;
import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId;
import org.springframework.data.neo4j.integration.shared.common.ThingWithAssignedId;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
/**
* @author Michael J. Simons

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.ArrayList;
import java.util.List;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.core.schema.TargetNode;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.Objects;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.time.LocalDateTime;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.Set;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.core.schema.TargetNode;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.Set;

View File

@@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
/**
* @author Gerrit Meier
*/
@Node
public class EntityWithConvertedId {
@Id private IdentifyingEnum identifyingEnum;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.List;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.core.schema.TargetNode;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.Objects;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.core.schema.TargetNode;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import lombok.AllArgsConstructor;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import lombok.AllArgsConstructor;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
/**
* @author Gerrit Meier

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.List;
import java.util.Objects;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.time.LocalDate;
import java.util.Objects;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.List;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.beans.factory.annotation.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
/**
* @author Gerrit Meier

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
/**
* @author Gerrit Meier

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
/**
* @author Gerrit Meier

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import lombok.Getter;
import lombok.Setter;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.List;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.List;
import java.util.Set;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.Set;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.HashMap;
import java.util.List;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import java.util.HashMap;
import java.util.List;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import lombok.Getter;
import lombok.Setter;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.shared;
package org.springframework.data.neo4j.integration.shared.common;
import lombok.EqualsAndHashCode;
import lombok.Getter;

Some files were not shown because too many files have changed in this diff Show More