From 070d664c8ab8535ed8907c0dbb29562451e9250d Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Thu, 2 Jul 2020 10:19:24 +0200 Subject: [PATCH] DATAGRAPH-1333 - Migrate SDN/RX to SDN Replace SDN with the new library Spring Data Neo4j RX as the new Spring Data Neo4j 6.0. --- Jenkinsfile | 20 +- README.adoc | 179 ++- checkstyle/config.xml | 23 - checkstyle/java-header.txt | 17 - checkstyle/suppressions.xml | 7 - etc/checkstyle/java-header.txt | 7 +- etc/checkstyle/suppressions.xml | 2 +- etc/jqassistant/naming.adoc | 4 +- etc/jqassistant/structure.adoc | 4 +- pom.xml | 347 +++- spring-data-neo4j-distribution/pom.xml | 45 - spring-data-neo4j/pom.xml | 258 --- .../data/neo4j/annotation/Depth.java | 39 - .../annotation/EnableBookmarkManagement.java | 45 - .../neo4j/annotation/EnableNeo4jAuditing.java | 71 - .../data/neo4j/annotation/ExistsQuery.java | 46 - .../data/neo4j/annotation/Query.java | 55 - .../data/neo4j/annotation/QueryResult.java | 36 - .../data/neo4j/annotation/UseBookmark.java | 42 - .../data/neo4j/annotation/package-info.java | 19 - .../BeanFactoryBookmarkOperationAdvisor.java | 35 - .../data/neo4j/bookmark/BookmarkInfo.java | 52 - .../neo4j/bookmark/BookmarkInterceptor.java | 45 - .../BookmarkManagementConfiguration.java | 55 - .../data/neo4j/bookmark/BookmarkManager.java | 42 - .../bookmark/BookmarkOperationPointcut.java | 43 - .../data/neo4j/bookmark/BookmarkSupport.java | 32 - .../bookmark/CaffeineBookmarkManager.java | 63 - .../data/neo4j/bookmark/package-info.java | 19 - .../MetaDataDrivenConversionService.java | 123 -- .../Neo4jOgmEntityInstantiatorAdapter.java | 115 -- .../data/neo4j/conversion/PointConverter.java | 52 - .../data/neo4j/conversion/package-info.java | 20 - .../exception/Neo4jErrorStatusCodes.java | 114 -- .../UncategorizedNeo4jException.java | 30 - .../data/neo4j/exception/package-info.java | 19 - .../data/neo4j/mapping/MetaDataProvider.java | 30 - .../neo4j/mapping/Neo4jMappingContext.java | 233 --- .../neo4j/mapping/Neo4jPersistentEntity.java | 123 -- .../mapping/Neo4jPersistentProperty.java | 192 --- .../data/neo4j/mapping/package-info.java | 19 - .../neo4j/repository/Neo4jRepository.java | 80 - .../cdi/Neo4jCdiRepositoryBean.java | 67 - .../cdi/Neo4jCdiRepositoryExtension.java | 110 -- .../neo4j/repository/cdi/package-info.java | 19 - .../config/EnableNeo4jRepositories.java | 154 -- .../config/Neo4jAuditingEventListener.java | 74 - .../config/Neo4jAuditingRegistrar.java | 83 - .../Neo4jMappingContextFactoryBean.java | 100 -- ...gmEntityInstantiatorConfigurationBean.java | 61 - .../config/Neo4jRepositoriesRegistrar.java | 38 - ...Neo4jRepositoryConfigurationExtension.java | 267 ---- .../Neo4jRepositoryNameSpaceHandler.java | 41 - .../data/neo4j/repository/package-info.java | 19 - .../query/AbstractGraphRepositoryQuery.java | 126 -- .../query/CustomResultConverter.java | 64 - .../query/FilterBuildersDefinition.java | 104 -- .../query/GraphParameterAccessor.java | 44 - .../repository/query/GraphParameters.java | 107 -- .../GraphParametersParameterAccessor.java | 83 - .../repository/query/GraphQueryExecution.java | 246 --- .../query/GraphQueryLookupStrategy.java | 116 -- .../repository/query/GraphQueryMethod.java | 162 -- .../query/GraphRepositoryQuery.java | 150 -- .../query/NamedGraphRepositoryQuery.java | 55 - .../repository/query/PartTreeNeo4jQuery.java | 121 -- .../data/neo4j/repository/query/Query.java | 185 --- .../query/QueryResultInstantiator.java | 56 - .../repository/query/QueryResultProxy.java | 74 - .../repository/query/TemplatedQuery.java | 70 - .../query/TemplatedQueryCreator.java | 70 - .../filter/BetweenComparisonBuilder.java | 109 -- .../filter/BooleanComparisonBuilder.java | 56 - .../filter/ContainsComparisonBuilder.java | 55 - .../filter/DistanceComparisonBuilder.java | 184 --- .../query/filter/ExistsFilterBuilder.java | 54 - .../query/filter/FilterBuilder.java | 176 --- .../query/filter/IsNullFilterBuilder.java | 55 - .../query/filter/NativeIdFilterFunction.java | 105 -- .../filter/PropertyComparisonBuilder.java | 134 -- .../repository/query/filter/package-info.java | 19 - .../neo4j/repository/query/package-info.java | 19 - .../spel/Neo4jQueryPlaceholderSupplier.java | 36 - .../query/spel/ParameterizedQuery.java | 64 - .../query/spel/PlaceholderSupplier.java | 22 - .../repository/query/spel/package-info.java | 19 - .../support/GraphEntityInformation.java | 66 - .../Neo4jAuditingBeanPostProcessor.java | 53 - .../Neo4jPersistenceExceptionTranslator.java | 34 - .../support/Neo4jRepositoryFactory.java | 113 -- .../support/Neo4jRepositoryFactoryBean.java | 98 -- .../support/SimpleNeo4jRepository.java | 199 --- .../repository/support/package-info.java | 19 - .../transaction/Neo4jTransactionManager.java | 426 ----- .../transaction/SessionFactoryUtils.java | 202 --- .../data/neo4j/transaction/SessionHolder.java | 60 - .../transaction/SharedSessionCreator.java | 164 -- .../data/neo4j/transaction/package-info.java | 19 - .../neo4j/util/PagingAndSortingUtils.java | 38 - .../data/neo4j/util/package-info.java | 19 - .../web/support/AsyncRequestInterceptor.java | 93 -- .../web/support/OpenSessionInViewFilter.java | 201 --- .../support/OpenSessionInViewInterceptor.java | 177 --- .../data/neo4j/web/support/package-info.java | 19 - .../javax.enterprise.inject.spi.Extension | 1 - .../main/resources/META-INF/spring.handlers | 1 - .../main/resources/META-INF/spring.schemas | 3 - .../repository/config/spring-neo4j-4.2.xsd | 45 - .../repository/config/spring-neo4j-5.0.xsd | 45 - .../repository/config/spring-neo4j-5.1.xsd | 45 - .../imperative/repositories/package-info.java | 4 - .../reactive/repositories/package-info.java | 4 - .../data/integration/shared/Club.java | 46 - .../integration/shared/PersonProjection.java | 29 - .../JavaConfigurationAuditingTests.java | 92 -- .../data/neo4j/auditing/domain/User.java | 97 -- .../auditing/repository/UserRepository.java | 24 - .../bookmark/BookmarkManagementTests.java | 232 --- .../data/neo4j/bookmark/BookmarkWrapper.java | 35 - ...ivenConversionServiceIntegrationTests.java | 75 - .../MetaDataDrivenConversionServiceTests.java | 57 - ...Neo4jOgmEntityInstantiatorAdapterTest.java | 145 -- .../data/neo4j/conversion/ogm618/MyNode.java | 70 - .../conversion/ogm618/MyNodeRepository.java | 34 - .../neo4j/conversion/ogm618/ResultHolder.java | 41 - .../conversion/support/ConvertedClass.java | 32 - .../neo4j/conversion/support/Converters.java | 92 -- .../EntityWithConvertedAttributes.java | 72 - .../invalid/EntityWithInvalidProperty.java | 47 - .../EntityWithInvalidPropertyRepository.java | 24 - .../neo4j/domain/invalid/package-info.java | 20 - .../data/neo4j/domain/sample/Address.java | 52 - .../neo4j/domain/sample/NodeWithUUIDAsId.java | 46 - .../data/neo4j/domain/sample/Role.java | 91 -- .../neo4j/domain/sample/SampleEntity.java | 49 - .../data/neo4j/domain/sample/SpecialUser.java | 20 - .../data/neo4j/domain/sample/User.java | 367 ----- .../data/neo4j/events/EventPublisher.java | 52 - .../data/neo4j/events/ModificationEvent.java | 34 - .../Neo4jModificationEventListener.java | 91 -- .../data/neo4j/events/PostDeleteEvent.java | 28 - .../data/neo4j/events/PostSaveEvent.java | 28 - .../data/neo4j/events/PreDeleteEvent.java | 28 - .../data/neo4j/events/PreSaveEvent.java | 28 - .../neo4j/examples/friends/FriendService.java | 59 - .../neo4j/examples/friends/FriendTests.java | 97 -- .../examples/friends/domain/Friendship.java | 75 - .../neo4j/examples/friends/domain/Person.java | 78 - .../friends/repo/FriendshipRepository.java | 31 - .../galaxy/GalaxyContextConfiguration.java | 29 - .../examples/galaxy/GalaxyServiceTests.java | 304 ---- .../examples/galaxy/WorldRepositoryTests.java | 100 -- .../neo4j/examples/galaxy/domain/World.java | 131 -- .../examples/galaxy/repo/WorldRepository.java | 39 - .../galaxy/service/GalaxyService.java | 189 --- .../neo4j/examples/jsr303/JSR303Tests.java | 107 -- .../examples/jsr303/WebConfiguration.java | 38 - .../jsr303/controller/AdultController.java | 57 - .../neo4j/examples/jsr303/domain/Adult.java | 73 - .../examples/jsr303/repo/AdultRepository.java | 26 - .../examples/jsr303/service/AdultService.java | 34 - .../movies/MoviesIntegrationTests.java | 712 --------- .../domain/AbstractAnnotatedEntity.java | 30 - .../movies/domain/AbstractEntity.java | 29 - .../neo4j/examples/movies/domain/Actor.java | 52 - .../neo4j/examples/movies/domain/Cinema.java | 107 -- .../domain/CinemaAndBlockbusterName.java | 33 - .../examples/movies/domain/Director.java | 26 - .../neo4j/examples/movies/domain/Genre.java | 43 - .../neo4j/examples/movies/domain/Movie.java | 52 - .../neo4j/examples/movies/domain/Person.java | 54 - .../neo4j/examples/movies/domain/Rating.java | 97 -- .../examples/movies/domain/ReleasedMovie.java | 54 - .../examples/movies/domain/TempMovie.java | 52 - .../neo4j/examples/movies/domain/User.java | 101 -- .../domain/queryresult/CinemaQueryResult.java | 48 - .../CinemaQueryResultInterface.java | 36 - .../CinemaQueryResultInterfaceImpl.java | 43 - .../EntityWrappingQueryResult.java | 72 - .../movies/domain/queryresult/Gender.java | 22 - .../queryresult/RichUserQueryResult.java | 62 - .../domain/queryresult/UserQueryResult.java | 97 -- .../queryresult/UserQueryResultObject.java | 47 - .../domain/queryresult/YearConverter.java | 37 - .../AbstractAnnotatedEntityRepository.java | 26 - .../movies/repo/AbstractEntityRepository.java | 26 - .../examples/movies/repo/ActorRepository.java | 24 - .../movies/repo/CinemaRepository.java | 131 -- .../repo/CinemaStreamingRepository.java | 48 - .../movies/repo/DirectorRepository.java | 25 - .../examples/movies/repo/GenreRepository.java | 26 - .../movies/repo/PersonRepository.java | 35 - .../movies/repo/RatingRepository.java | 64 - .../movies/repo/TempMovieRepository.java | 24 - .../movies/repo/UnmanagedUserPojo.java | 36 - .../examples/movies/repo/UserRepository.java | 189 --- .../examples/movies/service/UserService.java | 43 - .../movies/service/UserServiceImpl.java | 76 - .../examples/restaurants/RestaurantTests.java | 641 -------- .../examples/restaurants/domain/Diner.java | 54 - .../restaurants/domain/Restaurant.java | 154 -- .../repo/RestaurantRepository.java | 95 -- .../extensions/CustomGraphRepositoryImpl.java | 43 - .../CustomGraphRepositoryTests.java | 50 - .../extensions/CustomNeo4jRepository.java | 33 - .../data/neo4j/extensions/UserRepository.java | 25 - .../PersistenceConstructorsTests.java | 342 ---- .../constructors/domain/Friendship.java | 82 - .../constructors/domain/Group.java | 38 - .../constructors/domain/Person.java | 73 - .../domain/PersonMultipleConstructors.java | 48 - .../constructors/domain/PersonProjection.java | 54 - ...onWithAnnotatedPersistenceConstructor.java | 53 - .../domain/PersonWithCompositeAttribute.java | 49 - .../domain/PersonWithConverter.java | 49 - .../domain/PersonWithFinalName.java | 54 - .../domain/PersonWithManyToOneRel.java | 64 - .../conversion/ConversionServiceTests.java | 264 ---- .../conversion/JavaElementRepository.java | 30 - .../conversion/PensionRepository.java | 30 - ...HandleMultipleConversionServicesTests.java | 56 - ...ouldPickPrimaryConversionServiceTests.java | 106 -- .../conversion/SiteMemberRepository.java | 30 - .../SpringBigIntegerToBooleanConverter.java | 33 - .../SpringBooleanToBigIntegerConverter.java | 36 - .../SpringByteArrayToIntegerConverter.java | 31 - .../SpringIntegerToByteArrayConverter.java | 31 - ...pringIntegerToMonetaryAmountConverter.java | 28 - .../SpringLongToMonetaryAmountConverter.java | 28 - ...pringMonetaryAmountToIntegerConverter.java | 28 - .../SpringMonetaryAmountToLongConverter.java | 28 - ...SpringMonetaryAmountToNumberConverter.java | 28 - ...onetaryAmountToNumberConverterFactory.java | 47 - ...SpringNumberToMonetaryAmountConverter.java | 28 - .../conversion/domain/JavaElement.java | 60 - .../conversion/domain/MonetaryAmount.java | 57 - .../conversion/domain/PensionPlan.java | 64 - .../conversion/domain/SiteMember.java | 66 - .../mapping/Neo4jPersistentPropertyTests.java | 49 - .../neo4j/namedquery/NamedQueryTests.java | 110 -- .../domain/SampleEntityForNamedQuery.java | 38 - .../SampleEntityForNamedQueryRepository.java | 40 - .../NativeTypesContextConfiguration.java | 40 - .../nativetypes/SpatialConversionTests.java | 147 -- .../data/neo4j/nativetypes/SpatialDomain.java | 119 -- .../nativetypes/SpatialDomainRepository.java | 46 - .../neo4j/nativetypes/SpatialFindByTests.java | 96 -- .../neo4j/nativetypes/SpatialNearTests.java | 147 -- ...patialPersistenceContextConfiguration.java | 48 - .../data/neo4j/nativetypes/TimeDomain.java | 110 -- .../nativetypes/TimeDomainRepository.java | 40 - .../neo4j/nativetypes/TimeFindByTests.java | 114 -- .../data/neo4j/queries/DerivedQueryTests.java | 754 --------- .../DerivedRelationshipEntityQueryTests.java | 405 ----- .../data/neo4j/queries/Java8SupportTests.java | 96 -- .../queries/MoviesContextConfiguration.java | 27 - .../data/neo4j/queries/PagedQueryTests.java | 548 ------- .../data/neo4j/queries/ProjectionTests.java | 129 -- .../neo4j/queries/QueryIntegrationTests.java | 729 --------- .../queries/QueryResultIntegrationTests.java | 82 - .../neo4j/queries/QueryReturnTypesTests.java | 120 -- .../neo4j/queries/StoredProceduresTests.java | 120 -- .../neo4j/queries/ogmgh551/AnotherThing.java | 32 - .../neo4j/queries/ogmgh551/ThingEntity.java | 52 - .../queries/ogmgh551/ThingRepository.java | 29 - .../neo4j/queries/ogmgh551/ThingResult.java | 38 - .../data/neo4j/queries/ogmgh552/Thing.java | 30 - .../neo4j/queries/ogmgh552/ThingEntity.java | 32 - .../queries/ogmgh552/ThingRepository.java | 30 - .../stored_procedures/DocumentRepository.java | 29 - .../ProgrammaticRepositoryTests.java | 214 --- .../neo4j/repositories/RepoScanningTests.java | 71 - .../RepositoryDefinitionTests.java | 87 - .../data/neo4j/repositories/domain/Movie.java | 35 - .../data/neo4j/repositories/domain/User.java | 58 - .../repositories/repo/MovieRepository.java | 30 - .../repositories/repo/UserRepository.java | 46 - .../support/GraphRepositoryFactoryTests.java | 97 -- .../data/neo4j/repository/Contact.java | 46 - .../neo4j/repository/ContactRepository.java | 23 - .../MultipleSessionFactorySupportTests.java | 259 --- .../repository/Neo4jRepositoryTests.java | 105 -- .../repository/cdi/CdiExtensionTests.java | 105 -- .../repository/cdi/CdiPersonRepository.java | 35 - .../repository/cdi/Neo4jCdiProducer.java | 61 - .../cdi/Neo4jRepositoryExtensionTests.java | 78 - .../neo4j/repository/cdi/OtherQualifier.java | 34 - .../data/neo4j/repository/cdi/PersonDB.java | 34 - .../cdi/QualifiedPersonRepository.java | 29 - .../repository/cdi/RepositoryClient.java | 31 - .../repository/cdi/SamplePersonFragment.java | 25 - .../cdi/SamplePersonFragmentImpl.java | 28 - .../cdi/SamplePersonRepository.java | 27 - .../Neo4jRepositoriesRegistrarTests.java | 65 - ...RepositoryConfigurationExtensionTests.java | 173 -- .../config/RepositoriesJavaConfigTests.java | 58 - .../query/GraphQueryExecutionTests.java | 74 - .../DistanceComparisonBuilderTests.java | 41 - .../MinimalRelationshipEntityMappingTest.java | 85 - .../repository/relcentric/app/Actor.java | 50 - .../repository/relcentric/app/Movie.java | 33 - .../neo4j/repository/relcentric/app/Role.java | 57 - .../relcentric/app/RoleRepository.java | 24 - .../repository/sample/UserRepository.java | 78 - ...tTransactionDisablingIntegrationTests.java | 84 - ...ceExceptionTranslatorIntegrationTests.java | 82 - .../Neo4jRepositoryFactoryBeanTests.java | 88 -- .../support/SimpleNeo4jRepositoryTests.java | 159 -- .../support/TransactionalRepositoryTests.java | 162 -- .../TemplateApplicationEventTests.java | 112 -- .../template/TestNeo4jEventListener.java | 43 - ...lsAfterTestClassTestExecutionListener.java | 44 - .../test/GraphDatabaseServiceAssert.java | 61 - .../data/neo4j/test/Neo4jIntegrationTest.java | 89 -- .../test/Neo4jTestServerConfiguration.java | 117 -- .../data/neo4j/test/NodeAssert.java | 39 - .../neo4j/test/SessionFactoryRegistrar.java | 52 - .../data/neo4j/test/package-info.java | 19 - .../transaction/BookmarkTransactionTests.java | 144 -- .../ExtendedTransactionsTests.java | 150 -- .../neo4j/transaction/MapPropertiesTests.java | 131 -- .../Neo4jTransactionManagerTests.java | 435 ----- .../transaction/SessionFactoryUtilsTests.java | 82 - .../SharedSessionCreatorTests.java | 51 - .../TransactionIntegrationTests.java | 86 - .../transaction/TransactionRollbackTests.java | 115 -- .../TransactionalEventListenerTests.java | 570 ------- .../neo4j/transaction/domain/ThreadInfo.java | 70 - .../data/neo4j/transaction/domain/User.java | 55 - .../repo/ThreadInfoRepository.java | 27 - .../transaction/repo/UserRepository.java | 31 - .../transaction/service/BusinessService.java | 60 - .../neo4j/transaction/service/ServiceA.java | 43 - .../neo4j/transaction/service/ServiceB.java | 47 - .../transaction/service/WrapperService.java | 65 - .../data/neo4j/web/WebIntegrationTests.java | 183 --- ...ApplicationContextWebIntegrationTests.java | 148 -- .../neo4j/web/controller/UserController.java | 83 - .../data/neo4j/web/domain/Cinema.java | 60 - .../data/neo4j/web/domain/Genre.java | 58 - .../data/neo4j/web/domain/User.java | 82 - .../data/neo4j/web/repo/GenreRepository.java | 31 - .../data/neo4j/web/repo/UserRepository.java | 32 - .../data/neo4j/web/service/UserService.java | 31 - .../neo4j/web/service/UserServiceImpl.java | 66 - .../web/support/OpenSessionInViewTests.java | 391 ----- .../data/integration/shared/KotlinPerson.kt | 30 - .../integration/shared/KotlinRepository.kt | 27 - .../constructors/domain/KotlinFriendship.kt | 33 - .../constructors/domain/KotlinPerson.kt | 42 - .../test/resources/META-INF/spring.factories | 1 - .../src/test/resources/logback-test.xml | 43 - ...based-configuration-applicationContext.xml | 34 - spring-data-neo4j/template.mf | 19 - src/main/asciidoc/appendix/build.adoc | 214 +++ src/main/asciidoc/appendix/conversions.adoc | 195 +++ src/main/asciidoc/appendix/index.adoc | 15 + src/main/asciidoc/appendix/migrating.adoc | 137 ++ src/main/asciidoc/appendix/neo4j-client.adoc | 360 +++++ .../asciidoc/appendix/query-creation.adoc | 87 + ...c-repository-query-keywords-reference.adoc | 38 + ...pository-query-return-types-reference.adoc | 43 + src/main/asciidoc/auditing/index.adoc | 1 + src/main/asciidoc/auditing/sdc-auditing.adoc | 71 + src/main/asciidoc/faq.adoc | 61 - src/main/asciidoc/faq/faq.adoc | 216 +++ src/main/asciidoc/faq/index.adoc | 1 + src/main/asciidoc/foreword.adoc | 32 - .../getting-started/getting-started.adoc | 259 +++ src/main/asciidoc/getting-started/index.adoc | 1 + src/main/asciidoc/images/SDN-Architecture.png | Bin 71072 -> 0 bytes src/main/asciidoc/images/neo4j-cluster.png | Bin 42763 -> 0 bytes src/main/asciidoc/index.adoc | 103 +- .../building-blocks.adoc | 75 + .../introduction-and-preface/index.adoc | 5 + .../introduction.adoc | 21 + .../introduction-and-preface/preface.adoc | 137 ++ src/main/asciidoc/migration.adoc | 227 --- src/main/asciidoc/new-features.adoc | 33 - src/main/asciidoc/object-mapping/index.adoc | 3 + src/main/asciidoc/object-mapping/mapping.adoc | 396 +++++ .../object-mapping/sdc-object-mapping.adoc | 290 ++++ src/main/asciidoc/preface.adoc | 106 -- src/main/asciidoc/reference/auditing.adoc | 26 - .../asciidoc/reference/getting-started.adoc | 348 ---- src/main/asciidoc/reference/introduction.adoc | 39 - .../reference/neo4j-repositories.adoc | 693 -------- src/main/asciidoc/reference/ogm-support.adoc | 104 -- src/main/asciidoc/reference/projections.adoc | 138 -- src/main/asciidoc/repositories/index.adoc | 2 + .../repositories/sdc-projections.adoc | 182 +++ .../repositories/sdc-repositories.adoc | 1395 +++++++++++++++++ src/main/asciidoc/testing/index.adoc | 1 + src/main/asciidoc/testing/testing.adoc | 228 +++ .../neo4j}/config/AbstractNeo4jConfig.java | 21 +- .../config/AbstractReactiveNeo4jConfig.java | 21 +- .../neo4j}/config/EnableNeo4jAuditing.java | 9 +- .../neo4j}/config/Neo4jAuditingRegistrar.java | 13 +- .../config/Neo4jConfigurationSupport.java | 17 +- .../Neo4jDefaultCallbacksRegistrar.java | 16 +- ...eo4jDefaultReactiveCallbacksRegistrar.java | 16 +- .../data/neo4j}/config/package-info.java | 2 +- .../data/neo4j}/core/DatabaseSelection.java | 9 +- .../core/DatabaseSelectionProvider.java | 9 +- .../data/neo4j}/core/DefaultNeo4jClient.java | 23 +- .../core/DefaultReactiveNeo4jClient.java | 32 +- ...elegatingMappingFunctionWithNullCheck.java | 9 +- .../data/neo4j}/core/DynamicLabels.java | 14 +- .../data/neo4j}/core/NamedParameters.java | 9 +- .../data/neo4j}/core/Neo4jClient.java | 13 +- .../data/neo4j}/core/Neo4jOperations.java | 11 +- .../data/neo4j}/core/Neo4jTemplate.java | 62 +- .../core/NestedRelationshipContext.java | 15 +- ...tedRelationshipProcessingStateMachine.java | 11 +- .../data/neo4j}/core/PreparedQuery.java | 9 +- .../ReactiveDatabaseSelectionProvider.java | 9 +- .../data/neo4j}/core/ReactiveNeo4jClient.java | 13 +- .../neo4j}/core/ReactiveNeo4jOperations.java | 9 +- .../neo4j}/core/ReactiveNeo4jTemplate.java | 60 +- .../core/RelationshipStatementHolder.java | 15 +- .../core/SingleValueMappingFunction.java | 9 +- .../neo4j}/core/convert/AdditionalTypes.java | 9 +- .../data/neo4j}/core/convert/CypherTypes.java | 9 +- .../neo4j}/core/convert/Neo4jConversions.java | 12 +- .../neo4j}/core/convert/Neo4jConverter.java | 9 +- .../neo4j}/core/convert/Neo4jSimpleTypes.java | 17 +- .../neo4j}/core/convert/SpatialTypes.java | 23 +- .../core/convert/TemporalAmountAdapter.java | 9 +- .../neo4j}/core/convert/package-info.java | 2 +- .../core/mapping/DefaultNeo4jConverter.java | 39 +- .../mapping/DefaultNeo4jIsNewStrategy.java | 11 +- .../mapping/DefaultNeo4jPersistentEntity.java | 19 +- .../DefaultNeo4jPersistentProperty.java | 21 +- .../DefaultRelationshipDescription.java | 15 +- .../core/mapping/Neo4jMappingContext.java | 23 +- .../core/mapping/Neo4jPersistentEntity.java | 11 +- .../core/mapping/Neo4jPersistentProperty.java | 15 +- .../mapping/NodeDescriptionAndLabels.java | 11 +- .../core/mapping/NodeDescriptionStore.java | 11 +- .../neo4j}/core/mapping/package-info.java | 2 +- .../data/neo4j}/core/package-info.java | 2 +- .../data/neo4j}/core/schema/Constants.java | 9 +- .../neo4j}/core/schema/CypherGenerator.java | 87 +- .../neo4j}/core/schema/DynamicLabels.java | 9 +- .../neo4j}/core/schema/GeneratedValue.java | 9 +- .../core/schema/GraphPropertyDescription.java | 9 +- .../data/neo4j}/core/schema/Id.java | 9 +- .../neo4j}/core/schema/IdDescription.java | 17 +- .../data/neo4j}/core/schema/IdGenerator.java | 9 +- .../data/neo4j}/core/schema/Node.java | 9 +- .../neo4j}/core/schema/NodeDescription.java | 9 +- .../data/neo4j}/core/schema/Property.java | 9 +- .../data/neo4j}/core/schema/Relationship.java | 9 +- .../core/schema/RelationshipDescription.java | 16 +- .../core/schema/RelationshipProperties.java | 9 +- .../data/neo4j}/core/schema/Schema.java | 11 +- .../core/schema/UnknownEntityException.java | 9 +- .../data/neo4j}/core/schema/package-info.java | 2 +- .../neo4j}/core/support/Relationships.java | 11 +- .../core/support/UUIDStringGenerator.java | 11 +- .../transaction/Neo4jBookmarkManager.java | 9 +- .../Neo4jSessionSynchronization.java | 9 +- .../transaction/Neo4jTransactionContext.java | 9 +- .../transaction/Neo4jTransactionHolder.java | 11 +- .../transaction/Neo4jTransactionManager.java | 18 +- .../transaction/Neo4jTransactionUtils.java | 13 +- .../ReactiveNeo4jSessionSynchronization.java | 9 +- .../ReactiveNeo4jTransactionHolder.java | 13 +- .../ReactiveNeo4jTransactionManager.java | 24 +- .../neo4j}/core/transaction/package-info.java | 2 +- .../neo4j}/repository/Neo4jRepository.java | 9 +- .../neo4j}/repository/NoResultException.java | 9 +- .../repository/ReactiveNeo4jRepository.java | 9 +- .../config/EnableNeo4jRepositories.java | 28 +- .../EnableReactiveNeo4jRepositories.java | 22 +- .../config/Neo4jRepositoriesRegistrar.java | 9 +- ...Neo4jRepositoryConfigurationExtension.java | 20 +- .../ReactiveNeo4jRepositoriesRegistrar.java | 9 +- ...Neo4jRepositoryConfigurationExtension.java | 20 +- .../repository/config/StartupLogger.java | 87 + .../repository/config/package-info.java | 2 +- .../event/AuditingBeforeBindCallback.java | 9 +- .../repository/event/BeforeBindCallback.java | 9 +- .../event/IdGeneratingBeforeBindCallback.java | 11 +- .../neo4j}/repository/event/IdPopulator.java | 19 +- .../OptimisticLockingBeforeBindCallback.java | 15 +- .../ReactiveAuditingBeforeBindCallback.java | 9 +- .../event/ReactiveBeforeBindCallback.java | 9 +- ...eactiveIdGeneratingBeforeBindCallback.java | 11 +- ...veOptimisticLockingBeforeBindCallback.java | 15 +- .../neo4j}/repository/event/package-info.java | 2 +- .../data/neo4j}/repository/package-info.java | 2 +- .../repository/query/AbstractNeo4jQuery.java | 18 +- .../query/AbstractReactiveNeo4jQuery.java | 15 +- .../neo4j}/repository/query/BoundingBox.java | 9 +- .../neo4j}/repository/query/CountQuery.java | 9 +- .../repository/query/CypherAdapterUtils.java | 15 +- .../repository/query/CypherQueryCreator.java | 36 +- .../neo4j}/repository/query/ExistsQuery.java | 9 +- .../query/Neo4jParameterAccessor.java | 13 +- .../repository/query/Neo4jQueryExecution.java | 15 +- .../query/Neo4jQueryLookupStrategy.java | 13 +- .../repository/query/Neo4jQueryMethod.java | 9 +- .../repository/query/Neo4jQuerySupport.java | 16 +- .../repository/query/Neo4jQueryType.java | 9 +- .../query/OptionalUnwrappingConverter.java | 9 +- .../repository/query/PartTreeNeo4jQuery.java | 15 +- .../repository/query/PartValidator.java | 9 +- .../data/neo4j}/repository/query/Query.java | 9 +- .../repository/query/QueryAndParameters.java | 9 +- .../ReactiveNeo4jQueryLookupStrategy.java | 13 +- .../query/ReactiveNeo4jQueryMethod.java | 9 +- .../query/ReactivePartTreeNeo4jQuery.java | 15 +- .../query/ReactiveStringBasedNeo4jQuery.java | 15 +- .../query/StringBasedNeo4jQuery.java | 15 +- .../neo4j}/repository/query/package-info.java | 2 +- .../DefaultNeo4jEntityInformation.java | 11 +- .../support/Neo4jEntityInformation.java | 11 +- .../Neo4jPersistenceExceptionTranslator.java | 9 +- .../support/Neo4jRepositoryFactory.java | 23 +- .../support/Neo4jRepositoryFactoryBean.java | 13 +- .../Neo4jRepositoryFactorySupport.java | 9 +- .../neo4j}/repository/support/Predicate.java | 23 +- .../ReactiveNeo4jRepositoryFactory.java | 21 +- .../ReactiveNeo4jRepositoryFactoryBean.java | 13 +- ...stenceExceptionTranslationInterceptor.java | 9 +- ...enceExceptionTranslationPostProcessor.java | 13 +- .../support/SimpleNeo4jRepository.java | 21 +- .../support/SimpleQueryByExampleExecutor.java | 22 +- .../SimpleReactiveNeo4jRepository.java | 19 +- .../SimpleReactiveQueryByExampleExecutor.java | 17 +- .../repository/support/package-info.java | 2 +- .../data/neo4j}/types/AbstractPoint.java | 9 +- .../data/neo4j}/types/CartesianPoint2d.java | 9 +- .../data/neo4j}/types/CartesianPoint3d.java | 9 +- .../data/neo4j}/types/Coordinate.java | 9 +- .../data/neo4j}/types/GeographicPoint2d.java | 9 +- .../data/neo4j}/types/GeographicPoint3d.java | 9 +- .../data/neo4j}/types/Neo4jPoint.java | 9 +- .../data/neo4j}/types/PointBuilder.java | 9 +- .../data/neo4j}/types/package-info.java | 2 +- .../data/neo4j}/core/Neo4jClientExtensions.kt | 17 +- .../data/neo4j}/core/PreparedQueryFactory.kt | 9 +- .../core/ReactiveNeo4jClientExtensions.kt | 15 +- .../core/ReactiveNeo4jOperationsExtensions.kt | 9 +- .../data/neo4j}/core/cypher/Parameters.kt | 9 +- .../main/resources/META-INF/spring.factories | 2 +- .../main/resources/META-INF/spring.tooling | 0 .../config/Neo4jAuditingRegistrarTest.java | 9 +- .../core/DatabaseSelectionProviderTest.java | 9 +- ...atingMappingFunctionWithNullCheckTest.java | 9 +- .../data/neo4j}/core/NamedParametersTest.java | 9 +- .../data/neo4j}/core/Neo4jClientTest.java | 11 +- .../neo4j}/core/ReactiveNeo4jClientTest.java | 44 +- .../core/SingleValueMappingFunctionTest.java | 11 +- .../neo4j}/core/TransactionHandlingTest.java | 13 +- .../neo4j}/core/convert/SpatialTypesTest.java | 17 +- .../convert/TemporalAmountAdapterTest.java | 9 +- .../mapping/DefaultNeo4jConverterTest.java | 18 +- .../DefaultNeo4jIsNewStrategyTest.java | 15 +- .../DefaultNeo4jPersistentEntityTest.java | 36 +- .../DefaultNeo4jPersistentPropertyTest.java | 9 +- .../core/mapping/Neo4jMappingContextTest.java | 36 +- .../core/schema/CypherGeneratorTest.java | 23 +- .../neo4j}/core/schema/IdDescriptionTest.java | 9 +- .../transaction/Neo4jBookmarkManagerTest.java | 9 +- .../Neo4jTransactionManagerTest.java | 29 +- .../Neo4jTransactionUtilsTest.java | 17 +- .../ReactiveNeo4jTransactionManagerTest.java | 27 +- .../integration/Neo4jConversionsIT.java | 15 +- .../integration/imperative/AuditingIT.java | 23 +- .../integration/imperative/CallbacksIT.java | 21 +- .../imperative/CausalClusterLoadTestIT.java | 21 +- .../imperative/CustomBaseRepositoryIT.java | 28 +- .../imperative/DefaultNeo4jConverterIT.java | 27 +- .../imperative/DynamicLabelsIT.java | 25 +- .../imperative/DynamicRelationshipsIT.java | 25 +- .../imperative/ExceptionTranslationIT.java | 29 +- .../imperative/IdGeneratorsIT.java | 21 +- .../imperative/Neo4jOperationsIT.java | 29 +- .../imperative/OptimisticLockingIT.java | 23 +- .../integration/imperative/ProjectionIT.java | 27 +- ...elationshipsAsConstructorParametersIT.java | 19 +- .../imperative/RelationshipsIT.java | 17 +- .../integration/imperative/RepositoryIT.java | 52 +- .../RepositoryWithADifferentDatabaseIT.java | 13 +- .../StringlyTypedDynamicRelationshipsIT.java | 21 +- .../TransactionManagerMixedDatabasesTest.java | 23 +- .../imperative/TypeConversionIT.java | 40 +- .../repositories/PersonRepository.java | 31 +- .../repositories/ThingRepository.java | 13 +- .../imperative/repositories/package-info.java | 4 + .../neo4j}/integration/kotlin/KotlinIT.java | 21 +- .../CustomReactiveBaseRepositoryIT.java | 28 +- .../reactive/ReactiveAuditingIT.java | 25 +- .../reactive/ReactiveCallbacksIT.java | 25 +- .../ReactiveCausalClusterLoadTestIT.java | 21 +- .../reactive/ReactiveDynamicLabelsIT.java | 27 +- .../ReactiveDynamicRelationshipsIT.java | 29 +- .../ReactiveExceptionTranslationIT.java | 31 +- .../reactive/ReactiveIdGeneratorsIT.java | 23 +- .../reactive/ReactiveNeo4jOperationsIT.java | 31 +- .../reactive/ReactiveOptimisticLockingIT.java | 25 +- .../reactive/ReactiveProjectionIT.java | 29 +- .../reactive/ReactiveRelationshipsIT.java | 19 +- .../reactive/ReactiveRepositoryIT.java | 37 +- ...iveRepositoryWithADifferentDatabaseIT.java | 13 +- ...iveStringlyTypeDynamicRelationshipsIT.java | 25 +- ...eTransactionManagerMixedDatabasesTest.java | 25 +- .../reactive/ReactiveTypeConversionIT.java | 25 +- .../ReactivePersonRepository.java | 23 +- .../repositories/ReactiveThingRepository.java | 13 +- .../reactive/repositories/package-info.java | 4 + .../shared/AbstractNamedThing.java | 9 +- .../shared/AnotherThingWithAssignedId.java | 13 +- .../integration/shared/AuditableThing.java | 9 +- .../integration/shared/AuditingITBase.java | 13 +- .../integration/shared/BidirectionalEnd.java | 23 +- .../shared/BidirectionalStart.java | 17 +- .../integration/shared/CallbacksITBase.java | 13 +- .../data/neo4j/integration/shared/Club.java | 14 +- .../integration/shared/DeepRelationships.java | 15 +- .../shared/DtoPersonProjection.java | 9 +- .../shared/DynamicRelationshipsITBase.java | 13 +- .../shared/EntitiesWithDynamicLabels.java | 17 +- .../shared/EntityWithConvertedId.java | 11 +- .../data/neo4j}/integration/shared/Hobby.java | 15 +- .../shared/IdGeneratorsITBase.java | 13 +- .../shared/ImmutableAuditableThing.java | 11 +- ...mmutableAuditableThingWithGeneratedId.java | 13 +- .../integration/shared/ImmutablePerson.java | 16 +- .../integration/shared/Inheritance.java | 17 +- .../shared/LikesHobbyRelationship.java | 13 +- .../integration/shared/MultipleLabels.java | 17 +- .../shared/MultipleRelationshipsThing.java | 15 +- .../neo4j}/integration/shared/NamesOnly.java | 9 +- .../integration/shared/NamesOnlyDto.java | 9 +- .../shared/Neo4jConversionsITBase.java | 21 +- .../neo4j}/integration/shared/Person.java | 17 +- .../integration/shared/PersonProjection.java | 9 +- .../integration/shared/PersonSummary.java | 9 +- .../shared/PersonWithAllConstructor.java | 17 +- .../shared/PersonWithNoConstructor.java | 17 +- .../shared/PersonWithRelationship.java | 17 +- .../PersonWithRelationshipWithProperties.java | 17 +- .../shared/PersonWithRelatives.java | 15 +- .../PersonWithStringlyTypedRelatives.java | 15 +- .../integration/shared/PersonWithWither.java | 15 +- .../data/neo4j}/integration/shared/Pet.java | 17 +- ...nshipsAsConstructorParametersEntities.java | 17 +- .../shared/RelationshipsITBase.java | 13 +- .../integration/shared/SimilarThing.java | 17 +- .../shared/TestSequenceGenerator.java | 11 +- .../shared/ThingWithAllAdditionalTypes.java | 15 +- .../shared/ThingWithAllCypherTypes.java | 15 +- .../shared/ThingWithAllSpatialTypes.java | 23 +- .../shared/ThingWithAssignedId.java | 15 +- .../shared/ThingWithCustomTypes.java | 15 +- .../shared/ThingWithGeneratedId.java | 15 +- .../shared/ThingWithIdGeneratedByBean.java | 15 +- .../ThingWithNonExistingPrimitives.java | 15 +- .../integration/shared/ThingWithSequence.java | 15 +- .../integration/shared/ThingWithUUIDID.java | 15 +- .../integration/shared/VersionedThing.java | 17 +- .../shared/VersionedThingWithAssignedId.java | 15 +- .../config/EnableNeo4jRepositoriesTests.java | 9 +- .../repository/config/StartupLoggerTest.java | 22 +- .../event/AuditingBeforeBindCallbackTest.java | 11 +- .../repository/event/IdPopulatorTest.java | 23 +- .../repository/event/ImmutableSample.java | 9 +- ...eactiveAuditingBeforeBindCallbackTest.java | 11 +- .../data/neo4j}/repository/event/Sample.java | 9 +- .../repository/query/BoundingBoxTest.java | 9 +- .../repository/query/RepositoryQueryTest.java | 20 +- ...o4jPersistenceExceptionTranslatorTest.java | 9 +- .../Neo4jRepositoryFactorySupportTest.java | 28 +- .../support/Neo4jRepositoryFactoryTest.java | 9 +- .../ReactiveNeo4jRepositoryFactoryTest.java | 9 +- .../test/CausalClusterIntegrationTest.java | 9 +- .../data/neo4j}/test/DriverMocks.java | 9 +- .../data/neo4j}/test/Neo4jExtension.java | 9 +- .../neo4j}/test/Neo4jIntegrationTest.java | 9 +- .../neo4j}/types/GeographicPoint2dTest.java | 9 +- .../neo4j}/types/GeographicPoint3dTest.java | 9 +- .../neo4j}/core/Neo4jClientExtensionsTest.kt | 9 +- .../core/PreparedQueryExtensionsTest.kt | 9 +- .../core/ReactiveNeo4jClientExtensionsTest.kt | 9 +- .../ReactiveNeo4jOperationsExtensionsTest.kt | 9 +- .../data/neo4j}/core/cypher/ParametersTest.kt | 9 +- .../imperative/ImmutableRelationshipsIT.kt | 33 +- .../imperative/Neo4jClientKotlinInteropIT.kt | 25 +- .../ReactiveNeo4jClientKotlinInteropIT.kt | 27 +- .../neo4j/integration/shared/KotlinPerson.kt | 21 +- .../integration/shared/KotlinRepository.kt | 10 +- .../META-INF/neo4j-named-queries.properties | 7 +- src/test/resources/logback-test.xml | 40 + .../org.mockito.plugins.MockMaker | 0 697 files changed, 6852 insertions(+), 33948 deletions(-) delete mode 100644 checkstyle/config.xml delete mode 100644 checkstyle/java-header.txt delete mode 100644 checkstyle/suppressions.xml delete mode 100644 spring-data-neo4j-distribution/pom.xml delete mode 100644 spring-data-neo4j/pom.xml delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Depth.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/EnableBookmarkManagement.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/EnableNeo4jAuditing.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/ExistsQuery.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Query.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/QueryResult.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/UseBookmark.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BeanFactoryBookmarkOperationAdvisor.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkInfo.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkInterceptor.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkManagementConfiguration.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkManager.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkOperationPointcut.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkSupport.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/CaffeineBookmarkManager.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionService.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/Neo4jOgmEntityInstantiatorAdapter.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/PointConverter.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/Neo4jErrorStatusCodes.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/UncategorizedNeo4jException.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/MetaDataProvider.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jMappingContext.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentEntity.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentProperty.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/Neo4jRepository.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiRepositoryBean.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiRepositoryExtension.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositories.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jAuditingEventListener.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jAuditingRegistrar.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jMappingContextFactoryBean.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jOgmEntityInstantiatorConfigurationBean.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrar.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtension.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryNameSpaceHandler.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/AbstractGraphRepositoryQuery.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/CustomResultConverter.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/FilterBuildersDefinition.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParameterAccessor.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParameters.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParametersParameterAccessor.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryExecution.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryLookupStrategy.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryMethod.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphRepositoryQuery.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/NamedGraphRepositoryQuery.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/PartTreeNeo4jQuery.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/Query.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/QueryResultInstantiator.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/QueryResultProxy.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/TemplatedQuery.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/TemplatedQueryCreator.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/BetweenComparisonBuilder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/BooleanComparisonBuilder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/ContainsComparisonBuilder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/DistanceComparisonBuilder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/ExistsFilterBuilder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/FilterBuilder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/IsNullFilterBuilder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/NativeIdFilterFunction.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/PropertyComparisonBuilder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/Neo4jQueryPlaceholderSupplier.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/ParameterizedQuery.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/PlaceholderSupplier.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/GraphEntityInformation.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jAuditingBeanPostProcessor.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslator.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactory.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBean.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/Neo4jTransactionManager.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SessionFactoryUtils.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SessionHolder.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SharedSessionCreator.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/util/PagingAndSortingUtils.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/util/package-info.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/AsyncRequestInterceptor.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/OpenSessionInViewFilter.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/OpenSessionInViewInterceptor.java delete mode 100644 spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/package-info.java delete mode 100644 spring-data-neo4j/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension delete mode 100644 spring-data-neo4j/src/main/resources/META-INF/spring.handlers delete mode 100644 spring-data-neo4j/src/main/resources/META-INF/spring.schemas delete mode 100644 spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-4.2.xsd delete mode 100644 spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-5.0.xsd delete mode 100644 spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-5.1.xsd delete mode 100644 spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/package-info.java delete mode 100644 spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/package-info.java delete mode 100644 spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Club.java delete mode 100644 spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonProjection.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/JavaConfigurationAuditingTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/domain/User.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/repository/UserRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/bookmark/BookmarkManagementTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/bookmark/BookmarkWrapper.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionServiceIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionServiceTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/Neo4jOgmEntityInstantiatorAdapterTest.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/MyNode.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/MyNodeRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/ResultHolder.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/ConvertedClass.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/Converters.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/EntityWithConvertedAttributes.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/EntityWithInvalidProperty.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/EntityWithInvalidPropertyRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/package-info.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/Address.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/NodeWithUUIDAsId.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/Role.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/SampleEntity.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/SpecialUser.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/User.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/EventPublisher.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/ModificationEvent.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/Neo4jModificationEventListener.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PostDeleteEvent.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PostSaveEvent.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PreDeleteEvent.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PreSaveEvent.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/FriendService.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/FriendTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/domain/Friendship.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/domain/Person.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/repo/FriendshipRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyContextConfiguration.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyServiceTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/WorldRepositoryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/domain/World.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/repo/WorldRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/service/GalaxyService.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/JSR303Tests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/WebConfiguration.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/controller/AdultController.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/domain/Adult.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/repo/AdultRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/service/AdultService.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/AbstractAnnotatedEntity.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/AbstractEntity.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Actor.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Cinema.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/CinemaAndBlockbusterName.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Director.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Genre.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Movie.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Person.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Rating.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/ReleasedMovie.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/TempMovie.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/User.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResult.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResultInterface.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResultInterfaceImpl.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/EntityWrappingQueryResult.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/Gender.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/RichUserQueryResult.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/UserQueryResult.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/UserQueryResultObject.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/YearConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/AbstractAnnotatedEntityRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/AbstractEntityRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/ActorRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/CinemaRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/CinemaStreamingRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/DirectorRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/GenreRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/PersonRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/RatingRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/TempMovieRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UnmanagedUserPojo.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UserRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/service/UserService.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/service/UserServiceImpl.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/RestaurantTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/domain/Diner.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/domain/Restaurant.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/repo/RestaurantRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomGraphRepositoryImpl.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomGraphRepositoryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomNeo4jRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/UserRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/PersistenceConstructorsTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Friendship.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Group.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Person.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonMultipleConstructors.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonProjection.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithAnnotatedPersistenceConstructor.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithCompositeAttribute.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithFinalName.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithManyToOneRel.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ConversionServiceTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/JavaElementRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/PensionRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ShouldGracefullyHandleMultipleConversionServicesTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ShouldPickPrimaryConversionServiceTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SiteMemberRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringBigIntegerToBooleanConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringBooleanToBigIntegerConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringByteArrayToIntegerConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringIntegerToByteArrayConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringIntegerToMonetaryAmountConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringLongToMonetaryAmountConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToIntegerConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToLongConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToNumberConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToNumberConverterFactory.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringNumberToMonetaryAmountConverter.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/JavaElement.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/MonetaryAmount.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/PensionPlan.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/SiteMember.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/Neo4jPersistentPropertyTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/NamedQueryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/domain/SampleEntityForNamedQuery.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/repo/SampleEntityForNamedQueryRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/NativeTypesContextConfiguration.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialConversionTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialDomain.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialDomainRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialFindByTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialNearTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialPersistenceContextConfiguration.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeDomain.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeDomainRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeFindByTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedQueryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedRelationshipEntityQueryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/Java8SupportTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/MoviesContextConfiguration.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/PagedQueryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ProjectionTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryResultIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryReturnTypesTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/StoredProceduresTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/AnotherThing.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingEntity.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingResult.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/Thing.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/ThingEntity.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/ThingRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/stored_procedures/DocumentRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/ProgrammaticRepositoryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/RepoScanningTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/RepositoryDefinitionTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/domain/Movie.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/domain/User.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/repo/MovieRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/repo/UserRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/support/GraphRepositoryFactoryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/Contact.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/ContactRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/MultipleSessionFactorySupportTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/Neo4jRepositoryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/CdiExtensionTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/CdiPersonRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiProducer.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/Neo4jRepositoryExtensionTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/OtherQualifier.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/PersonDB.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/QualifiedPersonRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/RepositoryClient.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonFragment.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonFragmentImpl.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrarTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtensionTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/RepositoriesJavaConfigTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/GraphQueryExecutionTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/filter/DistanceComparisonBuilderTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/MinimalRelationshipEntityMappingTest.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Actor.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Movie.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Role.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/RoleRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/sample/UserRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/DefaultTransactionDisablingIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslatorIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBeanTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepositoryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/TransactionalRepositoryTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/TemplateApplicationEventTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/TestNeo4jEventListener.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/CloseServerControlsAfterTestClassTestExecutionListener.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/GraphDatabaseServiceAssert.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/Neo4jIntegrationTest.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/Neo4jTestServerConfiguration.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/NodeAssert.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/SessionFactoryRegistrar.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/package-info.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/BookmarkTransactionTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/ExtendedTransactionsTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/MapPropertiesTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/Neo4jTransactionManagerTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/SessionFactoryUtilsTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/SharedSessionCreatorTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionRollbackTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionalEventListenerTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/domain/ThreadInfo.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/domain/User.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/repo/ThreadInfoRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/repo/UserRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/BusinessService.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/ServiceA.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/ServiceB.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/WrapperService.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/WebIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/XmlApplicationContextWebIntegrationTests.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/controller/UserController.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/Cinema.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/Genre.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/User.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/repo/GenreRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/repo/UserRepository.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/service/UserService.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/service/UserServiceImpl.java delete mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/support/OpenSessionInViewTests.java delete mode 100644 spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/shared/KotlinPerson.kt delete mode 100644 spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/shared/KotlinRepository.kt delete mode 100644 spring-data-neo4j/src/test/kotlin/org/springframework/data/neo4j/integration/constructors/domain/KotlinFriendship.kt delete mode 100644 spring-data-neo4j/src/test/kotlin/org/springframework/data/neo4j/integration/constructors/domain/KotlinPerson.kt delete mode 100644 spring-data-neo4j/src/test/resources/META-INF/spring.factories delete mode 100644 spring-data-neo4j/src/test/resources/logback-test.xml delete mode 100644 spring-data-neo4j/src/test/resources/xml-based-configuration-applicationContext.xml delete mode 100644 spring-data-neo4j/template.mf create mode 100644 src/main/asciidoc/appendix/build.adoc create mode 100644 src/main/asciidoc/appendix/conversions.adoc create mode 100644 src/main/asciidoc/appendix/index.adoc create mode 100644 src/main/asciidoc/appendix/migrating.adoc create mode 100644 src/main/asciidoc/appendix/neo4j-client.adoc create mode 100644 src/main/asciidoc/appendix/query-creation.adoc create mode 100644 src/main/asciidoc/appendix/sdc-repository-query-keywords-reference.adoc create mode 100644 src/main/asciidoc/appendix/sdc-repository-query-return-types-reference.adoc create mode 100644 src/main/asciidoc/auditing/index.adoc create mode 100644 src/main/asciidoc/auditing/sdc-auditing.adoc delete mode 100644 src/main/asciidoc/faq.adoc create mode 100644 src/main/asciidoc/faq/faq.adoc create mode 100644 src/main/asciidoc/faq/index.adoc delete mode 100644 src/main/asciidoc/foreword.adoc create mode 100644 src/main/asciidoc/getting-started/getting-started.adoc create mode 100644 src/main/asciidoc/getting-started/index.adoc delete mode 100644 src/main/asciidoc/images/SDN-Architecture.png delete mode 100644 src/main/asciidoc/images/neo4j-cluster.png create mode 100644 src/main/asciidoc/introduction-and-preface/building-blocks.adoc create mode 100644 src/main/asciidoc/introduction-and-preface/index.adoc create mode 100644 src/main/asciidoc/introduction-and-preface/introduction.adoc create mode 100644 src/main/asciidoc/introduction-and-preface/preface.adoc delete mode 100644 src/main/asciidoc/migration.adoc delete mode 100644 src/main/asciidoc/new-features.adoc create mode 100644 src/main/asciidoc/object-mapping/index.adoc create mode 100644 src/main/asciidoc/object-mapping/mapping.adoc create mode 100644 src/main/asciidoc/object-mapping/sdc-object-mapping.adoc delete mode 100644 src/main/asciidoc/preface.adoc delete mode 100644 src/main/asciidoc/reference/auditing.adoc delete mode 100644 src/main/asciidoc/reference/getting-started.adoc delete mode 100644 src/main/asciidoc/reference/introduction.adoc delete mode 100644 src/main/asciidoc/reference/neo4j-repositories.adoc delete mode 100644 src/main/asciidoc/reference/ogm-support.adoc delete mode 100644 src/main/asciidoc/reference/projections.adoc create mode 100644 src/main/asciidoc/repositories/index.adoc create mode 100644 src/main/asciidoc/repositories/sdc-projections.adoc create mode 100644 src/main/asciidoc/repositories/sdc-repositories.adoc create mode 100644 src/main/asciidoc/testing/index.adoc create mode 100644 src/main/asciidoc/testing/testing.adoc rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/config/AbstractNeo4jConfig.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/config/AbstractReactiveNeo4jConfig.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/config/EnableNeo4jAuditing.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/config/Neo4jAuditingRegistrar.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/config/Neo4jConfigurationSupport.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/config/Neo4jDefaultCallbacksRegistrar.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/config/Neo4jDefaultReactiveCallbacksRegistrar.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/config/package-info.java (83%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/DatabaseSelection.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/DatabaseSelectionProvider.java (93%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/DefaultNeo4jClient.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/DefaultReactiveNeo4jClient.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/DelegatingMappingFunctionWithNullCheck.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/DynamicLabels.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/NamedParameters.java (93%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/Neo4jClient.java (97%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/Neo4jOperations.java (97%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/Neo4jTemplate.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/NestedRelationshipContext.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/NestedRelationshipProcessingStateMachine.java (93%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/PreparedQuery.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/ReactiveDatabaseSelectionProvider.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/ReactiveNeo4jClient.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/ReactiveNeo4jOperations.java (97%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/ReactiveNeo4jTemplate.java (93%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/RelationshipStatementHolder.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/SingleValueMappingFunction.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/convert/AdditionalTypes.java (98%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/convert/CypherTypes.java (93%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/convert/Neo4jConversions.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/convert/Neo4jConverter.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/convert/Neo4jSimpleTypes.java (86%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/convert/SpatialTypes.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/convert/TemporalAmountAdapter.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/convert/package-info.java (66%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/DefaultNeo4jConverter.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/DefaultNeo4jIsNewStrategy.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/DefaultNeo4jPersistentEntity.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/DefaultNeo4jPersistentProperty.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/DefaultRelationshipDescription.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/Neo4jMappingContext.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/Neo4jPersistentEntity.java (85%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/Neo4jPersistentProperty.java (85%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/NodeDescriptionAndLabels.java (82%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/NodeDescriptionStore.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/mapping/package-info.java (81%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/package-info.java (80%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/Constants.java (88%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/CypherGenerator.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/DynamicLabels.java (88%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/GeneratedValue.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/GraphPropertyDescription.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/Id.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/IdDescription.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/IdGenerator.java (82%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/Node.java (88%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/NodeDescription.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/Property.java (86%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/Relationship.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/RelationshipDescription.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/RelationshipProperties.java (85%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/Schema.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/UnknownEntityException.java (85%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/schema/package-info.java (85%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/support/Relationships.java (88%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/support/UUIDStringGenerator.java (77%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/Neo4jBookmarkManager.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/Neo4jSessionSynchronization.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/Neo4jTransactionContext.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/Neo4jTransactionHolder.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/Neo4jTransactionManager.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/Neo4jTransactionUtils.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/ReactiveNeo4jSessionSynchronization.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/ReactiveNeo4jTransactionHolder.java (83%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/ReactiveNeo4jTransactionManager.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/core/transaction/package-info.java (70%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/Neo4jRepository.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/NoResultException.java (83%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/ReactiveNeo4jRepository.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/config/EnableNeo4jRepositories.java (79%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/config/EnableReactiveNeo4jRepositories.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/config/Neo4jRepositoriesRegistrar.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/config/Neo4jRepositoryConfigurationExtension.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/config/ReactiveNeo4jRepositoriesRegistrar.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/config/ReactiveNeo4jRepositoryConfigurationExtension.java (89%) create mode 100644 src/main/java/org/springframework/data/neo4j/repository/config/StartupLogger.java rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/config/package-info.java (69%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/AuditingBeforeBindCallback.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/BeforeBindCallback.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/IdGeneratingBeforeBindCallback.java (82%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/IdPopulator.java (82%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/OptimisticLockingBeforeBindCallback.java (83%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/ReactiveAuditingBeforeBindCallback.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/ReactiveBeforeBindCallback.java (88%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/ReactiveIdGeneratingBeforeBindCallback.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/ReactiveOptimisticLockingBeforeBindCallback.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/event/package-info.java (93%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/package-info.java (70%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/AbstractNeo4jQuery.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/AbstractReactiveNeo4jQuery.java (86%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/BoundingBox.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/CountQuery.java (83%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/CypherAdapterUtils.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/CypherQueryCreator.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/ExistsQuery.java (83%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/Neo4jParameterAccessor.java (79%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/Neo4jQueryExecution.java (84%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/Neo4jQueryLookupStrategy.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/Neo4jQueryMethod.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/Neo4jQuerySupport.java (93%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/Neo4jQueryType.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/OptionalUnwrappingConverter.java (83%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/PartTreeNeo4jQuery.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/PartValidator.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/Query.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/QueryAndParameters.java (81%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/ReactiveNeo4jQueryLookupStrategy.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/ReactiveNeo4jQueryMethod.java (94%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/ReactivePartTreeNeo4jQuery.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/ReactiveStringBasedNeo4jQuery.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/StringBasedNeo4jQuery.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/query/package-info.java (70%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/DefaultNeo4jEntityInformation.java (82%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/Neo4jEntityInformation.java (79%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/Neo4jPersistenceExceptionTranslator.java (98%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/Neo4jRepositoryFactory.java (82%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/Neo4jRepositoryFactoryBean.java (86%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/Neo4jRepositoryFactorySupport.java (89%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/Predicate.java (90%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/ReactiveNeo4jRepositoryFactory.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/ReactiveNeo4jRepositoryFactoryBean.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/ReactivePersistenceExceptionTranslationInterceptor.java (95%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/ReactivePersistenceExceptionTranslationPostProcessor.java (92%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/SimpleNeo4jRepository.java (88%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/SimpleQueryByExampleExecutor.java (85%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/SimpleReactiveNeo4jRepository.java (91%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/SimpleReactiveQueryByExampleExecutor.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/repository/support/package-info.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/AbstractPoint.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/CartesianPoint2d.java (85%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/CartesianPoint3d.java (86%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/Coordinate.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/GeographicPoint2d.java (86%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/GeographicPoint3d.java (87%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/Neo4jPoint.java (86%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/PointBuilder.java (86%) rename {spring-data-neo4j/src/main/java/org/neo4j/springframework/data => src/main/java/org/springframework/data/neo4j}/types/package-info.java (69%) rename {spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data => src/main/kotlin/org/springframework/data/neo4j}/core/Neo4jClientExtensions.kt (87%) rename {spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data => src/main/kotlin/org/springframework/data/neo4j}/core/PreparedQueryFactory.kt (82%) rename {spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data => src/main/kotlin/org/springframework/data/neo4j}/core/ReactiveNeo4jClientExtensions.kt (89%) rename {spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data => src/main/kotlin/org/springframework/data/neo4j}/core/ReactiveNeo4jOperationsExtensions.kt (85%) rename {spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data => src/main/kotlin/org/springframework/data/neo4j}/core/cypher/Parameters.kt (83%) rename {spring-data-neo4j/src => src}/main/resources/META-INF/spring.factories (56%) rename {spring-data-neo4j/src => src}/main/resources/META-INF/spring.tooling (100%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/config/Neo4jAuditingRegistrarTest.java (87%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/DatabaseSelectionProviderTest.java (89%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/DelegatingMappingFunctionWithNullCheckTest.java (87%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/NamedParametersTest.java (95%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/Neo4jClientTest.java (98%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/ReactiveNeo4jClientTest.java (88%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/SingleValueMappingFunctionTest.java (93%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/TransactionHandlingTest.java (96%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/convert/SpatialTypesTest.java (78%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/convert/TemporalAmountAdapterTest.java (90%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/mapping/DefaultNeo4jConverterTest.java (84%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/mapping/DefaultNeo4jIsNewStrategyTest.java (94%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/mapping/DefaultNeo4jPersistentEntityTest.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/mapping/DefaultNeo4jPersistentPropertyTest.java (88%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/mapping/Neo4jMappingContextTest.java (89%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/schema/CypherGeneratorTest.java (93%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/schema/IdDescriptionTest.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/transaction/Neo4jBookmarkManagerTest.java (92%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/transaction/Neo4jTransactionManagerTest.java (92%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/transaction/Neo4jTransactionUtilsTest.java (73%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/core/transaction/ReactiveNeo4jTransactionManagerTest.java (89%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/Neo4jConversionsIT.java (94%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/AuditingIT.java (87%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/CallbacksIT.java (80%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/CausalClusterLoadTestIT.java (88%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/CustomBaseRepositoryIT.java (77%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/DefaultNeo4jConverterIT.java (82%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/DynamicLabelsIT.java (96%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/DynamicRelationshipsIT.java (90%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/ExceptionTranslationIT.java (86%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/IdGeneratorsIT.java (85%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/Neo4jOperationsIT.java (94%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/OptimisticLockingIT.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/ProjectionIT.java (87%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/RelationshipsAsConstructorParametersIT.java (83%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/RelationshipsIT.java (94%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/RepositoryIT.java (98%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/RepositoryWithADifferentDatabaseIT.java (81%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/StringlyTypedDynamicRelationshipsIT.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/TransactionManagerMixedDatabasesTest.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/TypeConversionIT.java (87%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/repositories/PersonRepository.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/imperative/repositories/ThingRepository.java (74%) create mode 100644 src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/package-info.java rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/kotlin/KotlinIT.java (78%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/CustomReactiveBaseRepositoryIT.java (78%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveAuditingIT.java (90%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveCallbacksIT.java (86%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveCausalClusterLoadTestIT.java (89%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveDynamicLabelsIT.java (96%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveDynamicRelationshipsIT.java (90%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveExceptionTranslationIT.java (85%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveIdGeneratorsIT.java (89%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveNeo4jOperationsIT.java (93%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveOptimisticLockingIT.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveProjectionIT.java (86%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveRelationshipsIT.java (94%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveRepositoryIT.java (98%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveRepositoryWithADifferentDatabaseIT.java (82%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveStringlyTypeDynamicRelationshipsIT.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveTransactionManagerMixedDatabasesTest.java (92%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/ReactiveTypeConversionIT.java (82%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/repositories/ReactivePersonRepository.java (80%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/reactive/repositories/ReactiveThingRepository.java (72%) create mode 100644 src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/package-info.java rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/AbstractNamedThing.java (76%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/AnotherThingWithAssignedId.java (79%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/AuditableThing.java (77%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/AuditingITBase.java (92%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/BidirectionalEnd.java (58%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/BidirectionalStart.java (67%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/CallbacksITBase.java (87%) rename spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/stored_procedures/DocumentEntity.java => src/test/java/org/springframework/data/neo4j/integration/shared/Club.java (71%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/DeepRelationships.java (83%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/DtoPersonProjection.java (75%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/DynamicRelationshipsITBase.java (87%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/EntitiesWithDynamicLabels.java (88%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/EntityWithConvertedId.java (77%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/Hobby.java (76%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/IdGeneratorsITBase.java (85%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ImmutableAuditableThing.java (84%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ImmutableAuditableThingWithGeneratedId.java (81%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ImmutablePerson.java (75%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/Inheritance.java (90%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/LikesHobbyRelationship.java (84%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/MultipleLabels.java (70%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/MultipleRelationshipsThing.java (81%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/NamesOnly.java (77%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/NamesOnlyDto.java (79%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/Neo4jConversionsITBase.java (94%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/Person.java (73%) rename spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/domain/User.java => src/test/java/org/springframework/data/neo4j/integration/shared/PersonProjection.java (79%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/PersonSummary.java (77%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/PersonWithAllConstructor.java (74%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/PersonWithNoConstructor.java (64%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/PersonWithRelationship.java (75%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/PersonWithRelationshipWithProperties.java (72%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/PersonWithRelatives.java (78%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/PersonWithStringlyTypedRelatives.java (74%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/PersonWithWither.java (75%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/Pet.java (78%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/RelationshipsAsConstructorParametersEntities.java (76%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/RelationshipsITBase.java (77%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/SimilarThing.java (81%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/TestSequenceGenerator.java (82%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithAllAdditionalTypes.java (83%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithAllCypherTypes.java (79%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithAllSpatialTypes.java (63%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithAssignedId.java (73%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithCustomTypes.java (90%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithGeneratedId.java (67%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithIdGeneratedByBean.java (68%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithNonExistingPrimitives.java (68%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithSequence.java (70%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/ThingWithUUIDID.java (73%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/VersionedThing.java (73%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/integration/shared/VersionedThingWithAssignedId.java (77%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/config/EnableNeo4jRepositoriesTests.java (89%) rename spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/package-info.java => src/test/java/org/springframework/data/neo4j/repository/config/StartupLoggerTest.java (55%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/event/AuditingBeforeBindCallbackTest.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/event/IdPopulatorTest.java (82%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/event/ImmutableSample.java (82%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/event/ReactiveAuditingBeforeBindCallbackTest.java (92%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/event/Sample.java (80%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/query/BoundingBoxTest.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/query/RepositoryQueryTest.java (94%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/support/Neo4jPersistenceExceptionTranslatorTest.java (90%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/support/Neo4jRepositoryFactorySupportTest.java (70%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/support/Neo4jRepositoryFactoryTest.java (92%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/repository/support/ReactiveNeo4jRepositoryFactoryTest.java (92%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/test/CausalClusterIntegrationTest.java (90%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/test/DriverMocks.java (91%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/test/Neo4jExtension.java (97%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/test/Neo4jIntegrationTest.java (89%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/types/GeographicPoint2dTest.java (83%) rename {spring-data-neo4j/src/test/java/org/neo4j/springframework/data => src/test/java/org/springframework/data/neo4j}/types/GeographicPoint3dTest.java (84%) rename {spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data => src/test/kotlin/org/springframework/data/neo4j}/core/Neo4jClientExtensionsTest.kt (89%) rename {spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data => src/test/kotlin/org/springframework/data/neo4j}/core/PreparedQueryExtensionsTest.kt (82%) rename {spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data => src/test/kotlin/org/springframework/data/neo4j}/core/ReactiveNeo4jClientExtensionsTest.kt (96%) rename {spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data => src/test/kotlin/org/springframework/data/neo4j}/core/ReactiveNeo4jOperationsExtensionsTest.kt (91%) rename {spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data => src/test/kotlin/org/springframework/data/neo4j}/core/cypher/ParametersTest.kt (83%) rename {spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data => src/test/kotlin/org/springframework/data/neo4j}/integration/imperative/ImmutableRelationshipsIT.kt (83%) rename {spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data => src/test/kotlin/org/springframework/data/neo4j}/integration/imperative/Neo4jClientKotlinInteropIT.kt (83%) rename {spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data => src/test/kotlin/org/springframework/data/neo4j}/integration/reactive/ReactiveNeo4jClientKotlinInteropIT.kt (83%) rename spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/CinemaAndBlockbuster.java => src/test/kotlin/org/springframework/data/neo4j/integration/shared/KotlinPerson.kt (65%) rename spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/EntityRepository.java => src/test/kotlin/org/springframework/data/neo4j/integration/shared/KotlinRepository.kt (81%) rename {spring-data-neo4j/src => src}/test/resources/META-INF/neo4j-named-queries.properties (86%) create mode 100644 src/test/resources/logback-test.xml rename {spring-data-neo4j/src => src}/test/resources/mockito-extensions/org.mockito.plugins.MockMaker (100%) diff --git a/Jenkinsfile b/Jenkinsfile index 51cd8ecb2..291256d01 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,12 +24,15 @@ pipeline { image 'adoptopenjdk/openjdk8:latest' label 'data' args '-v $HOME:/tmp/jenkins-home' + args '-u root -v /var/run/docker.sock:/var/run/docker.sock' } } options { timeout(time: 30, unit: 'MINUTES') } steps { - sh 'rm -rf ?' + sh 'mkdir -p /tmp/jenkins-home' + sh 'chown -R 1001:1001 .' sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list verify -Dsort -U -B' + sh 'chown -R 1001:1001 .' } } @@ -47,12 +50,15 @@ pipeline { image 'adoptopenjdk/openjdk11:latest' label 'data' args '-v $HOME:/tmp/jenkins-home' + args '-u root -v /var/run/docker.sock:/var/run/docker.sock' } } options { timeout(time: 30, unit: 'MINUTES') } steps { - sh 'rm -rf ?' + sh 'mkdir -p /tmp/jenkins-home' + sh 'chown -R 1001:1001 .' sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list verify -Dsort -U -B' + sh 'chown -R 1001:1001 .' } } @@ -62,12 +68,15 @@ pipeline { image 'adoptopenjdk/openjdk14:latest' label 'data' args '-v $HOME:/tmp/jenkins-home' + args '-u root -v /var/run/docker.sock:/var/run/docker.sock' } } options { timeout(time: 30, unit: 'MINUTES') } steps { - sh 'rm -rf ?' + sh 'mkdir -p /tmp/jenkins-home' + sh 'chown -R 1001:1001 .' sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list verify -Dsort -U -B' + sh 'chown -R 1001:1001 .' } } } @@ -84,7 +93,7 @@ pipeline { docker { image 'adoptopenjdk/openjdk8:latest' label 'data' - args '-v $HOME:/tmp/jenkins-home' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } options { timeout(time: 20, unit: 'MINUTES') } @@ -94,8 +103,9 @@ pipeline { } steps { - sh 'rm -rf ?' + sh 'mkdir -p /tmp/jenkins-home' sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,artifactory ' + + '-Drunning-on-ci ' + '-Dartifactory.server=https://repo.spring.io ' + "-Dartifactory.username=${ARTIFACTORY_USR} " + "-Dartifactory.password=${ARTIFACTORY_PSW} " + diff --git a/README.adoc b/README.adoc index 31f62d722..ccf0ccedb 100644 --- a/README.adoc +++ b/README.adoc @@ -1,27 +1,35 @@ -= Spring Data Neo4j⚡️RX +image:https://spring.io/badges/spring-data-neo4j/ga.svg[Spring Data Neo4j,link=https://projects.spring.io/spring-data-neo4j#quick-start] image:https://spring.io/badges/spring-data-neo4j/snapshot.svg[Spring Data Neo4j,link=https://projects.spring.io/spring-data-neo4j#quick-start] + += Spring Data Neo4j image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-neo4j%2Fmaster&subject=Build[link=https://jenkins.spring.io/view/SpringData/job/spring-data-neo4j/] https://gitter.im/spring-projects/spring-data[image:https://badges.gitter.im/spring-projects/spring-data.svg[Gitter]] :sectanchors: // tag::properties[] -:groupId: org.neo4j.springframework.data -:artifactId: spring-data-neo4j-rx +:neo4jGroupId: org.neo4j.springframework.data +:springGroupId: org.springframework.data.neo4j +:artifactId: spring-data-neo4j :artifactIdStarter: spring-data-neo4j-rx-spring-boot-starter :neo4j-version: 4.0.4 :spring-boot-version: 2.3.0.RELEASE :spring-data-neo4j-rx-version: 1.1.1 +:spring-data-neo4j-version: 6.0.0 // end::properties[] -image:https://img.shields.io/maven-central/v/org.neo4j.springframework.data/spring-data-neo4j-rx.svg[Maven Central,link=http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.neo4j.springframework.data%22%20AND%20a%3A%22spring-data-neo4j-rx%22] - [abstract] -- -Spring Data Neo4j⚡️RX - or in short _SDN/RX_ - is an ongoing effort to create the next generation of Spring Data Neo4j, with full reactive support and lightweight mapping. -SDN/RX will work with immutable entities, regardless whether written in Java or Kotlin. +Spring Data Neo4j - or in short _SDN_ - is an ongoing effort to create the next generation of Spring Data Neo4j, with full reactive support and lightweight mapping. +SDN will work with immutable entities, regardless whether written in Java or Kotlin. -- The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services. -The SDN/RX project aims to provide a familiar and consistent Spring-based programming model for integrating with the https://neo4j.com/[Neo4j] Graph Database. +The SDN project aims to provide a familiar and consistent Spring-based programming model for integrating with the https://neo4j.com/[Neo4j] Graph Database. + +== Code of Conduct + +This project is governed by the link:https://github.com/spring-projects/.github/blob/master/CODE_OF_CONDUCT.md[Spring Code of Conduct]. +By participating, you are expected to uphold this code of conduct. +Please report unacceptable behavior to spring-code-of-conduct@pivotal.io. == Manual @@ -30,6 +38,75 @@ https://neo4j.github.io/sdn-rx[Manual]. == Getting Started +=== Maven configuration + +==== With Spring Boot + +If you are on https://spring.io/projects/spring-boot[Spring Boot], all you have to do is to add our starter: + +[source,xml,subs="verbatim,attributes"] +---- + + {neo4jgroupId} + {artifactIdStarter} + {spring-data-neo4j-rx-version} + +---- + +and configure your database connection: + +[source,properties] +---- +org.neo4j.driver.uri=bolt://localhost:7687 +org.neo4j.driver.authentication.username=neo4j +org.neo4j.driver.authentication.password=secret +---- + +Please have a look at our https://neo4j.github.io/sdn-rx[manual] for an overview about the architecture, how to define +mappings and more. + +==== Without Spring Boot + +If you are using a plain Spring Framework project without Spring Boot, please add this Maven dependency: + +[source,xml,subs="verbatim,attributes"] +---- + + {springGroupId} + {artifactId} + {spring-data-neo4j-version} + +---- + +and configure SDN for reactive database access like this: + +[source,java] +---- +@Configuration +@EnableReactiveNeo4jRepositories +@EnableTransactionManagement +class MyConfiguration extends AbstractReactiveNeo4jConfig { + + @Bean + public Driver driver() { + return GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "secret")); + } + + @Override + protected Collection getMappingBasePackages() { + return Collections.singletonList(Person.class.getPackage().getName()); + } +} +---- + +The imperative version looks pretty much the same but uses `EnableNeo4jRepositories` and `AbstractNeo4jConfig`. + +IMPORTANT: We recommend Spring Boot, the automatic configuration and especially the dependency management +through the Starters in contrast to the manual work of managing dependencies and configuration. ++ +Please consult our https://neo4j.github.io/sdn-rx[manual] for more information. + + Here is a quick teaser of a reactive application using Spring Data Repositories in Java: [source,java] @@ -71,77 +148,33 @@ class MyService { } ---- -TIP: SDN/RX is not only about reactive support, all features are available in both ways: Imperative and reactive, we - only prefer to showcase the new reactive database access support here. +=== Building SDN -=== Maven configuration +Please have a look at the documentation: https://neo4j.github.io/sdn-rx/current/#building-sdn-rx[Building SDN]. -==== With Spring Boot +== Getting Help -If you are on https://spring.io/projects/spring-boot[Spring Boot], all you have to do is to add our starter: +Having trouble with Spring Data? We’d love to help! -[source,xml,subs="verbatim,attributes"] ----- - - {groupId} - {artifactIdStarter} - {spring-data-neo4j-rx-version} - ----- +* Check the +https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/[reference documentation], and https://docs.spring.io/spring-data/neo4j/docs/current/api/[Javadocs]. +* Learn the Spring basics – Spring Data builds on Spring Framework, check the https://spring.io[spring.io] web-site for a wealth of reference documentation. +If you are just starting out with Spring, try one of the https://spring.io/guides[guides]. +* If you are upgrading, check out the https://docs.spring.io/spring-data/neo4j/docs/current/changelog.txt[changelog] for "`new and noteworthy`" features. +* Ask a question - we monitor https://stackoverflow.com[stackoverflow.com] for questions tagged with https://stackoverflow.com/questions/tagged/spring-data-neo4j[spring-data-neo4j]. +* Report bugs with Spring Data Neo4j at https://jira.spring.io/browse/DATAGRAPH[jira.spring.io/browse/DATAGRAPH]. -and configure your database connection: +== Reporting Issues -[source,properties] ----- -org.neo4j.driver.uri=bolt://localhost:7687 -org.neo4j.driver.authentication.username=neo4j -org.neo4j.driver.authentication.password=secret ----- +Spring Data uses JIRA as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below: -Please have a look at our https://neo4j.github.io/sdn-rx[manual] for an overview about the architecture, how to define -mappings and more. +* Before you log a bug, please search the +https://jira.spring.io/browse/DATAGRAPH[issue tracker] to see if someone has already reported the problem. +* If the issue doesn’t already exist, https://jira.spring.io/browse/DATAGRAPH[create a new issue]. +* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using and JVM version. +* If you need to paste code, or include a stack trace use JIRA `{code}…{code}` escapes before and after your text. +* If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code. -==== Without Spring Boot +== License -If you are using a plain Spring Framework project without Spring Boot, please add this Maven dependency: - -[source,xml,subs="verbatim,attributes"] ----- - - {groupId} - {artifactId} - {spring-data-neo4j-rx-version} - ----- - -and configure SDN/RX for reactive database access like this: - -[source,java] ----- -@Configuration -@EnableReactiveNeo4jRepositories -@EnableTransactionManagement -class MyConfiguration extends AbstractReactiveNeo4jConfig { - - @Bean - public Driver driver() { - return GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "secret")); - } - - @Override - protected Collection getMappingBasePackages() { - return Collections.singletonList(Person.class.getPackage().getName()); - } -} ----- - -The imperative version looks pretty much the same but uses `EnableNeo4jRepositories` and `AbstractNeo4jConfig`. - -IMPORTANT: We recommend Spring Boot, the automatic configuration and especially the dependency management - through the Starters in contrast to the manual work of managing dependencies and configuration. - + - Please consult our https://neo4j.github.io/sdn-rx[manual] for more information. - -=== Building SDN/RX - -Please have a look at the documentation: https://neo4j.github.io/sdn-rx/current/#building-sdn-rx[Building SDN/RX]. +Spring Data Neo4j is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license]. diff --git a/checkstyle/config.xml b/checkstyle/config.xml deleted file mode 100644 index 85a1cdc65..000000000 --- a/checkstyle/config.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/checkstyle/java-header.txt b/checkstyle/java-header.txt deleted file mode 100644 index 0fee0dc1f..000000000 --- a/checkstyle/java-header.txt +++ /dev/null @@ -1,17 +0,0 @@ -^\Q/*\E$ -^\Q * Copyright 2011-2020 the original author or authors.\E$ -^\Q *\E$ -^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$ -^\Q * you may not use this file except in compliance with the License.\E$ -^\Q * You may obtain a copy of the License at\E$ -^\Q *\E$ -^\Q * https://www.apache.org/licenses/LICENSE-2.0\E$ -^\Q *\E$ -^\Q * Unless required by applicable law or agreed to in writing, software\E$ -^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$ -^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$ -^\Q * See the License for the specific language governing permissions and\E$ -^\Q * limitations under the License.\E$ -^\Q */\E$ -^\Qpackage\E .+;$ -^.*$ diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml deleted file mode 100644 index 59845ab3b..000000000 --- a/checkstyle/suppressions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/etc/checkstyle/java-header.txt b/etc/checkstyle/java-header.txt index 8569a36d2..7be21cfed 100644 --- a/etc/checkstyle/java-header.txt +++ b/etc/checkstyle/java-header.txt @@ -1,14 +1,11 @@ ^\Q/*\E$ -^\Q * Copyright (c) 2019-2020 "Neo4j,"\E$ -^\Q * Neo4j Sweden AB [https://neo4j.com]\E$ -^\Q *\E$ -^\Q * This file is part of Neo4j.\E$ +^\Q * Copyright 2011-20\E\d\d\Q the original author or authors.\E$ ^\Q *\E$ ^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$ ^\Q * you may not use this file except in compliance with the License.\E$ ^\Q * You may obtain a copy of the License at\E$ ^\Q *\E$ -^\Q * https://www.apache.org/licenses/LICENSE-2.0\E$ +^\Q * https://www.apache.org/licenses/LICENSE-2.0\E$ ^\Q *\E$ ^\Q * Unless required by applicable law or agreed to in writing, software\E$ ^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$ diff --git a/etc/checkstyle/suppressions.xml b/etc/checkstyle/suppressions.xml index 829c1a269..d244e919b 100644 --- a/etc/checkstyle/suppressions.xml +++ b/etc/checkstyle/suppressions.xml @@ -1,7 +1,7 @@ + "https://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> diff --git a/etc/jqassistant/naming.adoc b/etc/jqassistant/naming.adoc index debb0f602..b8b760c84 100644 --- a/etc/jqassistant/naming.adoc +++ b/etc/jqassistant/naming.adoc @@ -5,12 +5,12 @@ The following naming conventions are used throughout the project: [[naming:TypeNameMustBeginWithGroupId]] [source,cypher,role=constraint] -.All Java types must be located in packages that start with `org.neo4j.springframework.data`. +.All Java types must be located in packages that start with `org.springframework.data.neo4j`. ---- MATCH (project:Maven:Project)-[:CREATES]->(:Artifact)-[:CONTAINS]->(type:Type) WHERE - NOT type.fqn starts with 'org.neo4j.springframework.data' + NOT type.fqn starts with 'org.springframework.data.neo4j' RETURN project as Project, collect(type) as TypeWithWrongName ---- diff --git a/etc/jqassistant/structure.adoc b/etc/jqassistant/structure.adoc index 871b61d85..46e968034 100644 --- a/etc/jqassistant/structure.adoc +++ b/etc/jqassistant/structure.adoc @@ -8,10 +8,10 @@ Most of the time, the package structure under `org.neo4j.springframework.data` s .The mapping package must not depend on any other SDN/RX packages than `schema` and `convert` ---- MATCH (a:Main:Artifact) -OPTIONAL MATCH (a) -[:CONTAINS]-> (s:Package) WHERE s.fqn in ['org.neo4j.springframework.data.core.schema', 'org.neo4j.springframework.data.core.convert'] +OPTIONAL MATCH (a) -[:CONTAINS]-> (s:Package) WHERE s.fqn in ['org.springframework.data.neo4j.core.schema', 'org.springframework.data.neo4j.core.convert'] WITH collect(s) as allowed, a MATCH (a) -[:CONTAINS]-> (p1:Package) -[:DEPENDS_ON]-> (p2:Package) <-[:CONTAINS]- (a) -WHERE p1.fqn = 'org.neo4j.springframework.data.core.mapping' +WHERE p1.fqn = 'org.springframework.data.neo4j.core.mapping' AND NOT (p2 in allowed OR (p1) -[:CONTAINS]-> (p2)) return p1,p2 ---- diff --git a/pom.xml b/pom.xml index 66c2f92ab..fcdbd0d8c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,7 @@ - + 4.0.0 org.springframework.data.build spring-data-parent - 2.3.1.RELEASE + 2.4.0-SNAPSHOT - org.neo4j.springframework.data - spring-data-neo4j-rx-parent - ${revision}${sha1}${changelist} - pom + org.springframework.data + spring-data-neo4j + 6.0.0-SNAPSHOT - Spring Data Neo4j RX + Spring Data Neo4j Next generation Object-Graph-Mapping for Spring Data. + https://projects.spring.io/spring-data-neo4j 2019 Neo4j, Neo4j Sweden AB @@ -52,7 +49,7 @@ Gerrit Meier gerrit.meier at neo4j.com Neo Technology - http://www.neotechnology.com + https://www.neotechnology.com Project Lead @@ -63,7 +60,7 @@ Michael Simons michael.simons at neo4j.com Neo Technology - http://www.neotechnology.com + https://www.neotechnology.com Project Lead @@ -71,19 +68,9 @@ - - spring-data-neo4j-rx - spring-data-neo4j-rx-spring-boot-starter-parent - examples/reactive-web - examples/imperative-web - examples/mapping - examples/multi-database - examples/rest - examples/docs - examples/kotlin - - + ja + 1.1.0 2.0.1 1.6.0 @@ -92,13 +79,17 @@ -SNAPSHOT 8.29 2020.0.0 + spring-data-neo4j + SDNEO4J 1.2.1 0.8.5 1.8 - + spring.data.neo4j + 2.3.1 1.8.0 1.8.0 1.8.0 + 4.0.2.2 5.6.1 3.1.0 3.0.0-M1 @@ -118,13 +109,12 @@ 3.0.1 ${project.build.directory}/docs UTF-8 - Arabba-RELEASE + Arabba-SR5 1.2.1 1.1 1.3.8 2.2.5 - - 2.3.1.RELEASE + 2.4.0-SNAPSHOT 1.13.0 ${skipTests} @@ -153,6 +143,12 @@ objenesis ${objenesis.version} + + javax.xml.bind + jaxb-api + ${jaxb.version} + provided + io.reactivex rxjava @@ -253,9 +249,162 @@ ${testcontainers.version} test + + eu.michael-simons.neo4j + junit-jupiter-causal-cluster-testcontainer-extension + ${junit-cc-testcontainer} + test + + + + io.projectreactor + reactor-core + true + + + io.projectreactor + reactor-test + test + true + + + io.reactivex + rxjava + true + + + io.reactivex + rxjava-reactive-streams + true + + + io.reactivex.rxjava2 + rxjava + true + + + javax.transaction + jta + 1.1 + test + + + org.springframework.data + spring-data-r2dbc + 1.0.0.RELEASE + test + + + io.r2dbc + r2dbc-h2 + test + + + org.neo4j + neo4j-cypher-dsl + + + org.apiguardian + apiguardian-api + + + org.assertj + assertj-core + test + + + org.junit.jupiter + junit-jupiter + test + + + org.mockito + mockito-core + test + + + org.mockito + mockito-junit-jupiter + test + + + org.neo4j.driver + neo4j-java-driver + + + org.springframework + spring-beans + + + org.springframework + spring-context + + + org.springframework + spring-core + + + org.springframework + spring-tx + + + org.springframework.data + spring-data-commons + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + true + + + org.jetbrains.kotlin + kotlin-reflect + true + + + org.jetbrains.kotlinx + kotlinx-coroutines-core + true + + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + true + + + io.mockk + mockk + ${mockk} + test + + + org.testcontainers + junit-jupiter + test + + + org.testcontainers + neo4j + test + + + eu.michael-simons.neo4j + junit-jupiter-causal-cluster-testcontainer-extension + test + + + + org.projectlombok + lombok + ${lombok} + true + test + + + @@ -280,26 +429,6 @@ false - - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - - etc/checkstyle/config.xml - etc/checkstyle/suppressions.xml - etc/checkstyle/java-header.txt - ${project.build.sourceEncoding} - true - true - true - - com.buschmais.jqassistant jqassistant-maven-plugin @@ -341,11 +470,6 @@ maven-install-plugin ${maven-install-plugin.version} - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - org.apache.maven.plugins maven-failsafe-plugin @@ -377,16 +501,8 @@ - maven-checkstyle-plugin - - - validate - validate - - check - - - + org.apache.maven.plugins + maven-assembly-plugin org.jacoco @@ -411,6 +527,12 @@ ${project.build.directory}/jacoco.exec + + report + + report + + @@ -541,6 +663,101 @@ + + com.buschmais.jqassistant + jqassistant-maven-plugin + + + jqassistant-scan + verify + + scan + + + + jacoco.xml + + + + ${project.basedir}/.git + + + ${project.reporting.outputDirectory}/jacoco + + + + + + jqassistant-analyze + + analyze + + + MINOR + + default + jqassistant-dashboard:Default + + + + + + + + + + spring-libs-snapshot + https://repo.spring.io/libs-snapshot + + + + + + spring-plugins-release + https://repo.spring.io/plugins-release + + + spring-libs-milestone + https://repo.spring.io/libs-milestone + + + + + + always-but-ci + + + !running-on-ci + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + validate + validate + + check + + + + + ${project.basedir}/etc/checkstyle/config.xml + ${project.basedir}/etc/checkstyle/suppressions.xml + ${project.basedir}/etc/checkstyle/java-header.txt + ${project.build.sourceEncoding} + true + true + true + + + + + + diff --git a/spring-data-neo4j-distribution/pom.xml b/spring-data-neo4j-distribution/pom.xml deleted file mode 100644 index c1c651182..000000000 --- a/spring-data-neo4j-distribution/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - 4.0.0 - - spring-data-neo4j-distribution - - pom - - Spring Data Neo4j - Distribution - Distribution build for Spring Data Neo4j - - - org.springframework.data - spring-data-neo4j-parent - 5.4.0-SNAPSHOT - ../pom.xml - - - - ${basedir}/.. - spring-data-neo4j - SDNEO4J - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - org.codehaus.mojo - wagon-maven-plugin - - - org.asciidoctor - asciidoctor-maven-plugin - - - - - - diff --git a/spring-data-neo4j/pom.xml b/spring-data-neo4j/pom.xml deleted file mode 100644 index 821a67158..000000000 --- a/spring-data-neo4j/pom.xml +++ /dev/null @@ -1,258 +0,0 @@ - - - - 4.0.0 - - - spring-data-neo4j-rx-parent - org.neo4j.springframework.data - ${revision}${sha1}${changelist} - - - spring-data-neo4j-rx - - SDN⚡️RX - Core module of SDN.rx. - - - spring.data.neo4j.rx - - - - - io.projectreactor - reactor-core - true - - - io.projectreactor - reactor-test - test - true - - - io.reactivex - rxjava - true - - - io.reactivex - rxjava-reactive-streams - true - - - io.reactivex.rxjava2 - rxjava - true - - - javax.transaction - jta - 1.1 - test - - - org.springframework.data - spring-data-r2dbc - 1.0.0.RELEASE - test - - - io.r2dbc - r2dbc-h2 - test - - - org.neo4j - neo4j-cypher-dsl - - - org.apiguardian - apiguardian-api - - - org.assertj - assertj-core - test - - - org.junit.jupiter - junit-jupiter - test - - - org.mockito - mockito-core - test - - - org.mockito - mockito-junit-jupiter - test - - - org.neo4j.driver - neo4j-java-driver - - - org.springframework - spring-beans - - - org.springframework - spring-context - - - org.springframework - spring-core - - - org.springframework - spring-tx - - - org.springframework.data - spring-data-commons - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - true - - - org.jetbrains.kotlin - kotlin-reflect - true - - - org.jetbrains.kotlinx - kotlinx-coroutines-core - true - - - org.jetbrains.kotlinx - kotlinx-coroutines-reactor - true - - - io.mockk - mockk - ${mockk} - test - - - org.testcontainers - junit-jupiter - test - - - org.testcontainers - neo4j - test - - - eu.michael-simons.neo4j - junit-jupiter-causal-cluster-testcontainer-extension - 4.0.2.2 - test - - - - org.projectlombok - lombok - ${lombok} - true - test - - - - - - - org.jacoco - jacoco-maven-plugin - - - report - - report - - - - - - com.buschmais.jqassistant - jqassistant-maven-plugin - - - jqassistant-scan - verify - - scan - - - - jacoco.xml - - - - ${project.basedir}/../.git - - - ${project.reporting.outputDirectory}/jacoco - - - - - - jqassistant-analyze - - analyze - - - MINOR - - default - jqassistant-dashboard:Default - - - - - - - - - - - - com.buschmais.jqassistant - jqassistant-maven-plugin - ${jqassistant.version} - - - - report - - - - - - - diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Depth.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Depth.java deleted file mode 100644 index 9d002c338..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Depth.java +++ /dev/null @@ -1,39 +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.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.data.annotation.QueryAnnotation; - -/** - * Specifies the depth of the query. Used with derived finders. - * - * @author Luanne Misquitta - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.PARAMETER, ElementType.METHOD }) -@QueryAnnotation -@Documented -public @interface Depth { - - int value() default 1; - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/EnableBookmarkManagement.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/EnableBookmarkManagement.java deleted file mode 100644 index 10a033dbd..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/EnableBookmarkManagement.java +++ /dev/null @@ -1,45 +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.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.context.annotation.Import; -import org.springframework.data.neo4j.bookmark.BookmarkManagementConfiguration; - -/** - * Enables bookmark management - *

- * Bean implementing {@link org.springframework.data.neo4j.bookmark.BookmarkManager} interface needs to exist in the - * context. Default implementation {@link org.springframework.data.neo4j.bookmark.CaffeineBookmarkManager} exists. Use - * scope of the bean to control how bookmarks are managed. singleton - suitable for application wide bookmarks, e.g. fat - * clients request,session - suitable for web applications - *

- * NOTE: Only usable with OGM Bolt driver. - * - * @author Frantisek Hartman - * @see UseBookmark - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(value = ElementType.TYPE) -@Documented -@Import(BookmarkManagementConfiguration.class) -public @interface EnableBookmarkManagement { -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/EnableNeo4jAuditing.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/EnableNeo4jAuditing.java deleted file mode 100644 index 05b3f804c..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/EnableNeo4jAuditing.java +++ /dev/null @@ -1,71 +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.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.context.annotation.Import; -import org.springframework.data.auditing.DateTimeProvider; -import org.springframework.data.domain.AuditorAware; -import org.springframework.data.neo4j.repository.config.Neo4jAuditingRegistrar; - -/** - * Annotation to enable auditing in Neo4j via annotation configuration. - * - * @author Frantisek Hartman - * @author Michael J. Simons - */ -@Inherited -@Documented -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Import(Neo4jAuditingRegistrar.class) -public @interface EnableNeo4jAuditing { - - /** - * Configures the {@link AuditorAware} bean to be used to lookup the current principal. - * - * @return - */ - String auditorAwareRef() default ""; - - /** - * Configures whether the creation and modification dates are set. Defaults to {@literal true}. - * - * @return - */ - boolean setDates() default true; - - /** - * Configures whether the entity shall be marked as modified on creation. Defaults to {@literal true}. - * - * @return - */ - boolean modifyOnCreate() default true; - - /** - * Configures a {@link DateTimeProvider} bean name that allows customizing the {@link org.joda.time.DateTime} to be - * used for setting creation and modification dates. - * - * @return - */ - String dateTimeProviderRef() default ""; -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/ExistsQuery.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/ExistsQuery.java deleted file mode 100644 index f771e5087..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/ExistsQuery.java +++ /dev/null @@ -1,46 +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.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.core.annotation.AliasFor; - -/** - * Annotation to declare a {@link Query} with a value containing an exists custom query. The result will then be used for - * boolean projection. - * - * @author Gerrit Meier - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) -@Documented -@Query(exists = true) -public @interface ExistsQuery { - - /** - * The cypher query. - * - * @see Query#value() - * @since 5.2 - */ - @AliasFor(annotation = Query.class) - String value() default ""; -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Query.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Query.java deleted file mode 100644 index 6172de67d..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/Query.java +++ /dev/null @@ -1,55 +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.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.data.annotation.QueryAnnotation; - -/** - * Annotation to declare finder queries directly on repository methods. - * - * @author Mark Angrish - * @author Luanne Misquitta - * @author Gerrit Meier - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD }) -@QueryAnnotation -@Documented -public @interface Query { - - /** - * Defines the Cypher query to be executed when the annotated method is called. - */ - String value() default ""; - - /** - * @return simpler count-query to be executed for @{see Pageable}-support - */ - String countQuery() default ""; - - /** - * Returns whether the defined query should be executed as an exists projection. - * - * @since 5.2 - */ - boolean exists() default false; -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/QueryResult.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/QueryResult.java deleted file mode 100644 index 4d2d0ed00..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/QueryResult.java +++ /dev/null @@ -1,36 +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.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation to be applied to interfaces and classes onto which arbitrary Cypher query results are to be mapped. - * - * @author Adam George - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -public @interface QueryResult { - - // no annotation properties needed - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/UseBookmark.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/UseBookmark.java deleted file mode 100644 index a1bd4caa7..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/UseBookmark.java +++ /dev/null @@ -1,42 +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.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Indicates that a transactional operation will use bookmarks that are currently stored in BookmarkManager when - * creating Neo4j session. Must be used on a method with @Transactional annotation. May be used on class - applies to - * all methods or on specific methods. - *

- * - * @author Frantisek Hartman - * @see EnableBookmarkManagement - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) -@Documented -public @interface UseBookmark { - - /** - * If the annotated method should set bookmark - */ - boolean value() default true; -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/package-info.java deleted file mode 100644 index 58df67027..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/annotation/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * A set of Neo4j specific annotations (especially Depth and Bookmark support). - */ -package org.springframework.data.neo4j.annotation; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BeanFactoryBookmarkOperationAdvisor.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BeanFactoryBookmarkOperationAdvisor.java deleted file mode 100644 index e7d21d357..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BeanFactoryBookmarkOperationAdvisor.java +++ /dev/null @@ -1,35 +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.bookmark; - -import org.springframework.aop.Pointcut; -import org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor; - -/** - * Advisor for BookmarkManagement - *

- * Used to setup BookmarkInfo for methods marked with @{@link org.springframework.data.neo4j.annotation.UseBookmark} - * - * @author Frantisek Hartman - * @author Michael J. Simons - */ -public class BeanFactoryBookmarkOperationAdvisor extends AbstractBeanFactoryPointcutAdvisor { - - @Override - public Pointcut getPointcut() { - return new BookmarkOperationPointcut(); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkInfo.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkInfo.java deleted file mode 100644 index 72b46477f..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkInfo.java +++ /dev/null @@ -1,52 +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.bookmark; - -import java.io.Serializable; -import java.util.Collection; - -/** - * Bookmark info stored as thread local - * - * @author Frantisek Hartman - */ -public class BookmarkInfo implements Serializable { - - private boolean useBookmark; - private Collection bookmarks; - - public BookmarkInfo() {} - - public BookmarkInfo(boolean useBookmark) { - this.useBookmark = true; - } - - public boolean shouldUseBookmark() { - return useBookmark; - } - - public void setUseBookmark(boolean useBookmark) { - this.useBookmark = useBookmark; - } - - public Collection getBookmarks() { - return bookmarks; - } - - public void setBookmarks(Collection bookmarks) { - this.bookmarks = bookmarks; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkInterceptor.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkInterceptor.java deleted file mode 100644 index c5bd38ead..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkInterceptor.java +++ /dev/null @@ -1,45 +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.bookmark; - -import org.aopalliance.intercept.MethodInterceptor; -import org.aopalliance.intercept.MethodInvocation; - -/** - * Interceptor that sets {@link BookmarkInfo} as a ThreadLocal - * - * @author Frantisek Hartman - */ -public class BookmarkInterceptor extends BookmarkSupport implements MethodInterceptor { - - @Override - public Object invoke(MethodInvocation invocation) throws Throwable { - BookmarkInfo previousValue; - - if (bookmarkInfoHolder.get() == null) { - previousValue = null; - } else { - previousValue = bookmarkInfoHolder.get(); - } - bookmarkInfoHolder.set(new BookmarkInfo(true)); - - try { - return invocation.proceed(); - } finally { - bookmarkInfoHolder.set(previousValue); - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkManagementConfiguration.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkManagementConfiguration.java deleted file mode 100644 index da3e19c09..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkManagementConfiguration.java +++ /dev/null @@ -1,55 +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.bookmark; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Role; - -/** - * Configuration used by @{@link org.springframework.data.neo4j.annotation.EnableBookmarkManagement} - *

- * Note on bookmark management implementation: The implementation closely follows implementation - * of @EnableTransactionManagement or @EnableCaching, with simplified pointcut. - *

- * The bookmark interceptor will set BookmarkInfo thread local when a methods is annotated with @UseBookmark. It is - * executed before transactional advice (see setOrder(0) ). Neo4j transaction manager then uses {@link BookmarkManager} - * bean to retrieve currently stored bookmarks and begins new transaction using these bookmarks. After commit new - * bookmark is stored in the BookmarkManager, replacing the bookmarks used to begin the transaction. The user needs to - * provide the BookmarkManager bean. - * - * @author Frantisek Hartman - */ -@Configuration -public class BookmarkManagementConfiguration { - - @Bean - @Role(BeanDefinition.ROLE_INFRASTRUCTURE) - public BeanFactoryBookmarkOperationAdvisor bookmarkAdvisor() { - BeanFactoryBookmarkOperationAdvisor advisor = new BeanFactoryBookmarkOperationAdvisor(); - advisor.setAdvice(bookmarkInterceptor()); - advisor.setOrder(0); - return advisor; - } - - @Bean - @Role(BeanDefinition.ROLE_INFRASTRUCTURE) - public BookmarkInterceptor bookmarkInterceptor() { - return new BookmarkInterceptor(); - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkManager.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkManager.java deleted file mode 100644 index ebf459ec9..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkManager.java +++ /dev/null @@ -1,42 +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.bookmark; - -import java.util.Collection; - -/** - * Bookmark manager keeps track of Neo4j transaction bookmarks - * - * @author Frantisek Hartman - * @see org.springframework.data.neo4j.annotation.EnableBookmarkManagement - */ -public interface BookmarkManager { - - /** - * Return stored bookmarks - * - * @return bookmarks - */ - Collection getBookmarks(); - - /** - * Stores bookmark to this manager - * - * @param bookmark new bookmark to store - * @param previous previous bookmarks that are to be replaced by new bookmark, may be empty - */ - void storeBookmark(String bookmark, Collection previous); -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkOperationPointcut.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkOperationPointcut.java deleted file mode 100644 index 0d49c9678..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkOperationPointcut.java +++ /dev/null @@ -1,43 +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.bookmark; - -import java.lang.reflect.Method; - -import org.springframework.aop.support.StaticMethodMatcherPointcut; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.data.neo4j.annotation.UseBookmark; - -/** - * Pointcut for methods marked with @{@link UseBookmark} - * - * @author Frantisek Hartman - */ -public class BookmarkOperationPointcut extends StaticMethodMatcherPointcut { - - @Override - public boolean matches(Method method, Class targetClass) { - UseBookmark classAnnotation = AnnotatedElementUtils.findMergedAnnotation(targetClass, UseBookmark.class); - UseBookmark methodAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, UseBookmark.class); - - // method matches if @UseBookmark is on class, is true and not on method or - // @UseBookmark is on method and is true - // it is needed to cover @UseBookmark on class and @UseBookmark(false) on method - return ((classAnnotation != null) && classAnnotation.value() && methodAnnotation == null) - || ((methodAnnotation != null) && methodAnnotation.value()); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkSupport.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkSupport.java deleted file mode 100644 index d6a647768..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/BookmarkSupport.java +++ /dev/null @@ -1,32 +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.bookmark; - -import org.springframework.core.NamedThreadLocal; - -/** - * Helper class to access BookmarkInfo thread local - * - * @author Frantisek Hartman - */ -public class BookmarkSupport { - - protected static final ThreadLocal bookmarkInfoHolder = new NamedThreadLocal<>("Bookmark info"); - - public static BookmarkInfo currentBookmarkInfo() { - return bookmarkInfoHolder.get(); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/CaffeineBookmarkManager.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/CaffeineBookmarkManager.java deleted file mode 100644 index 3f8b974d6..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/CaffeineBookmarkManager.java +++ /dev/null @@ -1,63 +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.bookmark; - -import java.util.Collection; -import java.util.HashSet; -import java.util.concurrent.TimeUnit; - -import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; - -/** - * Implementation of the bookmark manager using Caffeine cache - *

- * When using this class you must ensure that caffeine dependency is on your class path. - * - * @author Frantisek Hartman - */ -public class CaffeineBookmarkManager implements BookmarkManager { - - private final Cache cache; - - public CaffeineBookmarkManager() { - cache = Caffeine.newBuilder().maximumSize(10_000).expireAfterWrite(1, TimeUnit.MINUTES).build(); - } - - /** - * Create instance of {@link CaffeineBookmarkManager} with provided cache - * - * @param cache cache - */ - public CaffeineBookmarkManager(Cache cache) { - this.cache = cache; - } - - @Override - public Collection getBookmarks() { - // return defensive copy - return new HashSet<>(cache.asMap().values()); - } - - @Override - public void storeBookmark(String bookmark, Collection previous) { - // first invalidate previous bookmarks, because bookmark may be in `previous` collection for - // transaction, which didn't make any changes - - cache.invalidateAll(previous); - cache.put(bookmark, bookmark); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/package-info.java deleted file mode 100644 index d75f43004..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/bookmark/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Support for Neo4js bookmarks for use with the java driver / bolt transport. - */ -package org.springframework.data.neo4j.bookmark; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionService.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionService.java deleted file mode 100644 index 0879b416b..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionService.java +++ /dev/null @@ -1,123 +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.conversion; - -import java.util.Optional; - -import org.neo4j.ogm.metadata.ClassInfo; -import org.neo4j.ogm.metadata.FieldInfo; -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.typeconversion.AttributeConverter; -import org.neo4j.ogm.typeconversion.ProxyAttributeConverter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.ResolvableType; -import org.springframework.core.convert.converter.Converter; -import org.springframework.core.convert.support.GenericConversionService; - -/** - * Specialisation of {@link GenericConversionService} that creates Spring-compatible converters from those known by the - * mapping {@link MetaData}, allowing the OGM type converters to be reused throughout a Spring application. - * - * @author Adam George - * @author Luanne Misquitta - * @author Jasper Blues - * @author Michael J. Simons - */ -public class MetaDataDrivenConversionService extends GenericConversionService { - - private static final Logger logger = LoggerFactory.getLogger(MetaDataDrivenConversionService.class); - - /** - * Constructs a new {@link MetaDataDrivenConversionService} based on the given {@link MetaData}. - * - * @param metaData The OGM {@link MetaData} from which to elicit type converters configured in the underlying - * object-graph mapping layer - */ - public MetaDataDrivenConversionService(MetaData metaData) { - - for (ClassInfo classInfo : metaData.persistentEntities()) { - for (FieldInfo fieldInfo : classInfo.propertyFields()) { - if (fieldInfo.hasPropertyConverter()) { - addWrappedConverter(fieldInfo.getPropertyConverter()); - } - } - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private void addWrappedConverter(final AttributeConverter attributeConverter) { - - if (attributeConverter instanceof ProxyAttributeConverter) { - return; - } - - EntityToGraphTypeMapping entityToGraphTypeMapping = getEntityToGraphTypeMapping(attributeConverter); - - if (canConvert(entityToGraphTypeMapping.entityType, entityToGraphTypeMapping.graphType) - && canConvert(entityToGraphTypeMapping.graphType, entityToGraphTypeMapping.entityType)) { - logger.debug("Not adding Spring-compatible converter for " + attributeConverter.getClass() - + " because one that does the same job has already been registered with the ConversionService."); - } else { - Converter toGraphConverter = attributeConverter::toGraphProperty; - Converter toEntityConverter = attributeConverter::toEntityAttribute; - - // It could be argued that this is wrong as it potentially overrides a registered converted that doesn't handle - // both directions, but I've decided that it's better to ensure the same converter is used for load and save. - addConverter(entityToGraphTypeMapping.entityType, entityToGraphTypeMapping.graphType, toGraphConverter); - addConverter(entityToGraphTypeMapping.graphType, entityToGraphTypeMapping.entityType, toEntityConverter); - } - } - - static class EntityToGraphTypeMapping { - Class entityType; - Class graphType; - - private EntityToGraphTypeMapping(Class entityType, Class target) { - this.entityType = entityType; - this.graphType = target; - } - } - - static EntityToGraphTypeMapping getEntityToGraphTypeMapping(AttributeConverter attributeConverter) { - - ResolvableType resolvableType = ResolvableType.forClass(AttributeConverter.class, - attributeConverter.getClass()); - - if (!resolvableType.hasGenerics()) { - throw new IllegalStateException( - "Cannot resolve source and target types for the given attribute converter of class " - + attributeConverter.getClass()); - } - - Class sourceType = nestedTypeOrType(resolvableType.getGeneric(0)); - Class targetType = nestedTypeOrType(resolvableType.getGeneric(1)); - - return new EntityToGraphTypeMapping(sourceType, targetType); - } - - /** - * If the type can be resolved to a collection that has generics, we extract the collection type, otherwise we return - * the resolved type. - * - * @param type Type to resolve - * @return The types resolved class or in case of a generic collections, the collections elements class. - */ - private static Class nestedTypeOrType(ResolvableType type) { - return Optional.ofNullable(type.asCollection()).filter(ResolvableType::hasGenerics).map(r -> r.getGeneric(0)) - .orElse(type).resolve(Object.class); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/Neo4jOgmEntityInstantiatorAdapter.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/Neo4jOgmEntityInstantiatorAdapter.java deleted file mode 100644 index dd5744d8e..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/Neo4jOgmEntityInstantiatorAdapter.java +++ /dev/null @@ -1,115 +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.conversion; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Map; - -import org.neo4j.ogm.metadata.reflect.EntityAccessManager; -import org.springframework.core.convert.ConversionService; -import org.springframework.data.convert.EntityInstantiator; -import org.springframework.data.mapping.PreferredConstructor; -import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.mapping.model.ParameterValueProvider; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; -import org.springframework.data.neo4j.mapping.Neo4jPersistentEntity; -import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty; -import org.springframework.data.util.TypeInformation; -import org.springframework.lang.Nullable; -import org.springframework.util.Assert; - -/** - * Implements OGM instantiation callback in order to user Spring Data Commons infrastructure for instantiation. - * - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -public class Neo4jOgmEntityInstantiatorAdapter implements org.neo4j.ogm.session.EntityInstantiator { - - private final Neo4jMappingContext context; - private ConversionService conversionService; - - public Neo4jOgmEntityInstantiatorAdapter(MappingContext, Neo4jPersistentProperty> context, - @Nullable ConversionService conversionService) { - Assert.notNull(context, "MappingContext cannot be null"); - - this.context = (Neo4jMappingContext) context; - this.conversionService = conversionService; - } - - @SuppressWarnings({ "unchecked" }) - @Override - public T createInstance(Class clazz, Map propertyValues) { - - Neo4jPersistentEntity persistentEntity = (Neo4jPersistentEntity) context.getRequiredPersistentEntity(clazz); - EntityInstantiator sdnInstantiator = context.getInstantiatorFor(persistentEntity); - - return sdnInstantiator.createInstance(persistentEntity, getParameterProvider(propertyValues, conversionService)); - } - - private ParameterValueProvider getParameterProvider(Map propertyValues, - ConversionService conversionService) { - return new Neo4jPropertyValueProvider(propertyValues, conversionService); - } - - private static class Neo4jPropertyValueProvider implements ParameterValueProvider { - - private Map propertyValues; - private ConversionService conversionService; - - Neo4jPropertyValueProvider(Map propertyValues, ConversionService conversionService) { - this.conversionService = conversionService; - Assert.notNull(propertyValues, "Properties cannot be null"); - this.propertyValues = propertyValues; - } - - @SuppressWarnings({ "unchecked" }) - @Override - @Nullable - public Object getParameterValue(PreferredConstructor.Parameter parameter) { - - Object value = extractParameterValue(parameter); - if (value == null || conversionService == null) { - return value; - } else { - return conversionService.convert(value, parameter.getType().getType()); - } - } - - private Object extractParameterValue(PreferredConstructor.Parameter parameter) { - - Object value = propertyValues.get(parameter.getName()); - - // This recreates the behaviour of - // org.neo4j.ogm.context.SingleUseEntityMapper.writeProperty and - // org.neo4j.ogm.context.GraphEntityMapper.writeProperty - // As sad as it is to have in 3 places, this is the least invasive solution over both Neo4j-OGM and SDN - if (value != null && value.getClass().isArray()) { - value = Arrays.asList((Object[]) value); - } - TypeInformation typeInformation = parameter.getType(); - if (typeInformation.isCollectionLike()) { - Class collectionType = typeInformation.getType(); - Class elementType = typeInformation.getComponentType().getType(); - value = collectionType.isArray() - ? EntityAccessManager.merge(collectionType, value, new Object[] {}, elementType) - : EntityAccessManager.merge(collectionType, value, Collections.EMPTY_LIST, elementType); - } - return value; - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/PointConverter.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/PointConverter.java deleted file mode 100644 index 1c66c2422..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/PointConverter.java +++ /dev/null @@ -1,52 +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.conversion; - -import java.util.HashMap; -import java.util.Map; - -import org.neo4j.ogm.typeconversion.CompositeAttributeConverter; -import org.springframework.data.geo.Point; - -/** - * Converts latitude and longitude properties on a node entity to an instance of Point and vice-versa. - * - * @see Point - * @author Jasper Blues - */ -public class PointConverter implements CompositeAttributeConverter { - - @Override - public Map toGraphProperties(Point point) { - Map properties = new HashMap<>(); - if (point != null) { - properties.put("latitude", point.getX()); - properties.put("longitude", point.getY()); - } - return properties; - } - - @Override - public Point toEntityAttribute(Map map) { - Double latitude = (Double) map.get("latitude"); - Double longitude = (Double) map.get("longitude"); - if (latitude != null && longitude != null) { - return new Point(latitude, longitude); - } - return null; - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/package-info.java deleted file mode 100644 index f0fdebf7d..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/conversion/package-info.java +++ /dev/null @@ -1,20 +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. - */ -/** - * Adapter between Springs {@link org.springframework.core.convert.ConversionService conversion service infrastructure} - * and OGM infrastructure. - */ -package org.springframework.data.neo4j.conversion; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/Neo4jErrorStatusCodes.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/Neo4jErrorStatusCodes.java deleted file mode 100644 index 5db8483c5..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/Neo4jErrorStatusCodes.java +++ /dev/null @@ -1,114 +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.exception; - -import java.util.HashMap; - -import org.springframework.dao.*; - -/** - * Conversion table for Neo4j Errors to Spring Data Exception hierarchy. - * - * @author Mark Angrish - */ -public class Neo4jErrorStatusCodes { - - private static HashMap> errors; - - static { - errors = new HashMap<>(); - errors.put("Neo.ClientError.General.ForbiddenOnReadOnlyDatabase", PermissionDeniedDataAccessException.class); - errors.put("Neo.ClientError.LegacyIndex.LegacyIndexNotFound", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Procedure.ProcedureCallFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Procedure.ProcedureNotFound", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Procedure.ProcedureRegistrationFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Procedure.TypeError", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Request.Invalid", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Request.InvalidFormat", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Request.TransactionRequired", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Schema.ConstraintAlreadyExists", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Schema.ConstraintNotFound", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Schema.ConstraintValidationFailed", DataIntegrityViolationException.class); - errors.put("Neo.ClientError.Schema.ConstraintVerificationFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Schema.ForbiddenOnConstraintIndex", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Schema.IndexAlreadyExists", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Schema.IndexNotFound", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Schema.TokenNameError", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Security.AuthenticationRateLimit", PermissionDeniedDataAccessException.class); - errors.put("Neo.ClientError.Security.CredentialsExpired", PermissionDeniedDataAccessException.class); - errors.put("Neo.ClientError.Security.EncryptionRequired", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Security.Forbidden", PermissionDeniedDataAccessException.class); - errors.put("Neo.ClientError.Security.Unauthorized", PermissionDeniedDataAccessException.class); - errors.put("Neo.ClientError.Statement.ArgumentError", InvalidDataAccessApiUsageException.class); - errors.put("Neo.ClientError.Statement.ArithmeticError", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Statement.ConstraintVerificationFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Statement.EntityNotFound", EmptyResultDataAccessException.class); - errors.put("Neo.ClientError.Statement.ExternalResourceFailed", NonTransientDataAccessResourceException.class); - errors.put("Neo.ClientError.Statement.LabelNotFound", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Statement.ParameterMissing", InvalidDataAccessApiUsageException.class); - errors.put("Neo.ClientError.Statement.PropertyNotFound", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Statement.SemanticError", NonTransientDataAccessException.class); - errors.put("Neo.ClientError.Statement.SyntaxError", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Statement.TypeError", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Transaction.ForbiddenDueToTransactionType", - InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Transaction.TransactionAccessedConcurrently", - InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Transaction.TransactionEventHandlerFailed", - InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Transaction.TransactionHookFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Transaction.TransactionMarkedAsFailed", ConcurrencyFailureException.class); - errors.put("Neo.ClientError.Transaction.TransactionNotFound", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Transaction.TransactionTerminated", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.ClientError.Transaction.TransactionValidationFailed", - InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.General.IndexCorruptionDetected", DataAccessResourceFailureException.class); - errors.put("Neo.DatabaseError.General.SchemaCorruptionDetected", DataAccessResourceFailureException.class); - errors.put("Neo.DatabaseError.General.UnknownError", UncategorizedDataAccessException.class); - errors.put("Neo.DatabaseError.Schema.ConstraintCreationFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.ConstraintDropFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.IndexCreationFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.IndexDropFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.LabelAccessFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.LabelLimitReached", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.PropertyKeyAccessFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.RelationshipTypeAccessFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.SchemaRuleAccessFailed", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Schema.SchemaRuleDuplicateFound", InvalidDataAccessResourceUsageException.class); - errors.put("Neo.DatabaseError.Statement.ExecutionFailed", TransientDataAccessResourceException.class); - errors.put("Neo.DatabaseError.Transaction.TransactionCommitFailed", TransientDataAccessResourceException.class); - errors.put("Neo.DatabaseError.Transaction.TransactionLogError", TransientDataAccessResourceException.class); - errors.put("Neo.DatabaseError.Transaction.TransactionRollbackFailed", TransientDataAccessResourceException.class); - errors.put("Neo.DatabaseError.Transaction.TransactionStartFailed", TransientDataAccessResourceException.class); - errors.put("Neo.TransientError.General.DatabaseUnavailable", TransientDataAccessResourceException.class); - errors.put("Neo.TransientError.General.OutOfMemoryError", NonTransientDataAccessResourceException.class); - errors.put("Neo.TransientError.General.StackOverFlowError", NonTransientDataAccessResourceException.class); - errors.put("Neo.TransientError.Network.CommunicationError", DataAccessResourceFailureException.class); - errors.put("Neo.TransientError.Schema.SchemaModifiedConcurrently", ConcurrencyFailureException.class); - errors.put("Neo.TransientError.Security.ModifiedConcurrently", ConcurrencyFailureException.class); - errors.put("Neo.TransientError.Transaction.ConstraintsChanged", ConcurrencyFailureException.class); - errors.put("Neo.TransientError.Transaction.DeadlockDetected", ConcurrencyFailureException.class); - errors.put("Neo.TransientError.Transaction.InstanceStateChanged", ConcurrencyFailureException.class); - errors.put("Neo.TransientError.Transaction.LockClientStopped", NonTransientDataAccessResourceException.class); - errors.put("Neo.TransientError.Transaction.LockSessionExpired", DataAccessResourceFailureException.class); - errors.put("Neo.TransientError.Transaction.Outdated", TransientDataAccessResourceException.class); - errors.put("Neo.TransientError.Transaction.Terminated", TransientDataAccessResourceException.class); - } - - public static Class translate(String errorCode) { - return errors.get(errorCode); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/UncategorizedNeo4jException.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/UncategorizedNeo4jException.java deleted file mode 100644 index 6c9c4d400..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/UncategorizedNeo4jException.java +++ /dev/null @@ -1,30 +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.exception; - -import org.springframework.dao.UncategorizedDataAccessException; - -/** - * Exception for unrecognised Neo4j OGM errors. - * - * @author Mark Angrish - */ -public class UncategorizedNeo4jException extends UncategorizedDataAccessException { - - public UncategorizedNeo4jException(String msg, Throwable cause) { - super(msg, cause); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/package-info.java deleted file mode 100644 index c40bee015..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/exception/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Contains infrastructure for mapping Neo4j errors to Spring Data Exception hierarchy. - */ -package org.springframework.data.neo4j.exception; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/MetaDataProvider.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/MetaDataProvider.java deleted file mode 100644 index a0812338a..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/MetaDataProvider.java +++ /dev/null @@ -1,30 +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.mapping; - -import org.neo4j.ogm.metadata.MetaData; - -/** - * The only meta-data provider currently is a Neo4j-OGM {@link org.neo4j.ogm.session.SessionFactory} by proxy. The - * meta-data is needed during execution of graph-repository-queries to lookup mappings etc. - * - * @author Michael J. Simons - * @since 5.1.2 - */ -@FunctionalInterface -public interface MetaDataProvider { - MetaData getMetaData(); -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jMappingContext.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jMappingContext.java deleted file mode 100644 index 4d8b84652..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jMappingContext.java +++ /dev/null @@ -1,233 +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.mapping; - -import static java.util.Collections.*; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Optional; -import java.util.stream.Stream; - -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.neo4j.ogm.metadata.ClassInfo; -import org.neo4j.ogm.metadata.FieldInfo; -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.typeconversion.AttributeConverter; -import org.neo4j.ogm.typeconversion.ConverterBasedCollectionConverter; -import org.neo4j.ogm.types.spatial.CartesianPoint2d; -import org.neo4j.ogm.types.spatial.GeographicPoint2d; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.convert.EntityInstantiator; -import org.springframework.data.convert.EntityInstantiators; -import org.springframework.data.geo.Point; -import org.springframework.data.mapping.PersistentEntity; -import org.springframework.data.mapping.context.AbstractMappingContext; -import org.springframework.data.mapping.model.Property; -import org.springframework.data.mapping.model.SimpleTypeHolder; -import org.springframework.data.util.TypeInformation; -import org.springframework.util.ReflectionUtils; - -/** - * This class implements Spring Data's MappingContext interface, scavenging the required data from the OGM's metadata in - * order to for SDN to play nicely with Spring Data REST. The main thing to note is that this class is effectively a - * container shim for {@code ClassInfo} objects. We don't reload all the mapping information again. - * - * @author Vince Bickers - * @author Adam George - * @author Mark Paluch - * @author Michael J. Simons - * @since 4.0.0 - */ -public class Neo4jMappingContext extends AbstractMappingContext, Neo4jPersistentProperty> { - - private static final Logger logger = LoggerFactory.getLogger(Neo4jMappingContext.class); - - // Instantiation of the EntityInstantiators must happen only once, otherwise - // the org.springframework.data.convert.ClassGeneratingEntityInstantiator will - // be created every time an instantiator is requested and thus the whole thing - // will dynamically create classes like there is no tomorrow. - private final EntityInstantiators instantiators = new EntityInstantiators(); - private final MetaData metaData; - - /** - * Constructs a new {@link Neo4jMappingContext} based on the persistent entities in the given {@link MetaData}. - * - * @param metaData The OGM {@link MetaData} from which to extract the persistent entities - */ - public Neo4jMappingContext(MetaData metaData) { - this.metaData = metaData; - metaData.persistentEntities().stream().filter(k -> k.getUnderlyingClass() != null) - .forEach(k -> addPersistentEntity(k.getUnderlyingClass())); - - installDefaultConverter(); - - logger.info("Neo4jMappingContext initialisation completed"); - } - - private void installDefaultConverter() { - - Method setPropertyConverter = ReflectionUtils.findMethod(FieldInfo.class, "setPropertyConverter", - AttributeConverter.class); - - if (setPropertyConverter == null) { - return; - } - - setPropertyConverter.setAccessible(true); - - NativePointConverter nativePointConverter = new NativePointConverter(); - NativePointArrayConverter nativePointArrayConverter = new NativePointArrayConverter(); - - metaData.persistentEntities().stream().flatMap(classInfo -> Stream - .concat(classInfo.findFields(Point.class).stream(), classInfo.findIterableFields(Point.class).stream())) - .distinct().forEach(fieldInfo -> { - - AttributeConverter propertyConverter; - if (fieldInfo.isArray()) { - propertyConverter = nativePointArrayConverter; - } else if (fieldInfo.isIterable()) { - propertyConverter = new ConverterBasedCollectionConverter(fieldInfo.getField().getType(), - nativePointConverter); - } else { - propertyConverter = nativePointConverter; - } - - ReflectionUtils.invokeMethod(setPropertyConverter, fieldInfo, propertyConverter); - }); - } - - @Override - protected Neo4jPersistentEntity createPersistentEntity(TypeInformation typeInformation) { - logger.debug("Creating Neo4jPersistentEntity from type information: {}", typeInformation); - return new Neo4jPersistentEntity<>(typeInformation); - } - - @Override - protected Neo4jPersistentProperty createPersistentProperty(Property property, Neo4jPersistentEntity owner, - SimpleTypeHolder simpleTypeHolder) { - - ClassInfo owningClassInfo = this.metaData.classInfo(owner.getType().getName()); - - Field propertyField = property.getField().orElse(null); - - if (!property.isFieldBacked() && owningClassInfo != null) { - FieldInfo fieldInfo = owningClassInfo.propertyFieldByName(property.getName()); - if (fieldInfo == null) { - fieldInfo = owningClassInfo.relationshipFieldByName(property.getName()); - } - if (fieldInfo != null) { - propertyField = owningClassInfo.getField(fieldInfo); - } else { - // there is no field, probably because descriptor gave us a field name derived from a getter - logger.debug("Couldn't resolve a concrete field corresponding to property {} on {} ", property.getName(), - owningClassInfo.name()); - } - } - - return new Neo4jPersistentProperty(owningClassInfo, property, owner, - updateSimpleTypeHolder(simpleTypeHolder, propertyField)); - } - - public EntityInstantiator getInstantiatorFor(PersistentEntity entity) { - return instantiators.getInstantiatorFor(entity); - } - - private SimpleTypeHolder updateSimpleTypeHolder(SimpleTypeHolder currentSimpleTypeHolder, Field field) { - if (field == null) { - return currentSimpleTypeHolder; - } - - final Class fieldType = field.getType().isArray() ? field.getType().getComponentType() : field.getType(); - - if (shouldUpdateSimpleTypes(currentSimpleTypeHolder, field, fieldType)) { - SimpleTypeHolder updatedSimpleTypeHolder = new SimpleTypeHolder(singleton(fieldType), currentSimpleTypeHolder); - setSimpleTypeHolder(updatedSimpleTypeHolder); - return updatedSimpleTypeHolder; - } - return currentSimpleTypeHolder; - } - - private boolean shouldUpdateSimpleTypes(SimpleTypeHolder currentSimpleTypeHolder, Field field, - Class rawFieldType) { - if (field.isAnnotationPresent(Convert.class)) { - return true; - } - - if (currentSimpleTypeHolder.isSimpleType(rawFieldType) || rawFieldType.isInterface()) { - return false; - } - if (this.metaData.classInfo(rawFieldType.getName()) == null) { - logger.info("No class information found in OGM meta-data for {} so treating as simple type for SD Commons", - rawFieldType); - return true; - } - return false; - } - - /** - * This is used internally for automatic conversion of Spring Data Point to a fitting Neo4j point. While OGM native - * types treat longitude as x and latitude as y, we apply the same behaviour as SDN: x/y -> lat/long. We need however - * a geographic type, as all calculations expected from Spring Data are usually based on WGS-84 If you want to be - * explicit which coordinate system you use, please use {@link org.neo4j.ogm.types.spatial.GeographicPoint2d} or - * {@link CartesianPoint2d} in your domain model. - */ - private static class NativePointConverter implements AttributeConverter { - - @Override - public GeographicPoint2d toGraphProperty(Point value) { - - return Optional.ofNullable(value).map(p -> new GeographicPoint2d(value.getX(), value.getY())).orElse(null); - } - - @Override - public Point toEntityAttribute(GeographicPoint2d value) { - - return Optional.ofNullable(value).map(p -> new Point(value.getLatitude(), value.getLongitude())).orElse(null); - } - } - - /** - * Wrapper delegating to {@link NativePointConverter} for arrays of points. - */ - private static class NativePointArrayConverter implements AttributeConverter { - - private final NativePointConverter delegate = new NativePointConverter(); - - @Override - public GeographicPoint2d[] toGraphProperty(Point[] value) { - - if (value == null) { - return null; - } - - return Arrays.stream(value).map(delegate::toGraphProperty).toArray(GeographicPoint2d[]::new); - } - - @Override - public Point[] toEntityAttribute(GeographicPoint2d[] value) { - - if (value == null) { - return null; - } - - return Arrays.stream(value).map(delegate::toEntityAttribute).toArray(Point[]::new); - } - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentEntity.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentEntity.java deleted file mode 100644 index 654f9dc6f..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentEntity.java +++ /dev/null @@ -1,123 +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.mapping; - -import org.springframework.data.mapping.MappingException; -import org.springframework.data.mapping.PersistentProperty; -import org.springframework.data.mapping.model.BasicPersistentEntity; -import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty.PropertyType; -import org.springframework.data.support.IsNewStrategy; -import org.springframework.data.util.TypeInformation; - -/** - * This class implements Spring Data's PersistentEntity interface, scavenging the required data from the OGM's mapping - * classes in order to for SDN to play nicely with Spring Data REST. The main thing to note is that this class is - * effectively a shim for ClassInfo. We don't reload all the mapping information again. - *

- * These attributes do not appear to be used/needed for SDN 4 to inter-operate correctly with SD-REST: - *

- *
    - *
  • typeAlias
  • - *
  • typeInformation
  • - *
  • preferredConstructor (we always use the default constructor)
  • - *
  • versionProperty
  • - *
- * Consequently their associated getter methods always return default values of null or [true|false] However, because - * these method calls are not expected, we also log a warning message if they get invoked - * - * @author Vince Bickers - * @author Adam George - * @author Mark Paluch - * @author Oliver Gierke - * @author Michael J. Simons - * @since 4.0.0 - */ -public class Neo4jPersistentEntity extends BasicPersistentEntity { - - /** - * Constructs a new {@link Neo4jPersistentEntity} based on the given type information. - * - * @param information The {@link TypeInformation} upon which to base this persistent entity. - */ - Neo4jPersistentEntity(TypeInformation information) { - super(information); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mapping.model.BasicPersistentEntity#getFallbackIsNewStrategy() - */ - @Override - protected IsNewStrategy getFallbackIsNewStrategy() { - return new Neo4jIsNewStrategy(this); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mapping.model.BasicPersistentEntity#returnPropertyIfBetterIdPropertyCandidateOrNull(PersistentProperty) - */ - @Override - protected Neo4jPersistentProperty returnPropertyIfBetterIdPropertyCandidateOrNull(Neo4jPersistentProperty property) { - - if (!property.isIdProperty()) { - return null; - } - - Neo4jPersistentProperty existingIdProperty = this.getIdProperty(); - Neo4jPersistentProperty preferredIdProperty = existingIdProperty; - - if (existingIdProperty == null) { - preferredIdProperty = property; - } else if (existingIdProperty.getPropertyType() == property.getPropertyType()) { - throw new MappingException( - String.format("Attempt to add id property %s but already have property %s registered " - + "as id. Check your mapping configuration!", property.getField(), - existingIdProperty.getField())); - } else if (existingIdProperty.getPropertyType() == PropertyType.INTERNAL_ID_PROPERTY && property.getPropertyType() == PropertyType.ID_PROPERTY) { - preferredIdProperty = property; - } - return preferredIdProperty; - } - - /** - * Custom {@link IsNewStrategy} to also consider entities with identifiers of negative Long values new. - * See also DATAGRAPH-1031. - * - * @author Frantisek Hartman - * @author Oliver Gierke - */ - private static class Neo4jIsNewStrategy implements IsNewStrategy { - - private final Neo4jPersistentEntity entity; - - private Neo4jIsNewStrategy(Neo4jPersistentEntity entity) { - this.entity = entity; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.support.IsNewStrategy#isNew(java.lang.Object) - */ - @Override - public boolean isNew(Object bean) { - - PersistentProperty> property = entity.getRequiredIdProperty(); - Object value = entity.getPropertyAccessor(bean).getProperty(property); - - return value == null || (value instanceof Long && ((Long) value) < 0); - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentProperty.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentProperty.java deleted file mode 100644 index 74b60826a..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentProperty.java +++ /dev/null @@ -1,192 +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.mapping; - -import java.lang.reflect.Field; -import java.util.Optional; - -import org.neo4j.ogm.annotation.EndNode; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.Relationship; -import org.neo4j.ogm.annotation.StartNode; -import org.neo4j.ogm.annotation.Version; -import org.neo4j.ogm.metadata.ClassInfo; -import org.neo4j.ogm.metadata.FieldInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.data.mapping.Association; -import org.springframework.data.mapping.PersistentEntity; -import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty; -import org.springframework.data.mapping.model.Property; -import org.springframework.data.mapping.model.SimpleTypeHolder; -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * This class implements Spring Data's PersistentProperty interface, scavenging the required data from the OGM's mapping - * classes in order to for SDN to play nicely with Spring Data REST. The main thing to note is that this class is - * effectively a shim for FieldInfo. We don't reload all the mapping information again. We do not yet support - * getter/setter access to entity properties. - *

- * These attributes do not appear to be used/needed for SDN 4 to inter-operate correctly with SD-REST: - *

- *
    - *
  • mapValueType
  • - *
  • typeInformation
  • - *
  • isVersionProperty (there is no SDN versioning at this stage)
  • - *
  • isTransient (we never supply transient classes to the Spring mapping context)
  • - *
  • isWritable (we don't currently support read-only fields)
  • - *
- * Consequently their associated getter methods always return default values of null or [true|false] However, because - * these method calls are not expected, we also log a warning message if they get invoked - * - * @author Vince Bickers - * @author Adam George - * @author Luanne Misquitta - * @author Mark Angrish - * @author Mark Paluch - * @author Michael J. Simons - * @since 4.0.0 - */ -public class Neo4jPersistentProperty extends AnnotationBasedPersistentProperty { - - private static final Logger logger = LoggerFactory.getLogger(Neo4jPersistentProperty.class); - - enum PropertyType { - REGULAR_PROPERTY(false), INTERNAL_ID_PROPERTY(true), ID_PROPERTY(true); - - private final boolean idProperty; - - PropertyType(boolean idProperty) { - this.idProperty = idProperty; - } - } - - private final PropertyType propertyType; - - /** - * Constructs a new {@link Neo4jPersistentProperty} based on the given arguments. - * - * @param owningClassInfo The {@link ClassInfo} of the object of which the property field is a member - * @param property The property - * @param owner The owning {@link PersistentEntity} that corresponds to the given {@code ClassInfo} - * @param simpleTypeHolder The {@link SimpleTypeHolder} that dictates whether the type of this property is considered - * simple or not - */ - public Neo4jPersistentProperty(ClassInfo owningClassInfo, Property property, - PersistentEntity owner, SimpleTypeHolder simpleTypeHolder) { - super(property, owner, simpleTypeHolder); - - if (owningClassInfo == null) { - logger.warn("Owning ClassInfo is null for property: {}", property); - } - - if (owningClassInfo == null || owningClassIsSimple(owningClassInfo, simpleTypeHolder) - || owningClassDoesNotSupportIdProperties(owningClassInfo) || owningPropertyIsEnum(owner)) { - this.propertyType = PropertyType.REGULAR_PROPERTY; - } else if (isInternalIdentityField(owningClassInfo, property)) { - this.propertyType = PropertyType.INTERNAL_ID_PROPERTY; - } else if (isExplicitIdentityField(owningClassInfo, property)) { - this.propertyType = PropertyType.ID_PROPERTY; - } else { - this.propertyType = PropertyType.REGULAR_PROPERTY; - } - } - - private static boolean owningPropertyIsEnum(PersistentEntity owner) { - return owner.getType().isEnum(); - } - - private static boolean owningClassIsSimple(ClassInfo owningClassInfo, SimpleTypeHolder simpleTypeHolder) { - - return owningClassInfo.getUnderlyingClass() != null - && simpleTypeHolder.isSimpleType(owningClassInfo.getUnderlyingClass()); - } - - private static boolean owningClassDoesNotSupportIdProperties(ClassInfo owningClassInfo) { - - return owningClassInfo.isInterface() || owningClassInfo.annotationsInfo().get(QueryResult.class.getName()) != null - || owningClassInfo.isEnum(); - } - - private static boolean isInternalIdentityField(ClassInfo owningClassInfo, Property property) { - - Optional optionalInternalIdentityField = Optional.ofNullable(owningClassInfo.identityFieldOrNull()) - .map(FieldInfo::getField); - return property.getField().equals(optionalInternalIdentityField); - } - - private static boolean isExplicitIdentityField(ClassInfo owningClassInfo, Property property) { - - // Cannot use owningClassInfo.propertyField() as those are not initialized yet. They will - // be initialized on the call, but that would change behaviour: SDN fails late when there - // are invalid properties atm. Even if'ts better to fail early, it means at least changing - // a dozen tests in SDN itself. - return property.getField().map(field -> AnnotatedElementUtils.findMergedAnnotation(field, Id.class)).isPresent(); - } - - @Override - public boolean isIdProperty() { - return propertyType.idProperty; - } - - /** - * @return True if this property describes the internal ID property. - */ - public boolean isInternalIdProperty() { - return propertyType == PropertyType.INTERNAL_ID_PROPERTY; - } - - PropertyType getPropertyType() { - return propertyType; - } - - @Override - public boolean isVersionProperty() { - return isAnnotationPresent(Version.class); - } - - /** - * Overridden to force field access as opposed to getter method access for simplicity. - * - * @see org.springframework.data.mapping.model.AnnotationBasedPersistentProperty#usePropertyAccess() - */ - @Override - public boolean usePropertyAccess() { - logger.debug("[property].usePropertyAccess() returns false"); - return false; - } - - /** - * Determines whether or not this property should be considered an association to another entity or whether it's just - * a simple property that should be shown as a value. - *

- * This implementation works by looking for non-transient members annotated with @Relationship. - *

- * - * @return true if this property is an association to another entity, false if not - */ - @Override - public boolean isAssociation() { - return !isTransient() && (isAnnotationPresent(Relationship.class) || isAnnotationPresent(StartNode.class) - || isAnnotationPresent(EndNode.class)); - } - - @Override - protected Association createAssociation() { - return new Association(this, null); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/package-info.java deleted file mode 100644 index b2831413d..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Neo4j specific support classes for the Spring Data mapping subsystem. - */ -package org.springframework.data.neo4j.mapping; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/Neo4jRepository.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/Neo4jRepository.java deleted file mode 100644 index c807f0103..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/Neo4jRepository.java +++ /dev/null @@ -1,80 +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.repository; - -import java.io.Serializable; -import java.util.Optional; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.repository.NoRepositoryBean; -import org.springframework.data.repository.PagingAndSortingRepository; - -/** - * Neo4j OGM specific extension of {@link org.springframework.data.repository.Repository}. - * - * @author Vince Bickers - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - */ -@NoRepositoryBean -public interface Neo4jRepository extends PagingAndSortingRepository { - - S save(S s, int depth); - - Iterable save(Iterable entities, int depth); - - Optional findById(ID id, int depth); - - Iterable findAll(); - - Iterable findAll(int depth); - - Iterable findAll(Sort sort); - - Iterable findAll(Sort sort, int depth); - - Iterable findAllById(Iterable ids); - - Iterable findAllById(Iterable ids, int depth); - - Iterable findAllById(Iterable ids, Sort sort); - - Iterable findAllById(Iterable ids, Sort sort, int depth); - - /** - * Returns a {@link Page} of entities meeting the paging restriction provided in the {@code Pageable} object. - * {@link Page#getTotalPages()} returns an estimation of the total number of pages and should not be relied upon for - * accuracy. - * - * @param pageable - * @return a page of entities - */ - Page findAll(Pageable pageable); - - /** - * Returns a {@link Page} of entities meeting the paging restriction provided in the {@code Pageable} object. - * {@link Page#getTotalPages()} returns an estimation of the total number of pages and should not be relied upon for - * accuracy. - * - * @param pageable - * @param depth - * @return a page of entities - */ - Page findAll(Pageable pageable, int depth); -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiRepositoryBean.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiRepositoryBean.java deleted file mode 100644 index ec90cbc41..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiRepositoryBean.java +++ /dev/null @@ -1,67 +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.repository.cdi; - -import java.lang.annotation.Annotation; -import java.util.Optional; -import java.util.Set; - -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.BeanManager; - -import org.neo4j.ogm.session.Session; -import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactory; -import org.springframework.data.repository.cdi.CdiRepositoryBean; -import org.springframework.data.repository.config.CustomRepositoryImplementationDetector; - -/** - * {@link org.springframework.data.repository.cdi.CdiRepositoryBean} to create Neo4j repository instances via CDI. - * - * @author Mark Paluch - * @since 4.2 - */ -public class Neo4jCdiRepositoryBean extends CdiRepositoryBean { - private final Bean sessionBean; - - /** - * Creates a new {@link Neo4jCdiRepositoryBean}. - * - * @param sessionBean must not be {@literal null}. - * @param qualifiers must not be {@literal null}. - * @param repositoryType must not be {@literal null}. - * @param beanManager must not be {@literal null}. - * @param detector detector for the custom {@link org.springframework.data.repository.Repository} implementations - * {@link CustomRepositoryImplementationDetector}, can be {@literal null}. - */ - public Neo4jCdiRepositoryBean(Bean sessionBean, Set qualifiers, Class repositoryType, - BeanManager beanManager, Optional detector) { - super(qualifiers, repositoryType, beanManager, detector); - this.sessionBean = sessionBean; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.cdi.CdiRepositoryBean#create(javax.enterprise.context.spi.CreationalContext, java.lang.Class) - */ - @Override - protected T create(CreationalContext creationalContext, Class repositoryType) { - - Session session = getDependencyInstance(sessionBean, Session.class); - - return create(() -> new Neo4jRepositoryFactory(session), repositoryType); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiRepositoryExtension.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiRepositoryExtension.java deleted file mode 100644 index 1faa308e5..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiRepositoryExtension.java +++ /dev/null @@ -1,110 +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.repository.cdi; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; - -import javax.enterprise.event.Observes; -import javax.enterprise.inject.UnsatisfiedResolutionException; -import javax.enterprise.inject.spi.AfterBeanDiscovery; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.BeanManager; -import javax.enterprise.inject.spi.ProcessBean; - -import org.neo4j.ogm.session.Session; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.repository.cdi.CdiRepositoryBean; -import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport; - -/** - * CDI extension to export Neo4j repositories. - * - * @author Mark Paluch - * @since 4.2 - */ -public class Neo4jCdiRepositoryExtension extends CdiRepositoryExtensionSupport { - - private static final Logger LOG = LoggerFactory.getLogger(Neo4jCdiRepositoryExtension.class); - private final Map, Bean> sessions = new HashMap, Bean>(); - - public Neo4jCdiRepositoryExtension() { - LOG.info("Activating CDI extension for Spring Data Neo4j repositories."); - } - - @SuppressWarnings("unchecked") - void processBean(@Observes ProcessBean processBean) { - Bean bean = processBean.getBean(); - - for (Type type : bean.getTypes()) { - if (type instanceof Class && Session.class.isAssignableFrom((Class) type)) { - - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Discovered %s with qualifiers %s.", Session.class.getName(), bean.getQualifiers())); - } - - sessions.put(new HashSet(bean.getQualifiers()), (Bean) bean); - } - } - } - - void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager) { - - for (Entry, Set> entry : getRepositoryTypes()) { - - Class repositoryType = entry.getKey(); - Set qualifiers = entry.getValue(); - - // Create the bean representing the repository. - CdiRepositoryBean repositoryBean = createRepositoryBean(repositoryType, qualifiers, beanManager); - if (LOG.isInfoEnabled()) { - LOG.info(String.format("Registering bean for %s with qualifiers %s.", repositoryType.getName(), qualifiers)); - } - - // Register the bean to the container. - registerBean(repositoryBean); - afterBeanDiscovery.addBean(repositoryBean); - } - } - - /** - * Creates a {@link Bean}. - * - * @param The type of the repository. - * @param repositoryType The class representing the repository. - * @param beanManager The BeanManager instance. - * @return The bean. - */ - private CdiRepositoryBean createRepositoryBean(Class repositoryType, Set qualifiers, - BeanManager beanManager) { - Bean sessionBean = this.sessions.get(qualifiers); - - if (sessionBean == null) { - throw new UnsatisfiedResolutionException( - String.format("Unable to resolve a bean for '%s' with qualifiers %s.", Session.class.getName(), qualifiers)); - } - - return new Neo4jCdiRepositoryBean(sessionBean, qualifiers, repositoryType, beanManager, - Optional.of(getCustomImplementationDetector())); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/package-info.java deleted file mode 100644 index 40d16da26..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/cdi/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * CDI support for Neo4j specific repository implementation. - */ -package org.springframework.data.neo4j.repository.cdi; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositories.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositories.java deleted file mode 100644 index e4ddcc405..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositories.java +++ /dev/null @@ -1,154 +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.repository.config; - -import static org.springframework.data.neo4j.repository.config.Neo4jRepositoryConfigurationExtension.*; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Import; -import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactoryBean; -import org.springframework.data.repository.config.DefaultRepositoryBaseClass; -import org.springframework.data.repository.query.QueryLookupStrategy; -import org.springframework.transaction.PlatformTransactionManager; - -/** - * Annotation to enable Neo4j repositories. Will scan the package of the annotated configuration class for Spring Data - * repositories by default. - * - * @author Vince Bickers - * @author Mark Angrish - * @author Michael J. Simons - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@Inherited -@Import(Neo4jRepositoriesRegistrar.class) -public @interface EnableNeo4jRepositories { - - /** - * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation declarations e.g.: - * {@code @EnableExperimentalNeo4jRepositories("org.my.pkg")} instead of - * {@code @EnableExperimentalNeo4jRepositories(basePackages="org.my.pkg")}. - */ - String[] value() default {}; - - /** - * Base packages to scan for annotated components. {@link #value()} is an alias for (and mutually exclusive with) this - * attribute. Use {@link #basePackageClasses()} for a type-safe alternative to String-based package names. - */ - String[] basePackages() default {}; - - /** - * Type-safe alternative to {@link #basePackages()} for specifying the packages to scan for annotated components. The - * package of each class specified will be scanned. Consider creating a special no-op marker class or interface in - * each package that serves no purpose other than being referenced by this attribute. - */ - Class[] basePackageClasses() default {}; - - /** - * Specifies which types are eligible for component scanning. Further narrows the set of candidate components from - * everything in {@link #basePackages()} to everything in the base packages that matches the given filter or filters. - */ - ComponentScan.Filter[] includeFilters() default {}; - - /** - * Specifies which types are not eligible for component scanning. - */ - ComponentScan.Filter[] excludeFilters() default {}; - - /** - * Returns the postfix to be used when looking up custom repository implementations. Defaults to {@literal Impl}. So - * for a repository named {@code PersonRepository} the corresponding implementation class will be looked up scanning - * for {@code PersonRepositoryImpl}. - */ - String repositoryImplementationPostfix() default "Impl"; - - /** - * Configures the location of where to find the Spring Data named queries properties file. Will default to - * {@code META-INFO/neo4j-named-queries.properties}. - */ - String namedQueriesLocation() default ""; - - /** - * Returns the key of the {@link QueryLookupStrategy} to be used for lookup queries for query methods. Defaults to - * {@link org.springframework.data.repository.query.QueryLookupStrategy.Key#CREATE_IF_NOT_FOUND}. - */ - QueryLookupStrategy.Key queryLookupStrategy() default QueryLookupStrategy.Key.CREATE_IF_NOT_FOUND; - - /** - * Returns the {@link org.springframework.beans.factory.FactoryBean} class to be used for each repository instance. - * Defaults to {@link Neo4jRepositoryFactoryBean}. - */ - Class repositoryFactoryBeanClass() default Neo4jRepositoryFactoryBean.class; - - /** - * Configure the repository base class to be used to create repository proxies for this particular configuration. - * - * @return - */ - Class repositoryBaseClass() default DefaultRepositoryBaseClass.class; - - /** - * Configures the name of the {@link org.neo4j.ogm.session.SessionFactory} bean definition to be used to create - * repositories discovered through this annotation. Defaults to {@code sessionFactory}. - */ - String sessionFactoryRef() default DEFAULT_SESSION_FACTORY_BEAN_NAME; - - /** - * Configures the name of the {@link org.neo4j.ogm.session.Session} bean definition created. Defaults to a generated - * name. - * - * @since 5.1.0 - */ - String sessionBeanName() default GENERATE_BEAN_NAME; - - /** - * Configures the name of the {@link PlatformTransactionManager} bean definition to be used to create repositories - * discovered through this annotation. Defaults to {@code transactionManager}. - */ - String transactionManagerRef() default DEFAULT_TRANSACTION_MANAGER_BEAN_NAME; - - /** - * Configures the name of the {@link org.springframework.data.neo4j.mapping.Neo4jMappingContext} bean definition - * created. Defaults to a generated name. - * - * @since 5.1.0 - */ - String mappingContextBeanName() default GENERATE_BEAN_NAME; - - /** - * Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the - * repositories infrastructure. - */ - boolean considerNestedRepositories() default false; - - /** - * Configures whether to enable default transactions for Spring Data Neo4j repositories. Defaults to {@literal true}. - * If disabled, repositories must be used behind a facade that's configuring transactions (e.g. using Spring's - * annotation driven transaction facilities) or repository methods have to be used to demarcate transactions. - * - * @return whether to enable default transactions, defaults to {@literal true}. - */ - boolean enableDefaultTransactions() default true; -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jAuditingEventListener.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jAuditingEventListener.java deleted file mode 100644 index 3356b5cea..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jAuditingEventListener.java +++ /dev/null @@ -1,74 +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.repository.config; - -import org.neo4j.ogm.session.SessionFactory; -import org.neo4j.ogm.session.event.Event; -import org.neo4j.ogm.session.event.EventListener; -import org.neo4j.ogm.session.event.EventListenerAdapter; -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.data.auditing.AuditingHandler; -import org.springframework.data.auditing.IsNewAwareAuditingHandler; -import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.neo4j.repository.support.Neo4jAuditingBeanPostProcessor; -import org.springframework.util.Assert; - -/** - * @author Frantisek Hartman - */ -public class Neo4jAuditingEventListener extends EventListenerAdapter implements EventListener { - - private final ObjectFactory auditingHandlerFactory; - - /** - * Creates a new {@link Neo4jAuditingEventListener} using the given {@link MappingContext} and {@link AuditingHandler} - * provided by the given {@link ObjectFactory}. This constructor does an additional registration to the - * {@link SessionFactory}. Therefore the {@link SessionFactory} must already be instantiated. - * - * @deprecated this constructor could create a cyclic dependency to the session factory if this class gets registered - * as a bean in the context. - * @param auditingHandlerFactory must not be {@literal null}. - */ - @Deprecated - public Neo4jAuditingEventListener(ObjectFactory auditingHandlerFactory, - SessionFactory sessionFactory) { - - Assert.notNull(auditingHandlerFactory, "IsNewAwareAuditingHandler must not be null!"); - this.auditingHandlerFactory = auditingHandlerFactory; - - sessionFactory.register(this); - } - - /** - * Constructor used for creating an instance in the {@link Neo4jAuditingRegistrar} to get registered in the session - * "manually". The registration is done within the {@link Neo4jAuditingBeanPostProcessor}. - * - * @param auditingHandlerFactory {@link AuditingHandler} to hook into the {@code preSave} phase for auditing. - */ - public Neo4jAuditingEventListener(ObjectFactory auditingHandlerFactory) { - Assert.notNull(auditingHandlerFactory, "IsNewAwareAuditingHandler must not be null!"); - this.auditingHandlerFactory = auditingHandlerFactory; - } - - @Override - public void onPreSave(Event event) { - Object object = event.getObject(); - if (object != null) { - auditingHandlerFactory.getObject().markAudited(object); - } - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jAuditingRegistrar.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jAuditingRegistrar.java deleted file mode 100644 index e71bc52e8..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jAuditingRegistrar.java +++ /dev/null @@ -1,83 +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.repository.config; - -import java.lang.annotation.Annotation; - -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.data.auditing.IsNewAwareAuditingHandler; -import org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarSupport; -import org.springframework.data.auditing.config.AuditingConfiguration; -import org.springframework.data.config.ParsingUtils; -import org.springframework.data.mapping.context.PersistentEntities; -import org.springframework.data.neo4j.annotation.EnableNeo4jAuditing; -import org.springframework.data.neo4j.repository.support.Neo4jAuditingBeanPostProcessor; -import org.springframework.util.Assert; - -/** - * @author Frantisek Hartman - */ -public class Neo4jAuditingRegistrar extends AuditingBeanDefinitionRegistrarSupport { - - @Override - protected Class getAnnotation() { - return EnableNeo4jAuditing.class; - } - - @Override - protected String getAuditingHandlerBeanName() { - return "neo4jAuditingHandler"; - } - - @Override - protected BeanDefinitionBuilder getAuditHandlerBeanDefinitionBuilder(AuditingConfiguration configuration) { - - Assert.notNull(configuration, "AuditingConfiguration must not be null!"); - - BeanDefinitionBuilder handler = BeanDefinitionBuilder.rootBeanDefinition(IsNewAwareAuditingHandler.class); - - BeanDefinitionBuilder definition = BeanDefinitionBuilder - .genericBeanDefinition(Neo4jMappingContextFactoryBean.class); - definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR); - - BeanDefinitionBuilder entities = BeanDefinitionBuilder.rootBeanDefinition(PersistentEntities.class); - entities.addConstructorArgValue(definition); - - handler.addConstructorArgValue(definition.getBeanDefinition()); - return configureDefaultAuditHandlerAttributes(configuration, handler); - } - - @Override - protected void registerAuditListenerBeanDefinition(BeanDefinition auditingHandlerDefinition, - BeanDefinitionRegistry registry) { - - Assert.notNull(auditingHandlerDefinition, "BeanDefinition must not be null!"); - Assert.notNull(registry, "BeanDefinitionRegistry must not be null!"); - - BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder - .rootBeanDefinition(Neo4jAuditingBeanPostProcessor.class); - - beanDefinitionBuilder - .addConstructorArgValue(ParsingUtils.getObjectFactoryBeanDefinition(getAuditingHandlerBeanName(), registry)); - - registerInfrastructureBeanWithId(beanDefinitionBuilder.getBeanDefinition(), - Neo4jAuditingBeanPostProcessor.class.getName(), registry); - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jMappingContextFactoryBean.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jMappingContextFactoryBean.java deleted file mode 100644 index e8bf3e681..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jMappingContextFactoryBean.java +++ /dev/null @@ -1,100 +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.repository.config; - -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.beans.factory.config.AbstractFactoryBean; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; -import org.springframework.util.Assert; - -/** - * {@link FactoryBean} to setup {@link Neo4jMappingContext} instances from Spring configuration. - * - * @author Mark Angrish - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -public class Neo4jMappingContextFactoryBean extends AbstractFactoryBean - implements ApplicationContextAware { - - private final String sessionFactoryBeanName; - - private ListableBeanFactory beanFactory; - - /** - * Uses the default session factory name - * {@link Neo4jRepositoryConfigurationExtension#DEFAULT_SESSION_FACTORY_BEAN_NAME} for finding the session factory - * passed to the {@link Neo4jMappingContext}. - * - * @deprecated since 5.1.0, use {@link #Neo4jMappingContextFactoryBean(String)} instead - */ - @Deprecated - public Neo4jMappingContextFactoryBean() { - this(Neo4jRepositoryConfigurationExtension.DEFAULT_SESSION_FACTORY_BEAN_NAME); - } - - /** - * Configures the mapping context with a named {@link SessionFactory}. - * - * @param sessionFactoryBeanName must not be {@literal null} or empty. - * @since 5.1.0 - */ - public Neo4jMappingContextFactoryBean(String sessionFactoryBeanName) { - - Assert.hasText(sessionFactoryBeanName, "SessionFactoryBeanName must not be null or empty!"); - - this.sessionFactoryBeanName = sessionFactoryBeanName; - } - - /* - * (non-Javadoc) - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.beanFactory = applicationContext; - } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.config.AbstractFactoryBean#getObjectType() - */ - @Override - public Class getObjectType() { - return Neo4jMappingContext.class; - } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance() - */ - @Override - protected Neo4jMappingContext createInstance() { - - SessionFactory sessionFactory = beanFactory.getBean(this.sessionFactoryBeanName, SessionFactory.class); - Neo4jMappingContext context = new Neo4jMappingContext(sessionFactory.metaData()); - - context.initialize(); - - return context; - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jOgmEntityInstantiatorConfigurationBean.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jOgmEntityInstantiatorConfigurationBean.java deleted file mode 100644 index 7aa677290..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jOgmEntityInstantiatorConfigurationBean.java +++ /dev/null @@ -1,61 +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.repository.config; - -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.session.SessionFactory; -import org.neo4j.ogm.typeconversion.ConversionCallback; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.core.convert.ConversionService; -import org.springframework.data.neo4j.conversion.MetaDataDrivenConversionService; -import org.springframework.data.neo4j.conversion.Neo4jOgmEntityInstantiatorAdapter; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; - -/** - * - * @author Gerrit Meier - * @author Michael J. Simons - */ -class Neo4jOgmEntityInstantiatorConfigurationBean { - - public Neo4jOgmEntityInstantiatorConfigurationBean(SessionFactory sessionFactory, Neo4jMappingContext mappingContext, - ObjectProvider conversionServiceObjectProvider) { - - MetaData metaData = sessionFactory.metaData(); - ConversionService conversionService = conversionServiceObjectProvider - .getIfUnique(() -> new MetaDataDrivenConversionService(metaData)); - metaData.registerConversionCallback(new ConversionServiceBasedConversionCallback(conversionService)); - - sessionFactory.setEntityInstantiator(new Neo4jOgmEntityInstantiatorAdapter(mappingContext, conversionService)); - } - - private static class ConversionServiceBasedConversionCallback implements ConversionCallback { - - private final ConversionService delegate; - - public ConversionServiceBasedConversionCallback(ConversionService conversionService) { - this.delegate = conversionService; - } - - @Override - public T convert(Class targetType, Object value) { - if (value == null) { - return null; - } - return delegate.convert(value, targetType); - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrar.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrar.java deleted file mode 100644 index ec1368cf1..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrar.java +++ /dev/null @@ -1,38 +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.repository.config; - -import java.lang.annotation.Annotation; - -import org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport; -import org.springframework.data.repository.config.RepositoryConfigurationExtension; - -/** - * @author Vince Bickers - * @author Mark Angrish - */ -public class Neo4jRepositoriesRegistrar extends RepositoryBeanDefinitionRegistrarSupport { - - @Override - protected Class getAnnotation() { - return EnableNeo4jRepositories.class; - } - - @Override - protected RepositoryConfigurationExtension getExtension() { - return new Neo4jRepositoryConfigurationExtension(); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtension.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtension.java deleted file mode 100644 index 93e94f68d..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtension.java +++ /dev/null @@ -1,267 +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.repository.config; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; - -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.RelationshipEntity; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.AutowireCandidateQualifier; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.core.annotation.AnnotationAttributes; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator; -import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactoryBean; -import org.springframework.data.neo4j.transaction.SharedSessionCreator; -import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource; -import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport; -import org.springframework.data.repository.config.RepositoryConfigurationSource; -import org.springframework.data.repository.config.XmlRepositoryConfigurationSource; -import org.springframework.util.ClassUtils; -import org.springframework.util.StringUtils; - -/** - * Neo4j specific configuration extension parsing custom attributes from the XML namespace and - * {@link EnableNeo4jRepositories} annotation. Creates and registers {@link BeanDefinitionBuilder} for - * {@link SharedSessionCreator} and {@link Neo4jMappingContextFactoryBean}. Also, it registers a bean definition for a - * {@link PersistenceExceptionTranslationPostProcessor} to enable exception translation of persistence specific - * exceptions into Spring's {@link DataAccessException} hierarchy. - * - * @author Vince Bickers - * @author Mark Angrish - * @author Mark Paluch - * @author Gerrit Meier - * @author Michael J. Simons - */ -public class Neo4jRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport { - - /** See {@link AbstractBeanDefinition#INFER_METHOD}. */ - static final String GENERATE_BEAN_NAME = "(generated)"; - static final String DEFAULT_SESSION_FACTORY_BEAN_NAME = "sessionFactory"; - static final String DEFAULT_TRANSACTION_MANAGER_BEAN_NAME = "transactionManager"; - - private static final String ENABLE_DEFAULT_TRANSACTIONS_ATTRIBUTE = "enableDefaultTransactions"; - private static final String NEO4J_PERSISTENCE_EXCEPTION_TRANSLATOR_NAME = "neo4jPersistenceExceptionTranslator"; - private static final String MODULE_PREFIX = "neo4j"; - private static final String MODULE_NAME = "Neo4j"; - - /** - * We use a generated name for every pair of {@code SessionFactory} and {@code Session} unless the user configures a - * session bean name with {@code @EnableNeo4jRepositories(sessionBeanName="someName")}. - */ - private String sessionBeanName; - - /** - * We use a generated name for every pair of {@code SessionFactory} and {@code Neo4jMappingContext} unless the user - * configures a session bean name with {@code @EnableNeo4jRepositories(mappingContextBeanName="someName")}. - */ - private String neo4jMappingContextBeanName; - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getModuleName() - */ - @Override - public String getModuleName() { - return MODULE_NAME; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config14.RepositoryConfigurationExtension#getRepositoryFactoryBeanClassName() - */ - @Override - public String getRepositoryFactoryBeanClassName() { - return Neo4jRepositoryFactoryBean.class.getName(); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config14.RepositoryConfigurationExtensionSupport#getModulePrefix() - */ - @Override - protected String getModulePrefix() { - return MODULE_PREFIX; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getIdentifyingAnnotations() - */ - @Override - @SuppressWarnings("unchecked") - protected Collection> getIdentifyingAnnotations() { - return Arrays.asList(NodeEntity.class, RelationshipEntity.class); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getIdentifyingTypes() - */ - @Override - protected Collection> getIdentifyingTypes() { - return Collections.> singleton(Neo4jRepository.class); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#postProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.springframework.data.repository.config.RepositoryConfigurationSource) - */ - @Override - public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSource source) { - - String transactionManagerRefPropertyName = "transactionManagerRef"; - String transactionManagerPropertyName = "transactionManager"; - String mappingContextPropertyName = "mappingContext"; - String sessionPropertyName = "session"; - - Optional transactionManagerRef = source.getAttribute(transactionManagerRefPropertyName); - builder.addPropertyValue(transactionManagerPropertyName, - transactionManagerRef.orElse(DEFAULT_TRANSACTION_MANAGER_BEAN_NAME)); - - builder.addPropertyReference(sessionPropertyName, this.sessionBeanName); - builder.addPropertyReference(mappingContextPropertyName, this.neo4jMappingContextBeanName); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#postProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource) - */ - @Override - public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) { - - AnnotationAttributes attributes = config.getAttributes(); - - builder.addPropertyValue(ENABLE_DEFAULT_TRANSACTIONS_ATTRIBUTE, - attributes.getBoolean(ENABLE_DEFAULT_TRANSACTIONS_ATTRIBUTE)); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#postProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.springframework.data.repository.config.XmlRepositoryConfigurationSource) - */ - @Override - public void postProcess(BeanDefinitionBuilder builder, XmlRepositoryConfigurationSource config) { - - Optional enableDefaultTransactions = config.getAttribute(ENABLE_DEFAULT_TRANSACTIONS_ATTRIBUTE); - - if (enableDefaultTransactions.filter(StringUtils::hasText).isPresent()) { - enableDefaultTransactions - .ifPresent(value -> builder.addPropertyValue(ENABLE_DEFAULT_TRANSACTIONS_ATTRIBUTE, value)); - - } - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#registerBeansForRoot(org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.data.repository.config.RepositoryConfigurationSource) - */ - @Override - public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConfigurationSource config) { - - super.registerBeansForRoot(registry, config); - - Object source = config.getSource(); - if (source == null) { - return; - } - - String configuredSessionBeanName = config.getAttribute("sessionBeanName").orElse(GENERATE_BEAN_NAME); - this.sessionBeanName = registerWithGeneratedNameOrUseConfigured(createSharedSessionCreatorBeanDefinition(config), - registry, configuredSessionBeanName, source); - - String configuredMappingContextBeanName = config.getAttribute("mappingContextBeanName").orElse(GENERATE_BEAN_NAME); - this.neo4jMappingContextBeanName = registerWithGeneratedNameOrUseConfigured( - createNeo4jMappingContextFactoryBeanDefinition(config), registry, configuredMappingContextBeanName, source); - - registerIfNotAlreadyRegistered(() -> new RootBeanDefinition(Neo4jPersistenceExceptionTranslator.class), registry, - NEO4J_PERSISTENCE_EXCEPTION_TRANSLATOR_NAME, source); - - AbstractBeanDefinition rootBeanDefinition = BeanDefinitionBuilder - .rootBeanDefinition(Neo4jOgmEntityInstantiatorConfigurationBean.class) - .setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE) - .addConstructorArgReference(getSessionFactoryBeanName(config)) - .addConstructorArgReference(this.neo4jMappingContextBeanName).getBeanDefinition(); - registerWithGeneratedNameOrUseConfigured(rootBeanDefinition, registry, GENERATE_BEAN_NAME, source); - } - - /** - * Uses a generated bean name if {@code configuredBeanName} is equal to {@link #GENERATE_BEAN_NAME}, otherwise uses - * the configured bean name to register the new bean. Does not check if there's already a bean under the configured - * name but throws a {@link org.springframework.beans.factory.BeanDefinitionStoreException}. Checks whether a bean is - * already registered under {@code configuredBeanName} in the given {@link BeanDefinitionRegistry} and uses a - * generated name for registering the bean instead. If not, the suggested bean name is used. - * - * @param bean must not be {@literal null}. - * @param registry must not be {@literal null}. - * @param configuredBeanName must not be {@literal null} or empty. - * @param source must not be {@literal null}. - * @throws org.springframework.beans.factory.BeanDefinitionStoreException if the BeanDefinition is invalid or if there - * is already a BeanDefinition for the specified bean name * (and we are not allowed to override it) - * @return the bean name used for registering the given {@link AbstractBeanDefinition} - */ - private static String registerWithGeneratedNameOrUseConfigured(AbstractBeanDefinition bean, - BeanDefinitionRegistry registry, String configuredBeanName, Object source) { - - String registeredBeanName = configuredBeanName; - if (GENERATE_BEAN_NAME.equals(configuredBeanName)) { - registeredBeanName = registerWithSourceAndGeneratedBeanName(bean, registry, source); - } else { - bean.setSource(source); - registry.registerBeanDefinition(configuredBeanName, bean); - } - return registeredBeanName; - } - - private static AbstractBeanDefinition createSharedSessionCreatorBeanDefinition(RepositoryConfigurationSource config) { - - String sessionFactoryBeanName = getSessionFactoryBeanName(config); - - AbstractBeanDefinition sharedSessionCreatorBeanDefinition = BeanDefinitionBuilder // - .rootBeanDefinition(SharedSessionCreator.class, "createSharedSession") // - .addConstructorArgReference(sessionFactoryBeanName) // - .getBeanDefinition(); - - sharedSessionCreatorBeanDefinition - .addQualifier(new AutowireCandidateQualifier(Qualifier.class, sessionFactoryBeanName)); - - return sharedSessionCreatorBeanDefinition; - } - - private static AbstractBeanDefinition createNeo4jMappingContextFactoryBeanDefinition( - RepositoryConfigurationSource config) { - - return BeanDefinitionBuilder // - .rootBeanDefinition(Neo4jMappingContextFactoryBean.class) // - .addConstructorArgValue(getSessionFactoryBeanName(config)) // - .getBeanDefinition(); - } - - private static String getSessionFactoryBeanName(RepositoryConfigurationSource config) { - return Optional.of("sessionFactoryRef").flatMap(config::getAttribute).orElse(DEFAULT_SESSION_FACTORY_BEAN_NAME); - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryNameSpaceHandler.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryNameSpaceHandler.java deleted file mode 100644 index ebc5c0170..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryNameSpaceHandler.java +++ /dev/null @@ -1,41 +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.repository.config; - -import org.springframework.beans.factory.xml.NamespaceHandlerSupport; -import org.springframework.data.repository.config.RepositoryBeanDefinitionParser; -import org.springframework.data.repository.config.RepositoryConfigurationExtension; - -/** - * Simple namespace handler for {@literal repositories} namespace. - * - * @author Mark Angrish - */ -public class Neo4jRepositoryNameSpaceHandler extends NamespaceHandlerSupport { - - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.xml.NamespaceHandler#init() - */ - public void init() { - - RepositoryConfigurationExtension extension = new Neo4jRepositoryConfigurationExtension(); - RepositoryBeanDefinitionParser repositoryBeanDefinitionParser = new RepositoryBeanDefinitionParser(extension); - - registerBeanDefinitionParser("repositories", repositoryBeanDefinitionParser); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/package-info.java deleted file mode 100644 index e81c2bbfd..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Infrastructure for Neo4j specific repositories. - */ -package org.springframework.data.neo4j.repository; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/AbstractGraphRepositoryQuery.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/AbstractGraphRepositoryQuery.java deleted file mode 100644 index 833d2221b..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/AbstractGraphRepositoryQuery.java +++ /dev/null @@ -1,126 +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.repository.query; - -import java.util.EmptyStackException; - -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.model.QueryStatistics; -import org.neo4j.ogm.model.Result; -import org.neo4j.ogm.session.Session; -import org.springframework.data.repository.query.RepositoryQuery; - -/** - * Base class for @link {@link RepositoryQuery}s. - * - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -public abstract class AbstractGraphRepositoryQuery implements RepositoryQuery { - - protected final GraphQueryMethod queryMethod; - protected final MetaData metaData; - protected final Session session; - - protected AbstractGraphRepositoryQuery(GraphQueryMethod queryMethod, MetaData metaData, Session session) { - - this.queryMethod = queryMethod; - this.metaData = metaData; - this.session = session; - } - - protected abstract Query getQuery(Object[] parameters); - - @Override - public Object execute(Object[] parameters) { - - Query query; - try { - query = getQuery(parameters); - } catch (EmptyStackException e) { - throw new IllegalArgumentException("Not enough arguments for query " + getQueryMethod().getName()); - } - - return doExecute(query, parameters); - } - - protected abstract Object doExecute(Query params, Object[] parameters); - - @Override - public GraphQueryMethod getQueryMethod() { - return queryMethod; - } - - protected GraphQueryExecution getExecution(GraphParameterAccessor accessor) { - - if (queryMethod.isStreamQuery()) { - return new GraphQueryExecution.CollectionExecution(session, accessor); - } - if (isCountQuery()) { - return new GraphQueryExecution.CountByExecution(session); - } - if (isDeleteQuery()) { - return new GraphQueryExecution.DeleteByExecution(session, queryMethod); - } - if (isExistsQuery()) { - return new GraphQueryExecution.ExistsByExecution(session); - } - if (returnsOgmSpecificType()) { - return new GraphQueryExecution.QueryResultExecution(session, accessor); - } - if (queryMethod.isCollectionQuery()) { - return new GraphQueryExecution.CollectionExecution(session, accessor); - } - if (queryMethod.isPageQuery()) { - return new GraphQueryExecution.PagedExecution(session, accessor); - } - if (queryMethod.isSliceQuery()) { - return new GraphQueryExecution.SlicedExecution(session, accessor); - } - return new GraphQueryExecution.SingleEntityExecution(session, accessor); - } - - /** - * Does the query returns an OGM specific object type that should get a special processing ? - * - * @return true if that's the case - */ - private boolean returnsOgmSpecificType() { - Class returnType = queryMethod.getMethod().getReturnType(); - return QueryStatistics.class.isAssignableFrom(returnType) || Result.class.isAssignableFrom(returnType); - } - - /** - * Returns whether the query should get a count projection applied. - * - * @return - */ - protected abstract boolean isCountQuery(); - - /** - * Returns whether the query should get an exists projection applied. - * - * @return - */ - protected abstract boolean isExistsQuery(); - - /** - * Return weather the query should delete matching documents. - * - * @return - */ - protected abstract boolean isDeleteQuery(); -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/CustomResultConverter.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/CustomResultConverter.java deleted file mode 100644 index 4e2a3ffef..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/CustomResultConverter.java +++ /dev/null @@ -1,64 +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.repository.query; - -import static java.lang.reflect.Proxy.*; - -import java.util.Map; - -import org.neo4j.ogm.context.SingleUseEntityMapper; -import org.neo4j.ogm.metadata.MetaData; -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * Convert OGM special {@link QueryResult} annotated types into SD understandable type. - * - * @author Nicolas Mervaillie - * @author Gerrit Meier - * @author Michael J. Simons - */ -class CustomResultConverter implements Converter { - - private final MetaData metaData; - private final Class returnedType; - - private final QueryResultInstantiator entityInstantiator; - - CustomResultConverter(MetaData metaData, Class returnedType, QueryResultInstantiator entityInstantiator) { - - this.metaData = metaData; - this.returnedType = returnedType; - this.entityInstantiator = entityInstantiator; - } - - @Override - @SuppressWarnings("unchecked") - public Object convert(Object source) { - - if (returnedType.getAnnotation(QueryResult.class) == null) { - return source; - } - if (returnedType.isInterface()) { - Class[] interfaces = new Class[] { returnedType }; - return newProxyInstance(returnedType.getClassLoader(), interfaces, - new QueryResultProxy((Map) source)); - } - - SingleUseEntityMapper mapper = new SingleUseEntityMapper(metaData, entityInstantiator); - return mapper.map(returnedType, (Map) source); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/FilterBuildersDefinition.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/FilterBuildersDefinition.java deleted file mode 100644 index dd04b1f8a..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/FilterBuildersDefinition.java +++ /dev/null @@ -1,104 +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.repository.query; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.function.Predicate; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.Filters; -import org.springframework.data.mapping.PersistentPropertyPath; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; -import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty; -import org.springframework.data.neo4j.repository.query.filter.FilterBuilder; -import org.springframework.data.repository.query.parser.Part; - -/** - * A filter builder definition represents an ongoing state of {@link FilterBuilder filter builder} chained together with - * "and" or "or". It is used with a resolved parameters to create an instance {@link Filters} for building a query - * object. - * - * @author Luanne Misquitta - * @author Michael J. Simons - */ -class FilterBuildersDefinition { - - private final Class entityType; - - private final Part basePart; - - private final List filterBuilders; - private final Predicate isInternalIdProperty; - - static UnstartedBuild forType(Neo4jMappingContext mappingContext, Class entityType) { - return new UnstartedBuild(mappingContext, entityType); - } - - private FilterBuildersDefinition(Neo4jMappingContext mappingContext, Class entityType, Part basePart) { - this.entityType = entityType; - this.basePart = basePart; - this.filterBuilders = new LinkedList<>(); - this.isInternalIdProperty = part -> { - PersistentPropertyPath path = mappingContext - .getPersistentPropertyPath(part.getProperty()); - Neo4jPersistentProperty possibleIdProperty = path.getRequiredLeafProperty(); - return possibleIdProperty.isInternalIdProperty(); - }; - this.filterBuilders.add(FilterBuilder.forPartAndEntity(basePart, entityType, BooleanOperator.NONE, - isInternalIdProperty)); - } - - TemplatedQuery buildTemplatedQuery() { - return new TemplatedQuery(Collections.unmodifiableList(filterBuilders)); - } - - /** - * Comment on original DerivedQueryDefinition was: "because the OR is handled in a weird way. Luanne, explain better" - * - * @return - */ - Part getBasePart() { - return basePart; - } - - FilterBuildersDefinition and(Part part) { - this.filterBuilders.add(FilterBuilder.forPartAndEntity(part, entityType, BooleanOperator.AND, isInternalIdProperty)); - return this; - } - - FilterBuildersDefinition or(Part part) { - this.filterBuilders.add(FilterBuilder.forPartAndEntity(part, entityType, BooleanOperator.OR, isInternalIdProperty)); - return this; - } - - static class UnstartedBuild { - - private final Neo4jMappingContext mappingContext; - - private final Class entityType; - - UnstartedBuild(Neo4jMappingContext mappingContext, Class entityType) { - this.mappingContext = mappingContext; - this.entityType = entityType; - } - - FilterBuildersDefinition startWith(Part firstPart) { - return new FilterBuildersDefinition(mappingContext, entityType, firstPart); - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParameterAccessor.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParameterAccessor.java deleted file mode 100644 index 369607e8a..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParameterAccessor.java +++ /dev/null @@ -1,44 +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.repository.query; - -import org.neo4j.ogm.cypher.query.SortOrder; -import org.springframework.data.repository.query.ParameterAccessor; - -/** - * Class used to lookup and handle special parameters such as depth, spatial parameters... - * - * @author Nicolas Mervaillie - */ -public interface GraphParameterAccessor extends ParameterAccessor { - - /** - * Gets the loading depth value of the {@link org.springframework.data.neo4j.annotation.Depth} annotated method - * parameter. - * - * @return the depth value - */ - int getDepth(); - - /** - * Get OGM specific sort order translated from method parameters. - * - * @return The sort order - */ - SortOrder getOgmSort(); - - // Should probably do the same for ogm specific pagination -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParameters.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParameters.java deleted file mode 100644 index b11d73c97..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParameters.java +++ /dev/null @@ -1,107 +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.repository.query; - -import java.lang.reflect.Method; -import java.util.List; -import java.util.Optional; - -import org.springframework.core.MethodParameter; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.annotation.Depth; -import org.springframework.data.repository.query.Parameter; -import org.springframework.data.repository.query.Parameters; - -/** - * Custom extension of {@link Parameters} discovering additional to handle @link{Depth} special parameter. - * - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -public class GraphParameters extends Parameters { - - private Integer depthIndex; - - GraphParameters(Method method) { - super(method); - } - - GraphParameters(List parameters, Integer depthIndex) { - super(parameters); - this.depthIndex = depthIndex; - } - - @Override - protected GraphParameter createParameter(MethodParameter parameter) { - GraphParameter graphParameter = new GraphParameter(parameter); - - // Detect manually annotated @Depth and reject multiple annotated ones - if (this.depthIndex == null && graphParameter.isDepthParameter()) { - this.depthIndex = graphParameter.getIndex(); - } else if (graphParameter.isDepthParameter()) { - - String methodFragment = Optional.ofNullable(parameter) - .map(MethodParameter::getMethod) - .map(Method::toString) - .map(s -> "method " + s) - .orElse("unknown method"); - throw new IllegalStateException(String.format("Found multiple @Depth annotations on method %s! Only one allowed!", - methodFragment)); - } - - return graphParameter; - } - - @Override - protected GraphParameters createFrom(List parameters) { - return new GraphParameters(parameters, this.depthIndex); - } - - int getDepthIndex() { - return (depthIndex != null) ? depthIndex : -1; - } - - static class GraphParameter extends Parameter { - - private final MethodParameter parameter; - - /** - * Creates a new {@link GraphParameter}. - * - * @param parameter must not be {@literal null}. - */ - GraphParameter(MethodParameter parameter) { - super(parameter); - this.parameter = parameter; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.query.Parameter#isSpecialParameter() - */ - @Override - public boolean isSpecialParameter() { - return super.isSpecialParameter() || Distance.class.isAssignableFrom(getType()) - || parameter.getParameterAnnotation(Depth.class) != null || Distance.class.isAssignableFrom(getType()) - || Point.class.isAssignableFrom(getType()); - } - - boolean isDepthParameter() { - return parameter.getParameterAnnotation(Depth.class) != null; - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParametersParameterAccessor.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParametersParameterAccessor.java deleted file mode 100644 index 73fe7d597..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphParametersParameterAccessor.java +++ /dev/null @@ -1,83 +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.repository.query; - -import org.neo4j.ogm.cypher.query.SortOrder; -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.annotation.Depth; -import org.springframework.data.repository.query.ParametersParameterAccessor; - -/** - * Custom {@link ParametersParameterAccessor} to allow access to the {@link Depth} parameter. - * - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -public class GraphParametersParameterAccessor extends ParametersParameterAccessor implements GraphParameterAccessor { - - private static final int DEFAULT_QUERY_DEPTH = 1; - private final GraphQueryMethod method; - - /** - * Creates a new {@link ParametersParameterAccessor}. - * - * @param method must not be {@literal null}. - * @param values must not be {@literal null}. - */ - public GraphParametersParameterAccessor(GraphQueryMethod method, Object[] values) { - super(method.getParameters(), values); - - this.method = method; - } - - @Override - public int getDepth() { - - Depth methodAnnotation = AnnotatedElementUtils.findMergedAnnotation(method.getMethod(), Depth.class); - if (methodAnnotation != null) { - Object value = AnnotationUtils.getValue(methodAnnotation); - return value == null ? DEFAULT_QUERY_DEPTH : (int) value; - } - - GraphParameters graphParameters = method.getParameters(); - - int depthIndex = graphParameters.getDepthIndex(); - - if (depthIndex != -1) { - return getValue(depthIndex); - } else { - return DEFAULT_QUERY_DEPTH; - } - } - - @Override - public SortOrder getOgmSort() { - SortOrder sortOrder = new SortOrder(); - - if (getSort() != null) { - for (Sort.Order order : getSort()) { - if (order.isAscending()) { - sortOrder.add(order.getProperty()); - } else { - sortOrder.add(SortOrder.Direction.DESC, order.getProperty()); - } - } - } - return sortOrder; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryExecution.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryExecution.java deleted file mode 100644 index 7f5967ea8..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryExecution.java +++ /dev/null @@ -1,246 +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.repository.query; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.function.LongSupplier; - -import org.neo4j.ogm.model.Result; -import org.neo4j.ogm.session.Session; -import org.springframework.dao.IncorrectResultSizeDataAccessException; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.SliceImpl; -import org.springframework.data.neo4j.annotation.QueryResult; -import org.springframework.data.repository.support.PageableExecutionUtils; -import org.springframework.util.Assert; - -/** - * Classes intended to pilot query execution according to the type of the query. The type of the query is determined by - * looking at the result class of the method. - * - * @see AbstractGraphRepositoryQuery#getExecution(org.springframework.data.neo4j.repository.query.GraphParameterAccessor) - * @author Nicolas Mervaillie - */ -public interface GraphQueryExecution { - - Object execute(Query query, Class type); - - final class SingleEntityExecution implements GraphQueryExecution { - - private final Session session; - private final GraphParameterAccessor accessor; - - SingleEntityExecution(Session session, GraphParameterAccessor accessor) { - this.session = session; - this.accessor = accessor; - } - - @Override - public Object execute(Query query, Class type) { - Iterable result; - if (query.isFilterQuery()) { - result = session.loadAll(type, query.getFilters(), accessor.getDepth()); - } else { - // not using queryForObject here because it raises too generic RuntimeException - // if more than one result found - if (type.getAnnotation(QueryResult.class) != null) { - result = session.query(query.getCypherQuery(), query.getParameters()).queryResults(); - } else { - result = session.query(type, query.getCypherQuery(), query.getParameters()); - } - } - Iterator iterator = result.iterator(); - if (!iterator.hasNext()) { - return null; - } - Object ret = iterator.next(); - if (iterator.hasNext()) { - throw new IncorrectResultSizeDataAccessException("Incorrect result size: expected at most 1", 1); - } - return ret; - } - } - - final class CollectionExecution implements GraphQueryExecution { - - private final Session session; - private final GraphParameterAccessor accessor; - - CollectionExecution(Session session, GraphParameterAccessor accessor) { - this.session = session; - this.accessor = accessor; - } - - @Override - public Object execute(Query query, Class type) { - if (query.isFilterQuery()) { - return session.loadAll(type, query.getFilters(), accessor.getOgmSort(), accessor.getDepth()); - } else { - if (type.getAnnotation(QueryResult.class) != null || Map.class.isAssignableFrom(type)) { - return session.query(query.getCypherQuery(accessor.getSort()), query.getParameters()).queryResults(); - } else { - return session.query(type, query.getCypherQuery(accessor.getSort()), query.getParameters()); - } - } - } - } - - final class QueryResultExecution implements GraphQueryExecution { - - private final Session session; - private final GraphParameterAccessor accessor; - - QueryResultExecution(Session session, GraphParameterAccessor accessor) { - this.session = session; - this.accessor = accessor; - } - - @Override - public Object execute(Query query, Class type) { - return session.query(query.getCypherQuery(accessor.getSort()), query.getParameters()); - } - } - - final class PagedExecution implements GraphQueryExecution { - - private final Session session; - private final Pageable pageable; - private final GraphParameterAccessor accessor; - - PagedExecution(Session session, GraphParameterAccessor accessor) { - this.session = session; - this.pageable = accessor.getPageable(); - this.accessor = accessor; - } - - @Override - public Object execute(Query query, Class type) { - - List result; - long count; - if (query.isFilterQuery()) { - result = (List) session.loadAll(type, query.getFilters(), accessor.getOgmSort(), - query.getPagination(pageable, false), accessor.getDepth()); - count = session.count(type, query.getFilters()); - } else { - if (type.getAnnotation(QueryResult.class) != null) { - result = (List) session.query(query.getCypherQuery(pageable, false), query.getParameters()).queryResults(); - } else { - result = (List) session.query(type, query.getCypherQuery(pageable, false), query.getParameters()); - } - count = (result.size() > 0) ? countTotalNumberOfElements(query) : 0; - } - - return PageableExecutionUtils.getPage(result, pageable, (LongSupplier) () -> count); - } - - private Integer countTotalNumberOfElements(Query query) { - Assert.hasText(query.getCountQuery(), "Must specify a count query to get pagination info."); - return session.queryForObject(Integer.class, query.getCountQuery(), query.getParameters()); - } - } - - final class SlicedExecution implements GraphQueryExecution { - - private final Session session; - private final GraphParameterAccessor accessor; - private final Pageable pageable; - - SlicedExecution(Session session, GraphParameterAccessor accessor) { - this.session = session; - this.accessor = accessor; - this.pageable = accessor.getPageable(); - } - - @Override - public Object execute(Query query, Class type) { - - int pageSize = pageable.getPageSize(); - - List result; - if (query.isFilterQuery()) { - // For a slice, need one extra result to determine if there is a next page - result = (List) session.loadAll(type, query.getFilters(), accessor.getOgmSort(), - query.getPagination(pageable, true), accessor.getDepth()); - } else { - String cypherQuery = query.getCypherQuery(pageable, true); - if (type.getAnnotation(QueryResult.class) != null) { - result = (List) session.query(cypherQuery, query.getParameters()).queryResults(); - } else { - result = (List) session.query(type, cypherQuery, query.getParameters()); - } - } - - boolean hasNext = result.size() > pageSize; - return new SliceImpl(hasNext ? result.subList(0, pageSize) : result, pageable, hasNext); - } - } - - final class CountByExecution implements GraphQueryExecution { - - private final Session session; - - CountByExecution(Session session) { - this.session = session; - } - - @Override - public Object execute(Query query, Class type) { - return session.count(type, query.getFilters()); - } - } - - final class ExistsByExecution implements GraphQueryExecution { - - private final Session session; - - ExistsByExecution(Session session) { - this.session = session; - } - - @Override - public Object execute(Query query, Class type) { - if (query.isFilterQuery()) { - return session.count(type, query.getFilters()) > 0; - } - Result result = session.query(query.getCypherQuery(), query.getParameters()); - return result.iterator().hasNext(); - } - } - - final class DeleteByExecution implements GraphQueryExecution { - - private final Session session; - private final GraphQueryMethod graphQueryMethod; - - DeleteByExecution(Session session, GraphQueryMethod graphQueryMethod) { - this.session = session; - this.graphQueryMethod = graphQueryMethod; - } - - @Override - public Object execute(Query query, Class type) { - Class returnType = graphQueryMethod.getReturnedObjectType(); - - if (returnType.equals(Long.class)) { - return session.delete(type, query.getFilters(), graphQueryMethod.isCollectionQuery()); - } - throw new RuntimeException("Long or Iterable is required as the return type of a Delete query"); - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryLookupStrategy.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryLookupStrategy.java deleted file mode 100644 index 7cfa3f432..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryLookupStrategy.java +++ /dev/null @@ -1,116 +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.repository.query; - -import java.lang.reflect.Method; - -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.session.Session; -import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.neo4j.mapping.MetaDataProvider; -import org.springframework.data.neo4j.mapping.Neo4jPersistentEntity; -import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty; -import org.springframework.data.projection.ProjectionFactory; -import org.springframework.data.repository.core.NamedQueries; -import org.springframework.data.repository.core.RepositoryMetadata; -import org.springframework.data.repository.query.QueryLookupStrategy; -import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider; -import org.springframework.data.repository.query.RepositoryQuery; -import org.springframework.lang.Nullable; -import org.springframework.util.ReflectionUtils; - -/** - * @author Mark Angrish - * @author Luanne Misquitta - * @author Oliver Gierke - * @author Nicolas Mervaillie - * @author Gerrit Meier - * @author Michael J. Simons - * @author Ihor Dziuba - */ -public class GraphQueryLookupStrategy implements QueryLookupStrategy { - - private final MetaData metaData; - private final Session session; - private final QueryMethodEvaluationContextProvider evaluationContextProvider; - private final MappingContext, Neo4jPersistentProperty> mappingContext; - - /** - * @param session - * @param evaluationContextProvider - * @deprecated since 5.1.0, use - * {@link GraphQueryLookupStrategy#GraphQueryLookupStrategy(Session, QueryMethodEvaluationContextProvider, MappingContext)} - * instead and provide the mapping context. - */ - @Deprecated - public GraphQueryLookupStrategy(Session session, QueryMethodEvaluationContextProvider evaluationContextProvider) { - this(session, evaluationContextProvider, null); - } - - public GraphQueryLookupStrategy(Session session, QueryMethodEvaluationContextProvider evaluationContextProvider, - @Nullable MappingContext, Neo4jPersistentProperty> mappingContext) { - - this.metaData = getMetaData(session); - this.session = session; - this.evaluationContextProvider = evaluationContextProvider; - this.mappingContext = mappingContext; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.projection.ProjectionFactory, org.springframework.data.repository.core.NamedQueries) - */ - @Override - public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory, - NamedQueries namedQueries) { - - GraphQueryMethod queryMethod = new GraphQueryMethod(method, metadata, factory); - queryMethod.setMappingContext(this.mappingContext); - String namedQueryName = queryMethod.getNamedQueryName(); - String namedCountQueryName = queryMethod.getNamedCountQueryName(); - - if (namedQueries.hasQuery(namedQueryName)) { - String cypherQuery = namedQueries.getQuery(namedQueryName); - if (namedQueries.hasQuery(namedCountQueryName)){ - String countQuery = namedQueries.getQuery(namedCountQueryName); - return new NamedGraphRepositoryQuery(queryMethod, metaData, session, cypherQuery, countQuery, evaluationContextProvider); - } - return new NamedGraphRepositoryQuery(queryMethod, metaData, session, cypherQuery, evaluationContextProvider); - } else if (queryMethod.hasAnnotatedQuery()) { - return new GraphRepositoryQuery(queryMethod, metaData, session, evaluationContextProvider); - } else { - return new PartTreeNeo4jQuery(queryMethod, metaData, session); - } - } - - private static MetaData getMetaData(Session session) { - - // This is the case in most standard setups: The SharedSessionCreator adds this MetaDataProvider interface - if (session instanceof MetaDataProvider) { - return ((MetaDataProvider) session).getMetaData(); - } - - // That is usually the case in a programmatic setup of repositories or in the case of CDI environment. - // Note that in this case the meta-data is retrieved from the session, not from the session-factory. - Method getMetaData = ReflectionUtils.findMethod(session.getClass(), "metaData"); - if (getMetaData == null) { - throw new IllegalStateException("Could not retrieve Neo4j-OGM MetaData from session."); - } else { - return (MetaData) ReflectionUtils.invokeMethod(getMetaData, session); - } - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryMethod.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryMethod.java deleted file mode 100644 index 7dd89eb22..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphQueryMethod.java +++ /dev/null @@ -1,162 +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.repository.query; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.neo4j.annotation.Depth; -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.mapping.Neo4jPersistentEntity; -import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty; -import org.springframework.data.projection.ProjectionFactory; -import org.springframework.data.repository.core.RepositoryMetadata; -import org.springframework.data.repository.query.Parameters; -import org.springframework.data.repository.query.QueryMethod; -import org.springframework.lang.Nullable; -import org.springframework.util.StringUtils; - -/** - * @author Mark Angrish - * @author Luanne Misquitta - * @author Oliver Gierke - * @author Michael J. Simons - * @author Ihor Dziuba - */ -public class GraphQueryMethod extends QueryMethod { - - private final Method method; - private final Query queryAnnotation; - private final Integer queryDepthParamIndex; - private final boolean isExistsQuery; - private @Nullable MappingContext, Neo4jPersistentProperty> mappingContext; - - public GraphQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) { - super(method, metadata, factory); - - this.method = method; - this.queryAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, Query.class); - if (this.queryAnnotation != null) { - this.isExistsQuery = queryAnnotation.exists(); - } else { - this.isExistsQuery = false; - } - this.queryDepthParamIndex = getQueryDepthParamIndex(method); - Integer queryDepth = getStaticQueryDepth(method); - if (queryDepth != null && queryDepthParamIndex != null) { - throw new IllegalArgumentException(method.getName() + " cannot have both a method @Depth and a parameter @Depth"); - } - - } - - @Override - protected Parameters createParameters(Method method) { - return new GraphParameters(method); - } - - @Override - public GraphParameters getParameters() { - return (GraphParameters) super.getParameters(); - } - - public MappingContext, Neo4jPersistentProperty> getMappingContext() { - return mappingContext; - } - - public void setMappingContext(MappingContext, Neo4jPersistentProperty> mappingContext) { - this.mappingContext = mappingContext; - } - - public String getQuery() { - return queryAnnotation.value(); - } - - public Method getMethod() { - return method; - } - - /** - * Returns the name of the named query this method belongs to. - * - * @return - */ - public String getNamedQueryName() { - return String.format("%s.%s", getDomainClass().getSimpleName(), method.getName()); - } - - /** - * Returns the name of the count query related to named query this method belongs to - * - * @return - */ - public String getNamedCountQueryName() { - return String.format("%s.countQuery", getNamedQueryName()); - } - - public Integer getQueryDepthParamIndex() { - return queryDepthParamIndex; - } - - private Integer getQueryDepthParamIndex(Method method) { - Annotation[][] annotations = method.getParameterAnnotations(); - for (int i = 0; i < annotations.length; i++) { - if (annotations[i].length > 0) { - for (Annotation annotation : annotations[i]) { - if (annotation.annotationType() == Depth.class) { - if (method.getParameterTypes()[i] == Integer.class || method.getParameterTypes()[i] == int.class) { - return i; - } else { - throw new IllegalArgumentException("Depth parameter in " + method.getName() + " must be an integer"); - } - } - } - } - } - return null; - } - - private Integer getStaticQueryDepth(Method method) { - if (method.isAnnotationPresent(Depth.class)) { - return method.getAnnotation(Depth.class).value(); - } - return null; - } - - public String getCountQueryString() { - return queryAnnotation != null ? queryAnnotation.countQuery() : null; - } - - public boolean hasAnnotatedQuery() { - return getAnnotatedQuery() != null; - } - - boolean isAnnotatedExistsQuery() { - return isExistsQuery; - } - - private String getAnnotatedQuery() { - - String query = (String) AnnotationUtils.getValue(getQueryAnnotation()); - return StringUtils.hasText(query) ? query : null; - } - - private Query getQueryAnnotation() { - return AnnotatedElementUtils.findMergedAnnotation(method, Query.class); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphRepositoryQuery.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphRepositoryQuery.java deleted file mode 100644 index f3305a259..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/GraphRepositoryQuery.java +++ /dev/null @@ -1,150 +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.repository.query; - -import java.util.HashMap; -import java.util.Map; - -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.model.Result; -import org.neo4j.ogm.session.Session; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.neo4j.repository.query.spel.ParameterizedQuery; -import org.springframework.data.repository.query.Parameter; -import org.springframework.data.repository.query.Parameters; -import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider; -import org.springframework.data.repository.query.RepositoryQuery; -import org.springframework.data.repository.query.ResultProcessor; - -/** - * Specialisation of {@link RepositoryQuery} that handles mapping to object annotated with @Query. - * - * @author Mark Angrish - * @author Luanne Misquitta - * @author Jasper Blues - * @author Mark Paluch - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -public class GraphRepositoryQuery extends AbstractGraphRepositoryQuery { - - private static final Logger LOG = LoggerFactory.getLogger(GraphRepositoryQuery.class); - - private final QueryMethodEvaluationContextProvider evaluationContextProvider; - private final QueryResultInstantiator entityInstantiator; - private final boolean isExistsQuery; - - private ParameterizedQuery parameterizedQuery; - - GraphRepositoryQuery(GraphQueryMethod graphQueryMethod, MetaData metaData, Session session, - QueryMethodEvaluationContextProvider evaluationContextProvider - ) { - - super(graphQueryMethod, metaData, session); - - this.evaluationContextProvider = evaluationContextProvider; - this.entityInstantiator = new QueryResultInstantiator(metaData, queryMethod.getMappingContext()); - this.isExistsQuery = graphQueryMethod.isAnnotatedExistsQuery(); - } - - protected Object doExecute(Query query, Object[] parameters) { - - if (LOG.isDebugEnabled()) { - LOG.debug("Executing query for method {}", queryMethod.getName()); - } - - GraphParameterAccessor accessor = new GraphParametersParameterAccessor(queryMethod, parameters); - ResultProcessor processor = queryMethod.getResultProcessor().withDynamicProjection(accessor); - - Class methodReturnType = queryMethod.getMethod().getReturnType(); - Class processorReturnType = processor.getReturnedType().getReturnedType(); - - Object result = getExecution(accessor).execute(query, processorReturnType); - - return Result.class.equals(methodReturnType) ? result - : processor.processResult(result, new CustomResultConverter(metaData, - processorReturnType, entityInstantiator)); - } - - protected Query getQuery(Object[] parameters) { - ParameterizedQuery parameterizedQuery = getParameterizedQuery(); - Map parametersFromQuery = parameterizedQuery.resolveParameter(parameters, this::resolveParams); - return new Query(parameterizedQuery.getQueryString(), queryMethod.getCountQueryString(), parametersFromQuery); - } - - private ParameterizedQuery getParameterizedQuery() { - if (parameterizedQuery == null) { - - Parameters methodParameters = queryMethod.getParameters(); - parameterizedQuery = ParameterizedQuery.getParameterizedQuery(getAnnotationQueryString(), methodParameters, - evaluationContextProvider); - } - return parameterizedQuery; - } - - Map resolveParams(Parameters methodParameters, Object[] parameters) { - - Map resolvedParameters = new HashMap<>(); - - for (Parameter parameter : methodParameters) { - int parameterIndex = parameter.getIndex(); - Object parameterValue = getParameterValue(parameters[parameterIndex]); - - // We support using parameters based on their index and their name at the same time, - // so parameters are always bound by index. - resolvedParameters.put(Integer.toString(parameterIndex), parameterValue); - - // Make sure we don't add "special" parameters as named parameters - if (parameter.isNamedParameter()) { - // even though the above check ensures the presence usually, it's probably better to - // treat #isNamedParameter as a blackbox and not just calling #get() on the optional. - parameter.getName().ifPresent(parameterName -> resolvedParameters.put(parameterName, parameterValue)); - } - } - - return resolvedParameters; - } - - private String getAnnotationQueryString() { - return getQueryMethod().getQuery(); - } - - private Object getParameterValue(Object parameter) { - - // The parameter might be an entity, try to resolve its id - Object parameterValue = session.resolveGraphIdFor(parameter); - if (parameterValue == null) { // Either not an entity or not persisted - parameterValue = parameter; - } - return parameterValue; - } - - @Override - protected boolean isCountQuery() { - return false; - } - - @Override - protected boolean isExistsQuery() { - return isExistsQuery; - } - - @Override - protected boolean isDeleteQuery() { - return false; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/NamedGraphRepositoryQuery.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/NamedGraphRepositoryQuery.java deleted file mode 100644 index 4aff7c205..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/NamedGraphRepositoryQuery.java +++ /dev/null @@ -1,55 +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.repository.query; - -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.session.Session; -import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider; -import org.springframework.lang.Nullable; - -/** - * Specialisation of {@link GraphRepositoryQuery} that creates queries from named queries defined in - * {@code META-INFO/neo4j-named-queries.properties}. - * - * @author Gerrit Meier - * @author Michael J. Simons - * @author Ihor Dziuba - */ -public class NamedGraphRepositoryQuery extends GraphRepositoryQuery { - - private final String cypherQuery; - private @Nullable final String countQuery; - - NamedGraphRepositoryQuery(GraphQueryMethod graphQueryMethod, MetaData metaData, Session session, String cypherQuery, - QueryMethodEvaluationContextProvider evaluationContextProvider) { - - this(graphQueryMethod, metaData, session, cypherQuery, null, evaluationContextProvider); - } - - NamedGraphRepositoryQuery(GraphQueryMethod graphQueryMethod, MetaData metaData, Session session, String cypherQuery, - String countQuery, QueryMethodEvaluationContextProvider evaluationContextProvider) { - - super(graphQueryMethod, metaData, session, evaluationContextProvider); - this.cypherQuery = cypherQuery; - this.countQuery = countQuery; - } - - @Override - protected Query getQuery(Object[] parameters) { - - return new Query(cypherQuery, countQuery, resolveParams(queryMethod.getParameters(), parameters)); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/PartTreeNeo4jQuery.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/PartTreeNeo4jQuery.java deleted file mode 100644 index 5b848844b..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/PartTreeNeo4jQuery.java +++ /dev/null @@ -1,121 +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.repository.query; - -import java.util.HashMap; -import java.util.Map; - -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.session.Session; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; -import org.springframework.data.repository.query.RepositoryQuery; -import org.springframework.data.repository.query.ResultProcessor; -import org.springframework.data.repository.query.parser.PartTree; - -/** - * Specialisation of {@link RepositoryQuery} that handles mapping of filter finders. - * - * @author Mark Angrish - * @author Luanne Misquitta - * @author Jasper Blues - * @author Vince Bickers - * @author Nicolas Mervaillie - * @author Mark Paluch - * @author Michael J. Simons - */ -public class PartTreeNeo4jQuery extends AbstractGraphRepositoryQuery { - - private static final Logger LOG = LoggerFactory.getLogger(PartTreeNeo4jQuery.class); - private final GraphQueryMethod graphQueryMethod; - private final PartTree tree; - - private final TemplatedQuery queryTemplate; - - public PartTreeNeo4jQuery(GraphQueryMethod graphQueryMethod, MetaData metaData, Session session) { - super(graphQueryMethod, metaData, session); - - Class domainType = graphQueryMethod.getEntityInformation().getJavaType(); - this.graphQueryMethod = graphQueryMethod; - this.tree = new PartTree(graphQueryMethod.getName(), domainType); - - this.queryTemplate = new TemplatedQueryCreator(this.tree, - (Neo4jMappingContext) this.graphQueryMethod.getMappingContext(), domainType).createQuery(); - } - - @Override - protected Object doExecute(Query params, Object[] parameters) { - - if (LOG.isDebugEnabled()) { - LOG.debug("Executing query for method {}", graphQueryMethod.getName()); - } - - GraphParameterAccessor accessor = new GraphParametersParameterAccessor(graphQueryMethod, parameters); - Class returnType = graphQueryMethod.getMethod().getReturnType(); - - if (returnType.equals(Void.class)) { - throw new RuntimeException("Derived Queries must have a return type"); - } - - ResultProcessor processor = graphQueryMethod.getResultProcessor().withDynamicProjection(accessor); - Object results = getExecution(accessor).execute(params, processor.getReturnedType().getDomainType()); - - return processor.processResult(results); - } - - @Override - protected Query getQuery(Object[] parameters) { - - Map resolvedParameters = resolveParameters(parameters); - return this.queryTemplate.createExecutableQuery(resolvedParameters); - } - - @Override - protected boolean isCountQuery() { - return tree.isCountProjection(); - } - - @Override - protected boolean isExistsQuery() { - return tree.isExistsProjection(); - } - - @Override - protected boolean isDeleteQuery() { - return tree.isDelete(); - } - - /** - * Sets values from parameters supplied by the finder on {@link org.neo4j.ogm.cypher.Filter} built by the - * {@link GraphQueryMethod} - * - * @param parameters parameter values supplied by the finder method - * @return List of Parameter with values set - */ - private Map resolveParameters(Object[] parameters) { - Map resolvedParameters = new HashMap<>(); - - for (int i = 0; i < parameters.length; i++) { - if (graphQueryMethod.getQueryDepthParamIndex() == null - || (graphQueryMethod.getQueryDepthParamIndex() != null && graphQueryMethod.getQueryDepthParamIndex() != i)) { - resolvedParameters.put(i, parameters[i]); - } - } - - return resolvedParameters; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/Query.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/Query.java deleted file mode 100644 index 53ab2eed0..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/Query.java +++ /dev/null @@ -1,185 +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.repository.query; - -import java.util.Map; -import java.util.stream.Collectors; - -import org.neo4j.ogm.cypher.Filters; -import org.neo4j.ogm.cypher.query.Pagination; -import org.neo4j.ogm.cypher.query.SortOrder; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.util.PagingAndSortingUtils; -import org.springframework.lang.Nullable; -import org.springframework.util.Assert; - -/** - * Represents an OGM query. Can hold either cypher queries or filter definitions. Also in charge of adding pagination / - * sort to the string based queries as OGM does not support pagination and sort on those. - * - * @author Nicolas Mervaillie - * @author Michael J. Simons - * @author Ihor Dziuba - */ -public class Query { - - private static final String SKIP = "sdnSkip"; - private static final String LIMIT = "sdnLimit"; - private static final String SKIP_LIMIT = " SKIP $" + SKIP + " LIMIT $" + LIMIT; - private static final String ORDER_BY_CLAUSE = " ORDER BY %s"; - - private Filters filters; - private String cypherQuery; - private Map parameters; - private @Nullable String countQuery; - - public Query(Filters filters) { - Assert.notNull(filters, "Filters must not be null."); - this.filters = filters; - } - - public Query(String cypherQuery, @Nullable String countQuery, Map parameters) { - Assert.notNull(cypherQuery, "Query must not be null."); - Assert.notNull(parameters, "Parameters must not be null."); - this.cypherQuery = sanitize(cypherQuery); - this.countQuery = countQuery == null ? null : sanitize(countQuery); - this.parameters = parameters; - } - - public boolean isFilterQuery() { - return filters != null; - } - - public Filters getFilters() { - return filters; - } - - public String getCypherQuery() { - return cypherQuery; - } - - public Map getParameters() { - return parameters; - } - - public String getCountQuery() { - return countQuery; - } - - public String getCypherQuery(Pageable pageable, boolean forSlicing) { - String result = cypherQuery; - Sort sort = null; - if (pageable.isPaged() && pageable.getSort() != Sort.unsorted()) { - sort = pageable.getSort(); - } - if (sort != Sort.unsorted()) { - // Custom queries in the OGM do not support pageable - result = addSorting(result, sort); - } - result = addPaging(result, pageable, forSlicing); - return result; - } - - public String getCypherQuery(Sort sort) { - // Custom queries in the OGM do not support pageable - String result = cypherQuery; - if (sort != Sort.unsorted()) { - result = addSorting(cypherQuery, sort); - } - return result; - } - - private String addPaging(String cypherQuery, Pageable pageable, boolean forSlicing) { - // Custom queries in the OGM do not support pageable - cypherQuery = formatBaseQuery(cypherQuery); - cypherQuery = cypherQuery + SKIP_LIMIT; - parameters.put(SKIP, pageable.getPageNumber() * pageable.getPageSize()); - if (forSlicing) { - parameters.put(LIMIT, pageable.getPageSize() + 1); - } else { - parameters.put(LIMIT, pageable.getPageSize()); - } - return cypherQuery; - } - - private String addSorting(String baseQuery, Sort sort) { - baseQuery = formatBaseQuery(baseQuery); - if (sort == null) { - return baseQuery; - } - final String sortOrder = getSortOrder(sort); - if (sortOrder.isEmpty()) { - return baseQuery; - } - return baseQuery + String.format(ORDER_BY_CLAUSE, sortOrder); - } - - private String getSortOrder(Sort sort) { - return sort.stream() - .map(Query::getPropertySortOrder) - .collect(Collectors.joining(", ")); - } - - private static String getPropertySortOrder(Sort.Order order) { - StringBuilder sb = new StringBuilder(); - if(order.isIgnoreCase()){ - sb.append("toLower(").append(order.getProperty()).append(")"); - } else { - sb.append(order.getProperty()); - } - sb.append(" ").append(order.getDirection()); - return sb.toString(); - } - - private String formatBaseQuery(String cypherQuery) { - cypherQuery = cypherQuery.trim(); - if (cypherQuery.endsWith(";")) { - cypherQuery = cypherQuery.substring(0, cypherQuery.length() - 1); - } - return cypherQuery; - } - - public Pagination getPagination(Pageable pageable, boolean forSlicing) { - Pagination pagination = new Pagination(pageable.getPageNumber(), pageable.getPageSize() + ((forSlicing) ? 1 : 0)); - pagination.setOffset(pageable.getPageNumber() * pageable.getPageSize()); - return pagination; - } - - public SortOrder getSort(Pageable pageable) { - return PagingAndSortingUtils.convert(pageable.getSort()); - } - - private String sanitize(String cypherQuery) { - cypherQuery = cypherQuery.trim(); - if (cypherQuery.endsWith(";")) { - cypherQuery = cypherQuery.substring(0, cypherQuery.length() - 1); - } - return cypherQuery; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("Query{"); - if (filters != null) { - sb.append("filters=").append(filters); - } else { - sb.append("cypherQuery='").append(cypherQuery).append('\''); - } - sb.append('}'); - return sb.toString(); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/QueryResultInstantiator.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/QueryResultInstantiator.java deleted file mode 100644 index b42a82234..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/QueryResultInstantiator.java +++ /dev/null @@ -1,56 +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.repository.query; - -import java.util.Map; -import java.util.Optional; - -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator; -import org.neo4j.ogm.session.EntityInstantiator; -import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.neo4j.conversion.Neo4jOgmEntityInstantiatorAdapter; -import org.springframework.data.neo4j.mapping.Neo4jPersistentEntity; -import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty; -import org.springframework.lang.Nullable; - -/** - * This class uses the {@link Neo4jOgmEntityInstantiatorAdapter} that came with OGM 3.1.0+ if possible, otherwise falls back - * to {@link org.neo4j.ogm.metadata.reflect.ReflectionEntityInstantiator}, appearing in the same release. Thus it - * handles the conversion of non entity {@code QueryResult} objects the same way as entities, supporting non-default - * constructors and such. The {@link Neo4jOgmEntityInstantiatorAdapter} cannot be used if Springs mapping context is not - * available. - * - * @author Gerrit Meier - * @author Michael J. Simons - */ -class QueryResultInstantiator implements EntityInstantiator { - - private final EntityInstantiator delegate; - - QueryResultInstantiator(MetaData metadata, - @Nullable MappingContext, Neo4jPersistentProperty> mappingContext) { - - this.delegate = Optional.ofNullable(mappingContext) - . map(ctx -> new Neo4jOgmEntityInstantiatorAdapter(ctx, null)) - .orElseGet(() -> new ReflectionEntityInstantiator(metadata)); - } - - @Override - public T createInstance(Class clazz, Map propertyValues) { - return this.delegate.createInstance(clazz, propertyValues); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/QueryResultProxy.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/QueryResultProxy.java deleted file mode 100644 index 759278781..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/QueryResultProxy.java +++ /dev/null @@ -1,74 +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.repository.query; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.neo4j.ogm.annotation.Property; -import org.neo4j.ogm.session.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Method {@link InvocationHandler} used for proxy objects that implement arbitrary interfaces annotated with - * @QueryResult. - * - * @author Adam George - */ -class QueryResultProxy implements InvocationHandler { - - private static final Logger log = LoggerFactory.getLogger(QueryResultProxy.class); - - private static final Pattern beanGetterPattern = Pattern.compile("^(is|get)(\\w+)"); - - private final Map data; - - QueryResultProxy(Map queryResults) { - this.data = queryResults; - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if (isNotTraditionalGetter(method)) { - log.warn("QueryResult interface method " + method.getName() - + " doesn't appear to be a getter and therefore may not return the correct result."); - } - - if (method.isAnnotationPresent(Property.class)) { - Property annotation = method.getAnnotation(Property.class); - return Utils.coerceTypes(method.getReturnType(), data.get(annotation.name())); - } - - Matcher matcher = beanGetterPattern.matcher(method.getName()); - if (matcher.matches()) { - String propertyKey = matcher.group(2); - propertyKey = propertyKey.substring(0, 1).toLowerCase().concat(propertyKey.substring(1)); - return Utils.coerceTypes(method.getReturnType(), data.get(propertyKey)); - } - - return Utils.coerceTypes(method.getReturnType(), data.get(method.getName())); - } - - private boolean isNotTraditionalGetter(Method method) { - return method.getParameterTypes().length != 0 || Void.class.equals(method.getReturnType()) - || (!method.getName().startsWith("get") && !method.getName().startsWith("is")); - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/TemplatedQuery.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/TemplatedQuery.java deleted file mode 100644 index 0a10d045d..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/TemplatedQuery.java +++ /dev/null @@ -1,70 +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.repository.query; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Stack; - -import org.neo4j.ogm.cypher.Filter; -import org.neo4j.ogm.cypher.Filters; -import org.springframework.data.neo4j.repository.query.filter.FilterBuilder; - -/** - * A template query based on filters. {@link #createExecutableQuery(Map)} is used to create an executable query from - * resolved parameters. - * - * @author Luanne Misquitta - * @author Jasper Blues - * @author Nicolas Mervaillie - * @author Gerrit Meier - * @author Michael J. Simons - */ -class TemplatedQuery { - - private final List filterBuilders; - - static TemplatedQuery unfiltered() { - return new TemplatedQuery(Collections.emptyList()); - } - - TemplatedQuery(List filterBuilders) { - this.filterBuilders = filterBuilders; - } - - Query createExecutableQuery(Map resolvedParameters) { - - // building a stack of parameter values, so that the builders can pull them - // according to their needs (zero, one or more parameters) - // avoids to manage a current parameter index state here. - Stack parametersStack = new Stack<>(); - if (!resolvedParameters.isEmpty()) { - Integer maxParameterIndex = Collections.max(resolvedParameters.keySet()); - for (int i = 0; i <= maxParameterIndex; i++) { - parametersStack.add(0, resolvedParameters.get(i)); - } - } - - List filters = new ArrayList<>(); - for (FilterBuilder filterBuilder : filterBuilders) { - filters.addAll(filterBuilder.build(parametersStack)); - } - - return new Query(new Filters(filters)); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/TemplatedQueryCreator.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/TemplatedQueryCreator.java deleted file mode 100644 index 773e08ceb..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/TemplatedQueryCreator.java +++ /dev/null @@ -1,70 +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.repository.query; - -import java.util.Iterator; -import java.util.Optional; - -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; -import org.springframework.data.repository.query.parser.AbstractQueryCreator; -import org.springframework.data.repository.query.parser.Part; -import org.springframework.data.repository.query.parser.PartTree; -import org.springframework.lang.Nullable; - -/** - * An {@link AbstractQueryCreator} that builds a query template based on filters. The intermediate object is a filter - * definition whose state is modified during query creation. - * - * @author Luanne Misquitta - * @author Michael J. Simons - */ -class TemplatedQueryCreator extends AbstractQueryCreator { - - private final Neo4jMappingContext mappingContext; - private final Class entityType; - - public TemplatedQueryCreator(PartTree tree, Neo4jMappingContext mappingContext, Class entityType) { - super(tree); - - this.mappingContext = mappingContext; - this.entityType = entityType; - } - - @Override - protected FilterBuildersDefinition create(Part part, Iterator iterator) { - return FilterBuildersDefinition.forType(mappingContext, entityType) // - .startWith(part); - } - - @Override - protected FilterBuildersDefinition and(Part part, FilterBuildersDefinition base, Iterator iterator) { - return base.and(part); - } - - @Override - protected FilterBuildersDefinition or(FilterBuildersDefinition base, FilterBuildersDefinition criteria) { - return base.or(criteria.getBasePart()); - } - - @Override - protected TemplatedQuery complete(@Nullable FilterBuildersDefinition filterDefinition, Sort sort) { - - return Optional.ofNullable(filterDefinition) - .map(FilterBuildersDefinition::buildTemplatedQuery) - .orElseGet(TemplatedQuery::unfiltered); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/BetweenComparisonBuilder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/BetweenComparisonBuilder.java deleted file mode 100644 index 79e7f0418..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/BetweenComparisonBuilder.java +++ /dev/null @@ -1,109 +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.repository.query.filter; - -import static org.neo4j.ogm.cypher.ComparisonOperator.*; - -import java.util.Arrays; -import java.util.List; -import java.util.Stack; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.springframework.data.domain.Range; -import org.springframework.data.repository.query.parser.Part; - -/** - * @author Jasper Blues - * @author Nicolas Mervaillie - * @author Gerrit Meier - * @author Michael J. Simons - */ -class BetweenComparisonBuilder extends FilterBuilder { - - BetweenComparisonBuilder(Part part, BooleanOperator booleanOperator, Class entityType) { - super(part, booleanOperator, entityType); - } - - @Override - public List build(Stack params) { - - final Object lowerBoundOrRange = params.pop(); - - Object lowerBoundValue; - Object upperBoundValue; - - boolean inclusiveLowerBound = true; - boolean inclusiveUpperBound = true; - - if (lowerBoundOrRange instanceof Range) { - Range range = (Range) lowerBoundOrRange; - Range.Bound lowerBound = range.getLowerBound(); - lowerBoundValue = lowerBound.getValue(); - inclusiveLowerBound = lowerBound.isInclusive(); - - Range.Bound upperBound = range.getUpperBound(); - upperBoundValue = upperBound.getValue(); - inclusiveUpperBound = upperBound.isInclusive(); - } else { - lowerBoundValue = lowerBoundOrRange; - upperBoundValue = params.pop(); - } - - NestedAttributes nestedAttributes = getNestedAttributes(part); - - Filter lowerBoundFilter = createLowerBoundFilter(lowerBoundValue, inclusiveLowerBound, nestedAttributes); - Filter upperBoundFilter = createUpperBoundFilter(upperBoundValue, inclusiveUpperBound, nestedAttributes); - - return Arrays.asList(lowerBoundFilter, upperBoundFilter); - } - - private Filter createLowerBoundFilter(Object value, boolean inclusive, NestedAttributes nestedAttributes) { - return createBoundFilter(Bound.LOWER, value, inclusive, booleanOperator, nestedAttributes); - } - - private Filter createUpperBoundFilter(Object value, boolean inclusive, NestedAttributes nestedAttributes) { - return createBoundFilter(Bound.UPPER, value, inclusive, BooleanOperator.AND, nestedAttributes); - } - - private Filter createBoundFilter(Bound bound, Object value, boolean inclusive, BooleanOperator operator, - NestedAttributes nestedAttributes) { - Filter filter = new Filter(nestedAttributes.isEmpty() ? - propertyName() : - nestedAttributes.getLeafPropertySegment(), deriveComparisonOperator(bound, inclusive), value); - filter.setOwnerEntityType(entityType); - filter.setNegated(isNegated()); - filter.setBooleanOperator(operator); - filter.setNestedPath(nestedAttributes.getSegments()); - return filter; - } - - private ComparisonOperator deriveComparisonOperator(Bound bound, boolean inclusive) { - switch (bound) { - case LOWER: - return inclusive ? GREATER_THAN_EQUAL : GREATER_THAN; - case UPPER: - return inclusive ? LESS_THAN_EQUAL : LESS_THAN; - } - throw new IllegalArgumentException("unsupported bound"); - } - - private enum Bound { - UPPER, - LOWER - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/BooleanComparisonBuilder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/BooleanComparisonBuilder.java deleted file mode 100644 index b0769804d..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/BooleanComparisonBuilder.java +++ /dev/null @@ -1,56 +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.repository.query.filter; - -import static org.springframework.data.repository.query.parser.Part.Type.*; - -import java.util.Collections; -import java.util.List; -import java.util.Stack; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.springframework.data.repository.query.parser.Part; - -/** - * @author Jasper Blues - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -class BooleanComparisonBuilder extends FilterBuilder { - - BooleanComparisonBuilder(Part part, BooleanOperator booleanOperator, Class entityType) { - super(part, booleanOperator, entityType); - } - - @Override - public List build(Stack params) { - - NestedAttributes nestedAttributes = getNestedAttributes(part); - - Filter filter = new Filter( - nestedAttributes.isEmpty() ? propertyName() : nestedAttributes.getLeafPropertySegment(), - ComparisonOperator.IS_TRUE); - filter.setOwnerEntityType(entityType); - filter.setBooleanOperator(booleanOperator); - filter.setNegated(isNegated() || part.getType() == FALSE); - filter.setNestedPath(nestedAttributes.getSegments()); - - return Collections.singletonList(filter); - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/ContainsComparisonBuilder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/ContainsComparisonBuilder.java deleted file mode 100644 index 6c953c3b7..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/ContainsComparisonBuilder.java +++ /dev/null @@ -1,55 +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.repository.query.filter; - -import java.util.Collections; -import java.util.List; -import java.util.Stack; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.Filter; -import org.neo4j.ogm.cypher.function.ContainsAnyComparison; -import org.springframework.data.repository.query.parser.Part; - -/** - * Filter for entities having a collection like property (not) containing a given element. - * - * @author Gerrit Meier - * @author Michael J. Simons - */ -class ContainsComparisonBuilder extends FilterBuilder { - - ContainsComparisonBuilder(Part part, BooleanOperator booleanOperator, Class entityType) { - super(part, booleanOperator, entityType); - } - - @Override - public List build(Stack params) { - - NestedAttributes nestedAttributes = getNestedAttributes(part); - - final Object containingValue = params.pop(); - Filter containingFilter = new Filter( - nestedAttributes.isEmpty() ? propertyName() : nestedAttributes.getLeafPropertySegment(), - new ContainsAnyComparison(containingValue)); - containingFilter.setOwnerEntityType(entityType); - containingFilter.setBooleanOperator(booleanOperator); - containingFilter.setNegated(isNegated()); - containingFilter.setNestedPath(nestedAttributes.getSegments()); - - return Collections.singletonList(containingFilter); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/DistanceComparisonBuilder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/DistanceComparisonBuilder.java deleted file mode 100644 index 6831e4756..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/DistanceComparisonBuilder.java +++ /dev/null @@ -1,184 +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.repository.query.filter; - -import java.lang.reflect.Constructor; -import java.util.Collections; -import java.util.List; -import java.util.Stack; -import java.util.function.BiFunction; -import java.util.function.UnaryOperator; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.neo4j.ogm.cypher.function.DistanceComparison; -import org.neo4j.ogm.cypher.function.DistanceFromNativePoint; -import org.neo4j.ogm.cypher.function.DistanceFromPoint; -import org.neo4j.ogm.cypher.function.FilterFunction; -import org.neo4j.ogm.cypher.function.NativeDistanceComparison; -import org.neo4j.ogm.types.spatial.AbstractPoint; -import org.springframework.beans.BeanUtils; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Metrics; -import org.springframework.data.geo.Point; -import org.springframework.data.repository.query.parser.Part; - -/** - * @author Jasper Blues - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -class DistanceComparisonBuilder extends FilterBuilder { - - private final BiFunction filterSupplier; - - DistanceComparisonBuilder(Part part, BooleanOperator booleanOperator, Class entityType) { - super(part, booleanOperator, entityType); - - this.filterSupplier = createFilterSupplier(); - } - - private static BiFunction createFilterSupplier() { - try { - // Neo4j-OGM 3.2 - final Constructor ctor = Filter.class - .getDeclaredConstructor(String.class, FilterFunction.class, ComparisonOperator.class); - return (propertyName, filterFunction) -> - BeanUtils.instantiateClass(ctor, propertyName, filterFunction, ComparisonOperator.LESS_THAN); - } catch (NoSuchMethodException e) { - return (propertyName, filterFunction) -> new Filter(propertyName, filterFunction); - } - } - - @Override - public List build(Stack params) { - - Object firstArg = params.pop(); - Object secondArg = params.pop(); - - Filter distanceComparisonFilter; - - if (needsFilterForSpringPoint(firstArg, secondArg)) { - distanceComparisonFilter = springPointFilterOf(firstArg, secondArg); - } else { - distanceComparisonFilter = nativePointFilterOf(firstArg, secondArg); - } - - return Collections.singletonList(distanceComparisonFilter); - - } - - private Filter springPointFilterOf(Object firstArg, Object secondArg) { - - Distance distance; - Point point; - - if (firstArg instanceof Distance && secondArg instanceof Point) { - distance = (Distance) firstArg; - point = (Point) secondArg; - } else if (secondArg instanceof Distance && firstArg instanceof Point) { - distance = (Distance) secondArg; - point = (Point) firstArg; - } else { - throw new IllegalArgumentException( - "findNear requires an argument of type Distance and an argument of type Point"); - } - - return createFilterForSpringPoint(point, calculateDistanceInMeter(distance)); - } - - private Filter nativePointFilterOf(Object firstArg, Object secondArg) { - - Distance distance; - AbstractPoint spatialPoint; - - if (firstArg instanceof AbstractPoint && secondArg instanceof Distance) { - distance = (Distance) secondArg; - spatialPoint = (AbstractPoint) firstArg; - } else if (firstArg instanceof Distance && secondArg instanceof AbstractPoint) { - distance = (Distance) firstArg; - spatialPoint = (AbstractPoint) secondArg; - } else { - throw new IllegalArgumentException( - "findNear requires an argument of type Distance and an argument of type Point"); - } - - return createFilterForSpatialPoint(spatialPoint, calculateDistanceInMeter(distance)); - } - - private boolean needsFilterForSpringPoint(Object firstArg, Object secondArg) { - return (firstArg instanceof Point || secondArg instanceof Point); - } - - private Filter createFilterForSpatialPoint(AbstractPoint spatialPoint, double meters) { - - NativeDistanceComparison distanceComparison = NativeDistanceComparison - .distanceComparisonFor(new DistanceFromNativePoint(spatialPoint, meters)); - NestedAttributes nestedAttributes = getNestedAttributes(part); - - String propertyName = super.part.getProperty().getLeafProperty().getSegment(); - - Filter filter = filterSupplier.apply(propertyName, distanceComparison); - filter.setOwnerEntityType(entityType); - filter.setBooleanOperator(booleanOperator); - filter.setNegated(isNegated()); - filter.setNestedPath(nestedAttributes.getSegments()); - return filter; - } - - private Filter createFilterForSpringPoint(Point point, double meters) { - - DistanceFromPoint distanceFromPoint = new DistanceFromPoint(point.getX(), point.getY(), meters); - - DistanceComparison distanceComparison = new DistanceComparison(distanceFromPoint) { - - @Override - public String expression(String nodeIdentifier, String filteredProperty, - UnaryOperator createUniqueParameterName) { - String latitudeProperty = nodeIdentifier + ".latitude"; - String longitudeProperty = nodeIdentifier + ".longitude"; - - return String.format( - "distance(coalesce(point({latitude: %s, longitude: %s}), %s), point({latitude:$lat, longitude:$lon})) " - + "%s $distance ", - latitudeProperty, longitudeProperty, nodeIdentifier + "." + propertyName(), - ComparisonOperator.LESS_THAN.getValue()); - } - }; - - NestedAttributes nestedAttributes = getNestedAttributes(part); - - Filter filter = filterSupplier.apply(nestedAttributes.getLeafPropertySegment(), distanceComparison); - filter.setOwnerEntityType(entityType); - filter.setBooleanOperator(booleanOperator); - filter.setNegated(isNegated()); - filter.setNestedPath(nestedAttributes.getSegments()); - return filter; - } - - static double calculateDistanceInMeter(Distance distance) { - - if (distance.getMetric() == Metrics.KILOMETERS) { - return distance.getValue() / 0.001d; - } else if (distance.getMetric() == Metrics.MILES) { - return distance.getValue() / 0.00062137d; - } else { - return distance.getValue(); - } - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/ExistsFilterBuilder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/ExistsFilterBuilder.java deleted file mode 100644 index 90d97755d..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/ExistsFilterBuilder.java +++ /dev/null @@ -1,54 +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.repository.query.filter; - -import java.util.Collections; -import java.util.List; -import java.util.Stack; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.springframework.data.repository.query.parser.Part; - -/** - * @author Jasper Blues - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -class ExistsFilterBuilder extends FilterBuilder { - - ExistsFilterBuilder(Part part, BooleanOperator booleanOperator, Class entityType) { - super(part, booleanOperator, entityType); - } - - @Override - public List build(Stack params) { - - NestedAttributes nestedAttributes = getNestedAttributes(part); - - Filter filter = new Filter( - nestedAttributes.isEmpty() ? propertyName() : nestedAttributes.getLeafPropertySegment(), - ComparisonOperator.EXISTS); - filter.setOwnerEntityType(entityType); - filter.setBooleanOperator(booleanOperator); - filter.setNegated(isNegated()); - filter.setNestedPath(nestedAttributes.getSegments()); - - return Collections.singletonList(filter); - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/FilterBuilder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/FilterBuilder.java deleted file mode 100644 index 052bb2be2..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/FilterBuilder.java +++ /dev/null @@ -1,176 +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.repository.query.filter; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Stack; -import java.util.function.Predicate; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.Filter; -import org.springframework.data.mapping.PropertyPath; -import org.springframework.data.repository.query.parser.Part; -import org.springframework.lang.Nullable; - -/** - * The name of this class is wrong: It builds a list of filters, not a single filter. Starting with Neo4j-OGM 4.0, - * there will be an actual filter builder in OGM and this class needs to be renamed. - * - * @author Jasper Blues - * @author Nicolas Mervaillie - * @author Gerrit Meier - * @author Michael J. Simons - */ -public abstract class FilterBuilder { - - protected Part part; - protected BooleanOperator booleanOperator; - protected Class entityType; - protected Predicate isInternalIdProperty = part -> false; - - public static FilterBuilder forPartAndEntity(Part part, Class entityType, BooleanOperator booleanOperator, - Predicate isInternalIdProperty) { - FilterBuilder filterBuilder; - switch (part.getType()) { - case NEAR: - filterBuilder = new DistanceComparisonBuilder(part, booleanOperator, entityType); - break; - case BETWEEN: - filterBuilder = new BetweenComparisonBuilder(part, booleanOperator, entityType); - break; - case NOT_CONTAINING: - case CONTAINING: - filterBuilder = resolveMatchingContainsFilterBuilder(part, entityType, booleanOperator); - break; - case IS_NULL: - case IS_NOT_NULL: - filterBuilder = new IsNullFilterBuilder(part, booleanOperator, entityType); - break; - case EXISTS: - filterBuilder = new ExistsFilterBuilder(part, booleanOperator, entityType); - break; - case TRUE: - case FALSE: - filterBuilder = new BooleanComparisonBuilder(part, booleanOperator, entityType); - break; - default: - filterBuilder = new PropertyComparisonBuilder(part, booleanOperator, entityType); - break; - } - - filterBuilder.isInternalIdProperty = isInternalIdProperty; - return filterBuilder; - } - - FilterBuilder(Part part, BooleanOperator booleanOperator, Class entityType) { - this.part = part; - this.booleanOperator = booleanOperator; - this.entityType = entityType; - } - - public abstract List build(Stack params); - - boolean isNegated() { - return part.getType().name().startsWith("NOT"); - } - - protected String propertyName() { - return part.getProperty().getSegment(); - } - - protected final NestedAttributes getNestedAttributes(Part part) { - - PropertyPath property = part.getProperty(); - if (!property.hasNext()) { - return EMPTY_NESTED_ATTRIBUTES; - } else { - List segments = new ArrayList<>(); - segments.add(new Filter.NestedPathSegment(property.getSegment(), property.getType())); - segments.addAll(deepNestedProperty(property)); - return new NestedAttributes(property.getOwningType().getType(), segments, - property.getLeafProperty().getSegment()); - } - } - - public static final NestedAttributes EMPTY_NESTED_ATTRIBUTES = new NestedAttributes(Void.class, - Collections.emptyList(), null); - - protected static final class NestedAttributes { - - private final Class owningType; - private final List segments; - private final String leafPropertySegment; - - NestedAttributes(Class owningType, List segments, - @Nullable String leafPropertySegment) { - this.owningType = owningType; - this.segments = new ArrayList<>(segments); - this.leafPropertySegment = leafPropertySegment; - } - - public Filter.NestedPathSegment[] getSegments() { - return segments.toArray(new Filter.NestedPathSegment[segments.size()]); - } - - public String getLeafPropertySegment() { - return leafPropertySegment; - } - - public boolean isEmpty() { - return this == EMPTY_NESTED_ATTRIBUTES; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - NestedAttributes that = (NestedAttributes) o; - return owningType.equals(that.owningType) && - segments.equals(that.segments) && - Objects.equals(leafPropertySegment, that.leafPropertySegment); - } - - @Override public int hashCode() { - return Objects.hash(owningType, segments, leafPropertySegment); - } - } - - private List deepNestedProperty(PropertyPath path) { - List segments = new ArrayList<>(); - if (path.hasNext()) { - PropertyPath next = path.next(); - if (next != null && !next.equals(next.getLeafProperty())) { - segments.add(new Filter.NestedPathSegment(next.getSegment(), next.getType())); - segments.addAll(deepNestedProperty(next)); - } - } - return segments; - } - - private static FilterBuilder resolveMatchingContainsFilterBuilder(Part part, Class entityType, - BooleanOperator booleanOperator) { - boolean usePropertyComparison = !part.getProperty().getTypeInformation().isCollectionLike(); - if (usePropertyComparison) { - return new PropertyComparisonBuilder(part, booleanOperator, entityType); - } - return new ContainsComparisonBuilder(part, booleanOperator, entityType); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/IsNullFilterBuilder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/IsNullFilterBuilder.java deleted file mode 100644 index abcd2c1c0..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/IsNullFilterBuilder.java +++ /dev/null @@ -1,55 +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.repository.query.filter; - -import static org.springframework.data.repository.query.parser.Part.Type.*; - -import java.util.Collections; -import java.util.List; -import java.util.Stack; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.springframework.data.repository.query.parser.Part; - -/** - * @author Jasper Blues - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -class IsNullFilterBuilder extends FilterBuilder { - - IsNullFilterBuilder(Part part, BooleanOperator booleanOperator, Class entityType) { - super(part, booleanOperator, entityType); - } - - @Override - public List build(Stack params) { - - NestedAttributes nestedAttributes = getNestedAttributes(part); - - Filter filter = new Filter( - nestedAttributes.isEmpty() ? propertyName() : nestedAttributes.getLeafPropertySegment(), - ComparisonOperator.IS_NULL); - filter.setOwnerEntityType(entityType); - filter.setBooleanOperator(booleanOperator); - filter.setNegated(isNegated() || part.getType() == IS_NOT_NULL); - filter.setNestedPath(nestedAttributes.getSegments()); - - return Collections.singletonList(filter); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/NativeIdFilterFunction.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/NativeIdFilterFunction.java deleted file mode 100644 index 4e00b8193..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/NativeIdFilterFunction.java +++ /dev/null @@ -1,105 +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.repository.query.filter; - -import static org.neo4j.ogm.cypher.ComparisonOperator.*; - -import java.util.Collections; -import java.util.EnumSet; -import java.util.Map; -import java.util.function.UnaryOperator; - -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.neo4j.ogm.cypher.PropertyValueTransformer; -import org.neo4j.ogm.cypher.function.FilterFunction; - -/** - * This is a specialised filter function taking care of filtering native id properties. - * - * @author Michael J. Simons - * @soundtrack Freddie Mercury - Never Boring - */ -final class NativeIdFilterFunction implements FilterFunction { - - // This function belongs somewhat more into OGM than SDN. The reason having it here is simple: The filter is build - // explicitly and not via reflection and we don't want to have yet another shim managing separate possible versions - // OGM like we already have with the embedded support, entity instantiator and some other things. ^ms - - protected static final String PARAMETER_NAME = "idProperty"; - - private final ComparisonOperator operator; - private final Object value; - private Filter filter; - - NativeIdFilterFunction(ComparisonOperator operator, Object value) { - this.operator = operator; - this.value = value; - } - - @Override - public Object getValue() { - return this.value; - } - - @Override - public String expression(String nodeIdentifier, String filteredProperty, - UnaryOperator createUniqueParameterName) { - - switch (operator) { - case EQUALS: - case GREATER_THAN: - case GREATER_THAN_EQUAL: - case LESS_THAN: - case LESS_THAN_EQUAL: - case IN: - return String.format("id(%s) %s $`%s` ", nodeIdentifier, operator.getValue(), - createUniqueParameterName.apply(PARAMETER_NAME)); - default: - throw new IllegalArgumentException("Unsupported comparision operator for an ID attribute."); - } - } - - @Override - public Map parameters(UnaryOperator createUniqueParameterName, - PropertyValueTransformer valueTransformer) { - - Map map = Collections.emptyMap(); - if (EnumSet.of(EQUALS, GREATER_THAN, GREATER_THAN_EQUAL, LESS_THAN, LESS_THAN_EQUAL, IN).contains(operator)) { - map = Collections.singletonMap(createUniqueParameterName.apply(PARAMETER_NAME), - valueTransformer.transformPropertyValue(this.value)); - } - return map; - } - - public Map parameters() { - throw new UnsupportedOperationException( - "This method has been kept here for backward compatiblity and should never be called."); - } - - public String expression(String s) { - throw new UnsupportedOperationException( - "This method has been kept here for backward compatiblity and should never be called."); - } - - public Filter getFilter() { - return filter; - } - - public void setFilter(Filter filter) { - this.filter = filter; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/PropertyComparisonBuilder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/PropertyComparisonBuilder.java deleted file mode 100644 index 18f89c9c4..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/PropertyComparisonBuilder.java +++ /dev/null @@ -1,134 +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.repository.query.filter; - -import static org.springframework.data.repository.query.parser.Part.Type.*; - -import java.util.Collections; -import java.util.List; -import java.util.Stack; - -import org.neo4j.ogm.cypher.BooleanOperator; -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.springframework.data.repository.query.parser.Part; -import org.springframework.util.Assert; - -/** - * @author Jasper Blues - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -class PropertyComparisonBuilder extends FilterBuilder { - - PropertyComparisonBuilder(Part part, BooleanOperator booleanOperator, Class entityType) { - super(part, booleanOperator, entityType); - } - - @Override - public List build(Stack params) { - - NestedAttributes nestedAttributes = getNestedAttributes(part); - - Object value = params.pop(); - - Filter filter; - String propertyName = nestedAttributes.isEmpty() ? propertyName() : nestedAttributes.getLeafPropertySegment(); - if (isInternalIdProperty.test(part)) { - filter = new Filter(new NativeIdFilterFunction(convertToComparisonOperator(part.getType()), value)); - filter.setPropertyName(propertyName); - } else { - filter = new Filter(propertyName, convertToComparisonOperator(part.getType()), value); - } - filter.setOwnerEntityType(entityType); - filter.setBooleanOperator(booleanOperator); - filter.setNegated(isNegated()); - filter.setNestedPath(nestedAttributes.getSegments()); - applyCaseInsensitivityIfShouldIgnoreCase(part, filter); - - return Collections.singletonList(filter); - } - - private ComparisonOperator convertToComparisonOperator(Part.Type type) { - - switch (type) { - case AFTER: - case GREATER_THAN: - return ComparisonOperator.GREATER_THAN; - case GREATER_THAN_EQUAL: - return ComparisonOperator.GREATER_THAN_EQUAL; - case BEFORE: - case LESS_THAN: - return ComparisonOperator.LESS_THAN; - case LESS_THAN_EQUAL: - return ComparisonOperator.LESS_THAN_EQUAL; - case REGEX: - return ComparisonOperator.MATCHES; - case LIKE: - case NOT_LIKE: - return ComparisonOperator.LIKE; - case STARTING_WITH: - return ComparisonOperator.STARTING_WITH; - case ENDING_WITH: - return ComparisonOperator.ENDING_WITH; - case CONTAINING: - case NOT_CONTAINING: - return ComparisonOperator.CONTAINING; - case IN: - case NOT_IN: - return ComparisonOperator.IN; - case SIMPLE_PROPERTY: - return ComparisonOperator.EQUALS; - default: - throw new IllegalArgumentException("No ComparisonOperator for Part.Type " + type); - } - } - - /** - * Sets the filter to ignore the case in case the underlying {@link Part} requires ignoring case and the property - * actually supports it. - * - * @param part - * @param filter - */ - private void applyCaseInsensitivityIfShouldIgnoreCase(Part part, Filter filter) { - - switch (part.shouldIgnoreCase()) { - case ALWAYS: - Assert.state(canIgnoreCase(part), "Unable to ignore case of " + part.getProperty().getLeafType().getName() - + " types, the property '" + part.getProperty().getSegment() + "' must reference a String"); - filter.ignoreCase(); - break; - case WHEN_POSSIBLE: - if (canIgnoreCase(part)) { - filter.ignoreCase(); - } - break; - case NEVER: - default: - break; - } - } - - private boolean canIgnoreCase(Part part) { - return isSupportedIgnoreKeyword(part) && String.class.equals(part.getProperty().getLeafType()); - } - - private boolean isSupportedIgnoreKeyword(Part part) { - Part.Type type = part.getType(); - return type == SIMPLE_PROPERTY || type == CONTAINING; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/package-info.java deleted file mode 100644 index 4d9a58db5..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/filter/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Support for creating Cypher queries through Neo4j-OGMs filter mechanism. Not to be meant as part of an public api. - */ -package org.springframework.data.neo4j.repository.query.filter; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/package-info.java deleted file mode 100644 index 53d4fe21e..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Query implementation to execute queries against Neo4j. - */ -package org.springframework.data.neo4j.repository.query; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/Neo4jQueryPlaceholderSupplier.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/Neo4jQueryPlaceholderSupplier.java deleted file mode 100644 index 0d38a7e84..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/Neo4jQueryPlaceholderSupplier.java +++ /dev/null @@ -1,36 +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.repository.query.spel; - -public class Neo4jQueryPlaceholderSupplier implements PlaceholderSupplier { - - private static final String PLACEHOLDER = "spel_expr"; - private int index = 0; - - @Override - public String nextPlaceholder() { - return parameterName(index++); - } - - public String parameterName(int index) { - return PLACEHOLDER + index; - } - - @Override - public String decoratePlaceholder(String placeholder) { - return "$" + placeholder; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/ParameterizedQuery.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/ParameterizedQuery.java deleted file mode 100644 index 8e7e43a40..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/ParameterizedQuery.java +++ /dev/null @@ -1,64 +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.repository.query.spel; - -import java.util.Map; -import java.util.function.BiFunction; - -import org.springframework.data.repository.query.Parameters; -import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider; -import org.springframework.data.repository.query.SpelEvaluator; -import org.springframework.data.repository.query.SpelQueryContext; -import org.springframework.data.repository.query.SpelQueryContext.EvaluatingSpelQueryContext; - -public class ParameterizedQuery { - - private final Parameters methodParameters; - private final SpelEvaluator spelEvaluator; - - private ParameterizedQuery(Parameters methodParameters, SpelEvaluator spelEvaluator) { - this.methodParameters = methodParameters; - this.spelEvaluator = spelEvaluator; - } - - public static ParameterizedQuery getParameterizedQuery(String queryString, Parameters methodParameters, - QueryMethodEvaluationContextProvider evaluationContextProvider) { - - Neo4jQueryPlaceholderSupplier supplier = new Neo4jQueryPlaceholderSupplier(); - - EvaluatingSpelQueryContext context = SpelQueryContext.of( // - (index, prefix) -> supplier.parameterName(index), // - (prefix, name) -> supplier.decoratePlaceholder(name)) // - .withEvaluationContextProvider(evaluationContextProvider); - - SpelEvaluator evaluator = context.parse(queryString, methodParameters); - return new ParameterizedQuery(methodParameters, evaluator); - } - - public Map resolveParameter(Object[] parameters, - BiFunction, Object[], Map> nativePlaceholderFunction) { - - Map parameterValues = spelEvaluator.evaluate(parameters); - Map nativeParameterValues = nativePlaceholderFunction.apply(methodParameters, parameters); - parameterValues.putAll(nativeParameterValues); - return parameterValues; - } - - public String getQueryString() { - return spelEvaluator.getQueryString(); - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/PlaceholderSupplier.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/PlaceholderSupplier.java deleted file mode 100644 index 129f59b2c..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/PlaceholderSupplier.java +++ /dev/null @@ -1,22 +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.repository.query.spel; - -interface PlaceholderSupplier { - String nextPlaceholder(); - - String decoratePlaceholder(String placeholder); -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/package-info.java deleted file mode 100644 index 29d1149b6..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/spel/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Spring Expression Language (SpEL) support. - */ -package org.springframework.data.neo4j.repository.query.spel; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/GraphEntityInformation.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/GraphEntityInformation.java deleted file mode 100644 index 5c925bf46..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/GraphEntityInformation.java +++ /dev/null @@ -1,66 +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.repository.support; - -import java.io.Serializable; - -import org.neo4j.ogm.metadata.ClassInfo; -import org.neo4j.ogm.metadata.FieldInfo; -import org.neo4j.ogm.metadata.MetaData; -import org.springframework.data.repository.core.support.AbstractEntityInformation; - -/** - * @author Mark Angrish - * @author Mark Paluch - */ -public class GraphEntityInformation extends AbstractEntityInformation { - - private final MetaData metaData; - - public GraphEntityInformation(MetaData metaData, Class type) { - super(type); - this.metaData = metaData; - } - - @Override - @SuppressWarnings("unchecked") - public ID getId(T entity) { - final ClassInfo classInfo = metaData.classInfo(getJavaType().getName()); - final FieldInfo primaryIndex = classInfo.primaryIndexField(); - - return (ID) getId(entity, classInfo, primaryIndex); - } - - private Object getId(T entity, ClassInfo classInfo, FieldInfo primaryIndex) { - if (primaryIndex != null) { - return classInfo.propertyField(primaryIndex.getName()).readProperty(entity); - } else { - return classInfo.propertyField(classInfo.identityField().getName()).readProperty(entity); - } - } - - @Override - @SuppressWarnings("unchecked") - public Class getIdType() { - final FieldInfo primaryIndex = metaData.classInfo(getJavaType().getName()).primaryIndexField(); - - if (primaryIndex != null) { - return (Class) primaryIndex.convertedType(); - } - return (Class) Long.class; - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jAuditingBeanPostProcessor.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jAuditingBeanPostProcessor.java deleted file mode 100644 index bba7c107e..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jAuditingBeanPostProcessor.java +++ /dev/null @@ -1,53 +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.repository.support; - -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.data.auditing.IsNewAwareAuditingHandler; -import org.springframework.data.neo4j.repository.config.Neo4jAuditingEventListener; -import org.springframework.util.Assert; - -public class Neo4jAuditingBeanPostProcessor implements BeanPostProcessor { - - private final ObjectFactory isNewAwareHandler; - - public Neo4jAuditingBeanPostProcessor(ObjectFactory isNewAwareHandler) { - - Assert.notNull(isNewAwareHandler, "IsNewAwareHandler must not be null!"); - - this.isNewAwareHandler = isNewAwareHandler; - } - - /* - * (non-Javadoc) - * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String) - */ - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - - if (!SessionFactory.class.isInstance(bean)) { - return bean; - } - - SessionFactory sessionFactory = (SessionFactory) bean; - sessionFactory.register(new Neo4jAuditingEventListener(isNewAwareHandler)); - - return sessionFactory; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslator.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslator.java deleted file mode 100644 index 0885bcd41..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslator.java +++ /dev/null @@ -1,34 +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.repository.support; - -import org.springframework.dao.DataAccessException; -import org.springframework.dao.support.PersistenceExceptionTranslator; -import org.springframework.data.neo4j.transaction.SessionFactoryUtils; - -/** - * A PersistenceExceptionTranslator to get picked up by the Spring exception translation infrastructure. - * - * @author Gerrit Meier - */ -public class Neo4jPersistenceExceptionTranslator implements PersistenceExceptionTranslator { - - @Override - public DataAccessException translateExceptionIfPossible(RuntimeException ex) { - return SessionFactoryUtils.convertOgmAccessException(ex); - } - -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactory.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactory.java deleted file mode 100644 index 808e1df5b..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactory.java +++ /dev/null @@ -1,113 +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.repository.support; - -import java.util.Optional; - -import org.neo4j.ogm.session.Neo4jSession; -import org.neo4j.ogm.session.Session; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; -import org.springframework.data.neo4j.mapping.Neo4jPersistentEntity; -import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty; -import org.springframework.data.neo4j.repository.query.GraphQueryLookupStrategy; -import org.springframework.data.repository.core.EntityInformation; -import org.springframework.data.repository.core.RepositoryInformation; -import org.springframework.data.repository.core.RepositoryMetadata; -import org.springframework.data.repository.core.support.RepositoryFactorySupport; -import org.springframework.data.repository.query.QueryLookupStrategy; -import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider; -import org.springframework.lang.Nullable; -import org.springframework.util.Assert; - -/** - * Neo4j OGM specific generic repository factory. - * - * @author Vince Bickers - * @author Luanne Misquitta - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - * @author Michael J. Simons - */ -public class Neo4jRepositoryFactory extends RepositoryFactorySupport { - - private static final Logger logger = LoggerFactory.getLogger(Neo4jRepositoryFactory.class); - - private final Session session; - - private @Nullable final MappingContext, Neo4jPersistentProperty> mappingContext; - - /** - * @param session - * @deprecated since 5.1.0, use {@link Neo4jRepositoryFactory#Neo4jRepositoryFactory(Session, MappingContext)} instead - * and provide the mapping context. - */ - @Deprecated - public Neo4jRepositoryFactory(Session session) { - this(session, null); - } - - public Neo4jRepositoryFactory(Session session, MappingContext, Neo4jPersistentProperty> mappingContext) { - Assert.notNull(session, "Session must not be null!"); - - this.session = session; - if (mappingContext != null) { - this.mappingContext = mappingContext; - } else if(session instanceof Neo4jSession) { - logger.debug("Creating a new mapping context"); - this.mappingContext = new Neo4jMappingContext(((Neo4jSession) session).metaData()); - ((Neo4jMappingContext) this.mappingContext).initialize(); - } else { - logger.warn("No mapping context present, some operations won't support persistence constructors"); - this.mappingContext = null; - } - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.core.support.RepositoryFactorySupport#setBeanClassLoader(java.lang.ClassLoader) - */ - @Override - public void setBeanClassLoader(ClassLoader classLoader) { - super.setBeanClassLoader(classLoader); - } - - @Override - public EntityInformation getEntityInformation(Class type) { - Assert.notNull(type, "Domain class must not be null!"); - - return new GraphEntityInformation(((Neo4jSession) session).metaData(), type); - } - - @Override - protected Object getTargetRepository(RepositoryInformation information) { - return getTargetRepositoryViaReflection(information, information.getDomainType(), session); - } - - @Override - protected Class getRepositoryBaseClass(RepositoryMetadata repositoryMetadata) { - return SimpleNeo4jRepository.class; - } - - @Override - protected Optional getQueryLookupStrategy(QueryLookupStrategy.Key key, - QueryMethodEvaluationContextProvider evaluationContextProvider) { - return Optional.of(new GraphQueryLookupStrategy(session, evaluationContextProvider, this.mappingContext)); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBean.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBean.java deleted file mode 100644 index 7667e7649..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBean.java +++ /dev/null @@ -1,98 +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.repository.support; - -import java.io.Serializable; - -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; -import org.springframework.data.repository.Repository; -import org.springframework.data.repository.core.support.RepositoryFactorySupport; -import org.springframework.data.repository.core.support.TransactionalRepositoryFactoryBeanSupport; -import org.springframework.util.Assert; - -/** - * Special adapter for Springs {@link org.springframework.beans.factory.FactoryBean} interface to allow easy setup of - * repository factories via Spring configuration. - * - * @param the type of the repository - * @author Vince Bickers - * @author Luanne Misquitta - * @author Mark Angrish - * @author Michael J. Simons - */ -public class Neo4jRepositoryFactoryBean, S, ID extends Serializable> - extends TransactionalRepositoryFactoryBeanSupport { - - private Session session; - private Neo4jMappingContext mappingContext; - - /** - * Creates a new {@link Neo4jRepositoryFactoryBean} for the given repository interface. - * - * @param repositoryInterface must not be {@literal null}. - */ - public Neo4jRepositoryFactoryBean(Class repositoryInterface) { - super(repositoryInterface); - } - - @Autowired - public void setSession(Session session) { - this.session = session; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport#setMappingContext(org.springframework.data.mapping.context.MappingContext) - */ - @Override - public void setMappingContext(MappingContext mappingContext) { - super.setMappingContext(mappingContext); - - if (mappingContext instanceof Neo4jMappingContext) { - this.mappingContext = (Neo4jMappingContext) mappingContext; - } - } - - @Override - public void afterPropertiesSet() { - Assert.notNull(session, "Session must not be null!"); - super.afterPropertiesSet(); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.core.support.TransactionalRepositoryFactoryBeanSupport#doCreateRepositoryFactory() - */ - @Override - protected RepositoryFactorySupport doCreateRepositoryFactory() { - return createRepositoryFactory(session); - } - - /** - * Returns a {@link RepositoryFactorySupport}. - * - * @deprecated since 5.1.0, will be removed in 5.2.x. - * @param session - * @return - */ - @Deprecated - protected RepositoryFactorySupport createRepositoryFactory(Session session) { - return new Neo4jRepositoryFactory(session, mappingContext); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java deleted file mode 100644 index fa4affefe..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java +++ /dev/null @@ -1,199 +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.repository.support; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Optional; - -import org.neo4j.ogm.cypher.query.Pagination; -import org.neo4j.ogm.session.Session; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.neo4j.util.PagingAndSortingUtils; -import org.springframework.data.repository.support.PageableExecutionUtils; -import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.Assert; - -/** - * Default implementation of the {@link org.springframework.data.repository.CrudRepository} interface. This will offer - * you a more sophisticated interface than the plain {@link Session} . - * - * @param the type of the entity to handle - * @author Vince Bickers - * @author Luanne Misquitta - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - * @author Gerrit Meier - */ -@Repository -@Transactional(readOnly = true) -public class SimpleNeo4jRepository implements Neo4jRepository { - - private static final int DEFAULT_QUERY_DEPTH = 1; - private static final String ID_MUST_NOT_BE_NULL = "The given id must not be null!"; - - private final Class clazz; - private final Session session; - - /** - * Creates a new {@link SimpleNeo4jRepository} to manage objects of the given domain type. - * - * @param domainClass must not be {@literal null}. - * @param session must not be {@literal null}. - */ - public SimpleNeo4jRepository(Class domainClass, Session session) { - Assert.notNull(domainClass, "Domain class must not be null!"); - Assert.notNull(session, "Session must not be null!"); - - this.clazz = domainClass; - this.session = session; - } - - @Transactional - @Override - public S save(S entity) { - session.save(entity); - return entity; - } - - @Transactional - @Override - public Iterable saveAll(Iterable entities) { - session.save(entities); - return entities; - } - - @Override - public Optional findById(ID id) { - Assert.notNull(id, ID_MUST_NOT_BE_NULL); - return Optional.ofNullable(session.load(clazz, id)); - } - - @Override - public boolean existsById(ID id) { - return findById(id).isPresent(); - } - - @Override - public long count() { - return session.countEntitiesOfType(clazz); - } - - @Transactional - @Override - public void deleteById(ID id) { - findById(id).ifPresent(session::delete); - } - - @Transactional - @Override - public void delete(T t) { - session.delete(t); - } - - @Transactional - @Override - public void deleteAll(Iterable ts) { - for (T t : ts) { - session.delete(t); - } - } - - @Transactional - @Override - public void deleteAll() { - session.deleteAll(clazz); - } - - @Transactional - @Override - public S save(S s, int depth) { - session.save(s, depth); - return s; - } - - @Transactional - @Override - public Iterable save(Iterable ses, int depth) { - session.save(ses, depth); - return ses; - } - - @Override - public Optional findById(ID id, int depth) { - return Optional.ofNullable(session.load(clazz, id, depth)); - } - - // findAll and variants - @Override - public Iterable findAll() { - return findAll(DEFAULT_QUERY_DEPTH); - } - - @Override - public Iterable findAll(int depth) { - return session.loadAll(clazz, depth); - } - - @Override - public Iterable findAllById(Iterable longs) { - return findAllById(longs, DEFAULT_QUERY_DEPTH); - } - - @Override - public Iterable findAllById(Iterable ids, int depth) { - return session.loadAll(clazz, (Collection) ids, depth); - } - - @Override - public Iterable findAll(Sort sort) { - return findAll(sort, DEFAULT_QUERY_DEPTH); - } - - @Override - public Iterable findAll(Sort sort, int depth) { - return session.loadAll(clazz, PagingAndSortingUtils.convert(sort), depth); - } - - @Override - public Iterable findAllById(Iterable ids, Sort sort) { - return findAllById(ids, sort, DEFAULT_QUERY_DEPTH); - } - - @Override - public Iterable findAllById(Iterable ids, Sort sort, int depth) { - return session.loadAll(clazz, (Collection) ids, PagingAndSortingUtils.convert(sort), depth); - } - - @Override - public Page findAll(Pageable pageable) { - return findAll(pageable, DEFAULT_QUERY_DEPTH); - } - - @Override - public Page findAll(Pageable pageable, int depth) { - Pagination pagination = new Pagination(pageable.getPageNumber(), pageable.getPageSize()); - Collection data = session.loadAll(clazz, PagingAndSortingUtils.convert(pageable.getSort()), pagination, depth); - - return PageableExecutionUtils.getPage(new ArrayList<>(data), pageable, () -> session.countEntitiesOfType(clazz)); - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/package-info.java deleted file mode 100644 index 3eb87a797..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/support/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Neo4j repository implementations. - */ -package org.springframework.data.neo4j.repository.support; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/Neo4jTransactionManager.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/Neo4jTransactionManager.java deleted file mode 100644 index 6dc92207d..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/Neo4jTransactionManager.java +++ /dev/null @@ -1,426 +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.transaction; - -import static java.util.Collections.*; - -import java.util.Collection; - -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.neo4j.ogm.transaction.Transaction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.NoSuchBeanDefinitionException; -import org.springframework.dao.DataAccessException; -import org.springframework.data.neo4j.bookmark.BookmarkInfo; -import org.springframework.data.neo4j.bookmark.BookmarkManager; -import org.springframework.data.neo4j.bookmark.BookmarkSupport; -import org.springframework.transaction.CannotCreateTransactionException; -import org.springframework.transaction.IllegalTransactionStateException; -import org.springframework.transaction.InvalidIsolationLevelException; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionException; -import org.springframework.transaction.support.AbstractPlatformTransactionManager; -import org.springframework.transaction.support.DefaultTransactionStatus; -import org.springframework.transaction.support.ResourceTransactionManager; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -/** - * {@link PlatformTransactionManager} implementation for a single Neo4j OGM {@link SessionFactory}. Binds a Neo4j OGM - * Session from the specified factory to the thread, potentially allowing for one thread-bound Session per factory. - * {@link SharedSessionCreator} is aware of thread-bound session and participates in such transactions automatically. It - * is required for Neo4j OGM access code supporting this transaction management mechanism. - *

- * This transaction manager is appropriate for applications that use a single Neo4j OGM SessionFactory for transactional - * data access. JTA (usually through {@link org.springframework.transaction.jta.JtaTransactionManager}) has not been - * tested or considered at the moment. - *

- * This transaction manager does not support nested transactions or requires new propagation. - * - * @author Mark Angrish - * @see #setSessionFactory - */ -public class Neo4jTransactionManager extends AbstractPlatformTransactionManager - implements ResourceTransactionManager, BeanFactoryAware, InitializingBean { - - private static final Logger logger = LoggerFactory.getLogger(Neo4jTransactionManager.class); - - private SessionFactory sessionFactory; - private BookmarkManager bookmarkManager; - - /** - * Create a new Neo4jTransactionManager instance. - *

- * An SessionFactory has to be set to be able to use it. - * - * @see #setSessionFactory(SessionFactory) - */ - public Neo4jTransactionManager() { - this(null); - } - - /** - * Create a new Neo4jTransactionManager instance. - * - * @param sessionFactory SessionFactory to manage transactions for - */ - public Neo4jTransactionManager(SessionFactory sessionFactory) { - - setTransactionSynchronization(SYNCHRONIZATION_ON_ACTUAL_TRANSACTION); - this.sessionFactory = sessionFactory; - } - - /** - * Set the SessionFactory that this instance should manage transactions for. - *

- * By default, a default SessionFactory will be retrieved by finding a single unique bean of type SessionFactory in - * the containing BeanFactory. - */ - public void setSessionFactory(SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; - } - - /** - * Return the SessionFactory that this instance should manage transactions for. - */ - public SessionFactory getSessionFactory() { - return this.sessionFactory; - } - - /** - * Retrieves a default SessionFactory bean. - */ - @Override - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - if (getSessionFactory() == null) { - setSessionFactory(beanFactory.getBean(SessionFactory.class)); - } - try { - bookmarkManager = beanFactory.getBean(BookmarkManager.class); - logger.debug("Found BookmarkManager {}", bookmarkManager); - } catch (NoSuchBeanDefinitionException e) { - logger.debug("No BookmarkManager bean found, bookmark management not enabled"); - } - } - - @Override - public void afterPropertiesSet() throws Exception { - if (getSessionFactory() == null) { - throw new IllegalArgumentException("'sessionFactory' is required"); - } - } - - @Override - public Object getResourceFactory() { - return getSessionFactory(); - } - - @Override - protected Object doGetTransaction() { - Neo4jTransactionObject txObject = new Neo4jTransactionObject(); - - SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory()); - if (sessionHolder != null) { - if (logger.isDebugEnabled()) { - logger.debug("Found thread-bound Session [" + sessionHolder.getSession() + "] for Neo4j OGM transaction"); - } - txObject.setSessionHolder(sessionHolder, false); - } - return txObject; - } - - @Override - protected boolean isExistingTransaction(Object transaction) { - return ((Neo4jTransactionObject) transaction).hasTransaction(); - } - - @Override - protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException { - Neo4jTransactionObject txObject = (Neo4jTransactionObject) transaction; - - try { - if (txObject.getSessionHolder() == null || txObject.getSessionHolder().isSynchronizedWithTransaction()) { - Session session = sessionFactory.openSession(); - if (logger.isDebugEnabled()) { - logger.debug("Opened new Session [" + session + "] for Neo4j OGM transaction"); - } - txObject.setSessionHolder(new SessionHolder(session), true); - } - - Session session = txObject.getSessionHolder().getSession(); - - if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) { - // We should set a specific isolation level but are not allowed to... - throw new InvalidIsolationLevelException( - "Neo4jTransactionManager is not allowed to support custom isolation levels."); - } - - if (definition.getPropagationBehavior() != TransactionDefinition.PROPAGATION_REQUIRED) { - throw new IllegalTransactionStateException("Neo4jTransactionManager only supports 'required' propagation."); - } - - Transaction.Type type = getTransactionType(definition, txObject); - Transaction transactionData = session.beginTransaction(type, getBookmarks()); - - txObject.setTransactionData(transactionData); - if (logger.isDebugEnabled()) { - logger.debug("Beginning Transaction [" + transactionData + "] on Session [" + session + "]"); - } - - // Bind the session holder to the thread. - if (txObject.isNewSessionHolder()) { - TransactionSynchronizationManager.bindResource(getSessionFactory(), txObject.getSessionHolder()); - } - - if (definition.isReadOnly()) { - TransactionSynchronizationManager.setCurrentTransactionReadOnly(true); - } - - txObject.getSessionHolder().setSynchronizedWithTransaction(true); - } catch (TransactionException ex) { - closeSessionAfterFailedBegin(txObject); - throw ex; - } catch (Throwable ex) { - closeSessionAfterFailedBegin(txObject); - throw new CannotCreateTransactionException("Could not open Neo4j Session for transaction", ex); - } - } - - private Transaction.Type getTransactionType(TransactionDefinition definition, Neo4jTransactionObject txObject) { - Transaction.Type type; - if (definition.isReadOnly() && txObject.isNewSessionHolder()) { - type = Transaction.Type.READ_ONLY; - } else if (txObject.transactionData != null) { - type = txObject.transactionData.type(); - } else { - type = Transaction.Type.READ_WRITE; - } - return type; - } - - private Iterable getBookmarks() { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - if (bookmarkInfo != null && bookmarkInfo.shouldUseBookmark()) { - if (bookmarkManager != null) { - Collection bookmarks = bookmarkManager.getBookmarks(); - bookmarkInfo.setBookmarks(bookmarks); - return bookmarks; - - } else { - throw new IllegalStateException("Configured @UseBookmark but no BookmarkManager bean found."); - } - } else { - return emptySet(); - } - } - - /** - * Close the current transaction's Session. Called after a transaction begin attempt failed. - * - * @param txObject the current transaction - */ - private void closeSessionAfterFailedBegin(Neo4jTransactionObject txObject) { - if (txObject.isNewSessionHolder()) { - Session session = txObject.getSessionHolder().getSession(); - try { - if (session.getTransaction() != null) { - session.getTransaction().rollback(); - } - } catch (Throwable ex) { - logger.debug("Could not rollback Session after failed transaction begin", ex); - } finally { - txObject.setSessionHolder(null, false); - } - } - } - - @Override - protected Object doSuspend(Object transaction) { - Neo4jTransactionObject txObject = (Neo4jTransactionObject) transaction; - txObject.setSessionHolder(null, false); - SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(getSessionFactory()); - return new SuspendedResourcesHolder(sessionHolder); - } - - @Override - protected void doResume(Object transaction, Object suspendedResources) { - SuspendedResourcesHolder resourcesHolder = (SuspendedResourcesHolder) suspendedResources; - if (TransactionSynchronizationManager.hasResource(getSessionFactory())) { - // From non-transactional code running in active transaction synchronization - // -> can be safely removed, will be closed on transaction completion. - TransactionSynchronizationManager.unbindResource(getSessionFactory()); - } - TransactionSynchronizationManager.bindResource(getSessionFactory(), resourcesHolder.getSessionHolder()); - } - - @Override - protected void doCommit(DefaultTransactionStatus status) { - - Neo4jTransactionObject txObject = (Neo4jTransactionObject) status.getTransaction(); - Session session = txObject.getSessionHolder().getSession(); - - try (Transaction tx = session.getTransaction()) { - - if (status.isDebug()) { - logger.debug("Committing Neo4j OGM transaction [" + tx + "] on Session [" + session + "]"); - } - - if (tx != null) { - tx.commit(); - - if (bookmarkManager != null) { - String lastBookmark = session.getLastBookmark(); - - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - Collection bookmarks; - if (bookmarkInfo != null && bookmarkInfo.getBookmarks() != null) { - bookmarks = bookmarkInfo.getBookmarks(); - } else { - bookmarks = emptySet(); - } - logger.debug("Found bookmarks {}, replacing with {}", bookmarks, lastBookmark); - bookmarkManager.storeBookmark(lastBookmark, bookmarks); - } - } - } catch (RuntimeException ex) { - DataAccessException dae = SessionFactoryUtils.convertOgmAccessException(ex); - throw (dae != null ? dae : ex); - } - } - - @Override - protected void doRollback(DefaultTransactionStatus status) { - Neo4jTransactionObject txObject = (Neo4jTransactionObject) status.getTransaction(); - Session session = txObject.getSessionHolder().getSession(); - - try (Transaction tx = session.getTransaction()) { - - if (status.isDebug()) { - logger.debug("Rolling back Neo4j transaction [" + tx + "] on Session [" + session + "]"); - } - - if (tx != null) { - tx.rollback(); - } - } catch (RuntimeException ex) { - DataAccessException dae = SessionFactoryUtils.convertOgmAccessException(ex); - throw (dae != null ? dae : ex); - } finally { - if (!txObject.isNewSessionHolder()) { - // Clear all pending inserts/updates/deletes in the Session. - session.clear(); - } - } - } - - @Override - protected void doSetRollbackOnly(DefaultTransactionStatus status) { - Neo4jTransactionObject txObject = (Neo4jTransactionObject) status.getTransaction(); - if (status.isDebug()) { - logger.debug( - "Setting Neo4j OGM transaction on Session [" + txObject.getSessionHolder().getSession() + "] rollback-only"); - } - status.setRollbackOnly(); - } - - @Override - protected void doCleanupAfterCompletion(Object transaction) { - Neo4jTransactionObject txObject = (Neo4jTransactionObject) transaction; - - // Remove the session holder from the thread, if still there. - if (txObject.isNewSessionHolder()) { - TransactionSynchronizationManager.unbindResourceIfPossible(getSessionFactory()); - } - - Transaction rawTransaction = txObject.getTransactionData(); - - if (rawTransaction != null && rawTransaction.status().equals(Transaction.Status.OPEN)) { - rawTransaction.close(); - } - - // Remove the session holder from the thread. - if (txObject.isNewSessionHolder()) { - Session session = txObject.getSessionHolder().getSession(); - if (logger.isDebugEnabled()) { - logger.debug("Closing Neo4j Session [" + session + "] after transaction"); - } - } else { - logger.debug("Not closing pre-bound Neo4j Session after transaction"); - } - - txObject.getSessionHolder().clear(); - } - - /** - * Neo4j OGM transaction object, representing a SessionHolder. Used as transaction object by Neo4jTransactionManager. - */ - private static class Neo4jTransactionObject { - - private SessionHolder sessionHolder; - - private boolean newSessionHolder; - - private Transaction transactionData; - - void setSessionHolder(SessionHolder sessionHolder, boolean newSessionHolder) { - this.sessionHolder = sessionHolder; - this.newSessionHolder = newSessionHolder; - } - - SessionHolder getSessionHolder() { - return this.sessionHolder; - } - - boolean isNewSessionHolder() { - return this.newSessionHolder; - } - - boolean hasTransaction() { - return (this.sessionHolder != null && this.sessionHolder.isTransactionActive()); - } - - void setTransactionData(Transaction rawTransaction) { - this.transactionData = rawTransaction; - this.sessionHolder.setTransactionActive(true); - } - - Transaction getTransactionData() { - return this.transactionData; - } - } - - /** - * Holder for suspended resources. Used internally by {@code doSuspend} and {@code doResume}. - */ - private static class SuspendedResourcesHolder { - - private final SessionHolder sessionHolder; - - private SuspendedResourcesHolder(SessionHolder sessionHolder) { - this.sessionHolder = sessionHolder; - } - - private SessionHolder getSessionHolder() { - return this.sessionHolder; - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SessionFactoryUtils.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SessionFactoryUtils.java deleted file mode 100644 index 52f216395..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SessionFactoryUtils.java +++ /dev/null @@ -1,202 +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.transaction; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import org.neo4j.ogm.autoindex.MissingIndexException; -import org.neo4j.ogm.exception.ConnectionException; -import org.neo4j.ogm.exception.CypherException; -import org.neo4j.ogm.exception.ResultProcessingException; -import org.neo4j.ogm.exception.TransactionException; -import org.neo4j.ogm.exception.core.InvalidDepthException; -import org.neo4j.ogm.exception.core.MappingException; -import org.neo4j.ogm.exception.core.MetadataException; -import org.neo4j.ogm.exception.core.MissingOperatorException; -import org.neo4j.ogm.exception.core.TransactionManagerException; -import org.neo4j.ogm.exception.core.UnknownStatementTypeException; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.Ordered; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataAccessResourceFailureException; -import org.springframework.dao.DataRetrievalFailureException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.dao.TypeMismatchDataAccessException; -import org.springframework.data.neo4j.exception.Neo4jErrorStatusCodes; -import org.springframework.data.neo4j.exception.UncategorizedNeo4jException; -import org.springframework.transaction.support.ResourceHolderSynchronization; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.util.Assert; - -/** - * Helper class featuring methods for Neo4j OGM Session handling, allowing for reuse of Session instances within - * transactions. Also provides support for exception translation. - *

- * Mainly intended for internal use within the framework. - * - * @author Mark Angrish - * @author Michael J. Simons - */ -public class SessionFactoryUtils { - - private static final Logger logger = LoggerFactory.getLogger(SessionFactoryUtils.class); - - /** - * @deprecated since 5.2, this has been a Noop since 4.2 and has no meaning since then. It will be removed in the next major version. - * @param session - */ - @Deprecated - public static void closeSession(Session session) {} - - public static Session getSession(SessionFactory sessionFactory) throws IllegalStateException { - - Assert.notNull(sessionFactory, "No SessionFactory specified"); - - SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory); - if (sessionHolder != null) { - if (!sessionHolder.isSynchronizedWithTransaction() - && TransactionSynchronizationManager.isSynchronizationActive()) { - sessionHolder.setSynchronizedWithTransaction(true); - TransactionSynchronizationManager - .registerSynchronization(new SessionSynchronization(sessionHolder, sessionFactory, false)); - } - return sessionHolder.getSession(); - } - - if (!TransactionSynchronizationManager.isSynchronizationActive()) { - return null; - } - - Session session = sessionFactory.openSession(); - - logger.debug("Registering transaction synchronization for Neo4j Session"); - // Use same Session for further Neo4j actions within the transaction. - // Thread object will get removed by synchronization at transaction completion. - - sessionHolder = new SessionHolder(session); - sessionHolder.setSynchronizedWithTransaction(true); - TransactionSynchronizationManager - .registerSynchronization(new SessionSynchronization(sessionHolder, sessionFactory, true)); - TransactionSynchronizationManager.bindResource(sessionFactory, sessionHolder); - - return session; - } - - /** - * Convert the given runtime exception to an appropriate exception from the {@code org.springframework.dao} hierarchy. - * Return null if no translation is appropriate: any other exception may have resulted from user code, and should not - * be translated. - * - * @param ex runtime exception that occurred - * @return the corresponding DataAccessException instance, or {@code null} if the exception should not be translated - */ - public static DataAccessException convertOgmAccessException(RuntimeException ex) { - - // TODO: The OGM should not be throwing common runtime exceptions as these mask user errors. - // TODO: Instead we should be defining our own Exceptions that can then be translated into Spring Exceptions. - if (ex instanceof IllegalStateException) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - - if (ex instanceof InvalidDepthException) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - if (ex instanceof ResultProcessingException) { - return new DataRetrievalFailureException(ex.getMessage(), ex); - } - if (ex instanceof MappingException) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - if (ex instanceof MetadataException) { - return new TypeMismatchDataAccessException(ex.getMessage(), ex); - } - if (ex instanceof UnknownStatementTypeException) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - if (ex instanceof ConnectionException) { - return new DataAccessResourceFailureException(ex.getMessage(), ex); - } - if (ex instanceof MissingOperatorException) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - if (ex instanceof TransactionException) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - if (ex instanceof TransactionManagerException) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - if (ex instanceof MissingIndexException) { - return new InvalidDataAccessApiUsageException(ex.getMessage(), ex); - } - - // All exceptions coming back from the database. - if (ex instanceof CypherException) { - String code = ((CypherException) ex).getCode(); - final Class dae = Neo4jErrorStatusCodes.translate(code); - - if (dae != null) { - try { - final Constructor constructor = dae.getDeclaredConstructor(String.class, - Throwable.class); - return constructor.newInstance(ex.getMessage(), ex); - } catch (InstantiationException | IllegalAccessException | NoSuchMethodException - | InvocationTargetException e) { - return null; - } - } - - return new UncategorizedNeo4jException(ex.getMessage(), ex); - } - // If we get here, we have an exception that resulted from user code, - // rather than the persistence provider, so we return null to indicate - // that translation should not occur. - return null; - } - - private static class SessionSynchronization extends ResourceHolderSynchronization - implements Ordered { - - private final boolean newSession; - - SessionSynchronization(SessionHolder sessionHolder, SessionFactory sessionFactory, boolean newSession) { - super(sessionHolder, sessionFactory); - this.newSession = newSession; - } - - @Override - public int getOrder() { - return 900; - } - - @Override - public void flushResource(SessionHolder resourceHolder) {} - - @Override - protected boolean shouldUnbindAtCompletion() { - return this.newSession; - } - - @Override - protected boolean shouldReleaseAfterCompletion(SessionHolder resourceHolder) { - // return !resourceHolder.getSession().isClosed(); - return false; - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SessionHolder.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SessionHolder.java deleted file mode 100644 index 10b8368b3..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SessionHolder.java +++ /dev/null @@ -1,60 +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.transaction; - -import org.neo4j.ogm.session.Session; -import org.springframework.transaction.support.ResourceHolderSupport; -import org.springframework.util.Assert; - -/** - * Holder wrapping a Neo4j OGM Session. Neo4jTransactionManager binds instances of this class to the thread, for a given - * SessionFactory. - *

- * Note: This is an SPI class, not intended to be used by applications. - * - * @author Mark Angrish - * @see Neo4jTransactionManager - * @see SessionFactoryUtils - */ -public class SessionHolder extends ResourceHolderSupport { - - private final Session session; - - private boolean transactionActive; - - public SessionHolder(Session session) { - Assert.notNull(session, "Session must not be null"); - this.session = session; - } - - public Session getSession() { - return this.session; - } - - protected void setTransactionActive(boolean transactionActive) { - this.transactionActive = transactionActive; - } - - protected boolean isTransactionActive() { - return this.transactionActive; - } - - @Override - public void clear() { - super.clear(); - this.transactionActive = false; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SharedSessionCreator.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SharedSessionCreator.java deleted file mode 100644 index 462247517..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/SharedSessionCreator.java +++ /dev/null @@ -1,164 +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.transaction; - -import static org.neo4j.ogm.transaction.Transaction.Status.*; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.lang.reflect.Proxy; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; - -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.neo4j.mapping.MetaDataProvider; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.util.ReflectionUtils; - -/** - * Delegate for creating a shareable Neo4j OGM {@link Session} reference for a given {@link SessionFactory}. - *

- * A shared Session will behave just like a Session fetched from an application SessionFactory. It will delegate all - * calls to the current transactional Session, if any; otherwise it will fall back to a newly created Session per - * operation. - * - * @author Mark Angrish - * @author Michael J. Simons - * @see Neo4jTransactionManager - */ -public class SharedSessionCreator { - - private static final Set TRANSACTION_REQUIRING_METHODS; - - static { - Set tmp = new HashSet<>(); - tmp.add("deleteAll"); - tmp.add("save"); - tmp.add("delete"); - tmp.add("purgeDatabase"); - - TRANSACTION_REQUIRING_METHODS = Collections.unmodifiableSet(tmp); - } - - /** - * Create a transactional Session proxy for the given SessionFactory. - * - * @param sessionFactory SessionFactory to obtain Sessions from as needed {@code createSession} call (may be - * {@code null}) Session. Allows the addition or specification of proprietary interfaces. - * @return a shareable transactional Session proxy - */ - public static Session createSharedSession(SessionFactory sessionFactory) { - return (Session) Proxy.newProxyInstance(SharedSessionCreator.class.getClassLoader(), - new Class[] { Session.class, MetaDataProvider.class }, new SharedSessionInvocationHandler(sessionFactory)); - } - - /** - * Invocation handler that delegates all calls to the current transactional Session, if any; else, it will fall back - * to a newly created Session per operation. - */ - private static class SharedSessionInvocationHandler implements InvocationHandler { - - private final Logger logger = LoggerFactory.getLogger(getClass()); - - private final SessionFactory sessionFactory; - - private final Method queryMethod; - - public SharedSessionInvocationHandler(SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; - this.queryMethod = ReflectionUtils - .findMethod(Session.class, "query", String.class, Map.class, boolean.class); - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) { - String methodName = method.getName(); - switch (methodName) { - case "equals": - // Only consider equal when proxies are identical. - return (proxy == args[0]); - case "hashCode": - // Use hashCode of Session proxy. - return hashCode(); - case "toString": - // Deliver toString without touching a target Session. - return "Shared Session proxy for target factory [" + sessionFactory + "]"; - case "getMetaData": - return this.sessionFactory.metaData(); - case "beginTransaction": - throw new IllegalStateException( - "Not allowed to create transaction on shared Session - " - + "use Spring transactions instead"); - default: - Function methodCall; - if (isGenericQueryMethod(method)) { - Object[] newArgs = new Object[args.length + 1]; - System.arraycopy(args, 0, newArgs, 0, args.length); - newArgs[newArgs.length - 1] = TransactionSynchronizationManager.isCurrentTransactionReadOnly(); - methodCall = targetSession -> ReflectionUtils.invokeMethod(queryMethod, targetSession, newArgs); - } else { - methodCall = targetSession -> ReflectionUtils.invokeMethod(method, targetSession, args); - } - return invokeInTransaction(methodName, methodCall); - } - } - - private static boolean isGenericQueryMethod(Method method) { - - Parameter[] parameters = method.getParameters(); - return "query".equals(method.getName()) && method.getParameterCount() == 2 && - parameters[0].getType() == String.class && parameters[1].getType() == Map.class; - } - - private Object invokeInTransaction(String methodName, Function methodCall) { - - // Determine current Session: either the transactional one - // managed by the factory or a temporary one for the given invocation. - Session targetSession = SessionFactoryUtils.getSession(this.sessionFactory); - - if (TRANSACTION_REQUIRING_METHODS.contains(methodName)) { - if (targetSession == null - || (!TransactionSynchronizationManager.isActualTransactionActive() - && targetSession.getTransaction() != null - && EnumSet.of(CLOSED, COMMITTED, ROLLEDBACK) - .contains(targetSession.getTransaction().status()))) { - throw new IllegalStateException("No Session with actual transaction available " - + "for current thread - cannot reliably process '" + methodName + "' call"); - } - } - - // Regular Session operations. - if (targetSession == null) { - logger.debug("Creating new Session for shared Session invocation"); - targetSession = this.sessionFactory.openSession(); - } - - // Invoke method on current Session. - try { - return methodCall.apply(targetSession); - } finally { - } - } - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/package-info.java deleted file mode 100644 index 1adfdbfd5..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/transaction/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Spring Data Neo4js implementation of a {@link org.springframework.transaction.PlatformTransactionManager}. - */ -package org.springframework.data.neo4j.transaction; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/util/PagingAndSortingUtils.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/util/PagingAndSortingUtils.java deleted file mode 100644 index 725b962bb..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/util/PagingAndSortingUtils.java +++ /dev/null @@ -1,38 +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.util; - -import org.neo4j.ogm.cypher.query.SortOrder; -import org.springframework.data.domain.Sort; - -public class PagingAndSortingUtils { - - public static SortOrder convert(Sort sort) { - - SortOrder sortOrder = new SortOrder(); - - if (sort != Sort.unsorted()) { - for (Sort.Order order : sort) { - if (order.isAscending()) { - sortOrder.add(order.getProperty()); - } else { - sortOrder.add(SortOrder.Direction.DESC, order.getProperty()); - } - } - } - return sortOrder; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/util/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/util/package-info.java deleted file mode 100644 index 84633a8c4..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/util/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Util classes for iteration and pagination. - */ -package org.springframework.data.neo4j.util; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/AsyncRequestInterceptor.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/AsyncRequestInterceptor.java deleted file mode 100644 index 1e7114e21..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/AsyncRequestInterceptor.java +++ /dev/null @@ -1,93 +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.web.support; - -import java.util.concurrent.Callable; - -import org.neo4j.ogm.session.SessionFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.neo4j.transaction.SessionHolder; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.context.request.async.CallableProcessingInterceptor; -import org.springframework.web.context.request.async.DeferredResult; -import org.springframework.web.context.request.async.DeferredResultProcessingInterceptor; - -/** - * An interceptor with asynchronous web requests used in OpenSessionInViewFilter and OpenSessionInViewInterceptor. - * Ensures the following: 1) The session is bound/unbound when "callable processing" is started 2) The session is closed - * if an async request times out - * - * @author Mark Angrish - * @author Michael J. Simons - */ -class AsyncRequestInterceptor implements CallableProcessingInterceptor, DeferredResultProcessingInterceptor { - - private static final Logger logger = LoggerFactory.getLogger(AsyncRequestInterceptor.class); - - private final SessionFactory sessionFactory; - - private final SessionHolder sessionHolder; - - private volatile boolean timeoutInProgress; - - public AsyncRequestInterceptor(SessionFactory sessionFactory, SessionHolder sessionHolder) { - this.sessionFactory = sessionFactory; - this.sessionHolder = sessionHolder; - } - - @Override - public void preProcess(NativeWebRequest request, Callable task) { - bindSession(); - } - - public void bindSession() { - this.timeoutInProgress = false; - TransactionSynchronizationManager.bindResource(this.sessionFactory, this.sessionHolder); - } - - @Override - public void postProcess(NativeWebRequest request, Callable task, Object concurrentResult) { - TransactionSynchronizationManager.unbindResource(this.sessionFactory); - } - - @Override - public Object handleTimeout(NativeWebRequest request, Callable task) { - this.timeoutInProgress = true; - return RESULT_NONE; // give other interceptors a chance to handle the timeout - } - - @Override - public void afterCompletion(NativeWebRequest request, Callable task) throws Exception { - closeAfterTimeout(); - } - - private void closeAfterTimeout() { - if (this.timeoutInProgress) { - logger.debug("Closing Neo4j OGM Session after async request timeout"); - } - } - - @Override - public void beforeConcurrentHandling(NativeWebRequest request, DeferredResult deferredResult) {} - - @Override - public boolean handleTimeout(NativeWebRequest request, DeferredResult deferredResult) { - this.timeoutInProgress = true; - return true; // give other interceptors a chance to handle the timeout - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/OpenSessionInViewFilter.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/OpenSessionInViewFilter.java deleted file mode 100644 index 1e7dc7d92..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/OpenSessionInViewFilter.java +++ /dev/null @@ -1,201 +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.web.support; - -import java.io.IOException; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.data.neo4j.transaction.SessionHolder; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.util.StringUtils; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.request.async.CallableProcessingInterceptor; -import org.springframework.web.context.request.async.WebAsyncManager; -import org.springframework.web.context.request.async.WebAsyncUtils; -import org.springframework.web.context.support.WebApplicationContextUtils; -import org.springframework.web.filter.OncePerRequestFilter; - -/** - * Servlet Filter that binds a Neo4j OGM Session to the thread for the entire processing of the request. Intended for - * the "Open Session in View" pattern, i.e. to allow for lazy loading in web views despite the original transactions - * already being completed. - *

- * This filter makes OGM Sessions available via the current thread, which will be autodetected by transaction managers. - * At the moment this service is only suitable for transactions via {@link Neo4jTransactionManager}. - *

- * Looks up the SessionFactory in Spring's root web application context. Supports an "sessionFactoryBeanName" filter - * init-param in {@code web.xml}; the default bean name is "sessionFactory". - * - * @see OpenSessionInViewInterceptor - * @see Neo4jTransactionManager - * @see TransactionSynchronizationManager - * - * @author Mark Angrish - * @author Michael J. Simons - */ -public class OpenSessionInViewFilter extends OncePerRequestFilter { - - /** - * Default SessionFactory bean name: "sessionFactory". - * - * @see #setSessionFactoryBeanName - */ - public static final String DEFAULT_SESSION_FACTORY_BEAN_NAME = "sessionFactory"; - - private String sessionFactoryBeanName = DEFAULT_SESSION_FACTORY_BEAN_NAME; - - private volatile SessionFactory sessionFactory; - - /** - * Set the bean name of the SessionFactory to fetch from Spring's root application context. - *

- * Default is "sessionFactory". - * - * @see #DEFAULT_SESSION_FACTORY_BEAN_NAME - */ - public void setSessionFactoryBeanName(String sessionFactoryBeanName) { - this.sessionFactoryBeanName = sessionFactoryBeanName; - } - - /** - * Return the bean name of the SessionFactory to fetch from Spring's root application context. - */ - protected String getSessionFactoryBeanName() { - return this.sessionFactoryBeanName; - } - - /** - * Returns "false" so that the filter may re-bind the opened {@code Session} to each asynchronously dispatched thread - * and postpone closing it until the very last asynchronous dispatch. - */ - @Override - protected boolean shouldNotFilterAsyncDispatch() { - return false; - } - - /** - * Returns "false" so that the filter may provide an {@code Session} to each error dispatches. - */ - @Override - protected boolean shouldNotFilterErrorDispatch() { - return false; - } - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws ServletException, IOException { - - SessionFactory sessionFactory = lookupSessionFactory(request); - boolean participate = false; - - WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request); - String key = getAlreadyFilteredAttributeName(); - - if (TransactionSynchronizationManager.hasResource(sessionFactory)) { - // Do not modify the Session: just set the participate flag. - participate = true; - } else { - boolean isFirstRequest = !isAsyncDispatch(request); - if (isFirstRequest || !applySessionBindingInterceptor(asyncManager, key)) { - logger.debug("Opening Neo4j OGM Session in OpenSessionInViewFilter"); - Session session = createSession(sessionFactory); - SessionHolder sessionHolder = new SessionHolder(session); - TransactionSynchronizationManager.bindResource(sessionFactory, sessionHolder); - - AsyncRequestInterceptor interceptor = new AsyncRequestInterceptor(sessionFactory, sessionHolder); - asyncManager.registerCallableInterceptor(key, interceptor); - asyncManager.registerDeferredResultInterceptor(key, interceptor); - } - } - - try { - filterChain.doFilter(request, response); - } finally { - if (!participate) { - TransactionSynchronizationManager.unbindResource(sessionFactory); - if (!isAsyncStarted(request)) { - logger.debug("Closed Neo4J OGM Session in OpenSessionInViewFilter"); - } - } - } - } - - /** - * Look up the SessionFactory that this filter should use, taking the current HTTP request as argument. - *

- * The default implementation delegates to the {@code lookupSessionFactory} without arguments, caching the - * SessionFactory reference once obtained. - * - * @return the SessionFactory to use - * @see #lookupSessionFactory() - */ - protected SessionFactory lookupSessionFactory(HttpServletRequest request) { - if (this.sessionFactory == null) { - this.sessionFactory = lookupSessionFactory(); - } - return this.sessionFactory; - } - - /** - * Look up the SessionFactory that this filter should use. - *

- * The default implementation looks for a bean with the specified name in Spring's root application context. - * - * @return the SessionFactory to use - * @see #getSessionFactoryBeanName - */ - protected SessionFactory lookupSessionFactory() { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); - String sessionFactoryBeanName = getSessionFactoryBeanName(); - if (StringUtils.hasLength(sessionFactoryBeanName)) { - return wac.getBean(sessionFactoryBeanName, SessionFactory.class); - } else if (wac.containsBean(DEFAULT_SESSION_FACTORY_BEAN_NAME)) { - return wac.getBean(DEFAULT_SESSION_FACTORY_BEAN_NAME, SessionFactory.class); - } else { - // Includes fallback search for single SessionFactory bean by type. - return wac.getBean(SessionFactory.class); - } - } - - /** - * Create a Neo4j OGM Session to be bound to a request. - *

- * Can be overridden in subclasses. - * - * @param sessionFactory the SessionFactory to use - * @see SessionFactory#openSession - */ - protected Session createSession(SessionFactory sessionFactory) { - return sessionFactory.openSession(); - } - - private boolean applySessionBindingInterceptor(WebAsyncManager asyncManager, String key) { - - CallableProcessingInterceptor processingInterceptor = asyncManager.getCallableInterceptor(key); - if (processingInterceptor == null) { - return false; - } - ((AsyncRequestInterceptor) processingInterceptor).bindSession(); - return true; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/OpenSessionInViewInterceptor.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/OpenSessionInViewInterceptor.java deleted file mode 100644 index 6d2fd7ac4..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/OpenSessionInViewInterceptor.java +++ /dev/null @@ -1,177 +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.web.support; - -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.dao.DataAccessException; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.data.neo4j.transaction.SessionHolder; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.ui.ModelMap; -import org.springframework.web.context.request.AsyncWebRequestInterceptor; -import org.springframework.web.context.request.WebRequest; -import org.springframework.web.context.request.async.CallableProcessingInterceptor; -import org.springframework.web.context.request.async.WebAsyncManager; -import org.springframework.web.context.request.async.WebAsyncUtils; - -/** - * Spring web request interceptor that binds a Neo4j OGM Session to the thread for the entire processing of the request. - * Intended for the "Open Session in View" pattern, i.e. to allow for lazy loading in web views despite the original - * transactions already being completed. - *

- * This interceptor makes Neo4j OGM Sessions available via the current thread, which will be autodetected by transaction - * managers. It is suitable for service layer transactions via {@link Neo4jTransactionManager}. - *

- * In contrast to {@link OpenSessionInViewFilter}, this interceptor is set up in a Spring application context and can - * thus take advantage of bean wiring. - * - * @see OpenSessionInViewFilter - * @see Neo4jTransactionManager - * @see TransactionSynchronizationManager - * - * @author Mark Angrish - * @author Michael J. Simons - */ -public class OpenSessionInViewInterceptor implements BeanFactoryAware, AsyncWebRequestInterceptor { - - /** - * Logger available to subclasses - */ - protected final Logger logger = LoggerFactory.getLogger(getClass()); - - /** - * Suffix that gets appended to the SessionFactory toString representation for the "participate in existing session - * handling" request attribute. - * - * @see #getParticipateAttributeName - */ - public static final String PARTICIPATE_SUFFIX = ".PARTICIPATE"; - - private SessionFactory sessionFactory; - - /** - * Set the Neo4j OGM SessionFactory that should be used to create Sessions. - * - * @see SessionFactory#openSession - */ - public void setSessionFactory(SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; - } - - /** - * Return the Neo4j OGM SessionFactory that should be used to create Sessions. - */ - public SessionFactory getSessionFactory() { - return this.sessionFactory; - } - - /** - * Retrieves the default SessionFactory bean. - */ - @Override - public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - if (getSessionFactory() == null) { - setSessionFactory(beanFactory.getBean(SessionFactory.class)); - } - } - - @Override - public void preHandle(WebRequest request) throws DataAccessException { - String participateAttributeName = getParticipateAttributeName(); - - WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request); - if (asyncManager.hasConcurrentResult()) { - if (applyCallableInterceptor(asyncManager, participateAttributeName)) { - return; - } - } - - if (TransactionSynchronizationManager.hasResource(getSessionFactory())) { - // Do not modify the Session: just mark the request accordingly. - Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST); - int newCount = (count != null ? count + 1 : 1); - request.setAttribute(getParticipateAttributeName(), newCount, WebRequest.SCOPE_REQUEST); - } else { - logger.debug("Opening Neo4j OGM Session in OpenSessionInViewInterceptor"); - Session session = sessionFactory.openSession(); - SessionHolder sessionHolder = new SessionHolder(session); - TransactionSynchronizationManager.bindResource(getSessionFactory(), sessionHolder); - - AsyncRequestInterceptor interceptor = new AsyncRequestInterceptor(getSessionFactory(), sessionHolder); - asyncManager.registerCallableInterceptor(participateAttributeName, interceptor); - asyncManager.registerDeferredResultInterceptor(participateAttributeName, interceptor); - } - } - - @Override - public void postHandle(WebRequest request, ModelMap model) {} - - @Override - public void afterCompletion(WebRequest request, Exception ex) throws DataAccessException { - if (!decrementParticipateCount(request)) { - TransactionSynchronizationManager.unbindResource(getSessionFactory()); - logger.debug("Closed Neo4j OGM Session in OpenSessionInViewInterceptor"); - } - } - - private boolean decrementParticipateCount(WebRequest request) { - String participateAttributeName = getParticipateAttributeName(); - Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST); - if (count == null) { - return false; - } - // Do not modify the Session: just clear the marker. - if (count > 1) { - request.setAttribute(participateAttributeName, count - 1, WebRequest.SCOPE_REQUEST); - } else { - request.removeAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST); - } - return true; - } - - @Override - public void afterConcurrentHandlingStarted(WebRequest request) { - if (!decrementParticipateCount(request)) { - TransactionSynchronizationManager.unbindResource(getSessionFactory()); - } - } - - /** - * Return the name of the request attribute that identifies that a request is already filtered. Default implementation - * takes the toString representation of the SessionFactory instance and appends ".FILTERED". - * - * @see #PARTICIPATE_SUFFIX - */ - protected String getParticipateAttributeName() { - return getSessionFactory().toString() + PARTICIPATE_SUFFIX; - } - - private boolean applyCallableInterceptor(WebAsyncManager asyncManager, String key) { - - CallableProcessingInterceptor callableInterceptor = asyncManager.getCallableInterceptor(key); - if (callableInterceptor == null) { - return false; - } - ((AsyncRequestInterceptor) callableInterceptor).bindSession(); - return true; - } -} diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/package-info.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/package-info.java deleted file mode 100644 index 1f2e560d2..000000000 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/web/support/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Support classes for web requests. - */ -package org.springframework.data.neo4j.web.support; diff --git a/spring-data-neo4j/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/spring-data-neo4j/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension deleted file mode 100644 index effa7a79b..000000000 --- a/spring-data-neo4j/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension +++ /dev/null @@ -1 +0,0 @@ -org.springframework.data.neo4j.repository.cdi.Neo4jCdiRepositoryExtension diff --git a/spring-data-neo4j/src/main/resources/META-INF/spring.handlers b/spring-data-neo4j/src/main/resources/META-INF/spring.handlers deleted file mode 100644 index 24c984aec..000000000 --- a/spring-data-neo4j/src/main/resources/META-INF/spring.handlers +++ /dev/null @@ -1 +0,0 @@ -http\://www.springframework.org/schema/data/neo4j=org.springframework.data.neo4j.repository.config.Neo4jRepositoryNameSpaceHandler diff --git a/spring-data-neo4j/src/main/resources/META-INF/spring.schemas b/spring-data-neo4j/src/main/resources/META-INF/spring.schemas deleted file mode 100644 index db5fea8b3..000000000 --- a/spring-data-neo4j/src/main/resources/META-INF/spring.schemas +++ /dev/null @@ -1,3 +0,0 @@ -http\://www.springframework.org/schema/data/neo4j/spring-neo4j-4.2.xsd=org/springframework/data/neo4j/repository/config/spring-neo4j-4.2.xsd -http\://www.springframework.org/schema/data/neo4j/spring-neo4j-5.0.xsd=org/springframework/data/neo4j/repository/config/spring-neo4j-5.0.xsd -http\://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd=org/springframework/data/neo4j/repository/config/spring-neo4j-5.1.xsd diff --git a/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-4.2.xsd b/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-4.2.xsd deleted file mode 100644 index 0ea7c6b24..000000000 --- a/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-4.2.xsd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-5.0.xsd b/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-5.0.xsd deleted file mode 100644 index 0ea7c6b24..000000000 --- a/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-5.0.xsd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-5.1.xsd b/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-5.1.xsd deleted file mode 100644 index 0ea7c6b24..000000000 --- a/spring-data-neo4j/src/main/resources/org/springframework/data/neo4j/repository/config/spring-neo4j-5.1.xsd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/package-info.java b/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/package-info.java deleted file mode 100644 index 0c7436a73..000000000 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Repositories shared between tests. - */ -package org.neo4j.springframework.data.integration.imperative.repositories; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/package-info.java b/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/package-info.java deleted file mode 100644 index 0b4200fc0..000000000 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Repositories shared between tests. - */ -package org.neo4j.springframework.data.integration.reactive.repositories; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Club.java b/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Club.java deleted file mode 100644 index bab34b1ab..000000000 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Club.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. - * - * 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.neo4j.springframework.data.integration.shared; - -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; - -/** - * @author Gerrit Meier - */ -@Node -public class Club { - - @Id @GeneratedValue private Long id; - - private String name; - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonProjection.java b/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonProjection.java deleted file mode 100644 index ba0fc92be..000000000 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonProjection.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. - * - * 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.neo4j.springframework.data.integration.shared; - -/** - * @author Gerrit Meier - */ -public interface PersonProjection { - - String getName(); - - String getSameValue(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/JavaConfigurationAuditingTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/JavaConfigurationAuditingTests.java deleted file mode 100644 index 5509927b1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/JavaConfigurationAuditingTests.java +++ /dev/null @@ -1,92 +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.auditing; - -import static java.util.Optional.*; -import static org.assertj.core.api.Assertions.*; - -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.Optional; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.domain.AuditorAware; -import org.springframework.data.neo4j.annotation.EnableNeo4jAuditing; -import org.springframework.data.neo4j.auditing.domain.User; -import org.springframework.data.neo4j.auditing.repository.UserRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Frantisek Hartman - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration -public class JavaConfigurationAuditingTests { - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.auditing.domain", - repositoryPackages = "org.springframework.data.neo4j.auditing.repository") - @EnableNeo4jAuditing(modifyOnCreate = false) - static class Neo4jConfiguration { - - @Bean - public AuditorAware auditorAware() { - return () -> of("userId"); - } - } - - @Autowired private UserRepository userRepository; - - @Test - public void whenSaveEntity_thenSetCreatedAndCreatedBy() { - User user = new User("John Doe"); - userRepository.save(user); - - Optional loaded = userRepository.findById(user.getId()); - assertThat(loaded).isPresent(); - - User found = loaded.get(); - assertThat(found.getCreated()).isNotNull().isCloseTo(LocalDateTime.now(), within(1, ChronoUnit.SECONDS)); - assertThat(found.getCreatedBy()).isEqualTo("userId"); - - assertThat(found.getModified()).isNull(); - assertThat(found.getModifiedBy()).isNull(); - } - - @Test - public void whenUpdateEntity_thenSetModifiedAndModifiedBy() { - User user = new User("John Doe"); - userRepository.save(user); - - user.setName("Johan Doe"); - userRepository.save(user); - - Optional loaded = userRepository.findById(user.getId()); - assertThat(loaded).isPresent(); - - User found = loaded.get(); - - assertThat(found.getModified()).isNotNull().isCloseTo(LocalDateTime.now(), within(1, ChronoUnit.SECONDS)); - assertThat(found.getModifiedBy()).isEqualTo("userId"); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/domain/User.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/domain/User.java deleted file mode 100644 index 0fb93a2fb..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/domain/User.java +++ /dev/null @@ -1,97 +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.auditing.domain; - -import java.time.LocalDateTime; - -import org.neo4j.ogm.annotation.NodeEntity; -import org.springframework.data.annotation.CreatedBy; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.LastModifiedBy; -import org.springframework.data.annotation.LastModifiedDate; - -/** - * @author Frantisek Hartman - */ -@NodeEntity -public class User { - - Long id; - - String name; - - @CreatedDate LocalDateTime created; - - @CreatedBy String createdBy; - - @LastModifiedDate LocalDateTime modified; - - @LastModifiedBy String modifiedBy; - - public User() {} - - public User(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public LocalDateTime getCreated() { - return created; - } - - public void setCreated(LocalDateTime created) { - this.created = created; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public LocalDateTime getModified() { - return modified; - } - - public void setModified(LocalDateTime modified) { - this.modified = modified; - } - - public String getModifiedBy() { - return modifiedBy; - } - - public void setModifiedBy(String modifiedBy) { - this.modifiedBy = modifiedBy; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/repository/UserRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/repository/UserRepository.java deleted file mode 100644 index ba97bad0a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/auditing/repository/UserRepository.java +++ /dev/null @@ -1,24 +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.auditing.repository; - -import org.springframework.data.neo4j.auditing.domain.User; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Frantisek Hartman - */ -public interface UserRepository extends Neo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/bookmark/BookmarkManagementTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/bookmark/BookmarkManagementTests.java deleted file mode 100644 index aa56b57ca..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/bookmark/BookmarkManagementTests.java +++ /dev/null @@ -1,232 +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.bookmark; - -import static org.assertj.core.api.Assertions.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.annotation.EnableBookmarkManagement; -import org.springframework.data.neo4j.annotation.UseBookmark; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author Frantisek Hartman - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = BookmarkManagementTests.BookmarkManagementConfiguration.class) -public class BookmarkManagementTests { - - @Autowired private UseBookmarkOnMethodBean useBookmarkOnMethodBean; - - @Autowired private UseBookmarkOnClassBean useBookmarkOnClassBean; - - @Autowired private UseNoBookmarkBean useNoBookmarkBean; - - @Autowired private UseBookmarkWrapperOnClassBean useBookmarkWrapperOnClassBean; - - @Autowired private UseBookmarkWrapperOnMethodBean useBookmarkWrapperOnMethodBean; - - // Bookmark on method - @Test - public void givenUseBookmarkOnMethod_whenRun_thenShouldUseBookmarkIsSet() { - useBookmarkOnMethodBean.runWithBookmark(() -> { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNotNull(); - assertThat(bookmarkInfo.shouldUseBookmark()).isTrue(); - }); - } - - @Test - public void givenUseBookmarkOnMethod_whenRun_thenRemoveBookmarkInfoAfterRun() { - useBookmarkOnMethodBean.runWithBookmark(() -> {}); - - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNull(); - } - - @Test - public void givenMethodWithoutUseBookmark_whenRun_thenNoBookmarkInfoSet() { - useBookmarkOnMethodBean.runWithoutBookmark(() -> { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNull(); - }); - } - - // BookmarkWrapper on method - @Test - public void givenUseBookmarkWrapperOnMethod_whenRun_thenShouldUseBookmarkIsSet() { - useBookmarkWrapperOnMethodBean.runWithBookmark(() -> { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNotNull(); - assertThat(bookmarkInfo.shouldUseBookmark()).isTrue(); - }); - } - - @Test - public void givenUseBookmarkWrapperOnMethod_whenRun_thenRemoveBookmarkInfoAfterRun() { - useBookmarkWrapperOnMethodBean.runWithBookmark(() -> {}); - - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNull(); - } - - // Bookmark on class - @Test - public void givenUseBookmarkOnClass_whenRunMethod_thenShouldUseBookmarkIsSet() { - useBookmarkOnClassBean.runWithBookmark(() -> { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNotNull(); - assertThat(bookmarkInfo.shouldUseBookmark()).isTrue(); - }); - } - - @Test - public void givenUseBookmarkOnClassAndMethodFalse_whenRunMethod_thenShouldUseBookmarkIsSetToFalse() { - useBookmarkOnClassBean.runWithoutBookmark(() -> { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNull(); - }); - } - - @Test // DATAGRAPH-1115 - public void givenUseBookmarkWrapperOnClass_whenRunMethod_thenShouldUseBookmarkIsSet() { - useBookmarkWrapperOnClassBean.runWithBookmark(() -> { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNotNull(); - assertThat(bookmarkInfo.shouldUseBookmark()).isTrue(); - }); - } - - @Test - public void givenUseBookmarkWrapperOnClassAndMethodFalse_whenRunMethod_thenShouldUseBookmarkIsSetToFalse() { - useBookmarkWrapperOnClassBean.runWithoutBookmark(() -> { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNull(); - }); - } - - @Test - public void givenUseBookmarkWrapperOnClass_whenRun_thenRemoveBookmarkInfoAfterRun() { - useBookmarkWrapperOnClassBean.runWithBookmark(() -> {}); - - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNull(); - } - - // No Bookmark - @Test - public void givenNoBookmark_whenRunMethod_thenShouldUseBookmarkIsSet() { - useNoBookmarkBean.runWithBookmark(() -> { - BookmarkInfo bookmarkInfo = BookmarkSupport.currentBookmarkInfo(); - assertThat(bookmarkInfo).isNull(); - }); - } - - @Configuration - @EnableBookmarkManagement - @EnableTransactionManagement() - static class BookmarkManagementConfiguration { - - @Bean - public UseBookmarkOnMethodBean testBean() { - return new UseBookmarkOnMethodBean(); - } - - @Bean - public UseBookmarkOnClassBean useBookmarkOnClassBean() { - return new UseBookmarkOnClassBean(); - } - - @Bean - public UseNoBookmarkBean useNoBookmarkBean() { - return new UseNoBookmarkBean(); - } - - @Bean - public UseBookmarkWrapperOnClassBean useBookmarkWrapperOnClassBean() { - return new UseBookmarkWrapperOnClassBean(); - } - - @Bean - public UseBookmarkWrapperOnMethodBean useBookmarkWrapperOnMethodBean() { - return new UseBookmarkWrapperOnMethodBean(); - } - } - - static class UseBookmarkOnMethodBean { - - @UseBookmark - public void runWithBookmark(Runnable runnable) { - runnable.run(); - } - - public void runWithoutBookmark(Runnable runnable) { - runnable.run(); - } - - } - - @UseBookmark - static class UseBookmarkOnClassBean { - - public void runWithBookmark(Runnable runnable) { - runnable.run(); - } - - @UseBookmark(false) - public void runWithoutBookmark(Runnable runnable) { - runnable.run(); - } - - } - - @BookmarkWrapper - static class UseBookmarkWrapperOnClassBean { - - public void runWithBookmark(Runnable runnable) { - runnable.run(); - } - - @BookmarkWrapper(false) - public void runWithoutBookmark(Runnable runnable) { - runnable.run(); - } - - } - - static class UseBookmarkWrapperOnMethodBean { - - @BookmarkWrapper - public void runWithBookmark(Runnable runnable) { - runnable.run(); - } - - } - - static class UseNoBookmarkBean { - - public void runWithBookmark(Runnable runnable) { - runnable.run(); - } - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/bookmark/BookmarkWrapper.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/bookmark/BookmarkWrapper.java deleted file mode 100644 index 03ba6ab2b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/bookmark/BookmarkWrapper.java +++ /dev/null @@ -1,35 +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.bookmark; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.data.neo4j.annotation.UseBookmark; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) -@Documented -@UseBookmark -public @interface BookmarkWrapper { - - @AliasFor(annotation = UseBookmark.class, attribute = "value") - boolean value() default true; -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionServiceIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionServiceIntegrationTests.java deleted file mode 100644 index 46af75f1d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionServiceIntegrationTests.java +++ /dev/null @@ -1,75 +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.conversion; - -import static org.assertj.core.api.Assertions.*; - -import java.util.Arrays; -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Result; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.conversion.support.ConvertedClass; -import org.springframework.data.neo4j.conversion.support.EntityRepository; -import org.springframework.data.neo4j.conversion.support.EntityWithConvertedAttributes; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Michael J. Simons - * @soundtrack Murray Gold - Doctor Who Season 9 - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = MetaDataDrivenConversionServiceIntegrationTests.Config.class) -public class MetaDataDrivenConversionServiceIntegrationTests { - - @Autowired private GraphDatabaseService graphDatabaseService; - - @Autowired private EntityRepository entityRepository; - - @Test // DATAGRAPH-1131 - public void conversionWithConverterHierarchyShouldWork() { - - ConvertedClass convertedClass = new ConvertedClass(); - convertedClass.setValue("Some value"); - EntityWithConvertedAttributes entity = new EntityWithConvertedAttributes("name"); - entity.setConvertedClass(convertedClass); - entity.setDoubles(Arrays.asList(21.0, 21.0)); - entity.setTheDouble(42.0); - entityRepository.save(entity); - - Result result = graphDatabaseService - .execute("MATCH (e:EntityWithConvertedAttributes) RETURN e.convertedClass, e.doubles, e.theDouble"); - - assertThat(result.hasNext()).isTrue(); - Map row = result.next(); - assertThat(row) // - .containsEntry("e.convertedClass", "n/a") // - .containsEntry("e.doubles", "21.0,21.0") // - .containsEntry("e.theDouble", "that has been a double"); - - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.conversion.support", - repositoryPackages = "org.springframework.data.neo4j.conversion.support") - static class Config {} -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionServiceTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionServiceTests.java deleted file mode 100644 index 870020cfa..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/MetaDataDrivenConversionServiceTests.java +++ /dev/null @@ -1,57 +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.conversion; - -import static org.assertj.core.api.Assertions.*; - -import org.junit.Test; -import org.springframework.data.neo4j.conversion.support.ConvertedClass; -import org.springframework.data.neo4j.conversion.support.Converters; - -/** - * @author Michael J. Simons - * @soundtrack Murray Gold - Doctor Who Season 9 - */ -public class MetaDataDrivenConversionServiceTests { - - @Test - public void shouldDetermineConvertersForClasses() { - MetaDataDrivenConversionService.EntityToGraphTypeMapping entityToGraphTypeMapping = MetaDataDrivenConversionService - .getEntityToGraphTypeMapping(new Converters.DoubleToStringConverter()); - - assertThat(entityToGraphTypeMapping.entityType).isEqualTo(Double.class); - assertThat(entityToGraphTypeMapping.graphType).isEqualTo(String.class); - } - - @Test - public void shouldDetermineConvertersForTypedClasses() { - MetaDataDrivenConversionService.EntityToGraphTypeMapping entityToGraphTypeMapping = MetaDataDrivenConversionService - .getEntityToGraphTypeMapping(new Converters.ListToStringConverter()); - - assertThat(entityToGraphTypeMapping.entityType).isEqualTo(Double.class); - assertThat(entityToGraphTypeMapping.graphType).isEqualTo(String.class); - } - - @Test // DATAGRAPH-1131 - public void shouldWorkWithConvertersInvolvingAbstractBaseClasses() { - MetaDataDrivenConversionService.EntityToGraphTypeMapping entityToGraphTypeMapping = MetaDataDrivenConversionService - .getEntityToGraphTypeMapping(new Converters.ConvertedClassToStringConverter()); - - assertThat(entityToGraphTypeMapping.entityType).isEqualTo(ConvertedClass.class); - assertThat(entityToGraphTypeMapping.graphType).isEqualTo(String.class); - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/Neo4jOgmEntityInstantiatorAdapterTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/Neo4jOgmEntityInstantiatorAdapterTest.java deleted file mode 100644 index f49abce22..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/Neo4jOgmEntityInstantiatorAdapterTest.java +++ /dev/null @@ -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.conversion; - -import static org.assertj.core.api.Assertions.*; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.stream.Stream; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.driver.Config; -import org.neo4j.driver.GraphDatabase; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Label; -import org.neo4j.graphdb.Node; -import org.neo4j.harness.ServerControls; -import org.neo4j.harness.TestServerBuilders; -import org.neo4j.ogm.drivers.bolt.driver.BoltDriver; -import org.neo4j.ogm.session.SessionFactory; -import org.neo4j.procedure.Context; -import org.neo4j.procedure.Name; -import org.neo4j.procedure.Procedure; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.conversion.ogm618.MyNode; -import org.springframework.data.neo4j.conversion.ogm618.MyNodeRepository; -import org.springframework.data.neo4j.conversion.ogm618.ResultHolder; -import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author Michael J. Simons - */ -@ContextConfiguration(classes = { Neo4jOgmEntityInstantiatorAdapterTest.ContextConfig.class }) -@RunWith(SpringRunner.class) -public class Neo4jOgmEntityInstantiatorAdapterTest { - - private static final Config driverConfig = Config.builder().withoutEncryption().build(); - - private static ServerControls serverControls; - private static URI boltURI; - - @BeforeClass - public static void initializeNeo4j() { - - serverControls = TestServerBuilders.newInProcessBuilder() - .withProcedure(Neo4jOgmEntityInstantiatorAdapterTest.ListReturningThing.class) - .withFixture("CREATE (m:MyNode{name: 'All the', things: []})").newServer(); - boltURI = serverControls.boltURI(); - } - - @Autowired - private MyNodeRepository myNodeRepository; - - @Test - public void ctorShouldHandleEmptyArrayFromAttributes() { - - Optional optionalNode = myNodeRepository.findOneByName("All the"); - assertThat(optionalNode).isPresent().get().extracting(MyNode::getThings).asList().isEmpty(); - } - - @Test - public void ctorShouldHandleEmptyArrayFromStoredProcedure() { - - List resultHolders = myNodeRepository.generateListOfNodes(false); - assertThat(resultHolders).isNotNull().hasSize(1); - - assertThat(resultHolders.get(0).getResult()).isNotNull().hasSize(1); - } - - @Test - public void ctorShouldHandleNonEmptyListFromStoredProcedure() { - - List resultHolders = myNodeRepository.generateListOfNodes(true); - assertThat(resultHolders).isNotNull().hasSize(1); - - assertThat(resultHolders.get(0).getResult()).isNotNull().isEmpty(); - } - - public static class ListReturningThing { - - @Context - public GraphDatabaseService db; - - @Procedure("test.generateListOfNodes") - public Stream generateListOfNodes(@Name("empty") boolean empty) { - List result = new ArrayList<>(); - if (!empty) { - db.findNodes(Label.label("MyNode")).forEachRemaining(result::add); - } - return Stream.of(new ListOfNodesResult(result)); - } - - public static class ListOfNodesResult { - public List result; - - public ListOfNodesResult(List result) { - this.result = result; - } - } - } - - @Configuration - @ComponentScan(basePackageClasses = ResultHolder.class) - @EnableNeo4jRepositories(basePackageClasses = ResultHolder.class) - @EnableTransactionManagement - static class ContextConfig { - - @Bean - public PlatformTransactionManager transactionManager() { - return new Neo4jTransactionManager(sessionFactory()); - } - - @Bean - public SessionFactory sessionFactory() { - - return new SessionFactory(new BoltDriver(GraphDatabase.driver(boltURI, driverConfig)), - ResultHolder.class.getPackage().getName()); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/MyNode.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/MyNode.java deleted file mode 100644 index f50262f0f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/MyNode.java +++ /dev/null @@ -1,70 +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.conversion.ogm618; - -import java.util.List; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * @author Michael J. Simons - */ -@NodeEntity -public class MyNode { - - @Id @GeneratedValue - private Long id; - - private String name; - - private List things; - - public MyNode(String name, List things) { - this.name = name; - this.things = things; - } - - public Long getId() { - return id; - } - - public void setId(final Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - public List getThings() { - return things; - } - - public void setThings(List things) { - this.things = things; - } - - @Override - public String toString() { - return "MyNode{" + "id=" + id + ", name='" + name + '\'' + ", things=" + things + '}'; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/MyNodeRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/MyNodeRepository.java deleted file mode 100644 index f2dd8692b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/MyNodeRepository.java +++ /dev/null @@ -1,34 +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.conversion.ogm618; - -import java.util.List; -import java.util.Optional; - -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.repository.Repository; -import org.springframework.data.repository.query.Param; - -/** - * @author Michael J. Simons - */ -public interface MyNodeRepository extends Repository { - - @Query("CALL test.generateListOfNodes({empty})") - List generateListOfNodes(@Param("empty") boolean empty); - - Optional findOneByName(String name); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/ResultHolder.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/ResultHolder.java deleted file mode 100644 index a8ef874ce..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/ogm618/ResultHolder.java +++ /dev/null @@ -1,41 +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.conversion.ogm618; - -import java.util.List; - -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * @author Michael J. Simons - */ -@QueryResult -public class ResultHolder { - private List result; - - public ResultHolder(List result) { - this.result = result; - } - - public List getResult() { - return result; - } - - @Override - public String toString() { - return "ResultHolder{" + "result=" + result + '}'; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/ConvertedClass.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/ConvertedClass.java deleted file mode 100644 index 48763c07a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/ConvertedClass.java +++ /dev/null @@ -1,32 +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.conversion.support; - -/** - * @author Michael J. Simons - * @soundtrack Murray Gold - Doctor Who Season 9 - */ -public class ConvertedClass { - private String value; - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/Converters.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/Converters.java deleted file mode 100644 index 70b5681b0..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/Converters.java +++ /dev/null @@ -1,92 +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.conversion.support; - -import static java.util.stream.Collectors.joining; - -import java.util.List; - -import org.neo4j.ogm.typeconversion.AttributeConverter; - -/** - * Wraps a some converters. - * - * @author Michael J. Simons - * @soundtrack Murray Gold - Doctor Who Season 9 - */ -public final class Converters { - - private Converters() { - } - - /** - * Concrete implementation doesn't matter and is meaningless on purpose. - * - * @param - */ - public static abstract class AbstractObjectToString implements AttributeConverter { - - @Override - public String toGraphProperty(T value) { - return "n/a"; - } - - @Override - public T toEntityAttribute(String value) { - try { - return getTypeClass().newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - protected abstract Class getTypeClass(); - } - - public static class ConvertedClassToStringConverter extends AbstractObjectToString { - - @Override - protected Class getTypeClass() { - return ConvertedClass.class; - } - } - - public static class DoubleToStringConverter implements AttributeConverter { - - @Override - public String toGraphProperty(Double value) { - return "that has been a double"; - } - - @Override - public Double toEntityAttribute(String value) { - return null; - } - } - - public static class ListToStringConverter implements AttributeConverter, String> { - - @Override - public String toGraphProperty(List value) { - return value.stream().map(d -> d.toString()).collect(joining(",")); - } - - @Override - public List toEntityAttribute(String value) { - return null; - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/EntityWithConvertedAttributes.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/EntityWithConvertedAttributes.java deleted file mode 100644 index ef8f083b6..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/EntityWithConvertedAttributes.java +++ /dev/null @@ -1,72 +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.conversion.support; - -import java.util.List; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Property; -import org.neo4j.ogm.annotation.typeconversion.Convert; - -@NodeEntity -public class EntityWithConvertedAttributes { - @Id @GeneratedValue private Long id; - - private String name; - - @Property - @Convert(Converters.ConvertedClassToStringConverter.class) - private ConvertedClass convertedClass; - - @Property - @Convert(Converters.ListToStringConverter.class) - private List doubles; - - @Convert(Converters.DoubleToStringConverter.class) - private Double theDouble; - - public EntityWithConvertedAttributes() {} - - public EntityWithConvertedAttributes(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void setConvertedClass(ConvertedClass convertedClass) { - this.convertedClass = convertedClass; - } - - public void setDoubles(List doubles) { - this.doubles = doubles; - } - - public void setTheDouble(Double theDouble) { - this.theDouble = theDouble; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/EntityWithInvalidProperty.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/EntityWithInvalidProperty.java deleted file mode 100644 index b27983c62..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/EntityWithInvalidProperty.java +++ /dev/null @@ -1,47 +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.domain.invalid; - -import java.time.Year; - -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Property; - -/** - * An entity with invalid properties that should fail serialisation and persistence. - * - * @author Michael J. Simons - * @soundtrack Opeth - Blackwater Park - */ -@NodeEntity -public class EntityWithInvalidProperty { - private Long id; - - // This property would need a converter. - @Property(name = "yearOfBirth") private Year year; - - public EntityWithInvalidProperty(Year year) { - this.year = year; - } - - public Long getId() { - return id; - } - - public Year getYear() { - return year; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/EntityWithInvalidPropertyRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/EntityWithInvalidPropertyRepository.java deleted file mode 100644 index 29d108a53..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/EntityWithInvalidPropertyRepository.java +++ /dev/null @@ -1,24 +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.domain.invalid; - -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Michael J. Simons - * @soundtrack Opeth - Blackwater Park - */ -public interface EntityWithInvalidPropertyRepository extends Neo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/package-info.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/package-info.java deleted file mode 100644 index 56115fafb..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/invalid/package-info.java +++ /dev/null @@ -1,20 +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. - */ -/** - * Contains some invalid entities and repositories, that are used during tests of exception handling and other edge - * cases. - */ -package org.springframework.data.neo4j.domain.invalid; diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/Address.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/Address.java deleted file mode 100644 index 13d39ab25..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/Address.java +++ /dev/null @@ -1,52 +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.domain.sample; - -/** - * @author Mark Angrish - */ -public class Address { - - private String country; - private String city; - private String streetName; - private String streetNo; - - public Address() {} - - public Address(String country, String city, String streetName, String streetNo) { - this.country = country; - this.city = city; - this.streetName = streetName; - this.streetNo = streetNo; - } - - public String getCountry() { - return country; - } - - public String getCity() { - return city; - } - - public String getStreetName() { - return streetName; - } - - public String getStreetNo() { - return streetNo; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/NodeWithUUIDAsId.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/NodeWithUUIDAsId.java deleted file mode 100644 index 9c4ae64d7..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/NodeWithUUIDAsId.java +++ /dev/null @@ -1,46 +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.domain.sample; - -import java.util.UUID; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.neo4j.ogm.id.UuidStrategy; -import org.neo4j.ogm.typeconversion.UuidStringConverter; - -/** - * @author Michael J. Simons - */ -public class NodeWithUUIDAsId { - - @Id @GeneratedValue(strategy = UuidStrategy.class) @Convert(UuidStringConverter.class) private UUID myNiceId; - - private String someProperty; - - public NodeWithUUIDAsId(String someProperty) { - this.someProperty = someProperty; - } - - public UUID getMyNiceId() { - return myNiceId; - } - - public String getSomeProperty() { - return someProperty; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/Role.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/Role.java deleted file mode 100644 index 27a3e451c..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/Role.java +++ /dev/null @@ -1,91 +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.domain.sample; - -import java.util.UUID; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * Sample domain class representing roles. - * - * @author Mark Angrish - * @author Michael J. Simons - */ -@NodeEntity -public class Role { - - private static final String PREFIX = "ROLE_"; - - @Id @GeneratedValue private Long id; - - private UUID uuid; - private String name; - - /** - * Creates a new instance of {@code Role}. - */ - public Role() {} - - /** - * Creates a new preconfigured {@code Role}. - * - * @param name - */ - public Role(final String name) { - this.name = name; - } - - /** - * Returns the id. - * - * @return - */ - public Long getId() { - - return id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - - return PREFIX + name; - } - - /** - * Returns whether the role is to be considered new. - * - * @return - */ - public boolean isNew() { - - return id == null; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/SampleEntity.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/SampleEntity.java deleted file mode 100644 index 4907b4158..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/SampleEntity.java +++ /dev/null @@ -1,49 +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.domain.sample; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.springframework.util.Assert; - -/** - * @author Mark Angrish - * @author Mark Paluch - * @author Michael J. Simons - */ -@NodeEntity -public class SampleEntity { - - @Id @GeneratedValue protected Long id; - private String first; - private String second; - - protected SampleEntity() { - - } - - public SampleEntity(String first, String second) { - Assert.notNull(first, "First must not be null!"); - Assert.notNull(second, "Second mot be null!"); - this.first = first; - this.second = second; - } - - public Long getId() { - return id; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/SpecialUser.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/SpecialUser.java deleted file mode 100644 index 74c2d6b07..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/SpecialUser.java +++ /dev/null @@ -1,20 +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.domain.sample; - -public class SpecialUser extends User { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/User.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/User.java deleted file mode 100644 index 41a63869d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/domain/sample/User.java +++ /dev/null @@ -1,367 +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.domain.sample; - -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Relationship; -import org.neo4j.ogm.annotation.Version; -import org.neo4j.ogm.annotation.typeconversion.DateString; - -/** - * Domain class representing a person emphasizing the use of {@code AbstractEntity}. No declaration of an id is - * required. The id is typed by the parameterizable superclass. - */ -@NodeEntity -public class User { - - @Id @GeneratedValue private Long id; - - private String firstname; - - private String lastname; - - @Version Long version; - - private int age; - - private boolean active; - - @DateString private Date createdAt; - - private String emailAddress; - - @Relationship private Set colleagues; - - @Relationship private Set roles; - - private User manager; - - private Address address; - - private byte[] binaryData; - - private Set attributes; - - @DateString private Date dateOfBirth; - - /** - * Creates a new empty instance of {@code User}. - */ - public User() { - this(null, null, null); - } - - /** - * Creates a new instance of {@code User} with preinitialized values for firstname, lastname, email address and roles. - * - * @param firstname - * @param lastname - * @param emailAddress - * @param roles - */ - public User(String firstname, String lastname, String emailAddress, Role... roles) { - - this.firstname = firstname; - this.lastname = lastname; - this.emailAddress = emailAddress; - this.active = true; - this.roles = new HashSet<>(Arrays.asList(roles)); - this.colleagues = new HashSet<>(); - this.attributes = new HashSet<>(); - this.createdAt = new Date(); - } - - /** - * @return the id - */ - public Long getId() { - - return id; - } - - /** - * @param id the id to set - */ - public void setId(Long id) { - - this.id = id; - } - - /** - * Returns the firstname. - * - * @return the firstname - */ - public String getFirstname() { - - return firstname; - } - - /** - * Sets the firstname. - * - * @param firstname the firstname to set - */ - public void setFirstname(final String firstname) { - - this.firstname = firstname; - } - - /** - * Returns the lastname. - * - * @return the lastname - */ - public String getLastname() { - - return lastname; - } - - /** - * Sets the lastname. - * - * @param lastname the lastname to set - */ - public void setLastname(String lastname) { - - this.lastname = lastname; - } - - /** - * @return the age - */ - public int getAge() { - return age; - } - - /** - * @param age the age to set - */ - public void setAge(int age) { - this.age = age; - } - - /** - * Returns the email address. - * - * @return the emailAddress - */ - public String getEmailAddress() { - - return emailAddress; - } - - /** - * Sets the email address. - * - * @param emailAddress the emailAddress to set - */ - public void setEmailAddress(String emailAddress) { - - this.emailAddress = emailAddress; - } - - /** - * @param active the active to set - */ - public void setActive(boolean active) { - this.active = active; - } - - /** - * @return the active - */ - public boolean isActive() { - return active; - } - - /** - * Returns the user's roles. - * - * @return the roles - */ - public Set getRoles() { - - return roles; - } - - /** - * Gives the user a role. Adding a role the user already owns is a no-op. - */ - public void addRole(Role role) { - - roles.add(role); - } - - /** - * Revokes a role from a user. - * - * @param role - */ - public void removeRole(Role role) { - - roles.remove(role); - } - - /** - * Returns the colleagues of the user. - * - * @return the colleagues - */ - public Set getColleagues() { - - return colleagues; - } - - /** - * Adds a new colleague to the user. Adding the user himself as colleague is a no-op. - * - * @param collegue - */ - public void addColleague(User collegue) { - - // Prevent from adding the user himself as colleague. - if (this.equals(collegue)) { - return; - } - - colleagues.add(collegue); - collegue.getColleagues().add(this); - } - - /** - * Removes a colleague from the list of colleagues. - * - * @param colleague - */ - public void removeColleague(User colleague) { - - colleagues.remove(colleague); - colleague.getColleagues().remove(this); - } - - /** - * @return the manager - */ - public User getManager() { - - return manager; - } - - /** - * @param manager the manager to set - */ - public void setManager(User manager) { - - this.manager = manager; - } - - /** - * @return the createdAt - */ - public Date getCreatedAt() { - return createdAt; - } - - /** - * @return the address - */ - public Address getAddress() { - return address; - } - - /** - * @param address the address to set - */ - public void setAddress(Address address) { - this.address = address; - } - - /** - * @param binaryData the binaryData to set - */ - public void setBinaryData(byte[] binaryData) { - this.binaryData = binaryData; - } - - /** - * @return the binaryData - */ - public byte[] getBinaryData() { - return binaryData; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - - if (!(obj instanceof User)) { - return false; - } - - User that = (User) obj; - - if (null == this.getId() || null == that.getId()) { - return false; - } - - return this.getId().equals(that.getId()); - } - - /** - * @return the attributes - */ - public Set getAttributes() { - return attributes; - } - - /** - * @param attributes the attributes to set - */ - public void setAttributes(Set attributes) { - this.attributes = attributes; - } - - public Date getDateOfBirth() { - return dateOfBirth; - } - - public void setDateOfBirth(Date dateOfBirth) { - this.dateOfBirth = dateOfBirth; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - - return "User: " + getId() + ", " + getFirstname() + " " + getLastname() + ", " + getEmailAddress(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/EventPublisher.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/EventPublisher.java deleted file mode 100644 index e00bd8d12..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/EventPublisher.java +++ /dev/null @@ -1,52 +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.events; - -import org.neo4j.ogm.session.event.Event; -import org.neo4j.ogm.session.event.EventListenerAdapter; -import org.springframework.context.ApplicationEventPublisher; - -/** - * @author Mark Angrish - */ -public class EventPublisher extends EventListenerAdapter { - - private final ApplicationEventPublisher publisher; - - public EventPublisher(ApplicationEventPublisher publisher) { - this.publisher = publisher; - } - - @Override - public void onPreSave(Event event) { - this.publisher.publishEvent(new PreSaveEvent(event)); - } - - @Override - public void onPostSave(Event event) { - this.publisher.publishEvent(new PostSaveEvent(event)); - } - - @Override - public void onPreDelete(Event event) { - this.publisher.publishEvent(new PreDeleteEvent(event)); - } - - @Override - public void onPostDelete(Event event) { - this.publisher.publishEvent(new PostDeleteEvent(event)); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/ModificationEvent.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/ModificationEvent.java deleted file mode 100644 index 421204edc..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/ModificationEvent.java +++ /dev/null @@ -1,34 +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.events; - -import org.neo4j.ogm.session.event.Event; - -/** - * Created by markangrish on 22/09/2016. - */ -public class ModificationEvent { - - private Event source; - - public ModificationEvent(Event source) { - this.source = source; - } - - public Event getSource() { - return source; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/Neo4jModificationEventListener.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/Neo4jModificationEventListener.java deleted file mode 100644 index 7641c5a88..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/Neo4jModificationEventListener.java +++ /dev/null @@ -1,91 +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.events; - -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; - -/** - * Created by markangrish on 22/09/2016. - */ -@Component -public class Neo4jModificationEventListener { - - private int preSaveEventCount = 0; - private int postSaveEventCount = 0; - private int preDeleteEventCount = 0; - private int postDeleteEventCount = 0; - private PreSaveEvent preSaveEvent; - private PostSaveEvent postSaveEvent; - private PreDeleteEvent preDeleteEvent; - private PostDeleteEvent postDeleteEvent; - - @EventListener - public void onPreSaveEvent(PreSaveEvent event) { - preSaveEvent = event; - preSaveEventCount++; - } - - @EventListener - public void onPostSaveEvent(PostSaveEvent event) { - postSaveEventCount++; - postSaveEvent = event; - } - - @EventListener - public void onPreDeleteEvent(PreDeleteEvent event) { - preDeleteEventCount++; - preDeleteEvent = event; - } - - @EventListener - public void onPostDeleteEvent(PostDeleteEvent event) { - postDeleteEventCount++; - postDeleteEvent = event; - } - - public boolean receivedPreSaveEvent() { - return preSaveEventCount == 1; - } - - public boolean receivedPostSaveEvent() { - return postSaveEventCount == 1; - } - - public boolean receivedPreDeleteEvent() { - return preDeleteEventCount == 1; - } - - public boolean receivedPostDeleteEvent() { - return postDeleteEventCount == 1; - } - - public PreSaveEvent getPreSaveEvent() { - return preSaveEvent; - } - - public PostSaveEvent getPostSaveEvent() { - return postSaveEvent; - } - - public PreDeleteEvent getPreDeleteEvent() { - return preDeleteEvent; - } - - public PostDeleteEvent getPostDeleteEvent() { - return postDeleteEvent; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PostDeleteEvent.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PostDeleteEvent.java deleted file mode 100644 index 4add16284..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PostDeleteEvent.java +++ /dev/null @@ -1,28 +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.events; - -import org.neo4j.ogm.session.event.Event; - -/** - * Created by markangrish on 22/09/2016. - */ -public class PostDeleteEvent extends ModificationEvent { - - public PostDeleteEvent(Event event) { - super(event); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PostSaveEvent.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PostSaveEvent.java deleted file mode 100644 index 94e2b7506..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PostSaveEvent.java +++ /dev/null @@ -1,28 +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.events; - -import org.neo4j.ogm.session.event.Event; - -/** - * Created by markangrish on 22/09/2016. - */ -public class PostSaveEvent extends ModificationEvent { - - public PostSaveEvent(Event event) { - super(event); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PreDeleteEvent.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PreDeleteEvent.java deleted file mode 100644 index 5488e4fb1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PreDeleteEvent.java +++ /dev/null @@ -1,28 +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.events; - -import org.neo4j.ogm.session.event.Event; - -/** - * Created by markangrish on 22/09/2016. - */ -public class PreDeleteEvent extends ModificationEvent { - - public PreDeleteEvent(Event event) { - super(event); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PreSaveEvent.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PreSaveEvent.java deleted file mode 100644 index 2798738af..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/events/PreSaveEvent.java +++ /dev/null @@ -1,28 +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.events; - -import org.neo4j.ogm.session.event.Event; - -/** - * Created by markangrish on 22/09/2016. - */ -public class PreSaveEvent extends ModificationEvent { - - public PreSaveEvent(Event event) { - super(event); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/FriendService.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/FriendService.java deleted file mode 100644 index df41d4023..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/FriendService.java +++ /dev/null @@ -1,59 +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.examples.friends; - -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.examples.friends.domain.Friendship; -import org.springframework.data.neo4j.examples.friends.domain.Person; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Luanne Misquitta - * @author Mark Angrish - */ -@Service -public class FriendService { - - @Autowired Session session; - - @Transactional - public void createPersonAndFriends() { - Person john = new Person(); - john.setFirstName("John"); - session.save(john); - - Person bob = new Person(); - bob.setFirstName("Bob"); - session.save(bob); - - Person bill = new Person(); - bill.setFirstName("Bill"); - session.save(bill); - - john = session.load(Person.class, john.getId()); - bob = session.load(Person.class, bob.getId()); - Friendship friendship1 = john.addFriend(bob); - friendship1.setTimestamp(System.currentTimeMillis()); - session.save(john); - john = session.load(Person.class, john.getId()); - bill = session.load(Person.class, bill.getId()); - Friendship friendship2 = john.addFriend(bill); - friendship2.setTimestamp(System.currentTimeMillis()); - session.save(john); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/FriendTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/FriendTests.java deleted file mode 100644 index 1a1df591f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/FriendTests.java +++ /dev/null @@ -1,97 +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.examples.friends; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.examples.friends.domain.Friendship; -import org.springframework.data.neo4j.examples.friends.domain.Person; -import org.springframework.data.neo4j.examples.friends.repo.FriendshipRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Luanne Misquitta - * @author Mark Angrish - * @author Michael J. Simons - */ -@ContextConfiguration(classes = FriendTests.FriendContext.class) -@RunWith(SpringRunner.class) -public class FriendTests { - - @Autowired GraphDatabaseService graphDatabaseService; - @Autowired Session session; - @Autowired FriendshipRepository friendshipRepository; - @Autowired FriendService friendService; - - @Before - public void cleanUpDatabase() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Test // DATAGRAPH-703 - @Transactional - public void savingPersonWhenTransactionalShouldWork() { - friendService.createPersonAndFriends(); - - session.clear(); - Person john = session.loadAll(Person.class, new Filter("firstName", ComparisonOperator.EQUALS, "John")).iterator() - .next(); - assertThat(john).isNotNull(); - assertThat(john.getFriendships().size()).isEqualTo(2); - } - - @Test // DATAGRAPH-694 - @Transactional - public void circularParametersShouldNotProduceInfiniteRecursion() { - Person john = new Person(); - john.setFirstName("John"); - session.save(john); - - Person bob = new Person(); - bob.setFirstName("Bob"); - session.save(bob); - - Friendship friendship1 = john.addFriend(bob); - friendship1.setTimestamp(System.currentTimeMillis()); - session.save(john); - - Friendship queriedFriendship = friendshipRepository.getFriendship(john, bob); - - assertThat(queriedFriendship).isNotNull(); - assertThat(queriedFriendship.getPersonStartNode().getFirstName()) - .isEqualTo("John"); - assertThat(queriedFriendship.getPersonEndNode().getFirstName()).isEqualTo("Bob"); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.examples.friends.domain", - repositoryPackages = "org.springframework.data.neo4j.examples.friends.repo") - @ComponentScan(basePackageClasses = FriendService.class) - static class FriendContext {} -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/domain/Friendship.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/domain/Friendship.java deleted file mode 100644 index 2c5f724a1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/domain/Friendship.java +++ /dev/null @@ -1,75 +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.examples.friends.domain; - -import org.neo4j.ogm.annotation.EndNode; -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.RelationshipEntity; -import org.neo4j.ogm.annotation.StartNode; - -/** - * @author Luanne Misquitta - */ -@RelationshipEntity(type = "IS_FRIEND") -public class Friendship { - - @Id @GeneratedValue private Long id; - - @StartNode private Person personStartNode; - @EndNode private Person personEndNode; - - private long timestamp; - - public Friendship() {} - - public Friendship(Person personStartNode, Person personEndNode) { - this.personStartNode = personStartNode; - this.personEndNode = personEndNode; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Person getPersonStartNode() { - return personStartNode; - } - - public void setPersonStartNode(Person personStartNode) { - this.personStartNode = personStartNode; - } - - public Person getPersonEndNode() { - return personEndNode; - } - - public void setPersonEndNode(Person personEndNode) { - this.personEndNode = personEndNode; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/domain/Person.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/domain/Person.java deleted file mode 100644 index e6d1906cb..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/domain/Person.java +++ /dev/null @@ -1,78 +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.examples.friends.domain; - -import java.util.HashSet; -import java.util.Set; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Relationship; - -/** - * @author Luanne Misquitta - * @author Michael J. Simons - */ -@NodeEntity -public class Person { - @Id @GeneratedValue Long id; - - private String firstName; - private String lastName; - - @Relationship(type = "IS_FRIEND") private Set friendships = new HashSet<>(); - - public Person() {} - - public Friendship addFriend(Person newFriend) { - Friendship friendship = new Friendship(this, newFriend); - this.friendships.add(friendship); - return friendship; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public Set getFriendships() { - return friendships; - } - - public void setFriendships(Set friendships) { - this.friendships = friendships; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/repo/FriendshipRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/repo/FriendshipRepository.java deleted file mode 100644 index 5308476c3..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/friends/repo/FriendshipRepository.java +++ /dev/null @@ -1,31 +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.examples.friends.repo; - -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.examples.friends.domain.Friendship; -import org.springframework.data.neo4j.examples.friends.domain.Person; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Luanne Misquitta - */ -public interface FriendshipRepository extends Neo4jRepository { - - @Query("MATCH (person1)-[rel:IS_FRIEND]->(person2) WHERE ID(person1)=$0 AND ID(person2)=$1 return rel") - Friendship getFriendship(Person person1, Person person2); - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyContextConfiguration.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyContextConfiguration.java deleted file mode 100644 index 30d3b4a1e..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyContextConfiguration.java +++ /dev/null @@ -1,29 +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.examples.galaxy; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; - -/** - * @author Michael J. Simons - */ -@Neo4jIntegrationTest(domainPackages = { "org.springframework.data.neo4j.examples.galaxy.domain", - "org.springframework.data.neo4j.queries.ogmgh552" }, - repositoryPackages = { "org.springframework.data.neo4j.examples.galaxy.repo", - "org.springframework.data.neo4j.queries.ogmgh552" }) -@ComponentScan("org.springframework.data.neo4j.examples.galaxy.service") -public class GalaxyContextConfiguration {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyServiceTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyServiceTests.java deleted file mode 100644 index 9cf6abb9c..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/GalaxyServiceTests.java +++ /dev/null @@ -1,304 +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.examples.galaxy; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Optional; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.ogm.cypher.query.Pagination; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.examples.galaxy.domain.World; -import org.springframework.data.neo4j.examples.galaxy.service.GalaxyService; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.*; - -/** - * @author Vince Bickers - * @author Mark Paluch - * @author Michael J. Simons - */ -@ContextConfiguration(classes = GalaxyContextConfiguration.class) -@RunWith(SpringRunner.class) -@Transactional -public class GalaxyServiceTests { - - @Autowired - private GalaxyService galaxyService; - - @Before - public void setUp() { - galaxyService.deleteAll(); - assertThat(galaxyService.getNumberOfWorlds()).isEqualTo(0); - } - - @Test - public void shouldAllowDirectWorldCreation() { - - World myWorld = galaxyService.createWorld("mine", 0); - Collection foundWorlds = (Collection) galaxyService.getAllWorlds(); - - assertThat(foundWorlds.size()).isEqualTo(1); - World mine = foundWorlds.iterator().next(); - - assertThat(mine.getName()).isEqualTo(myWorld.getName()); - } - - @Test - public void shouldHaveCorrectNumberOfWorlds() { - galaxyService.makeSomeWorlds(); - assertThat(galaxyService.getNumberOfWorlds()).isEqualTo(13); - } - - @Test - public void createAllWorldsAtOnce() { - galaxyService.makeAllWorldsAtOnce(); - assertThat(galaxyService.getNumberOfWorlds()).isEqualTo(13); - - World earth = galaxyService.findWorldByName("Earth"); - World mars = galaxyService.findWorldByName("Mars"); - - assertThat(mars.canBeReachedFrom(earth)).isTrue(); - assertThat(earth.canBeReachedFrom(mars)).isTrue(); - } - - @Test - public void shouldFindWorldsById() { - galaxyService.makeSomeWorlds(); - - for (World world : galaxyService.getAllWorlds()) { - Optional foundWorld = galaxyService.findWorldById(world.getId()); - assertThat(foundWorld.isPresent()).isTrue(); - } - } - - @Test - public void shouldFindWorldsByName() { - galaxyService.makeSomeWorlds(); - for (World world : galaxyService.getAllWorlds()) { - World foundWorld = galaxyService.findWorldByName(world.getName()); - assertThat(foundWorld).isNotNull(); - } - } - - @Test - public void shouldReachMarsFromEarth() { - galaxyService.makeSomeWorlds(); - - World earth = galaxyService.findWorldByName("Earth"); - World mars = galaxyService.findWorldByName("Mars"); - - assertThat(mars.canBeReachedFrom(earth)).isTrue(); - assertThat(earth.canBeReachedFrom(mars)).isTrue(); - } - - @Test - public void shouldFindAllWorlds() { - - Collection madeWorlds = galaxyService.makeSomeWorlds(); - Iterable foundWorlds = galaxyService.getAllWorlds(); - - int countOfFoundWorlds = 0; - for (World foundWorld : foundWorlds) { - assertThat(madeWorlds.contains(foundWorld)).isTrue(); - countOfFoundWorlds++; - } - - assertThat(countOfFoundWorlds).isEqualTo(madeWorlds.size()); - } - - @SuppressWarnings("unchecked") - @Test - public void shouldFindWorldsWith1Moon() { - galaxyService.makeSomeWorlds(); - - for (World worldWithOneMoon : galaxyService.findAllByNumberOfMoons(1)) { - assertThat(worldWithOneMoon.getName()).satisfiesAnyOf(s -> { - assertThat(s).contains("Earth"); - }, s -> { - assertThat(s).contains("Midgard"); - }); - } - } - - @Test - public void shouldNotFindKrypton() { - galaxyService.makeSomeWorlds(); - World krypton = galaxyService.findWorldByName("Krypton"); - assertThat(krypton).isNull(); - } - - @Test - public void shouldSupportPaging() { - - List worlds = (List) galaxyService.makeAllWorldsAtOnce(); - - int count = worlds.size(); - int PAGE_SIZE = 3; - int pages = count / PAGE_SIZE + 1; - long n = 0; - for (World world : worlds) { - n += world.getId(); - } - - for (int page = 0; page < pages; page++) { - Iterable paged = galaxyService - .findAllWorlds(new Pagination(page, PAGE_SIZE)); - for (World world : paged) { - n -= world.getId(); - } - } - - assertThat(n).isEqualTo(0L); - } - - @Test - public void shouldDetectNotOnLastPage() { - - int count = galaxyService.makeAllWorldsAtOnce().size(); - - assertThat(13).isEqualTo(count); - - Pageable pageable = PageRequest.of(2, 3); - Page worlds = galaxyService.findAllWorlds(pageable); - - assertThat(worlds.hasNext()).isTrue(); - } - - @Test - public void shouldDetectLastPage() { - - int count = galaxyService.makeAllWorldsAtOnce().size(); - - assertThat(13).isEqualTo(count); - - Pageable pageable = PageRequest.of(4, 3); - Page worlds = galaxyService.findAllWorlds(pageable); - - assertThat(worlds.hasNext()).isFalse(); - } - - @Test - public void shouldPageAllWorlds() { - - long sum = 0; - List worlds = (List) galaxyService.makeAllWorldsAtOnce(); - for (World world : worlds) { - sum += world.getId(); - } - // note: this doesn't work, because deleted node ids are not reclaimed - // long sum = (size * size - size) / 2; // 0-based node ids - - Pageable pageable = PageRequest.of(0, 3); - - for (; ; ) { - Page page = galaxyService.findAllWorlds(pageable); - for (World world : page) { - sum -= world.getId(); - } - if (!page.hasNext()) { - break; - } - pageable = pageable.next(); - } - - assertThat(sum).isEqualTo(0); - } - - @Test - public void shouldPageAllWorldsSorted() { - - List worlds = (List) galaxyService.makeAllWorldsAtOnce(); - int count = worlds.size(); - assertThat(13).isEqualTo(count); - - String[] sortedNames = getNamesSorted(worlds); - - Pageable pageable = PageRequest.of(0, 3, Sort.Direction.ASC, "name"); - - int i = 0; - for (; ; ) { - Page page = galaxyService.findAllWorlds(pageable); - for (World world : page) { - assertThat(world.getName()).isEqualTo(sortedNames[i]); - count--; - i++; - } - if (!page.hasNext()) { - break; - } - pageable = pageable.next(); - } - - assertThat(count).isEqualTo(0); - } - - @Test - public void shouldIterateAllWorldsSorted() { - - List worlds = (List) galaxyService.makeAllWorldsAtOnce(); - int count = worlds.size(); - assertThat(13).isEqualTo(count); - - String[] sortedNames = getNamesSorted(worlds); - - Sort sort = Sort.by(Sort.Direction.ASC, "name"); - int i = 0; - for (World world : galaxyService.findAllWorlds(sort)) { - assertThat(world.getName()).isEqualTo(sortedNames[i]); - count--; - i++; - } - - assertThat(count).isEqualTo(0); - } - - @Test // DATAGRAPH-783 - public void shouldFindWorldWithRadius() { - galaxyService.deleteAll(); - World earth = new World("Earth", 1); - earth.setRadius(6371.0f); - galaxyService.create(earth); - - earth = galaxyService.findByName("Earth"); - assertThat(earth.getRadius()).isEqualTo(Float.valueOf(6371.0f)); - } - - private String[] getNamesSorted(List worlds) { - List names = new ArrayList(); - - for (World world : worlds) { - names.add(world.getName()); - } - - String[] sortedNames = names.toArray(new String[] {}); - Arrays.sort(sortedNames); - return sortedNames; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/WorldRepositoryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/WorldRepositoryTests.java deleted file mode 100644 index 22d3cea3b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/WorldRepositoryTests.java +++ /dev/null @@ -1,100 +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.examples.galaxy; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.IncorrectResultSizeDataAccessException; -import org.springframework.data.neo4j.examples.galaxy.domain.World; -import org.springframework.data.neo4j.examples.galaxy.repo.WorldRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.support.TransactionTemplate; - -import static org.assertj.core.api.Assertions.*; - -/** - * @author Nicolas Mervaillie - * @author Mark Angrish - * @author Gerrit Meier - * @author Michael J. Simons - */ -@ContextConfiguration(classes = GalaxyContextConfiguration.class) -@RunWith(SpringRunner.class) -public class WorldRepositoryTests { - - @Autowired - WorldRepository worldRepository; - - boolean failed = false; - - @Test // DATAGRAPH-951 - public void multipleThreadsResultsGetMixedUp() throws Exception { - - World world1 = new World("world 1", 1); - worldRepository.save(world1, 0); - - World world2 = new World("world 2", 2); - worldRepository.save(world2, 0); - - int iterations = 10; - - ExecutorService service = Executors.newFixedThreadPool(2); - final CountDownLatch countDownLatch = new CountDownLatch(iterations * 2); - - for (int i = 0; i < iterations; i++) { - - service.execute(() -> { - World world = worldRepository.findByName("world 1"); - - if (!"world 1".equals(world.getName())) { - failed = true; - } - countDownLatch.countDown(); - }); - - service.execute(() -> { - - World world = worldRepository.findByName("world 2"); - - if (!"world 2".equals(world.getName())) { - failed = true; - } - countDownLatch.countDown(); - }); - } - countDownLatch.await(); - assertThat(failed).isFalse(); - } - - @Test(expected = IncorrectResultSizeDataAccessException.class) // DATAGRAPH-948 - public void findByNameSingleResult() { - World world1 = new World("world 1", 1); - worldRepository.save(world1, 0); - - World world2 = new World("world 1", 2); - worldRepository.save(world2, 0); - - // there are 2 results, 1 is returned instead of IncorrectResultSizeDataAccessException thrown - worldRepository.findByName("world 1"); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/domain/World.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/domain/World.java deleted file mode 100644 index 0af42d36b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/domain/World.java +++ /dev/null @@ -1,131 +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.examples.galaxy.domain; - -import java.util.HashSet; -import java.util.Set; - -import org.neo4j.ogm.annotation.Relationship; - -/** - * @author Vince Bickers - * @author Luanne Misquitta - */ -public class World { - - private final static String REACHABLE_BY_ROCKET = "REACHABLE_BY_ROCKET"; - - private Long id; - - private String name; - - private int moons; - - private Float radius; - - private Long updated; - - public Long getUpdated() { - return updated; - } - - public void setUpdated(long updated) { - this.updated = updated; - } - - @Relationship(type = REACHABLE_BY_ROCKET, - direction = "UNDIRECTED") private Set reachableByRocket = new HashSet<>(); - - public World(String name, int moons) { - this.name = name; - this.moons = moons; - } - - public World() {} - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public int getMoons() { - return moons; - } - - public void addRocketRouteTo(World otherWorld) { - reachableByRocket.add(otherWorld); - // symmetric relationship. - otherWorld.reachableByRocket.add(this); // bi-directional in domain. - } - - public Set getReachableByRocket() { - return this.reachableByRocket; - } - - public void setReachableByRocket(Set reachableByRocket) { - this.reachableByRocket.clear(); - this.reachableByRocket = reachableByRocket; - } - - public boolean canBeReachedFrom(World otherWorld) { - for (World world : reachableByRocket) { - if (world.equals(otherWorld)) { - return true; - } - } - return false; - } - - public Float getRadius() { - return radius; - } - - public void setRadius(Float radius) { - this.radius = radius; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - World world = (World) o; - - if (moons != world.moons) - return false; - if (id != null ? !id.equals(world.id) : world.id != null) - return false; - return !(name != null ? !name.equals(world.name) : world.name != null); - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + moons; - return result; - } - - @Override - public String toString() { - return String.format("World{name='%s', moons=%d}", name, moons); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/repo/WorldRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/repo/WorldRepository.java deleted file mode 100644 index a7b830c13..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/repo/WorldRepository.java +++ /dev/null @@ -1,39 +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.examples.galaxy.repo; - -import org.neo4j.ogm.model.Result; -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.examples.galaxy.domain.World; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Vince Bickers - * @author Luanne Misquitta - */ -@Repository -public interface WorldRepository extends Neo4jRepository { - - @Query("MATCH (n:World) SET n.updated=timestamp()") - void touchAllWorlds(); - - @Query("MATCH (n:World) SET n.updated=timestamp()") - Result touchAllWorldsWithStatistics(); - - World findByName(String name); - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/service/GalaxyService.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/service/GalaxyService.java deleted file mode 100644 index f25c0e6e3..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/galaxy/service/GalaxyService.java +++ /dev/null @@ -1,189 +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.examples.galaxy.service; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Optional; - -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.neo4j.ogm.cypher.query.Pagination; -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.examples.galaxy.domain.World; -import org.springframework.data.neo4j.examples.galaxy.repo.WorldRepository; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Vince Bickers - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - */ -@Service -@Transactional -public class GalaxyService { - - @Autowired private WorldRepository worldRepository; - - @Autowired Session session; - - public long getNumberOfWorlds() { - return worldRepository.count(); - } - - public World createWorld(String name, int moons) { - return worldRepository.save(new World(name, moons)); - } - - public World create(World world) { - return worldRepository.save(world); - } - - public Iterable getAllWorlds() { - return worldRepository.findAll(); - } - - public Optional findWorldById(Long id) { - return worldRepository.findById(id); - } - - public World findWorldByName(String name) { - Iterable worlds = findByProperty("name", name); - if (worlds.iterator().hasNext()) { - return worlds.iterator().next(); - } else { - return null; - } - } - - public Iterable findAllByNumberOfMoons(int numberOfMoons) { - return findByProperty("moons", numberOfMoons); - } - - public Collection makeSomeWorlds() { - - Collection worlds = new ArrayList(); - - // Solar worlds - worlds.add(createWorld("Mercury", 0)); - worlds.add(createWorld("Venus", 0)); - - World earth = createWorld("Earth", 1); - World mars = createWorld("Mars", 2); - - mars.addRocketRouteTo(earth); - - // todo: handle bi-directional automatically - // earth.addRocketRouteTo(mars); - - // this is a bit silly - worldRepository.save(mars); - - // todo: handle-bidirectional automatically - // worldRepository.save(earth); - - worlds.add(earth); - worlds.add(mars); - - worlds.add(createWorld("Jupiter", 63)); - worlds.add(createWorld("Saturn", 62)); - worlds.add(createWorld("Uranus", 27)); - worlds.add(createWorld("Neptune", 13)); - - // Norse worlds - worlds.add(createWorld("Alfheimr", 0)); - worlds.add(createWorld("Midgard", 1)); - worlds.add(createWorld("Muspellheim", 2)); - worlds.add(createWorld("Asgard", 63)); - worlds.add(createWorld("Hel", 62)); - - return worlds; - } - - // not in original - public Collection makeAllWorldsAtOnce() { - - Collection worlds = new ArrayList(); - - // Solar worlds - - worlds.add(new World("Mercury", 0)); - worlds.add(new World("Venus", 0)); - - World earth = new World("Earth", 1); - World mars = new World("Mars", 2); - - mars.addRocketRouteTo(earth); - earth.addRocketRouteTo(mars); - - worlds.add(earth); - worlds.add(mars); - - worlds.add(new World("Jupiter", 63)); - worlds.add(new World("Saturn", 62)); - worlds.add(new World("Uranus", 27)); - worlds.add(new World("Neptune", 13)); - - // Norse worlds - worlds.add(new World("Alfheimr", 0)); - worlds.add(new World("Midgard", 1)); - worlds.add(new World("Muspellheim", 2)); - worlds.add(new World("Asgard", 63)); - worlds.add(new World("Hel", 62)); - - worldRepository.saveAll(worlds); - - return worlds; - } - - public void deleteAll() { - worldRepository.deleteAll(); - } - - private Iterable findByProperty(String propertyName, Object propertyValue) { - return session.loadAll(World.class, new Filter(propertyName, ComparisonOperator.EQUALS, propertyValue)); - } - - public Iterable findByProperty(String propertyName, Object propertyValue, int depth) { - return session.loadAll(World.class, new Filter(propertyName, ComparisonOperator.EQUALS, propertyValue), depth); - } - - public Iterable findAllWorlds(Pagination paging) { - return session.loadAll(World.class, paging, 0); - } - - public Iterable findAllWorlds(Sort sort) { - return worldRepository.findAll(sort, 0); - } - - public Page findAllWorlds(Pageable pageable) { - return worldRepository.findAll(pageable, 0); - } - - public Iterable findAllWorlds(Sort sort, int depth) { - return worldRepository.findAll(sort, depth); - } - - public World findByName(String name) { - return worldRepository.findByName(name); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/JSR303Tests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/JSR303Tests.java deleted file mode 100644 index 3f9a95026..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/JSR303Tests.java +++ /dev/null @@ -1,107 +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.examples.jsr303; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.examples.jsr303.domain.Adult; -import org.springframework.data.neo4j.examples.jsr303.service.AdultService; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.http.MediaType; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * @author Vince Bickers - * @author Mark Angrish - * @author Michael J. Simons - */ -@ContextConfiguration(classes = { WebConfiguration.class, JSR303Tests.JSR303Context.class }) -@WebAppConfiguration -@RunWith(SpringRunner.class) -public class JSR303Tests { - - private static final ObjectMapper objectMapper = new ObjectMapper(); - - @Autowired private AdultService service; - - @Autowired WebApplicationContext wac; - - private MockMvc mockMvc; - - @Before - public void setUp() { - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); - } - - @Test - public void testCanCreateAnAdult() throws Exception { - - Adult adult = new Adult("Peter", 18); - String json = objectMapper.writeValueAsString(adult); - - mockMvc.perform(post("/adults").contentType(MediaType.APPLICATION_JSON).content(json)).andExpect(status().isOk()); - } - - @Test - public void testCantCreateAnAdultUnderEighteen() throws Exception { - - Adult adult = new Adult("Peter", 16); - String json = objectMapper.writeValueAsString(adult); - - mockMvc.perform(post("/adults").contentType(MediaType.APPLICATION_JSON).content(json)) - .andExpect(status().isBadRequest()); - } - - @Test - public void testCantCreateAnAdultWithNoName() throws Exception { - - Adult adult = new Adult(null, 21); - String json = objectMapper.writeValueAsString(adult); - - mockMvc.perform(post("/adults").contentType(MediaType.APPLICATION_JSON).content(json)) - .andExpect(status().isBadRequest()); - } - - @Test - public void testCantCreateAnAdultWitAShortName() throws Exception { - - Adult adult = new Adult("A", 21); - String json = objectMapper.writeValueAsString(adult); - - mockMvc.perform(post("/adults").contentType(MediaType.APPLICATION_JSON).content(json)) - .andExpect(status().isBadRequest()); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.examples.jsr303.domain", - repositoryPackages = "org.springframework.data.neo4j.examples.jsr303.repo") - @ComponentScan(basePackageClasses = AdultService.class) - static class JSR303Context {} -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/WebConfiguration.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/WebConfiguration.java deleted file mode 100644 index 4579dbe41..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/WebConfiguration.java +++ /dev/null @@ -1,38 +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.examples.jsr303; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - * @author Vince Bickers - * @author Michael J. Simons - */ -@Configuration -@ComponentScan("org.springframework.data.neo4j.examples.jsr303.controller") -@EnableWebMvc -class WebConfiguration implements WebMvcConfigurer { - - @Bean(name = "validator") - public LocalValidatorFactoryBean validator() { - return new LocalValidatorFactoryBean(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/controller/AdultController.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/controller/AdultController.java deleted file mode 100644 index 70e167636..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/controller/AdultController.java +++ /dev/null @@ -1,57 +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.examples.jsr303.controller; - -import javax.validation.Valid; -import javax.validation.ValidationException; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.examples.jsr303.domain.Adult; -import org.springframework.data.neo4j.examples.jsr303.service.AdultService; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -/** - * @author Vince Bickers - */ -@Controller -public class AdultController { - - @Autowired private AdultService service; - - @RequestMapping(value = "/adults", method = RequestMethod.POST, consumes = "application/json") - @ResponseBody - public Adult create(@Valid @RequestBody Adult entity, BindingResult bindingResult) { - // in practice we'd do a bit more than this... - if (bindingResult.hasErrors()) { - throw new ValidationException("oops"); - } - return service.save(entity); - } - - @ExceptionHandler(ValidationException.class) - @ResponseBody - @ResponseStatus(value = HttpStatus.BAD_REQUEST) - public void handleException(ValidationException ve) {} - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/domain/Adult.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/domain/Adult.java deleted file mode 100644 index 171d00bfc..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/domain/Adult.java +++ /dev/null @@ -1,73 +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.examples.jsr303.domain; - -import javax.validation.constraints.AssertTrue; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * @author Vince Bickers - * @author Mark Angrish - */ -@NodeEntity -public class Adult { - - @Id @GeneratedValue private Long id; - - @NotNull @Size(min = 2, max = 50) private String name; - - @Min(18) private Integer age; - - @AssertTrue private boolean votingAge; - - public Adult() {} - - public Adult(String name, Integer age) { - this.name = name; - this.age = age; - this.votingAge = true; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getAge() { - return age; - } - - public void setAge(Integer age) { - this.age = age; - } - - public boolean isVotingAge() { - return votingAge; - } - - public void setVotingAge(boolean votingAge) { - this.votingAge = votingAge; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/repo/AdultRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/repo/AdultRepository.java deleted file mode 100644 index 9bcd885ff..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/repo/AdultRepository.java +++ /dev/null @@ -1,26 +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.examples.jsr303.repo; - -import org.springframework.data.neo4j.examples.jsr303.domain.Adult; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Vince Bickers - */ -@Repository -public interface AdultRepository extends Neo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/service/AdultService.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/service/AdultService.java deleted file mode 100644 index 3f999b380..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/jsr303/service/AdultService.java +++ /dev/null @@ -1,34 +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.examples.jsr303.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.examples.jsr303.domain.Adult; -import org.springframework.data.neo4j.examples.jsr303.repo.AdultRepository; -import org.springframework.stereotype.Service; - -/** - * @author Vince Bickers - */ -@Service -public class AdultService { - - @Autowired private AdultRepository repository; - - public Adult save(Adult adult) { - return repository.save(adult); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java deleted file mode 100644 index 3c19e4cd2..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/MoviesIntegrationTests.java +++ /dev/null @@ -1,712 +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.examples.movies; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.neo4j.test.GraphDatabaseServiceAssert.assertThat; - -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.TimeZone; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Result; -import org.neo4j.ogm.cypher.ComparisonOperator; -import org.neo4j.ogm.cypher.Filter; -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.data.neo4j.examples.movies.domain.Actor; -import org.springframework.data.neo4j.examples.movies.domain.Cinema; -import org.springframework.data.neo4j.examples.movies.domain.Genre; -import org.springframework.data.neo4j.examples.movies.domain.Movie; -import org.springframework.data.neo4j.examples.movies.domain.Rating; -import org.springframework.data.neo4j.examples.movies.domain.ReleasedMovie; -import org.springframework.data.neo4j.examples.movies.domain.TempMovie; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.repo.AbstractAnnotatedEntityRepository; -import org.springframework.data.neo4j.examples.movies.repo.AbstractEntityRepository; -import org.springframework.data.neo4j.examples.movies.repo.ActorRepository; -import org.springframework.data.neo4j.examples.movies.repo.CinemaRepository; -import org.springframework.data.neo4j.examples.movies.repo.RatingRepository; -import org.springframework.data.neo4j.examples.movies.repo.TempMovieRepository; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; -import org.springframework.data.neo4j.examples.movies.service.UserService; -import org.springframework.data.neo4j.queries.MoviesContextConfiguration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * @author Michal Bachman - * @author Luanne Misquitta - * @author Vince Bickers - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - * @author Gerrit Meier - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@RunWith(SpringRunner.class) -public class MoviesIntegrationTests { - - private static final String KNOWN_MAIL_ADDRESS_1 = "a@example.org"; - private static final String KNOWN_MAIL_ADDRESS_2 = "b@example.org"; - private static final String UNKNOWN_MAIL_ADDRESS = "c@example.org"; - - @Autowired private GraphDatabaseService graphDatabaseService; - @Autowired private Session session; - @Autowired private UserRepository userRepository; - @Autowired private UserService userService; - @Autowired private CinemaRepository cinemaRepository; - @Autowired private AbstractAnnotatedEntityRepository abstractAnnotatedEntityRepository; - @Autowired private AbstractEntityRepository abstractEntityRepository; - @Autowired private TempMovieRepository tempMovieRepository; - @Autowired private ActorRepository actorRepository; - @Autowired private RatingRepository ratingRepository; - @Autowired private TransactionTemplate transactionTemplate; - - @Before - public void setUp() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Test - public void shouldSaveUser() { - User user = new User("Michal"); - userRepository.save(user); - - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Michal'}) RETURN n") - .withId(user.getId()); - } - - @Test - public void shouldSaveUserWithoutName() { - User user = new User(); - userRepository.save(user); - - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person) RETURN n").withId(user.getId()); - } - - @Test - public void shouldSaveReleasedMovie() { - - Calendar cinemaReleaseDate = createDate(1994, Calendar.SEPTEMBER, 10, "GMT"); - Calendar cannesReleaseDate = createDate(1994, Calendar.MAY, 12, "GMT"); - - ReleasedMovie releasedMovie = new ReleasedMovie("Pulp Fiction", cinemaReleaseDate.getTime(), - cannesReleaseDate.getTime()); - - abstractAnnotatedEntityRepository.save(releasedMovie); - - assertThat(graphDatabaseService) - .containsNode("MATCH (m:ReleasedMovie:AbstractAnnotatedEntity {cinemaRelease:'1994-09-10T00:00:00.000Z'," - + "cannesRelease:768700800000,title:'Pulp Fiction'}) RETURN m AS n"); - } - - @Test - public void shouldSaveReleasedMovie2() { - - Calendar cannesReleaseDate = createDate(1994, Calendar.MAY, 12, "GMT"); - - ReleasedMovie releasedMovie = new ReleasedMovie("Pulp Fiction", null, cannesReleaseDate.getTime()); - - abstractAnnotatedEntityRepository.save(releasedMovie); - - assertThat(graphDatabaseService).containsNode( - "MATCH (m:ReleasedMovie:AbstractAnnotatedEntity {cannesRelease:768700800000,title:'Pulp Fiction'}) RETURN m AS n"); - } - - @Test - public void shouldSaveMovie() { - - Movie movie = new Movie("Pulp Fiction"); - movie.setTags(new String[] { "cool", "classic" }); - movie.setImage(new byte[] { 1, 2, 3 }); - - abstractEntityRepository.save(movie); - - // byte arrays have to be transferred with a JSON-supported format. Base64 is the default. - assertThat(graphDatabaseService).containsNode( - "MATCH (m:Movie {name:'Pulp Fiction', tags:['cool','classic'], " + "image:'AQID'}) RETURN m AS n"); - } - - @Test - public void shouldSaveUsers() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Set set = new HashSet<>(); - set.add(new User("Michal")); - set.add(new User("Adam")); - set.add(new User("Vince")); - - userRepository.saveAll(set); - assertThat(userRepository.count()).isEqualTo(3); - } - }); - - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Michal'}) RETURN n"); - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Vince'}) RETURN n"); - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Adam'}) RETURN n"); - - } - - @Test - public void shouldSaveUsers2() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List list = new LinkedList<>(); - list.add(new User("Michal")); - list.add(new User("Adam")); - list.add(new User("Vince")); - - userRepository.saveAll(list); - assertThat(userRepository.count()).isEqualTo(3); - } - }); - - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Michal'}) RETURN n"); - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Vince'}) RETURN n"); - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Adam'}) RETURN n"); - } - - @Test - public void shouldUpdateUserUsingRepository() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.save(new User("Michal")); - user.setName("Adam"); - userRepository.save(user); - } - }); - - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Adam'}) RETURN n"); - } - - @Test - @Ignore // FIXME - // this test expects the session/tx to check for dirty objects, which it currently does not do - // you must save objects explicitly. - public void shouldUpdateUserUsingTransactionalService() { - User user = new User("Michal"); - userRepository.save(user); - - userService.updateUser(user, "Adam"); // notice userRepository.save(..) isn't called, - // not even in the service impl! - - assertThat(graphDatabaseService).containsNode("MATCH (n:User:Person {name:'Adam'}) RETURN n"); - } - - @Test - public void shouldFindUser() { - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = new User("Michal"); - userRepository.save(user); - - Optional loaded = userRepository.findById(user.getId()); - - assertThat(loaded.isPresent()).isTrue(); - - loaded.ifPresent(loadedUser -> { - assertThat(loadedUser.getName()).isEqualTo("Michal"); - assertThat(loadedUser.equals(user)).isTrue(); - assertThat(loadedUser == user).isTrue(); - }); - } - }); - } - - @Test - public void shouldFindActorByNumericValueOfStringProperty() { - Actor actor = new Actor("1", "Tom Hanks"); - actorRepository.save(actor); - - assertThat(findByProperty(Actor.class, "id", "1").iterator().next()).isNotNull(); - } - - @Test - @Ignore - public void shouldFindUserWithoutName() { - User user = new User(); - userRepository.save(user); - - Optional loaded = userRepository.findById(user.getId()); - - assertThat(loaded.isPresent()).isTrue(); - - loaded.ifPresent(loadedUser -> { - assertThat(loadedUser.getName()).isNull(); - assertThat(loadedUser.equals(user)).isTrue(); - assertThat(loadedUser == user).isTrue(); - }); - } - - @Test - public void shouldDeleteUser() { - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = new User("Michal"); - userRepository.save(user); - userRepository.delete(user); - - assertThat(userRepository.findAll().iterator().hasNext()).isFalse(); - assertThat(userRepository.findAll(1).iterator().hasNext()).isFalse(); - assertThat(userRepository.existsById(user.getId())).isFalse(); - assertThat(userRepository.count()).isEqualTo(0); - assertThat(userRepository.findById(user.getId()).isPresent()).isFalse(); - assertThat(userRepository.findById(user.getId(), 5).isPresent()) - .isFalse(); - } - }); - - try (Result result = graphDatabaseService.execute("MATCH (n) RETURN n")) { - assertThat(result.hasNext()).isFalse(); - } - } - - @Test - public void shouldHandleMultipleConcurrentRequests() throws InterruptedException { - - ExecutorService executor = Executors.newFixedThreadPool(10); - final CountDownLatch latch = new CountDownLatch(100); - - for (int i = 0; i < 100; i++) { - executor.submit(() -> { - userRepository.save(new User()); - latch.countDown(); - }); - } - - latch.await(); // pause until the count reaches 0 - - executor.shutdown(); - - assertThat(userRepository.count()).isEqualTo(100); - } - - @Test(expected = DataAccessException.class) - public void shouldInterceptOGMExceptions() { - // ratings are REs and must be found to at least depth 1 in order to get the start and end nodes - ratingRepository.findAll(0); - } - - @Test - public void shouldSaveUserAndNewGenre() { - User user = new User("Michal"); - user.interestedIn(new Genre("Drama")); - - userRepository.save(user); - - assertThat(graphDatabaseService) - .containsNode("MATCH (u:User:Person {name:'Michal'})-[:INTERESTED]->(g:Genre {name:'Drama'}) RETURN u AS n") - .withId(user.getId()); - } - - @Test - public void shouldSaveUserAndNewGenres() { - User user = new User("Michal"); - user.interestedIn(new Genre("Drama")); - user.interestedIn(new Genre("Historical")); - user.interestedIn(new Genre("Thriller")); - - userRepository.save(user); - - assertThat(graphDatabaseService).containsNode("MATCH (u:User:Person {name:'Michal'})," - + "(g1:Genre {name:'Drama'})," + "(g2:Genre {name:'Historical'})," + "(g3:Genre {name:'Thriller'})," - + "(u)-[:INTERESTED]->(g1)," + "(u)-[:INTERESTED]->(g2)," + "(u)-[:INTERESTED]->(g3) RETURN u AS n ") - .withId(user.getId()); - } - - @Test - public void shouldSaveUserAndNewGenre2() { - User user = new User("Michal"); - user.interestedIn(new Genre("Drama")); - - userRepository.save(user, 1); - - assertThat(graphDatabaseService) - .containsNode("MATCH (u:User:Person {name:'Michal'})-[:INTERESTED]->(g:Genre {name:'Drama'}) RETURN u AS n") - .withId(user.getId()); - } - - @Test - public void shouldSaveUserAndExistingGenre() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User michal = new User("Michal"); - Genre drama = new Genre("Drama"); - michal.interestedIn(drama); - - userRepository.save(michal); - - User vince = new User("Vince"); - vince.interestedIn(drama); - - userRepository.save(vince); - } - }); - - assertThat(graphDatabaseService) - .containsNode("MATCH (m:User:Person {name:'Michal'})," + "(v:User:Person {name:'Vince'})," - + "(g:Genre {name:'Drama'})," + "(m)-[:INTERESTED]->(g)," + "(v)-[:INTERESTED]->(g) RETURN m AS n"); - } - - @Test - public void shouldSaveUserButNotGenre() { - User user = new User("Michal"); - user.interestedIn(new Genre("Drama")); - - userRepository.save(user, 0); - - assertThat(graphDatabaseService).containsNode("MATCH (u:User:Person {name:'Michal'}) RETURN u AS n") - .withId(user.getId()); - } - - @Test - public void shouldUpdateGenreWhenSavedThroughUser() { - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User michal = new User("Michal"); - Genre drama = new Genre("Drama"); - michal.interestedIn(drama); - - userRepository.save(michal); - - drama.setName("New Drama"); - - userRepository.save(michal); - } - }); - - assertThat(graphDatabaseService).containsNode("MATCH (m:User:Person {name:'Michal'})," - + "(g:Genre {name:'New Drama'})," + "(m)-[:INTERESTED]->(g) RETURN m AS n"); - } - - @Test - public void shouldRemoveGenreFromUser() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User michal = new User("Michal"); - Genre drama = new Genre("Drama"); - michal.interestedIn(drama); - - userRepository.save(michal); - - michal.notInterestedIn(drama); - - userRepository.save(michal); - } - }); - - assertThat(graphDatabaseService) - .containsNode("MATCH (m:User:Person {name:'Michal'})," + "(g:Genre {name:'Drama'}) RETURN m AS n"); - } - - @Test - public void shouldRemoveGenreFromUserUsingService() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User michal = new User("Michal"); - Genre drama = new Genre("Drama"); - michal.interestedIn(drama); - - userRepository.save(michal); - - userService.notInterestedIn(michal.getId(), drama.getId()); - } - }); - - assertThat(graphDatabaseService) - .containsNode("MATCH (m:User:Person {name:'Michal'})," + "(g:Genre {name:'Drama'}) RETURN m AS n"); - } - - @Test - public void shouldAddNewVisitorToCinema() { - Cinema cinema = new Cinema("Odeon"); - cinema.addVisitor(new User("Michal")); - - cinemaRepository.save(cinema); - - assertThat(graphDatabaseService).containsNode("MATCH (m:User:Person {name:'Michal'})," - + "(c:Theatre {name:'Odeon', capacity:0})," + "(m)-[:VISITED]->(c) RETURN m AS n"); - } - - @Test - public void shouldAddExistingVisitorToCinema() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User michal = new User("Michal"); - userRepository.save(michal); - - Cinema cinema = new Cinema("Odeon"); - cinema.addVisitor(michal); - - cinemaRepository.save(cinema); - } - }); - - assertThat(graphDatabaseService).containsNode("MATCH (m:User:Person {name:'Michal'})," - + "(c:Theatre {name:'Odeon', capacity:0})," + "(m)-[:VISITED]->(c) RETURN m AS n"); - } - - @Test - public void shouldBefriendPeople() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User michal = new User("Michal"); - michal.befriend(new User("Adam")); - userRepository.save(michal); - } - }); - - try { - assertThat(graphDatabaseService) - .containsNode("MATCH (m:User {name:'Michal'})-[:FRIEND_OF]->(a:User:Person {name:'Adam'}) RETURN m AS n"); - } catch (AssertionError error) { - assertThat(graphDatabaseService).containsNode( - "MATCH (m:User:Person {name:'Michal'})<-[:FRIEND_OF]-(a:User:Person {name:'Adam'}) RETURN m AS n"); - } - } - - @Test - public void shouldLoadOutgoingFriendsWhenUndirected() { - - graphDatabaseService.execute("CREATE (m:User:Person {name:'Michal'})-[:FRIEND_OF]->(a:User {name:'Adam'})"); - - User michal = ((Iterable) findByProperty(User.class, "name", "Michal")).iterator().next(); - assertThat(michal.getFriends().size()).isEqualTo(1); - - User adam = michal.getFriends().iterator().next(); - assertThat(adam.getName()).isEqualTo("Adam"); - assertThat(adam.getFriends().size()).isEqualTo(1); - - assertThat(michal == adam.getFriends().iterator().next()).isTrue(); - assertThat(michal.equals(adam.getFriends().iterator().next())).isTrue(); - } - - @Test - public void shouldLoadIncomingFriendsWhenUndirected() { - - graphDatabaseService.execute("CREATE (m:User:Person {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - User michal = ((Iterable) findByProperty(User.class, "name", "Michal")).iterator().next(); - assertThat(michal.getFriends().size()).isEqualTo(1); - - User adam = michal.getFriends().iterator().next(); - assertThat(adam.getName()).isEqualTo("Adam"); - assertThat(adam.getFriends().size()).isEqualTo(1); - - assertThat(michal == adam.getFriends().iterator().next()).isTrue(); - assertThat(michal.equals(adam.getFriends().iterator().next())).isTrue(); - } - - @Test - public void shouldSaveNewUserAndNewMovieWithRatings() { - User user = new User("Michal"); - TempMovie movie = new TempMovie("Pulp Fiction"); - user.rate(movie, 5, "Best movie ever"); - userRepository.save(user); - - User michal = ((Iterable) findByProperty(User.class, "name", "Michal")).iterator().next(); - - assertThat(graphDatabaseService) - .containsNode("MATCH (u:User:Person {name:'Michal'})-[:RATED {stars:5, " - + "comment:'Best movie ever', ratingTimestamp:0}]->(m:Movie {name:'Pulp Fiction'}) RETURN u AS n") - .withId(michal.getId()); - } - - @Test - public void shouldSaveNewUserRatingsForAnExistingMovie() { - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - TempMovie movie = new TempMovie("Pulp Fiction"); - // Save the movie - movie = tempMovieRepository.save(movie); - - // Create a new user and rate an existing movie - User user = new User("Michal"); - user.rate(movie, 5, "Best movie ever"); - userRepository.save(user); - - TempMovie tempMovie = ((Iterable) findByProperty(TempMovie.class, "name", "Pulp Fiction")).iterator() - .next(); - assertThat(tempMovie.getRatings().size()).isEqualTo(1); - } - }); - } - - @Test // DATAGRAPH-707 - public void findByIdShouldConsiderTheEntityType() { - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - // Save the movie - TempMovie movie = tempMovieRepository.save(new TempMovie("Pulp Fiction")); - - // Create a new user and rate an existing movie - User user = new User("Michal"); - user.rate(movie, 5, "Best movie ever"); - userRepository.save(user); - - Optional tempMovieOptional = tempMovieRepository.findById(movie.getId()); - - assertThat(tempMovieOptional.isPresent()).isTrue(); - tempMovieOptional.ifPresent(actual -> { - assertThat(actual.getName()).isEqualTo(movie.getName()); - }); - - Optional userOptional = userRepository.findById(user.getId()); - - assertThat(userOptional.isPresent()).isTrue(); - userOptional.ifPresent(actual -> { - assertThat(actual.getName()).isEqualTo(user.getName()); - }); - - Optional ratingOptional = ratingRepository.findById(user.getRatings().iterator().next().getId()); - - assertThat(ratingOptional.isPresent()).isTrue(); - ratingOptional.ifPresent(actual -> { - assertThat(actual.getStars()).isEqualTo(5); - }); - - assertThat(tempMovieRepository.findById(user.getId()).isPresent()) - .isFalse(); - assertThat(userRepository.findById(movie.getId(), 0).isPresent()) - .isFalse(); - assertThat(ratingRepository.findById(user.getId()).isPresent()).isFalse(); - } - }); - } - - @Test // DATAGRAPH-760 - public void shouldSaveAndReturnManyEntities() { - User michal = new User("Michal"); - User adam = new User("Adam"); - User daniela = new User("Daniela"); - - List users = Arrays.asList(michal, adam, daniela); - Iterable savedUsers = userRepository.saveAll(users); - for (User user : savedUsers) { - assertThat(user.getId()).isNotNull(); - } - } - - @Test // DATAGRAPH-992 - public void findUserByContainingEmailAddresses() { - createUserForContainsTest(); - - User foundUser = userRepository.findByEmailAddressesContains(Collections.singletonList(KNOWN_MAIL_ADDRESS_1)); - assertThat(foundUser).isNotNull(); - - foundUser = userRepository.findByEmailAddressesContains(Arrays.asList(KNOWN_MAIL_ADDRESS_2, UNKNOWN_MAIL_ADDRESS)); - assertThat(foundUser).isNotNull(); - } - - @Test // DATAGRAPH-992 - public void findNoUserByContainingEmailAddresses() { - createUserForContainsTest(); - - User foundUser = userRepository.findByEmailAddressesContains(Collections.singletonList(UNKNOWN_MAIL_ADDRESS)); - assertThat(foundUser).isNull(); - } - - @Test // DATAGRAPH-992 - public void findUserByNotContainingEmailAddresses() { - createUserForContainsTest(); - - List foundUser = userRepository.findByEmailAddressesNotContaining(UNKNOWN_MAIL_ADDRESS); - assertThat(foundUser.get(0)).isNotNull(); - } - - @Test // DATAGRAPH-992 - public void findNoUserByNotContainingEmailAddresses() { - createUserForContainsTest(); - - List foundUser = userRepository.findByEmailAddressesNotContaining(KNOWN_MAIL_ADDRESS_1); - assertThat(foundUser.isEmpty()).isTrue(); - } - - private void createUserForContainsTest() { - User user = new User("Somebody"); - Set emailAddresses = new HashSet<>(); - emailAddresses.add(KNOWN_MAIL_ADDRESS_1); - emailAddresses.add(KNOWN_MAIL_ADDRESS_2); - user.setEmailAddresses(emailAddresses); - userRepository.save(user); - } - - private Calendar createDate(int y, int m, int d, String tz) { - - Calendar calendar = Calendar.getInstance(); - - calendar.set(y, m, d); - calendar.setTimeZone(TimeZone.getTimeZone(tz)); - - // need to do this to ensure the test passes, or the calendar will use the current time's values - // an alternative (better) would be to specify an date format using one of the @Date converters - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - - return calendar; - } - - protected Iterable findByProperty(Class clazz, String propertyName, Object propertyValue) { - return session.loadAll(clazz, new Filter(propertyName, ComparisonOperator.EQUALS, propertyValue)); - } - - private static class Neo4jFailedToStartException extends Exception { - - private Neo4jFailedToStartException(long timeoutValue) { - super(String.format("Could not start neo4j instance in [%d] ms", timeoutValue)); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/AbstractAnnotatedEntity.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/AbstractAnnotatedEntity.java deleted file mode 100644 index 2fc05f72c..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/AbstractAnnotatedEntity.java +++ /dev/null @@ -1,30 +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.examples.movies.domain; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * @author Michal Bachman - * @author Michael J. Simons - */ -@NodeEntity -public abstract class AbstractAnnotatedEntity { - - @Id @GeneratedValue Long nodeId; -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/AbstractEntity.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/AbstractEntity.java deleted file mode 100644 index 3a31f9d63..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/AbstractEntity.java +++ /dev/null @@ -1,29 +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.examples.movies.domain; - -/** - * @author Michal Bachman - * @author Luanne Misquitta - */ -public abstract class AbstractEntity { - - Long id; - - public Long getId() { - return id; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Actor.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Actor.java deleted file mode 100644 index decdd6bd4..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Actor.java +++ /dev/null @@ -1,52 +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.examples.movies.domain; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; - -/** - * @author Michal Bachman - */ -public class Actor { - - @Id @GeneratedValue Long nodeId; - String id; - String name; - - public Actor() {} - - public Actor(String id, String name) { - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Cinema.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Cinema.java deleted file mode 100644 index 53b360d00..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Cinema.java +++ /dev/null @@ -1,107 +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.examples.movies.domain; - -import java.util.HashSet; -import java.util.Set; - -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Property; -import org.neo4j.ogm.annotation.Relationship; - -/** - * @author Michal Bachman - * @author Luanne Misquitta - * @author Jasper Blues - */ -@NodeEntity(label = "Theatre") -public class Cinema { - - private Long id; - private String name; - - @Property(name = "city") private String location; - - @Relationship(type = "VISITED", direction = Relationship.INCOMING) private Set visited = new HashSet<>(); - - @Relationship(type = "BLOCKBUSTER", direction = Relationship.OUTGOING) private TempMovie blockbusterOfTheWeek; - - private int capacity; - - public Cinema() {} - - public Cinema(String name) { - this.name = name; - } - - public Cinema(String name, int capacity) { - this.name = name; - this.capacity = capacity; - } - - public void addVisitor(User user) { - visited.add(user); - } - - public String getName() { - return name; - } - - public String getLocation() { - return location; - } - - public Set getVisited() { - return visited; - } - - public int getCapacity() { - return capacity; - } - - public void setCapacity(int capacity) { - this.capacity = capacity; - } - - public TempMovie getBlockbusterOfTheWeek() { - return blockbusterOfTheWeek; - } - - public void setBlockbusterOfTheWeek(TempMovie blockbusterOfTheWeek) { - this.blockbusterOfTheWeek = blockbusterOfTheWeek; - } - - public void setLocation(String location) { - this.location = location; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - Cinema cinema = (Cinema) o; - - return !(name != null ? !name.equals(cinema.name) : cinema.name != null); - } - - @Override - public int hashCode() { - return name != null ? name.hashCode() : 0; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/CinemaAndBlockbusterName.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/CinemaAndBlockbusterName.java deleted file mode 100644 index dae5c5419..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/CinemaAndBlockbusterName.java +++ /dev/null @@ -1,33 +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.examples.movies.domain; - -import org.springframework.beans.factory.annotation.Value; - -/** - * Open projection interface for Cinema without users - * - * @author Nicolas Mervaillie - */ -public interface CinemaAndBlockbusterName { - - Long getId(); - - String getName(); - - @Value("#{target.blockbusterOfTheWeek.name}") - String blockBusterOfTheWeekName(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Director.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Director.java deleted file mode 100644 index 4ad2fd28f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Director.java +++ /dev/null @@ -1,26 +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.examples.movies.domain; - -/** - * @author Luanne Misquitta - */ -public class Director extends Person { - - private Long id; - - public Director() {} -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Genre.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Genre.java deleted file mode 100644 index 9388c3b58..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Genre.java +++ /dev/null @@ -1,43 +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.examples.movies.domain; - -/** - * @author Michal Bachman - */ -public class Genre { - - private Long id; - private String name; - - public Genre() {} - - public Genre(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Movie.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Movie.java deleted file mode 100644 index b023d08ae..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Movie.java +++ /dev/null @@ -1,52 +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.examples.movies.domain; - -/** - * @author Michal Bachman - */ -public class Movie extends AbstractEntity { - - private String name; - private String[] tags; - private byte[] image; - - public Movie() {} - - public Movie(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public String[] getTags() { - return tags; - } - - public void setTags(String[] tags) { - this.tags = tags; - } - - public byte[] getImage() { - return image; - } - - public void setImage(byte[] image) { - this.image = image; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Person.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Person.java deleted file mode 100644 index e9e431644..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Person.java +++ /dev/null @@ -1,54 +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.examples.movies.domain; - -/** - * @author Luanne Misquitta - */ -public class Person { - private Long id; - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - Person person = (Person) o; - - return !(name != null ? !name.equals(person.name) : person.name != null); - } - - @Override - public int hashCode() { - return name != null ? name.hashCode() : 0; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Rating.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Rating.java deleted file mode 100644 index 21febe9f9..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/Rating.java +++ /dev/null @@ -1,97 +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.examples.movies.domain; - -import org.neo4j.ogm.annotation.EndNode; -import org.neo4j.ogm.annotation.RelationshipEntity; -import org.neo4j.ogm.annotation.StartNode; - -/** - * @author Michal Bachman - */ -@RelationshipEntity(type = "RATED") -public class Rating implements Comparable { - private Long id; - - @StartNode private User user; - @EndNode private TempMovie movie; - private int stars; - private String comment; - - private long ratingTimestamp; - - public Rating() {} - - public Rating(User user, TempMovie movie, int stars, String comment) { - this.user = user; - this.movie = movie; - this.stars = stars; - this.comment = comment; - } - - public Long getId() { - return id; - } - - public void setUser(User user) { - this.user = user; - } - - public void setMovie(TempMovie movie) { - this.movie = movie; - } - - public void setStars(int stars) { - this.stars = stars; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public User getUser() { - return user; - } - - public TempMovie getMovie() { - return movie; - } - - public int getStars() { - return stars; - } - - public String getComment() { - return comment; - } - - public long getRatingTimestamp() { - return ratingTimestamp; - } - - public void setRatingTimestamp(long ratingTimestamp) { - this.ratingTimestamp = ratingTimestamp; - } - - @Override - public int compareTo(Object o) { - Rating other = (Rating) o; - if (stars == ((Rating) o).getStars()) { - return getUser().getName().compareTo(other.getUser().getName()); - } - return stars - other.getStars(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/ReleasedMovie.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/ReleasedMovie.java deleted file mode 100644 index 5364bc735..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/ReleasedMovie.java +++ /dev/null @@ -1,54 +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.examples.movies.domain; - -import java.util.Date; - -import org.neo4j.ogm.annotation.Property; -import org.neo4j.ogm.annotation.typeconversion.DateLong; - -/** - * @author Michal Bachman - */ -// the fields here will move to Movie, this separate class exists temporarily after its tests pass -public class ReleasedMovie extends AbstractAnnotatedEntity { - - private String title; - - @Property(name = "cinemaRelease") private Date released; - - @DateLong private Date cannesRelease; - - public ReleasedMovie() {} - - public ReleasedMovie(String title, Date released, Date cannesRelease) { - this.title = title; - this.released = released; - this.cannesRelease = cannesRelease; - } - - public String getTitle() { - return title; - } - - public Date getReleased() { - return released; - } - - public Date getCannesRelease() { - return cannesRelease; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/TempMovie.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/TempMovie.java deleted file mode 100644 index 7d4d2ed84..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/TempMovie.java +++ /dev/null @@ -1,52 +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.examples.movies.domain; - -import java.util.HashSet; -import java.util.Set; - -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Relationship; - -/** - * @author Michal Bachman - * @author Luanne Misquitta - */ -// todo merge with movie when tests fixed -@NodeEntity(label = "Movie") -public class TempMovie extends AbstractEntity { - - private String name; - @Relationship(type = "RATED", direction = Relationship.INCOMING) private Set ratings = new HashSet<>(); - - public TempMovie() {} - - public TempMovie(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void addRating(Rating rating) { - ratings.add(rating); - } - - public Set getRatings() { - return ratings; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/User.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/User.java deleted file mode 100644 index 5382fe525..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/User.java +++ /dev/null @@ -1,101 +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.examples.movies.domain; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.neo4j.ogm.annotation.Relationship; - -/** - * @author Michal Bachman - * @author Luanne Misquitta - * @author Gerrit Meier - */ -public class User extends Person { - - private String middleName; - private String surname; - - private Collection interested = new HashSet<>(); - - @Relationship(type = "FRIEND_OF", - direction = Relationship.UNDIRECTED) private Collection friends = new HashSet<>(); - - @Relationship(type = "RATED") private Set ratings = new HashSet<>(); - - private Set emailAddresses; - - public User() {} - - public User(String name) { - setName(name); - } - - public User(String name, String surname) { - setName(name); - this.surname = surname; - } - - public void interestedIn(Genre genre) { - interested.add(genre); - } - - public void notInterestedIn(Genre genre) { - interested.remove(genre); - } - - public void befriend(User user) { - friends.add(user); - user.friends.add(this); - } - - public Rating rate(TempMovie movie, int stars, String comment) { - Rating rating = new Rating(this, movie, stars, comment); - movie.addRating(rating); - ratings.add(rating); - return rating; - } - - public Collection getFriends() { - return friends; - } - - public String getMiddleName() { - return middleName; - } - - public Set getRatings() { - return ratings; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public String getSurname() { - return surname; - } - - public Set getEmailAddresses() { - return emailAddresses; - } - - public void setEmailAddresses(Set emailAddresses) { - this.emailAddresses = emailAddresses; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResult.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResult.java deleted file mode 100644 index f4e062a4c..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResult.java +++ /dev/null @@ -1,48 +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.examples.movies.domain.queryresult; - -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * A partial representation of Cinema returned as an @QueryResult. For testing DATAGRAPH-893 - * - * @author Jasper Blues - */ -@QueryResult -public class CinemaQueryResult { - - private Long id; - private String name; - - public CinemaQueryResult() {} - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResultInterface.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResultInterface.java deleted file mode 100644 index 6e996d291..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResultInterface.java +++ /dev/null @@ -1,36 +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.examples.movies.domain.queryresult; - -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * A partial representation of Cinema returned as an @QueryResult interface. For testing DATAGRAPH-893 - * - * @author Jasper Blues - */ -@QueryResult -public interface CinemaQueryResultInterface { - - Long getId(); - - void setId(Long id); - - String getName(); - - void setName(String name); - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResultInterfaceImpl.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResultInterfaceImpl.java deleted file mode 100644 index 786d92b83..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/CinemaQueryResultInterfaceImpl.java +++ /dev/null @@ -1,43 +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.examples.movies.domain.queryresult; - -/** - * @author Jasper Blues - */ -public class CinemaQueryResultInterfaceImpl implements CinemaQueryResultInterface { - - private Long id; - private String name; - - public CinemaQueryResultInterfaceImpl() {} - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/EntityWrappingQueryResult.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/EntityWrappingQueryResult.java deleted file mode 100644 index 3f54b661d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/EntityWrappingQueryResult.java +++ /dev/null @@ -1,72 +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.examples.movies.domain.queryresult; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.springframework.data.neo4j.annotation.QueryResult; -import org.springframework.data.neo4j.examples.movies.domain.Rating; -import org.springframework.data.neo4j.examples.movies.domain.TempMovie; -import org.springframework.data.neo4j.examples.movies.domain.User; - -/** - * {@link QueryResult} that wraps entity objects. - * - * @author Luanne Misquitta - */ -@QueryResult -public class EntityWrappingQueryResult { - - private User user; - private Set friends; - private List ratings; - private TempMovie[] movies; - private float avgRating; - private List allRatings; - private Collection> literalMap; - - public User getUser() { - return user; - } - - public Set getFriends() { - return friends; - } - - public List getRatings() { - return ratings; - } - - public float getAvgRating() { - return avgRating; - } - - public TempMovie[] getMovies() { - return movies; - } - - public List getAllRatings() { - return allRatings; - } - - public Collection> getLiteralMap() { - return literalMap; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/Gender.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/Gender.java deleted file mode 100644 index 28d0375c9..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/Gender.java +++ /dev/null @@ -1,22 +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.examples.movies.domain.queryresult; - -public enum Gender { - - FEMALE, MALE; - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/RichUserQueryResult.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/RichUserQueryResult.java deleted file mode 100644 index f8c631023..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/RichUserQueryResult.java +++ /dev/null @@ -1,62 +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.examples.movies.domain.queryresult; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.time.Year; - -import org.neo4j.ogm.annotation.Property; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * A {@link QueryResult} that contains rich types. - * - * @author Adam George - * @author Luanne Misquitta - * @author Michael J. Simons - */ -@QueryResult -public class RichUserQueryResult { - - private Gender userGender; // should be handled by default type conversion - private String userName; - private BigInteger userAccount; - private BigDecimal[] userDeposits; - - @Property(name = "yearOfBirth") @Convert(YearConverter.class) private Year yearOfBirth; - - public Gender getUserGender() { - return userGender; - } - - public String getUserName() { - return userName; - } - - public BigInteger getUserAccount() { - return userAccount; - } - - public BigDecimal[] getUserDeposits() { - return userDeposits; - } - - public Year getYearOfBirth() { - return yearOfBirth; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/UserQueryResult.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/UserQueryResult.java deleted file mode 100644 index 25bd80c24..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/UserQueryResult.java +++ /dev/null @@ -1,97 +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.examples.movies.domain.queryresult; - -import org.neo4j.ogm.annotation.Property; -import org.springframework.data.neo4j.annotation.QueryResult; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; - -/** - * Example POJO {@link QueryResult} to test mapping onto arbitrary objects, even for properties that are on the nodes - * but not in the entity classes. - * - * @see UserRepository - * @author Adam George - * @author Luanne Misquitta - */ -@QueryResult -public class UserQueryResult { - - private Long id; - Long userId; - private String userName; - - @Property(name = "user.age") private int age; - - UserQueryResult() { - // default constructor for OGM - } - - public UserQueryResult(String name, int age) { - this.userName = name; - this.age = age; - } - - public Long getUserId() { - return userId; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - @Override - public int hashCode() { - final int prime = 23; - int result = 1; - result = prime * result + age; - result = prime * result + ((userName == null) ? 0 : userName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - UserQueryResult other = (UserQueryResult) obj; - if (age != other.age) - return false; - if (userName == null) { - if (other.userName != null) - return false; - } else if (!userName.equals(other.userName)) - return false; - return true; - } - - @Override - public String toString() { - return "UserQueryResult{" + - "id=" + id + - ", userId=" + userId + - ", userName='" + userName + '\'' + - ", age=" + age + - '}'; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/UserQueryResultObject.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/UserQueryResultObject.java deleted file mode 100644 index 7a9617c05..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/UserQueryResultObject.java +++ /dev/null @@ -1,47 +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.examples.movies.domain.queryresult; - -import org.springframework.data.neo4j.annotation.QueryResult; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; - -/** - * Example interface annotated with {@link QueryResult} to test mapping onto proxied objects, where only getter methods - * are needed to define the mapped result columns. - * - * @see UserRepository - */ -@QueryResult -public class UserQueryResultObject { - - private String name; - private int ageOfUser; - private User user; - - public String getName() { - return name; - } - - public int getAgeOfUser() { - return ageOfUser; - } - - public User getUser() { - return user; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/YearConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/YearConverter.java deleted file mode 100644 index e0d8a1580..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/queryresult/YearConverter.java +++ /dev/null @@ -1,37 +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.examples.movies.domain.queryresult; - -import java.time.Year; -import java.util.Optional; - -import org.neo4j.ogm.typeconversion.AttributeConverter; - -/** - * @author Michael J. Simons - * @soundtrack Greta van Fleet - From The Fires - */ -public class YearConverter implements AttributeConverter { - @Override - public Long toGraphProperty(Year value) { - return Optional.ofNullable(value).map(Year::getValue).map(Integer::longValue).orElse(null); - } - - @Override - public Year toEntityAttribute(Long value) { - return Optional.ofNullable(value).map(Long::intValue).map(Year::of).orElse(null); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/AbstractAnnotatedEntityRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/AbstractAnnotatedEntityRepository.java deleted file mode 100644 index 5db954a3a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/AbstractAnnotatedEntityRepository.java +++ /dev/null @@ -1,26 +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.examples.movies.repo; - -import org.springframework.data.neo4j.examples.movies.domain.AbstractAnnotatedEntity; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - */ -@Repository -public interface AbstractAnnotatedEntityRepository extends Neo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/AbstractEntityRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/AbstractEntityRepository.java deleted file mode 100644 index 140e46fae..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/AbstractEntityRepository.java +++ /dev/null @@ -1,26 +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.examples.movies.repo; - -import org.springframework.data.neo4j.examples.movies.domain.AbstractEntity; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - */ -@Repository -public interface AbstractEntityRepository extends Neo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/ActorRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/ActorRepository.java deleted file mode 100644 index a591463a8..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/ActorRepository.java +++ /dev/null @@ -1,24 +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.examples.movies.repo; - -import org.springframework.data.neo4j.examples.movies.domain.Actor; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Michal Bachman - */ -public interface ActorRepository extends Neo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/CinemaRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/CinemaRepository.java deleted file mode 100644 index f8ac914b3..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/CinemaRepository.java +++ /dev/null @@ -1,131 +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.examples.movies.repo; - -import java.util.Collection; -import java.util.List; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.annotation.Depth; -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.examples.movies.domain.Cinema; -import org.springframework.data.neo4j.examples.movies.domain.CinemaAndBlockbuster; -import org.springframework.data.neo4j.examples.movies.domain.CinemaAndBlockbusterName; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.CinemaQueryResult; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.CinemaQueryResultInterface; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - * @author Luanne Misquitta - * @author Jasper Blues - */ -@Repository -public interface CinemaRepository extends Neo4jRepository { - - Collection findByName(String name); - - List findByLocation(String location); - - List findByLocation(String location, @Depth int depth); - - List findByLocationLike(String location); - - List findByNameAndLocation(String name, String location); - - List findByNameOrLocation(String name, String location); - - List findByCapacityGreaterThan(int capacity); - - List findByCapacityLessThan(int capacity); - - List findByVisitedName(String name); - - List findByVisitedInterestedName(String title); - - List findByLocationAndVisitedName(String location, String name); - - List findByLocationAndCapacityGreaterThan(String location, int capacity); - - List findByCapacityLessThanAndLocation(int capacity, String location); - - List findByCapacityGreaterThanOrLocation(int capacity, String location); - - List findByLocationOrCapacityLessThan(String location, int capacity); - - List findByLocationOrVisitedName(String location, String name); - - // invalid query : not enough arguments - List findByLocationOrVisitedName(String location); - - List findByVisitedNameAndBlockbusterOfTheWeekName(String location, String name); - - List findByVisitedNameOrBlockbusterOfTheWeekName(String location, String name); - - List findByVisitedNameAndVisitedMiddleName(String name, String middleName); - - List findByNameMatches(String name); - - Cinema findByName(String name, @Depth int depth); - - @Query(value = "MATCH (n:Theatre) RETURN n;", countQuery = "MATCH (n:Theatre) return count(*);") - Page getPagedCinemas(Pageable pageable); - - @Query(value = "MATCH (n:Theatre) RETURN n;") - Page getPagedCinemasWithoutCountQuery(Pageable pageable); - - @Query(value = "MATCH (n:Theatre) RETURN n", countQuery = "MATCH (n:Theatre) return count(*)") - Page getPagedCinemaQueryResults(Pageable pageable); - - @Query("MATCH (n:Theatre) RETURN n") - Slice getSlicedCinemaQueryResults(Pageable pageable); - - @Query(value = "MATCH (n:Theatre) RETURN n", countQuery = "MATCH (n:Theatre) return count(*)") - Page getPagedCinemaQueryResultInterfaces(Pageable pageable); - - @Query(value = "MATCH (n:Theatre {city:$city}) RETURN n ORDER BY n.name", - countQuery = "MATCH (n:Theatre {city:$city}) return count(*)") - Page getPagedCinemasByCityWithPageCount(@Param("city") String city, Pageable pageable); - - @Query("MATCH (n:Theatre) RETURN n") - Slice getSlicedCinemasByName(Pageable pageable); - - Page findByLocation(String city, Pageable pageable); - - Page findByLocationAndVisitedName(String location, String name, Pageable pageable); - - Page findByVisitedName(String name, Pageable pageable); - - List findByLocation(String city, Sort sort); - - Page findByCapacity(int capacity, Pageable pageable); - - @Query("MATCH (n:Theatre) RETURN n") - List getCinemasSortedByName(Sort sort); - - List findByNameLike(String name); - - List findByNameLike(String name, Sort sort); - - List findByNameStartingWith(String nameStart); - - List findByNameLike(String name, @Depth int depth); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/CinemaStreamingRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/CinemaStreamingRepository.java deleted file mode 100644 index dcda1f0cb..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/CinemaStreamingRepository.java +++ /dev/null @@ -1,48 +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.examples.movies.repo; - -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Stream; - -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.annotation.Depth; -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.examples.movies.domain.Cinema; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Repository; - -/** - * @author Nicolas Mervaillie - */ -@Repository -public interface CinemaStreamingRepository extends Neo4jRepository { - - Optional findByName(String name, @Depth int depth); - - @Query(value = "MATCH (n:Theatre) RETURN n;") - Stream getAllCinemas(); - - @Query("MATCH (n:Theatre) RETURN n") - Stream getCinemasSortedByName(Sort sort); - - @Async - @Query(value = "MATCH (n:Theatre) RETURN n;") - CompletableFuture> getAllCinemasAsync(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/DirectorRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/DirectorRepository.java deleted file mode 100644 index be6d2b6ab..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/DirectorRepository.java +++ /dev/null @@ -1,25 +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.examples.movies.repo; - -import org.springframework.data.neo4j.examples.movies.domain.Director; - -/** - * @author Luanne Misquitta - */ -public interface DirectorRepository extends PersonRepository { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/GenreRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/GenreRepository.java deleted file mode 100644 index cd6b919eb..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/GenreRepository.java +++ /dev/null @@ -1,26 +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.examples.movies.repo; - -import org.springframework.data.neo4j.examples.movies.domain.Genre; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - */ -@Repository -public interface GenreRepository extends Neo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/PersonRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/PersonRepository.java deleted file mode 100644 index a29f8866b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/PersonRepository.java +++ /dev/null @@ -1,35 +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.examples.movies.repo; - -import java.io.Serializable; -import java.util.Collection; - -import org.springframework.data.neo4j.examples.movies.domain.Person; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Luanne Misquitta - * @author Michael J. Simons - */ -public interface PersonRepository extends Neo4jRepository { - - Collection findByName(String name); - - Collection findByNameIgnoreCase(String name); - - Collection findByNameContainingIgnoreCase(String name); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/RatingRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/RatingRepository.java deleted file mode 100644 index 7ff7f691a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/RatingRepository.java +++ /dev/null @@ -1,64 +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.examples.movies.repo; - -import java.util.List; - -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.examples.movies.domain.Rating; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Luanne Misquitta - * @author Vince Bickers - */ -public interface RatingRepository extends Neo4jRepository { - - List findByStars(int stars); - - List findByStarsAndRatingTimestamp(int stars, long ratingTimestamp); - - List findByStarsOrRatingTimestamp(int stars, long ratingTimestamp); - - List findByStarsAndRatingTimestampLessThan(int stars, long ratingTimestamp); - - List findByStarsOrRatingTimestampGreaterThan(int stars, long ratingTimestamp); - - List findByUserName(String name); - - List findByMovieName(String name); - - List findByUserNameAndMovieName(String userName, String movieName); - - List findByUserNameAndStars(String name, int stars); - - List findByStarsAndMovieName(int stars, String name); - - List findByUserNameAndMovieNameAndStars(String userName, String movieName, int stars); - - List findByStarsOrUserName(int stars, String username); - - List findByUserNameAndUserMiddleName(String username, String middleName); - - Long countByStars(int stars); - - Long removeByUserName(String username); - - List deleteByStarsOrRatingTimestampGreaterThan(int stars, long ratingTimestamp); - - @Query("MATCH (a)-[r:RATED]-(b) WHERE ID(a)=$0 and ID(b)=$1 RETURN a,r,b") - Rating findRatingByUserAndTempMovie(long userId, long tempMovieId); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/TempMovieRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/TempMovieRepository.java deleted file mode 100644 index 95ff326a0..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/TempMovieRepository.java +++ /dev/null @@ -1,24 +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.examples.movies.repo; - -import org.springframework.data.neo4j.examples.movies.domain.TempMovie; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Michal Bachman - */ -public interface TempMovieRepository extends Neo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UnmanagedUserPojo.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UnmanagedUserPojo.java deleted file mode 100644 index 77226ee9f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UnmanagedUserPojo.java +++ /dev/null @@ -1,36 +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.examples.movies.repo; - -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * Test query result object to prove the case for POJOs NOT scanned by the mapping metadata. - */ -@QueryResult -public class UnmanagedUserPojo { - - private String name; - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UserRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UserRepository.java deleted file mode 100644 index bf4f9e248..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/repo/UserRepository.java +++ /dev/null @@ -1,189 +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.examples.movies.repo; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; -import org.springframework.data.neo4j.annotation.Depth; -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.EntityWrappingQueryResult; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.Gender; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.RichUserQueryResult; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.UserQueryResult; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.UserQueryResultObject; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - * @author Luanne Misquitta - * @author Gerrit Meier - * @author Michael J. Simons - */ -@Repository -public interface UserRepository extends PersonRepository { - - Collection findByMiddleName(String middleName); - - List findByRatingsStars(int stars); - - List findByRatingsStarsAndInterestedName(int stars, String name); - - List findByRatingsStarsAndInterestedNameIgnoreCase(int stars, String name); - - List findByRatingsStarsAndInterestedNameAllIgnoreCase(int stars, String name); - - List findByRatingsStarsIgnoreCase(int stars); - - @Query("MATCH (user:User) RETURN COUNT(user)") - int findTotalUsers(); - - @Query("MATCH (user:User) RETURN id(user)") - List getUserIds(); - - @Query("MATCH (user:User) RETURN user.name, id(user)") - Iterable> getUsersAsProperties(); - - @Query("MATCH (user:User) RETURN user") - Collection getAllUsers(); - - @Query("MATCH (m:Movie)<-[:ACTED_IN]-(a:User) RETURN m.name as movie, collect(a.name) as cast") - List> getGraph(); - - @Query("MATCH (user:User{name:$name}) RETURN user") - User findUserByNameWithNamedParam(@Param("name") String name); - - @Query("MATCH (user:User{name:$name}) RETURN user") - User findUserByNameWithNamedParamWithoutParamAnnotation(String name); - - @Query("MATCH (user:User{name:$0}) RETURN user") - User findUserByName(String name); - - @Query("MATCH (user:User) RETURN id(user) AS userId, id(user) as id, user.name AS userName, user.age ORDER BY user.age") - Iterable retrieveAllUsersAndTheirAges(); - - @Query("MATCH (user:User{name:$0}) RETURN user.name AS name") - UnmanagedUserPojo findIndividualUserAsDifferentObject(String name); - - @Query("MATCH (user:User) WHERE user.name=$0 RETURN user.name AS name, user.age AS ageOfUser") - UserQueryResultObject findIndividualUserAsProxiedObject(String name); - - @Query("MATCH (user:User) WHERE user.name=$0 RETURN user as user, user.age AS ageOfUser") - UserQueryResultObject findWrappedUserAsProxiedObject(String name); - - @Query("MATCH (user:User) WHERE user.gender=$0 RETURN user.name AS userName, user.gender AS userGender, user.account as userAccount, user.yearOfBirth as yearOfBirth, user.yearOfBirth as plainYearValue, user.deposits as userDeposits") - Iterable findUsersByGender(Gender gender); - - @Query("MATCH (user:User) WHERE user.name=$0 RETURN user") - EntityWrappingQueryResult findWrappedUserByName(String userName); - - @Query("MATCH (user:User)-[:FRIEND_OF]->(f) WHERE user.name=$0 RETURN user, collect(f) as friends") - EntityWrappingQueryResult findWrappedUserAndFriendsDepth0(String userName); - - @Query("MATCH (user:User)-[r:FRIEND_OF]->(f) WHERE user.name=$0 RETURN user, collect(r) as rels, collect(f) as friends") - EntityWrappingQueryResult findWrappedUserAndFriendsDepth1(String userName); - - @Query("MATCH (user:User)-[r:RATED]->(m) WHERE user.name=$0 RETURN user, collect(r) as ratings, collect(m) as movies, avg(r.stars) as avgRating") - EntityWrappingQueryResult findWrappedUserAndRatingsByName(String userName); - - @Query("MATCH (user:User)-[r:RATED]->(m) RETURN user, collect(r) as ratings, collect(m) as movies, avg(r.stars) as avgRating order by user.name desc") - List findAllUserRatings(); - - @Query("MATCH (user:User) RETURN ID(user)") - List getUserNodeIds(); - - @Query("MATCH (user:User) WHERE ID(user)=$0 return user") - User loadUserById(User user); - - @Query("MATCH (user:User) WHERE ID(user)=$userId RETURN user") - User loadUserByNamedId(@Param("userId") User user); - - @Query("MATCH (user:User) RETURN user") - Iterable getAllUsersIterable(); - - @Query("MATCH (user:User) set user.name=$0") - void setNamesNull(String name); - - List findByNameIsNotLike(String name); - - @Depth(value = 0) - User findBySurname(String surname); - - @Query("MATCH (user:User) RETURN user.unknown as allRatings") - EntityWrappingQueryResult findAllRatingsNull(); - - @Query("match (u:User)-[r:RATED]->(m:Movie) return u as user, collect({username: u.name, movietitle: m.title, stars:r.stars}) as literalMap") - List findRatingsWithLiteralMap(); - - Page findByNameAndSurname(String name, String surname, Pageable pageable); - - Slice findByNameAndRatingsStars(String name, int stars, Pageable pageable); - - Page findAllByIdIn(Iterable id, Pageable pageable); - - List findAllByIdInAndNameLike(Iterable id, String name); - - List findAllByIdAndName(Long id, String name); - - @Query("invalid") - void invalidQuery(); - - User findByEmailAddressesContains(List emails); - - List findByEmailAddressesNotContaining(String email); - - @Query("MATCH (user:User) WHERE user.name=:#{#searchUser.name} RETURN user") - User findUserByNameUsingSpElWithObject(@Param("searchUser") User user); - - @Query("MATCH (user:User) WHERE user.name=?#{[0]} RETURN user") - User findUserByNameUsingSpElWithIndex(String name); - - @Query("MATCH (user:User) WHERE user.name=:#{[0]} and user.name=:#{[0]} RETURN user") - User findUserByNameUsingSpElWithIndexColon(String name); - - @Query("MATCH (user:User) WHERE user.age=?#{5 + 5} RETURN user") - User findUserByNameUsingSpElWithSpElExpression(); - - @Query("MATCH (user:User) WHERE user.name=:#{#searchUser.name} and user.middleName=?#{#searchUser.middleName} RETURN user") - User findUserByNameAndMiddleNameUsingSpElWithObject(@Param("searchUser") User user); - - @Query("MATCH (user:User) WHERE user.name=:#{'Michal'} RETURN user") - User findUserByNameAndMiddleNameUsingSpElWithValue(); - - @Query("MATCH (user:User) WHERE user.name=?#{[0]} and user.surname=$name RETURN user") - User findUserByNameAndSurnameUsingSpElIndexAndPlaceholderWithOneParameter(@Param("name") String queryName); - - @Query("MATCH (user:User) WHERE user.name=:#{#name} and user.surname=$name RETURN user") - User findUserByNameAndSurnameUsingSpElPropertyAndPlaceholderWithOneParameter(@Param("name") String queryName); - - @Query("MATCH (user:User) WHERE user.name=:#{#name} and user.surname=$name RETURN user") - User findUserByNameAndSurnameUsingSpElPropertyAndIndexWithOneParameter(@Param("name") String queryName); - - @Query("MATCH (user:User) WHERE user.name=:#{#name} and user.surname=:#{#name} RETURN user") - User findUserByNameAndSurnameUsingSpElPropertyTwice(@Param("name") String queryName); - - @Query("MATCH (user:User) WHERE user.name=:#{#name} and user.surname=:#{[0]} RETURN user") - User findUserByNameAndSurnameUsingSpElPropertyAndSpElIndex(@Param("name") String queryName); - - @Query("MATCH (user:User) WHERE user.name=$name and user.name=$0 and user.name=:#{#name} and user.name=:#{[0]} RETURN user") - User findUserByNameUsingNativeIndexAndNameAndSpElNameAndSpElIndex(@Param("name") String queryName); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/service/UserService.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/service/UserService.java deleted file mode 100644 index 1590afe4a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/service/UserService.java +++ /dev/null @@ -1,43 +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.examples.movies.service; - -import java.util.Collection; - -import org.springframework.data.neo4j.annotation.UseBookmark; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Michal Bachman - */ -public interface UserService { - - @Transactional - void updateUser(User user, String newName); - - @Transactional - void notInterestedIn(Long userId, Long genreId); - - @Transactional - void saveWithTxAnnotationOnInterface(User user); - - void saveWithTxAnnotationOnImpl(User user); - - @UseBookmark - @Transactional - Collection getAllUsersWithBookmark(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/service/UserServiceImpl.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/service/UserServiceImpl.java deleted file mode 100644 index c29ff6f89..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/service/UserServiceImpl.java +++ /dev/null @@ -1,76 +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.examples.movies.service; - -import java.util.Collection; -import java.util.Optional; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.annotation.UseBookmark; -import org.springframework.data.neo4j.examples.movies.domain.Genre; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.repo.GenreRepository; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Michal Bachman - * @author Mark Paluch - * @author Jens Schauder - */ -@Service -public class UserServiceImpl implements UserService { - - @Autowired private UserRepository userRepository; - - @Autowired private GenreRepository genreRepository; - - @Override - public void updateUser(User user, String newName) { - user.setName(newName); - } - - @Override - public void notInterestedIn(Long userId, Long genreId) { - Optional user = userRepository.findById(userId); - - user.ifPresent(u -> { - Optional genre = genreRepository.findById(genreId); - genre.ifPresent(u::notInterestedIn); - - userRepository.save(u); - }); - } - - @Override - public void saveWithTxAnnotationOnInterface(User user) { - userRepository.save(user); - } - - @Transactional - @Override - public void saveWithTxAnnotationOnImpl(User user) { - userRepository.save(user); - } - - @Override - @Transactional - @UseBookmark - public Collection getAllUsersWithBookmark() { - return userRepository.getAllUsers(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/RestaurantTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/RestaurantTests.java deleted file mode 100644 index 15080e2ff..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/RestaurantTests.java +++ /dev/null @@ -1,641 +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.examples.restaurants; - -import static org.apache.webbeans.util.Asserts.assertNotNull; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.data.Offset.offset; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.domain.Range; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Metrics; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.examples.restaurants.domain.Diner; -import org.springframework.data.neo4j.examples.restaurants.domain.Restaurant; -import org.springframework.data.neo4j.examples.restaurants.repo.RestaurantRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * Tests that we support each kind of keyword specified by Part.Type - * - * @author Jasper Blues - * @author Gerrit Meier - * @author Michael J. Simons - */ -@ContextConfiguration(classes = { RestaurantTests.RestaurantContext.class }) -@RunWith(SpringRunner.class) -@DirtiesContext -public class RestaurantTests { - - @Autowired private RestaurantRepository restaurantRepository; - - @After - public void tearDown() { - restaurantRepository.deleteAll(); - } - - /** - * This test, as the below one does, asserts that the parameter index for each query part is set correctly. Most query - * parts are associated with one parameter, while certain kinds, such as NEAR, require more. - */ - @Test // DATAGRAPH-561 - public void shouldFindRestaurantsNear_nameParameterFirst() { - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Point(37.61649, -122.38681), - 94128); - restaurantRepository.save(restaurant); - - List results = restaurantRepository.findByNameAndLocationNear( - "San Francisco International Airport (SFO)", new Distance(150, Metrics.KILOMETERS), new Point(37.6, -122.3)); - - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - Restaurant found = results.get(0); - assertNotNull(found.getLocation()); - assertThat(found.getLocation().getX()).isCloseTo(37.61649, offset(0d)); - assertThat(found.getLocation().getY()).isCloseTo(-122.38681, offset(0d)); - } - - /** - * This test, as the above one does, asserts that the parameter index for each query part is set correctly. Most query - * parts are associated with one parameter, while certain kinds, such as NEAR, require more. - */ - @Test // DATAGRAPH-561 - public void shouldFindRestaurantsNear_locationFirst() { - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Point(37.61649, -122.38681), - 94128); - restaurantRepository.save(restaurant); - - List results = restaurantRepository.findByLocationNearAndName(new Distance(150, Metrics.KILOMETERS), - new Point(37.6, -122.3), "San Francisco International Airport (SFO)"); - - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - Restaurant found = results.get(0); - assertNotNull(found.getLocation()); - assertThat(found.getLocation().getX()).isCloseTo(37.61649, offset(0d)); - assertThat(found.getLocation().getY()).isCloseTo(-122.38681, offset(0d)); - } - - @Test // DATAGRAPH-904 - public void shouldFindRestaurantsWithScoreBetween() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 80.6); - restaurantRepository.save(cyma); - - Restaurant awful = new Restaurant("Awful", 20.0); - restaurantRepository.save(awful); - - List results = restaurantRepository.findByScoreBetween(70.0, 80.0); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - - List shouldBeEmpty = restaurantRepository.findByScoreBetween(30.0, 40.0); - assertNotNull(shouldBeEmpty); - assertThat(shouldBeEmpty.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-1027 - public void shouldFindRestaurantsWithScoreBetweenInclusive() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 80.6); - restaurantRepository.save(cyma); - - Restaurant awful = new Restaurant("Awful", 20.0); - restaurantRepository.save(awful); - - List results = restaurantRepository.findByScoreBetween(20.0, 80.6); - assertNotNull(results); - assertThat(results.size()).isEqualTo(3); - } - - @Test // DATAGRAPH-1202 - public void shouldFindRestaurantsWithScoreBetweenRangeInclusiveBothBounds() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 80.6); - restaurantRepository.save(cyma); - - Restaurant awful = new Restaurant("Awful", 20.0); - restaurantRepository.save(awful); - - Range.Bound lowerBoundInclusive = Range.Bound.inclusive(20.0); - Range.Bound upperBoundInclusive = Range.Bound.inclusive(80.6); - Range inclusiveBound = Range.of(lowerBoundInclusive, upperBoundInclusive); - - List results = restaurantRepository.findByScoreBetween(inclusiveBound); - assertNotNull(results); - assertThat(results.size()).isEqualTo(3); - } - - @Test // DATAGRAPH-1202 - public void shouldFindRestaurantsWithScoreBetweenRangeExclusiveBothBounds() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 80.6); - restaurantRepository.save(cyma); - - Restaurant awful = new Restaurant("Awful", 20.0); - restaurantRepository.save(awful); - - Range.Bound lowerBoundInclusive = Range.Bound.exclusive(20.0); - Range.Bound upperBoundInclusive = Range.Bound.exclusive(80.6); - Range inclusiveBound = Range.of(lowerBoundInclusive, upperBoundInclusive); - - List results = restaurantRepository.findByScoreBetween(inclusiveBound); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - } - - @Test // DATAGRAPH-1202 - public void shouldFindRestaurantsWithScoreBetweenRangeInclusiveLowerBounds() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 80.6); - restaurantRepository.save(cyma); - - Restaurant awful = new Restaurant("Awful", 20.0); - restaurantRepository.save(awful); - - Range.Bound lowerBoundInclusive = Range.Bound.inclusive(20.0); - Range.Bound upperBoundInclusive = Range.Bound.exclusive(80.6); - Range inclusiveBound = Range.of(lowerBoundInclusive, upperBoundInclusive); - - List results = restaurantRepository.findByScoreBetween(inclusiveBound); - assertNotNull(results); - assertThat(results.size()).isEqualTo(2); - } - - @Test // DATAGRAPH-1202 - public void shouldFindRestaurantsWithScoreBetweenRangeInclusiveUpperBounds() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 80.6); - restaurantRepository.save(cyma); - - Restaurant awful = new Restaurant("Awful", 20.0); - restaurantRepository.save(awful); - - Range.Bound lowerBoundInclusive = Range.Bound.exclusive(20.0); - Range.Bound upperBoundInclusive = Range.Bound.inclusive(80.6); - Range inclusiveBound = Range.of(lowerBoundInclusive, upperBoundInclusive); - - List results = restaurantRepository.findByScoreBetween(inclusiveBound); - assertNotNull(results); - assertThat(results.size()).isEqualTo(2); - } - - @Test // DATAGRAPH-904 - public void shouldFindByPropertyIsNull() { - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Point(37.61649, -122.38681), - 94128); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", "Mostly Ramen"); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByDescriptionIsNull(); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByPropertyIsNotNull() { - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Point(37.61649, -122.38681), - 94128); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", "Mostly Ramen"); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByDescriptionIsNotNull(); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Kuroda"); - } - - @Test // DATAGRAPH-904 - public void shouldFindBNestedProperty_different_entity_type_IsNull() { - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Point(37.61649, -122.38681), - 94128); - - Diner diner = new Diner("Jasper", null); - restaurant.addRegularDiner(diner); - - restaurantRepository.save(restaurant); - - List results = restaurantRepository.findByRegularDinersLastNameIsNull(); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - } - - @Test // DATAGRAPH-904 - public void shouldFindBNestedProperty_same_entity_type_IsNull() { - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Point(37.61649, -122.38681), - 94128); - - Diner diner = new Diner("Jasper", null); - restaurant.addRegularDiner(diner); - - Restaurant kuroda = new Restaurant("Kuroda", null); - restaurant.addSimilarRestaurant(kuroda); - - restaurantRepository.save(restaurant); - - List results = restaurantRepository.findBySimilarRestaurantsDescriptionIsNull(); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - } - - @Test // DATAGRAPH-904 - public void shouldFindByScoreLessThan() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 81.3); - restaurantRepository.save(cyma); - - List results = restaurantRepository.findByScoreLessThan(75); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Kuroda"); - - results = restaurantRepository.findByScoreLessThan(72.4); - assertNotNull(results); - assertThat(results.size()).isEqualTo(0); - - results = restaurantRepository.findByScoreLessThanEqual(72.4); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Kuroda"); - } - - @Test // DATAGRAPH-904 - public void shouldFindByScoreGreaterThan() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 81.3); - restaurantRepository.save(cyma); - - List results = restaurantRepository.findByScoreGreaterThan(75); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Cyma"); - - results = restaurantRepository.findByScoreGreaterThan(90.0); - assertNotNull(results); - assertThat(results.size()).isEqualTo(0); - - results = restaurantRepository.findByScoreGreaterThanEqual(81.3); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Cyma"); - } - - @Test // DATAGRAPH-904 - public void shouldFindByLaunchDateBefore() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - kuroda.setLaunchDate(new Date(1000)); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 80.5); - cyma.setLaunchDate(new Date(2000)); - restaurantRepository.save(cyma); - - List results = restaurantRepository.findByLaunchDateBefore(new Date(1001)); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Kuroda"); - - results = restaurantRepository.findByLaunchDateBefore(new Date(999)); - assertNotNull(results); - assertThat(results.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-904 - public void shouldFindByLaunchDateAfter() { - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - kuroda.setLaunchDate(new Date(1000)); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", 80.5); - cyma.setLaunchDate(new Date(2000)); - restaurantRepository.save(cyma); - - List results = restaurantRepository.findByLaunchDateAfter(new Date(1500)); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Cyma"); - - results = restaurantRepository.findByLaunchDateAfter(new Date(3000)); - assertNotNull(results); - assertThat(results.size()).isEqualTo(0); - } - - /** - * All findByPropertyLike does currently is to require an exact match, ignoring case. - */ - @Test // DATAGRAPH-904 - public void shouldFindByNameNotLike() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByNameNotLike("kuroda"); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - } - - /** - * All findByPropertyLike does currently is to require an exact match, ignoring case. - */ - @Test // DATAGRAPH-904 - public void shouldFindByNameLike() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByNameLike("*san francisco international*"); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByNameStartingWith() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByNameStartingWith("San Francisco"); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByNameEndingWith() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByNameEndingWith("Airport (SFO)"); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByNameContaining() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByNameContaining("International Airport"); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - results = restaurantRepository.findByNameNotContaining("International Airport"); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Kuroda"); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByNameContainingOrDescriptionIsNull() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - Restaurant cyma = new Restaurant("Cyma", "Greek Stuff"); - - List results = restaurantRepository.findByNameContaining("International Airport"); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - results = restaurantRepository.findByNameNotContainingOrDescriptionIsNull("International Airport"); - Collections.sort(results); - assertNotNull(results); - assertThat(results.size()).isEqualTo(2); - assertThat(results.get(0).getName()).isEqualTo("Kuroda"); - assertThat(results.get(1).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByNameIn() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByNameIn(Arrays.asList("Kuroda", "Foo", "Bar")); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Kuroda"); - - results = restaurantRepository.findByNameNotIn(Arrays.asList("Kuroda", "Foo", "Bar")); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByNameMatchesRegEx() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByNameMatchesRegex("(?i)san francisco.*"); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()) - .isEqualTo("San Francisco International Airport (SFO)"); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByNameExists() { - - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", 68.0); - restaurantRepository.save(restaurant); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByNameExists(); - assertNotNull(results); - assertThat(results.size()).isEqualTo(2); - - } - - @Test // DATAGRAPH-904 - public void shouldFindByPropertyIsTrue() { - Restaurant kazan = new Restaurant("Kazan", 77.0); - kazan.setHalal(true); - restaurantRepository.save(kazan); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - kuroda.setHalal(false); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByHalalIsTrue(); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Kazan"); - } - - @Test // DATAGRAPH-904 - public void shouldFindByPropertyIsFalse() { - Restaurant kazan = new Restaurant("Kazan", 77.0); - kazan.setHalal(true); - restaurantRepository.save(kazan); - - Restaurant kuroda = new Restaurant("Kuroda", 72.4); - kuroda.setHalal(false); - restaurantRepository.save(kuroda); - - List results = restaurantRepository.findByHalalIsFalse(); - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - assertThat(results.get(0).getName()).isEqualTo("Kuroda"); - } - - @Test // DATAGRAPH-1197 - public void shouldCheckExistenceForDerivedQueryMethod() { - Restaurant restaurant = new Restaurant("R1", "good"); - restaurantRepository.save(restaurant); - - assertThat(restaurantRepository.existsByDescription("good")).isTrue(); - } - - @Test // DATAGRAPH-1197 - public void shouldCheckNonExistenceForDerivedQueryMethod() { - Restaurant restaurant = new Restaurant("R1", "good"); - restaurantRepository.save(restaurant); - - assertThat(restaurantRepository.existsByDescription("bad")).isFalse(); - } - - @Test // DATAGRAPH-1197 - public void shouldCheckExistenceForQueryMethod() { - Restaurant restaurant = new Restaurant("R1", "good"); - restaurantRepository.save(restaurant); - - assertThat(restaurantRepository.existenceOfAGoodRestaurant()).isTrue(); - } - - @Test // DATAGRAPH-1197 - public void shouldCheckNonExistenceForQueryMethod() { - Restaurant restaurant = new Restaurant("R1", "bad"); - restaurantRepository.save(restaurant); - - assertThat(restaurantRepository.existenceOfAGoodRestaurant()).isFalse(); - } - - @Test // DATAGRAPH-1199 - public void shouldCheckExistenceForExistsQueryMethod() { - Restaurant restaurant = new Restaurant("R1", "good"); - restaurantRepository.save(restaurant); - - assertThat(restaurantRepository.existenceOfAGoodRestaurantWithExistsQuery()) - .isTrue(); - } - - @Test // DATAGRAPH-1199 - public void shouldCheckNonExistenceForExistsQueryMethod() { - Restaurant restaurant = new Restaurant("R1", "bad"); - restaurantRepository.save(restaurant); - - assertThat(restaurantRepository.existenceOfAGoodRestaurantWithExistsQuery()) - .isFalse(); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.examples.restaurants.domain", - repositoryPackages = "org.springframework.data.neo4j.examples.restaurants.repo") - @ComponentScan("org.springframework.data.neo4j.examples.restaurants") - static class RestaurantContext {} -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/domain/Diner.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/domain/Diner.java deleted file mode 100644 index 8247c42a6..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/domain/Diner.java +++ /dev/null @@ -1,54 +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.examples.restaurants.domain; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; - -/** - * An entity (most likely human) that consumes meals in a Restaurant. Not to be confused with the 50s concept that - * serves meals. - */ -public class Diner { - - @Id @GeneratedValue private Long id; - - private String firstName; - private String lastName; - - public Diner() {} - - public Diner(String firstName, String lastName) { - this.firstName = firstName; - this.lastName = lastName; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/domain/Restaurant.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/domain/Restaurant.java deleted file mode 100644 index 9079bb5fa..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/domain/Restaurant.java +++ /dev/null @@ -1,154 +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.examples.restaurants.domain; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.Relationship; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.neo4j.ogm.annotation.typeconversion.DateString; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.conversion.PointConverter; - -/** - * @author Jasper Blues - * @author Michael J. Simons - */ -public class Restaurant implements Comparable { - - @Id @GeneratedValue private Long id; - private String name; - @Convert(PointConverter.class) private Point location; - private int zip; - private double score; - private String description; - private boolean halal; - - @Relationship(type = "REGULAR_DINER", - direction = Relationship.OUTGOING) private List regularDiners = new ArrayList<>(); - - @Relationship(type = "SIMILAR_RESTAURANT", - direction = Relationship.OUTGOING) private List similarRestaurants = new ArrayList<>(); - - @DateString private Date launchDate; - - public Restaurant() {} - - public Restaurant(String name, Point location, int zip) { - this.name = name; - this.location = location; - this.zip = zip; - } - - public Restaurant(String name, double score) { - this.name = name; - this.score = score; - } - - public Restaurant(String name, String description) { - this.name = name; - this.description = description; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Point getLocation() { - return location; - } - - public void setLocation(Point location) { - this.location = location; - } - - public int getZip() { - return zip; - } - - public void setZip(int zip) { - this.zip = zip; - } - - public double getScore() { - return score; - } - - public void setScore(double score) { - this.score = score; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Date getLaunchDate() { - return launchDate; - } - - public void setLaunchDate(Date launchDate) { - this.launchDate = launchDate; - } - - public boolean halal() { - return halal; - } - - public void setHalal(boolean halal) { - this.halal = halal; - } - - public void addRegularDiner(Diner diner) { - this.regularDiners.add(diner); - } - - public List getRegularDiners() { - return this.regularDiners; - } - - public void addSimilarRestaurant(Restaurant restaurant) { - this.similarRestaurants.add(restaurant); - } - - public List getSimilarRestaurants() { - return this.similarRestaurants; - } - - @Override - public String toString() { - return "Restaurant{" + "name='" + name + '\'' + ", score=" + score + '}'; - } - - @Override - public int compareTo(Restaurant o) { - if (this == o) { - return 0; - } - return this.getName().compareTo(o.getName()); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/repo/RestaurantRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/repo/RestaurantRepository.java deleted file mode 100644 index bfde2746a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/restaurants/repo/RestaurantRepository.java +++ /dev/null @@ -1,95 +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.examples.restaurants.repo; - -import java.util.Date; -import java.util.List; - -import org.springframework.data.domain.Range; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.annotation.ExistsQuery; -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.examples.restaurants.domain.Restaurant; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Jasper Blues - */ -public interface RestaurantRepository extends Neo4jRepository { - - List findByNameAndLocationNear(String name, Distance distance, Point point); - - List findByLocationNearAndName(Distance distance, Point point, String name); - - List findByScoreBetween(double min, double max); - - List findByScoreBetween(Range range); - - List findByScoreLessThan(double max); - - List findByScoreLessThanEqual(double max); - - List findByScoreGreaterThan(double max); - - List findByScoreGreaterThanEqual(double max); - - List findByDescriptionIsNull(); - - List findByDescriptionIsNotNull(); - - List findByLaunchDateBefore(Date date); - - List findByLaunchDateAfter(Date date); - - List findByNameNotLike(String name); - - List findByNameLike(String name); - - List findByNameStartingWith(String string); - - List findByNameEndingWith(String string); - - List findByNameContaining(String string); - - List findByNameNotContaining(String string); - - List findByNameIn(Iterable candidates); - - List findByNameNotIn(Iterable candidates); - - List findByNameMatchesRegex(String foobar); - - List findByNameExists(); - - List findByHalalIsTrue(); - - List findByHalalIsFalse(); - - List findBySimilarRestaurantsDescriptionIsNull(); - - List findByRegularDinersLastNameIsNull(); - - List findByNameNotContainingOrDescriptionIsNull(String nameContaining); - - boolean existsByDescription(String description); - - @Query(value = "MATCH (r:Restaurant) WHERE r.description = 'good' return r", exists = true) - boolean existenceOfAGoodRestaurant(); - - @ExistsQuery("MATCH (r:Restaurant) WHERE r.description = 'good' return r") - boolean existenceOfAGoodRestaurantWithExistsQuery(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomGraphRepositoryImpl.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomGraphRepositoryImpl.java deleted file mode 100644 index 07ab7063f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomGraphRepositoryImpl.java +++ /dev/null @@ -1,43 +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.extensions; - -import java.io.Serializable; - -import org.neo4j.ogm.session.Session; -import org.springframework.data.neo4j.repository.support.SimpleNeo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * The class implementing our custom interface extension. - * - * @author Vince Bickers - * @author Luanne Misquitta - * @author Mark Angrish - */ -@Repository -public class CustomGraphRepositoryImpl extends SimpleNeo4jRepository - implements CustomNeo4jRepository { - - public CustomGraphRepositoryImpl(Class clazz, Session session) { - super(clazz, session); - } - - @Override - public boolean sharedCustomMethod() { - return true; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomGraphRepositoryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomGraphRepositoryTests.java deleted file mode 100644 index d38085999..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomGraphRepositoryTests.java +++ /dev/null @@ -1,50 +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.extensions; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author: Vince Bickers - * @author Michael J. Simons - */ -@ContextConfiguration(classes = CustomGraphRepositoryTests.CustomPersistenceContext.class) -@RunWith(SpringRunner.class) -public class CustomGraphRepositoryTests { - - @Autowired private UserRepository repository; - - /** - * asserts that the correct proxied object is created by Spring and that we can integrate with it. - */ - @Test - public void shouldExposeCommonMethodOnExtendedRepository() { - assertThat(repository.sharedCustomMethod()).isTrue(); - } - - @Configuration - @Neo4jIntegrationTest(repositoryBaseClass = CustomGraphRepositoryImpl.class, domainPackages = "org.springframework.data.neo4j.extensions.domain") - static class CustomPersistenceContext {} -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomNeo4jRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomNeo4jRepository.java deleted file mode 100644 index 21736a2f0..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/CustomNeo4jRepository.java +++ /dev/null @@ -1,33 +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.extensions; - -import java.io.Serializable; - -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.repository.NoRepositoryBean; - -/** - * This interface declares a custom method that we want to be available to all repositories that extend this class - * - * @author: Vince Bickers - */ -@NoRepositoryBean -public interface CustomNeo4jRepository extends Neo4jRepository { - - boolean sharedCustomMethod(); - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/UserRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/UserRepository.java deleted file mode 100644 index 77a1f16fb..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/UserRepository.java +++ /dev/null @@ -1,25 +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.extensions; - -import org.springframework.data.neo4j.extensions.domain.User; -import org.springframework.stereotype.Repository; - -/** - * @author: Vince Bickers - */ -@Repository -public interface UserRepository extends CustomNeo4jRepository {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/PersistenceConstructorsTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/PersistenceConstructorsTests.java deleted file mode 100644 index e964cb013..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/PersistenceConstructorsTests.java +++ /dev/null @@ -1,342 +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.constructors; - -import static java.util.stream.Collectors.*; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.stream.StreamSupport; - -import org.assertj.core.util.DateUtil; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.ogm.exception.core.MappingException; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.convert.ConversionService; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.conversion.MetaDataDrivenConversionService; -import org.springframework.data.neo4j.integration.constructors.domain.*; -import org.springframework.data.neo4j.mapping.Neo4jMappingContext; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = PersistenceConstructorsTests.PersistenceConstructorsPersistenceContext.class) -public class PersistenceConstructorsTests { - - @Autowired GraphDatabaseService graphDatabaseService; - - @Autowired Session session; - - @Autowired Neo4jMappingContext ctx; - - @Autowired PersonRepository personRepository; - - @Autowired PersonWithFinalNameRepository pfnRepository; - - @Autowired PersonMultipleConstructorsRepository pmcRepository; - - @Autowired PersonWithAnnotatedPersistenceConstructorRepository papcRepository; - - @Autowired PersonWithConverterRepository pwcRepository; - - @Autowired PersonWithCompositeAttributeRepository pwcaRepository; - - @Autowired PersonWithManyToOneRelRepository manyToOneRepository; - - @Autowired KotlinPersonRepository kotlinRepository; - - @Autowired KotlinDataPersonRepository kotlinDataPersonRepository; - - @Autowired TransactionTemplate transactionTemplate; - - @Test - public void shouldHandleSimpleEntityWithConstructor() { - - Person person = new Person("foo"); - personRepository.save(person); - session.clear(); - - List persons = iterableToList(personRepository.findAll()); - assertThat(persons.size()).isEqualTo(1); - assertThat(persons.get(0).getName()).isEqualTo("foo"); - } - - @Test - public void shouldHandleRelationshipEntityWithConstructor() { - - Person person = new Person("foo"); - Person friend = new Person("bar"); - person.addFriend(friend); - personRepository.save(person); - session.clear(); - - List persons = iterableToList(personRepository.findAll()); - assertThat(persons.size()).isEqualTo(2); - Person person1 = persons.stream().filter(p -> p.equals(person)).findFirst().get(); - assertThat(person1.getName()).isEqualTo("foo"); - assertThat(person1.getFriendships().size()).isEqualTo(1); - - Friendship friendship = person.getFriendships().get(0); - assertThat(friendship.getPersonStartNode()).isEqualTo(person); - assertThat(friendship.getPersonEndNode()).isEqualTo(friend); - assertThat(DateUtil.timeDifference(friendship.getTimestamp(), new Date()) < 1000) - .isTrue(); - assertThat(friendship.getLocation()).isEqualTo(new Point(1, 2)); - } - - @Test - public void shouldThrowAnExplicitExceptionIfMultipleConstructors() { - - PersonMultipleConstructors pmc = new PersonMultipleConstructors("foo"); - pmcRepository.save(pmc); - session.clear(); - - try { - pmcRepository.findAll(); - fail("Should have raised an exception"); - } catch (InvalidDataAccessApiUsageException e) { - assertThat(e.getCause().getClass()).isEqualTo(MappingException.class); - } - } - - @Test - public void shouldUseAnnotatedPersistenceConstructor() { - - PersonWithAnnotatedPersistenceConstructor pmc = new PersonWithAnnotatedPersistenceConstructor("foo", "bar"); - papcRepository.save(pmc); - session.clear(); - - List persons = iterableToList(papcRepository.findAll()); - assertThat(persons.size()).isEqualTo(1); - PersonWithAnnotatedPersistenceConstructor person = persons.get(0); - assertThat(person.getFirstName()).isEqualTo("foo"); - assertThat(person.getLastName()).isEqualTo("bar"); - } - - // This test is not really representative because atm relations are not passed to constructor by OGM - // they are populated in a second step, after object instantiation - @Test - public void shouldHandleRelationshipInCtor() { - PersonWithManyToOneRel person = new PersonWithManyToOneRel("foo", new Group("ADMIN")); - manyToOneRepository.save(person); - session.clear(); - - List persons = iterableToList(manyToOneRepository.findAll()); - assertThat(persons.size()).isEqualTo(1); - assertThat(persons.get(0).getName()).isEqualTo("foo"); - assertThat(persons.get(0).getGroup().getName()).isEqualTo("ADMIN"); - } - - @Test - @Ignore("final fields are not supported by OGM for now") - public void shouldHandleFinalFields() { - PersonWithFinalName person = new PersonWithFinalName("foo"); - pfnRepository.save(person); - session.clear(); - - List persons = iterableToList(pfnRepository.findAll()); - assertThat(persons.size()).isEqualTo(1); - assertThat(persons.get(0).getName()).isEqualTo("foo"); - } - - @Test - public void shouldHandleTypeConversion() { - Date date = new Date(); - PersonWithConverter person = new PersonWithConverter("foo", date); - pwcRepository.save(person); - session.clear(); - - List persons = iterableToList(pwcRepository.findAll()); - assertThat(persons.size()).isEqualTo(1); - assertThat(persons.get(0).getName()).isEqualTo("foo"); - assertThat(persons.get(0).getBirthDate()).isEqualTo(date); - } - - @Test - public void shouldHandleCompositeAttributes() { - Point location = new Point(1.0, 2.0); - PersonWithCompositeAttribute person = new PersonWithCompositeAttribute("foo", location); - pwcaRepository.save(person); - session.clear(); - - List persons = iterableToList(pwcaRepository.findAll()); - assertThat(persons.size()).isEqualTo(1); - assertThat(persons.get(0).getName()).isEqualTo("foo"); - assertThat(persons.get(0).getLocation()).isEqualTo(location); - } - - @Test - public void shouldSupportKotlinDataClasses() { - - KotlinPerson person = new KotlinPerson("foo", new ArrayList<>()); - kotlinRepository.save(person); - session.clear(); - - Collection persons = session.loadAll(KotlinPerson.class); - assertThat(persons.size()).isEqualTo(1); - assertThat(persons.iterator().next().getName()).isEqualTo("foo"); - } - - @Test // DATAGRAPH-1220 - public void shouldSupportKotlinDataClassesWithGeneratedIds() { - - KotlinDataPerson person0 = KotlinPersonKt.newDataPerson("Not to be persisted"); - - // Make sure we don't interfere with OGMs session cache but also don't clean it externally - - KotlinDataPerson person1 = transactionTemplate - .execute(t -> kotlinDataPersonRepository.save(KotlinPersonKt.newDataPerson("Data Person 1"))); - KotlinDataPerson person2 = transactionTemplate - .execute(t -> kotlinDataPersonRepository.save(KotlinPersonKt.newDataPerson("Data Person 2"))); - - // Assert that the id is actually null without database interaction - assertThat(person0.getId()).isNull(); - assertThat(person1.getId()).isNotNull(); - assertThat(person2.getId()).isNotNull(); - - // Load the rest - transactionTemplate.execute(t -> { - List loadedPersons = kotlinDataPersonRepository.findAll(); - assertThat(loadedPersons.size()).isEqualTo(2); - assertThat(loadedPersons).contains(person1, person2); - return null; - }); - - transactionTemplate.execute(t -> { - Optional loadedPerson1 = kotlinDataPersonRepository.findById(person1.getId()); - Optional loadedPerson2 = kotlinDataPersonRepository.findById(person2.getId()); - - assertThat(loadedPerson1.isPresent()).isTrue(); - assertThat(loadedPerson2.isPresent()).isTrue(); - return null; - }); - - // Double check the finder by another index field - transactionTemplate.execute(t -> { - - Optional loadedPerson1 = kotlinDataPersonRepository.findByName(person1.getName()); - assertThat(loadedPerson1.isPresent()).isTrue(); - return null; - }); - } - - @Test - public void shouldSupportQueryResults() { - session.query( - "MERGE (buffy:Person {name: 'Buffy'}) - [:IS_FRIEND {timestamp: 1533570712595, latitude: 34.10367, longitude: -118.272562}] -> (spike:Person {name: 'Spike'})\n" - + "MERGE (willow:Person {name: 'Willow'})\n" + "MERGE (xander:Person {name: 'Xander'})\n" - + "MERGE (buffy) - [:IS_FRIEND {timestamp: 1533570712595, latitude: 34.10367, longitude: -118.272562}] -> (willow)\n" - + "MERGE (willow) - [:IS_FRIEND {timestamp: 1533570712595, latitude: 34.10367, longitude: -118.272562}] -> (buffy)\n" - + "MERGE (buffy) - [:IS_FRIEND {timestamp: 1533570712595, latitude: 34.10367, longitude: -118.272562}] -> (xander)\n" - + "MERGE (xander) - [:IS_FRIEND {timestamp: 1533570712595, latitude: 34.10367, longitude: -118.272562}] -> (buffy)", - new HashMap<>()); - - List personsWithMutualFriends = personRepository.findPersonWithMutualFriendsByName("Buffy"); - assertThat(personsWithMutualFriends.size()).isEqualTo(1); - assertThat(personsWithMutualFriends.get(0).getNumberOfFriends()).isEqualTo(3L); - - List namesOfMutalFriends = personsWithMutualFriends.get(0).getMutualFriends().stream().map(Person::getName) - .collect(toList()); - assertThat(namesOfMutalFriends.containsAll(Arrays.asList("Willow", "Xander"))) - .isTrue(); - } - - @Before - public void setUp() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Repository - public interface PersonRepository extends Neo4jRepository { - @Query("MATCH (n:Person {name: $name}) \n" + "WITH n, size((n) - [:IS_FRIEND] -> ()) AS numberOfFriends\n" - + "MATCH (n) - [:IS_FRIEND] -> (m:Person) - [:IS_FRIEND] -> (n)\n" - + "RETURN n.name AS name, numberOfFriends, collect(m) AS mutualFriends") - List findPersonWithMutualFriendsByName(@Param("name") String name); - } - - @Repository - public interface KotlinPersonRepository extends Neo4jRepository {} - - @Repository - public interface KotlinDataPersonRepository extends Neo4jRepository { - - List findAll(); - - Optional findByName(String name); - } - - @Repository - public interface PersonMultipleConstructorsRepository extends Neo4jRepository {} - - @Repository - public interface PersonWithAnnotatedPersistenceConstructorRepository - extends Neo4jRepository {} - - @Repository - public interface PersonWithConverterRepository extends Neo4jRepository {} - - @Repository - public interface PersonWithCompositeAttributeRepository - extends Neo4jRepository {} - - @Repository - public interface PersonWithFinalNameRepository extends Neo4jRepository {} - - @Repository - public interface PersonWithManyToOneRelRepository extends Neo4jRepository {} - - private static List iterableToList(Iterable iterable) { - return StreamSupport.stream(iterable.spliterator(), false).collect(toList()); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.integration.constructors.domain", - repositoryPackages = "org.springframework.data.neo4j.integration.constructors", considerNestedRepositories = true) - static class PersistenceConstructorsPersistenceContext { - - @Bean - public ConversionService conversionService(SessionFactory sessionFactory) { - return new MetaDataDrivenConversionService(sessionFactory.metaData()); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Friendship.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Friendship.java deleted file mode 100644 index bfad5ac76..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Friendship.java +++ /dev/null @@ -1,82 +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.constructors.domain; - -import java.util.Date; - -import org.neo4j.ogm.annotation.EndNode; -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.RelationshipEntity; -import org.neo4j.ogm.annotation.StartNode; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.neo4j.ogm.annotation.typeconversion.DateLong; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.conversion.PointConverter; -import org.springframework.util.Assert; - -/** - * @author Nicolas Mervaillie - */ -@RelationshipEntity(type = "IS_FRIEND") -public class Friendship { - - @Id @GeneratedValue private Long id; - - @StartNode private Person personStartNode; - - @EndNode private Person personEndNode; - - @DateLong private Date timestamp; - - @Convert(PointConverter.class) private Point location; - - public Friendship(Person personStartNode, Person personEndNode, Date timestamp, Point location) { - Assert.notNull(timestamp, "Timestamp cannot be null"); - Assert.notNull(location, "Location cannot be null"); - Assert.notNull(personStartNode, "personStartNode cannot be null"); - Assert.notNull(personEndNode, "personEndNode cannot be null"); - // start & end nodes are passed as null - this.personStartNode = personStartNode; - this.personEndNode = personEndNode; - this.timestamp = timestamp; - this.location = location; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Person getPersonStartNode() { - return personStartNode; - } - - public Person getPersonEndNode() { - return personEndNode; - } - - public Date getTimestamp() { - return timestamp; - } - - public Point getLocation() { - return location; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Group.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Group.java deleted file mode 100644 index 6941c31f4..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Group.java +++ /dev/null @@ -1,38 +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.constructors.domain; - -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.springframework.util.Assert; - -/** - * @author Nicolas Mervaillie - */ -@NodeEntity -public class Group { - - @Id private String name; - - public Group(String name) { - Assert.notNull(name, "name should not be null"); - this.name = name; - } - - public String getName() { - return name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Person.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Person.java deleted file mode 100644 index 22785e1a0..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/Person.java +++ /dev/null @@ -1,73 +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.constructors.domain; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Objects; - -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Relationship; -import org.springframework.data.geo.Point; -import org.springframework.util.Assert; - -/** - * @author Nicolas Mervaillie - */ -@NodeEntity -public class Person { - - @Id private String name; - - @Relationship(type = "IS_FRIEND") private List friendships = new ArrayList<>(); - - public Person(String name) { - Assert.notNull(name, "name should not be null"); - this.name = name; - } - - public String getName() { - return name; - } - - public List getFriendships() { - return friendships; - } - - public Friendship addFriend(Person newFriend) { - Friendship friendship = new Friendship(this, newFriend, new Date(), new Point(1, 2)); - this.friendships.add(friendship); - return friendship; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - Person person = (Person) o; - return Objects.equals(name, person.name); - } - - @Override - public int hashCode() { - - return Objects.hash(name); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonMultipleConstructors.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonMultipleConstructors.java deleted file mode 100644 index e6ecc4de8..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonMultipleConstructors.java +++ /dev/null @@ -1,48 +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.constructors.domain; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * @author Nicolas Mervaillie - */ -@NodeEntity -public class PersonMultipleConstructors { - - @Id @GeneratedValue private Long id; - private String firstName; - private String lastName; - - public PersonMultipleConstructors(String lastName) { - this.lastName = lastName; - } - - public PersonMultipleConstructors(String firstName, String lastName) { - this.firstName = firstName; - this.lastName = lastName; - } - - public String getFirstName() { - return firstName; - } - - public String getLastName() { - return lastName; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonProjection.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonProjection.java deleted file mode 100644 index 7325450f2..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonProjection.java +++ /dev/null @@ -1,54 +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.constructors.domain; - -import java.util.List; - -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * An arbitrary {@link QueryResult} used as a projection of a person. - * - * @author Michael J. Simons - */ -@QueryResult -public class PersonProjection { - private String name; - - private long numberOfFriends; - - private List mutualFriends; - - public PersonProjection(String name, - long numberOfFriends, - List mutualFriends) { - this.name = name; - this.numberOfFriends = numberOfFriends; - this.mutualFriends = mutualFriends; - } - - public String getName() { - return name; - } - - public long getNumberOfFriends() { - return numberOfFriends; - } - - public List getMutualFriends() { - return mutualFriends; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithAnnotatedPersistenceConstructor.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithAnnotatedPersistenceConstructor.java deleted file mode 100644 index bf6cbbfd1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithAnnotatedPersistenceConstructor.java +++ /dev/null @@ -1,53 +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.constructors.domain; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.springframework.data.annotation.PersistenceConstructor; -import org.springframework.util.Assert; - -/** - * @author Nicolas Mervaillie - */ -@NodeEntity -public class PersonWithAnnotatedPersistenceConstructor { - - @Id @GeneratedValue private Long id; - private String firstName; - private String lastName; - - public PersonWithAnnotatedPersistenceConstructor(String lastName) { - this.lastName = lastName; - } - - @PersistenceConstructor - public PersonWithAnnotatedPersistenceConstructor(String firstName, String lastName) { - Assert.notNull(firstName, "firstName should not be null"); - Assert.notNull(lastName, "lastName should not be null"); - this.firstName = firstName; - this.lastName = lastName; - } - - public String getFirstName() { - return firstName; - } - - public String getLastName() { - return lastName; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithCompositeAttribute.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithCompositeAttribute.java deleted file mode 100644 index 85d703014..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithCompositeAttribute.java +++ /dev/null @@ -1,49 +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.constructors.domain; - -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.conversion.PointConverter; -import org.springframework.util.Assert; - -/** - * @author Nicolas Mervaillie - */ -@NodeEntity -public class PersonWithCompositeAttribute { - - @Id private String name; - - @Convert(PointConverter.class) private Point location; - - public PersonWithCompositeAttribute(String name, Point location) { - Assert.notNull(name, "name should not be null"); - Assert.notNull(location, "location should not be null"); - this.name = name; - this.location = location; - } - - public String getName() { - return name; - } - - public Point getLocation() { - return location; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithConverter.java deleted file mode 100644 index 902be8dbf..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithConverter.java +++ /dev/null @@ -1,49 +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.constructors.domain; - -import java.util.Date; - -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.typeconversion.DateLong; -import org.springframework.util.Assert; - -/** - * @author Nicolas Mervaillie - */ -@NodeEntity -public class PersonWithConverter { - - @Id private String name; - - @DateLong private Date birthDate; - - public PersonWithConverter(String name, Date birthDate) { - Assert.notNull(name, "name should not be null"); - Assert.notNull(birthDate, "birthDate should not be null"); - this.name = name; - this.birthDate = birthDate; - } - - public String getName() { - return name; - } - - public Date getBirthDate() { - return birthDate; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithFinalName.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithFinalName.java deleted file mode 100644 index 4d39f398a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithFinalName.java +++ /dev/null @@ -1,54 +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.constructors.domain; - -import java.util.Objects; - -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * @author Nicolas Mervaillie - */ -@NodeEntity -public class PersonWithFinalName { - - @Id private final String name; - - public PersonWithFinalName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - PersonWithFinalName person = (PersonWithFinalName) o; - return Objects.equals(name, person.name); - } - - @Override - public int hashCode() { - - return Objects.hash(name); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithManyToOneRel.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithManyToOneRel.java deleted file mode 100644 index fbb087102..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/constructors/domain/PersonWithManyToOneRel.java +++ /dev/null @@ -1,64 +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.constructors.domain; - -import java.util.Objects; - -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Relationship; -import org.springframework.util.Assert; - -/** - * @author Nicolas Mervaillie - */ -@NodeEntity -public class PersonWithManyToOneRel { - - @Id private String name; - - @Relationship(type = "BELONGS_TO") private Group group; - - public PersonWithManyToOneRel(String name, Group group) { - Assert.notNull(name, "name should not be null"); - this.name = name; - this.group = group; - } - - public String getName() { - return name; - } - - public Group getGroup() { - return group; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - PersonWithManyToOneRel person = (PersonWithManyToOneRel) o; - return Objects.equals(name, person.name); - } - - @Override - public int hashCode() { - - return Objects.hash(name); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ConversionServiceTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ConversionServiceTests.java deleted file mode 100644 index f687398f8..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ConversionServiceTests.java +++ /dev/null @@ -1,264 +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.conversion; - -import java.lang.annotation.ElementType; -import java.math.BigInteger; -import java.math.RoundingMode; -import java.util.Arrays; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.Result; -import org.neo4j.harness.ServerControls; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.convert.ConversionService; -import org.springframework.core.convert.ConverterNotFoundException; -import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.data.neo4j.conversion.MetaDataDrivenConversionService; -import org.springframework.data.neo4j.integration.conversion.domain.JavaElement; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; -import org.springframework.data.neo4j.integration.conversion.domain.PensionPlan; -import org.springframework.data.neo4j.integration.conversion.domain.SiteMember; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.support.TransactionTemplate; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * See DATAGRAPH-624 - * - * @author Adam George - * @author Luanne Misquitta - * @author Vince Bickers - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = ConversionServiceTests.ConversionServicePersistenceContext.class) -public class ConversionServiceTests { - - @Autowired private ServerControls neo4jTestServer; - @Autowired private PensionRepository pensionRepository; - @Autowired private JavaElementRepository javaElementRepository; - @Autowired private SiteMemberRepository siteMemberRepository; - // TODO See below, for the time being at least be explicit on which type of conversion service we're working on here - // The only thing that is under test, is the instance of MetaDataDrivenConversionService which get's even - // modified heavily be this test. This needs to be fixed in the near future. - // Also it doesn't test conversion with `graphPropertyType` attribute and a standard Spring Converter. - @Autowired private MetaDataDrivenConversionService conversionService; - - @Autowired Session session; - - @Autowired private TransactionTemplate transactionTemplate; - - @Before - public void setUp() { - neo4jTestServer.graph().execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - /** - * This should work by virtue of the fact that there's an OGM-level converter defined on a class we've scanned. - */ - @Test - public void shouldBeAbleToConvertBetweenBytesAndBase64EncodedDataViaSpringConversionService() { - String base64Representation = "YmNkZWY="; - byte[] binaryData = new byte[] { 98, 99, 100, 101, 102 }; - - assertThat(this.conversionService.canConvert(byte[].class, String.class)) - .isTrue(); - assertThat(this.conversionService.convert(binaryData, String.class)) - .isEqualTo(base64Representation); - - assertThat(this.conversionService.canConvert(String.class, byte[].class)) - .isTrue(); - assertThat(Arrays.equals(binaryData, this.conversionService - .convert(base64Representation, byte[].class))).isTrue(); - } - - @Test - public void shouldConvertBase64StringOutOfGraphDatabaseBackIntoByteArray() { - Result rs = neo4jTestServer.graph() - .execute("CREATE (u:SiteMember {profilePictureData:'MTIzNDU2Nzg5'}) RETURN id(u) AS userId"); - Long userId = (Long) rs.columnAs("userId").next(); - - byte[] expectedData = "123456789".getBytes(); - - SiteMember siteMember = this.siteMemberRepository.findById(userId).get(); - assertThat(Arrays.equals(expectedData, siteMember.getProfilePictureData())) - .as("The data wasn't converted correctly").isTrue(); - } - - @Test - public void shouldConvertFieldsUsingSpringConvertersAddedDirectlyToConversionService() { - - PensionPlan pensionToSave = transactionTemplate.execute(status -> { - conversionService.addConverter(new SpringMonetaryAmountToIntegerConverter()); - conversionService.addConverter(new SpringIntegerToMonetaryAmountConverter()); - conversionService.addConverter(new SpringMonetaryAmountToLongConverter()); - conversionService.addConverter(new SpringLongToMonetaryAmountConverter()); - - PensionPlan pensionToSave1 = new PensionPlan(new MonetaryAmount(16472, 81), "Tightfist Asset Management Ltd"); - - pensionRepository.save(pensionToSave1); - return pensionToSave1; - }); - - Result result = neo4jTestServer.graph().execute("MATCH (p:PensionPlan) RETURN p.fundValue AS fv"); - assertThat(result.hasNext()).as("Nothing was saved").isTrue(); - assertThat(String.valueOf(result.next().get("fv"))) - .as("The amount wasn't converted and persisted correctly") - .isEqualTo("1647281"); - result.close(); - - PensionPlan reloadedPension = this.pensionRepository.findById(pensionToSave.getPensionPlanId()).get(); - assertThat(reloadedPension.getFundValue()) - .as("The amount was converted incorrectly") - .isEqualTo(pensionToSave.getFundValue()); - } - - /** - * If target graph type is set to Integer but we have a converter for a Number then it should still save to the graph. - */ - @Test - public void shouldConvertFieldsUsingAnAvailableSupertypeConverterIfExactTypesDoNotMatch() { - - this.conversionService.addConverterFactory(new SpringMonetaryAmountToNumberConverterFactory()); - // this.conversionService.addConverter(new SpringIntegerToMonetaryAmountConverter()); - - PensionPlan pension = new PensionPlan(new MonetaryAmount(20_000, 00), "Ashes Assets LLP"); - this.pensionRepository.save(pension); - Result result = neo4jTestServer.graph().execute("MATCH (p:PensionPlan) RETURN p.fundValue AS fv"); - assertThat(result.hasNext()).as("Nothing was saved").isTrue(); - assertThat(String.valueOf(result.next().get("fv"))) - .as("The amount wasn't converted and persisted correctly") - .isEqualTo("2000000"); - result.close(); - } - - /** - * This should fix DATAGRAPH-659 too. - */ - @Test - public void shouldOperateWithDefaultSpringConvertersToConvertObjectTypesNotInMetaData() { - DefaultConversionService.addDefaultConverters(this.conversionService); - - JavaElement method = new JavaElement(); - method.setName("toString"); - method.setElementType(ElementType.METHOD); - - this.javaElementRepository.save(method); - - Result result = neo4jTestServer.graph().execute("MATCH (e:JavaElement) RETURN e.elementType AS type"); - assertThat(result.hasNext()).as("Nothing was saved").isTrue(); - assertThat(result.next().get("type")) - .as("The element type wasn't converted and persisted correctly") - .isEqualTo("METHOD"); - result.close(); - - JavaElement loadedObject = this.javaElementRepository.findAll().iterator().next(); - assertThat(loadedObject.getElementType()) - .as("The element type wasn't loaded and converted correctly") - .isEqualTo(ElementType.METHOD); - } - - @Test(expected = ConverterNotFoundException.class) - public void shouldThrowExceptionIfSuitableConverterIsNotFound() { - this.conversionService.addConverterFactory(new SpringMonetaryAmountToNumberConverterFactory()); - - PensionPlan pension = new PensionPlan(new MonetaryAmount(20_000, 00), "Ashes Assets LLP"); - pension.setJavaElement(new JavaElement()); - this.pensionRepository.save(pension); - } - - @Test - public void shouldUseSpecifiedAttributeConverterInsteadOfSprings() { - // We're registering Spring converters as well - this.conversionService.addConverter(new SpringIntegerToByteArrayConverter()); - this.conversionService.addConverter(new SpringByteArrayToIntegerConverter()); - - String base64Representation = "YmNkZWY="; - byte[] binaryData = new byte[] { 98, 99, 100, 101, 102 }; - - assertThat(this.conversionService.canConvert(byte[].class, String.class)) - .isTrue(); - assertThat(this.conversionService.convert(binaryData, String.class)) - .isEqualTo(base64Representation); - - assertThat(this.conversionService.canConvert(String.class, byte[].class)) - .isTrue(); - assertThat(Arrays.equals(binaryData, this.conversionService - .convert(base64Representation, byte[].class))).isTrue(); - - SiteMember siteMember = new SiteMember(); - siteMember.setProfilePictureData(binaryData); - this.siteMemberRepository.save(siteMember); - - siteMember = session.loadAll(SiteMember.class).iterator().next(); - assertThat(siteMember.getProfilePictureData()).isEqualTo(binaryData); - } - - @Test - public void shouldUseDefaultAttributeConverterInsteadOfSprings() { - // We're registering Spring converters which should not override the default ogm BigInteger converter - this.conversionService.addConverter(new SpringBigIntegerToBooleanConverter()); - this.conversionService.addConverter(new SpringBooleanToBigIntegerConverter()); - - byte[] binaryData = new byte[] { 98, 99, 100, 101, 102 }; - - SiteMember siteMember = new SiteMember(); - siteMember.setProfilePictureData(binaryData); - siteMember.setYears(BigInteger.valueOf(50)); - this.siteMemberRepository.save(siteMember); - - siteMember = session.loadAll(SiteMember.class).iterator().next(); - assertThat(siteMember.getProfilePictureData()).isEqualTo(binaryData); - assertThat(siteMember.getYears().intValue()).isEqualTo(50); - } - - @Test // DATAGRAPH-659 - public void shouldRecognizeJavaEnums() { - SiteMember siteMember = new SiteMember(); - siteMember.setRoundingModes(Arrays.asList(RoundingMode.DOWN, RoundingMode.FLOOR)); - this.siteMemberRepository.save(siteMember); - - siteMember = session.loadAll(SiteMember.class).iterator().next(); - assertThat(siteMember.getRoundingModes().size()).isEqualTo(2); - assertThat(siteMember.getRoundingModes().contains(RoundingMode.DOWN)).isTrue(); - assertThat(siteMember.getRoundingModes().contains(RoundingMode.FLOOR)).isTrue(); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.integration.conversion.domain", - repositoryPackages = "org.springframework.data.neo4j.integration.conversion") - static class ConversionServicePersistenceContext { - - @Bean - public ConversionService conversionService(SessionFactory sessionFactory) { - return new MetaDataDrivenConversionService(sessionFactory.metaData()); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/JavaElementRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/JavaElementRepository.java deleted file mode 100644 index b3e314c73..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/JavaElementRepository.java +++ /dev/null @@ -1,30 +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.conversion; - -import org.springframework.data.neo4j.integration.conversion.domain.JavaElement; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Adam George - */ -@Repository -public interface JavaElementRepository extends Neo4jRepository { - - // no additional repository methods - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/PensionRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/PensionRepository.java deleted file mode 100644 index 3b8074346..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/PensionRepository.java +++ /dev/null @@ -1,30 +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.conversion; - -import org.springframework.data.neo4j.integration.conversion.domain.PensionPlan; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Adam George - */ -@Repository -public interface PensionRepository extends Neo4jRepository { - - // no additional repository methods - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ShouldGracefullyHandleMultipleConversionServicesTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ShouldGracefullyHandleMultipleConversionServicesTests.java deleted file mode 100644 index 8618f1a0c..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ShouldGracefullyHandleMultipleConversionServicesTests.java +++ /dev/null @@ -1,56 +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.conversion; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.convert.ConversionService; -import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.data.neo4j.conversion.MetaDataDrivenConversionService; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration( - classes = ShouldGracefullyHandleMultipleConversionServicesTests.ConversionServicePersistenceContext.class) -public class ShouldGracefullyHandleMultipleConversionServicesTests { - - @Test - public void contextLoads() {} - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.integration.conversion.domain", - repositoryPackages = "org.springframework.data.neo4j.integration.conversion") - static class ConversionServicePersistenceContext { - - @Bean - public ConversionService conversionService1(SessionFactory sessionFactory) { - return new MetaDataDrivenConversionService(sessionFactory.metaData()); - } - - @Bean - public ConversionService conversionService2() { - return DefaultConversionService.getSharedInstance(); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ShouldPickPrimaryConversionServiceTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ShouldPickPrimaryConversionServiceTests.java deleted file mode 100644 index 1ae126100..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/ShouldPickPrimaryConversionServiceTests.java +++ /dev/null @@ -1,106 +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.conversion; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Result; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.core.convert.ConversionService; -import org.springframework.core.convert.converter.Converter; -import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.core.convert.support.GenericConversionService; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; -import org.springframework.data.neo4j.integration.conversion.domain.PensionPlan; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = ShouldPickPrimaryConversionServiceTests.ConversionServicePersistenceContext.class) -public class ShouldPickPrimaryConversionServiceTests { - - @Autowired private GraphDatabaseService graphDatabaseService; - - @Autowired private PensionRepository pensionRepository; - - @Before - public void setUp() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Test - public void shouldWorkWithArbitraryPrimaryConversionBeans() { - PensionPlan pension = new PensionPlan(new MonetaryAmount(16472, 81), "Tightfist Asset Management Ltd"); - pension = this.pensionRepository.save(pension); - - Result result = graphDatabaseService.execute("MATCH (p:PensionPlan) RETURN p.fundValue AS fv"); - assertThat(result.hasNext()).as("Nothing was saved").isTrue(); - assertThat(String.valueOf(result.next().get("fv"))) - .as("The amount wasn't converted and persisted correctly") - .isEqualTo("42"); - result.close(); - - PensionPlan reloadedPension = this.pensionRepository.findById(pension.getPensionPlanId()).get(); - assertThat(reloadedPension.getFundValue()) - .as("The amount was converted incorrectly") - .isEqualTo(new MonetaryAmount(21, 0)); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.integration.conversion.domain", - repositoryPackages = "org.springframework.data.neo4j.integration.conversion") - static class ConversionServicePersistenceContext { - - /** - * @return A pretty bogus conversion, basically only half the truth. - */ - @Bean - @Primary - public ConversionService conversionService1() { - GenericConversionService conversionService = new GenericConversionService(); - // Please don't replace with lambdas, otherwise Spring won't be able to determine source and target types - conversionService.addConverter(new Converter() { - @Override - public Integer convert(MonetaryAmount source) { - return 42; - } - }); - conversionService.addConverter(new Converter() { - @Override - public MonetaryAmount convert(Long source) { - return new MonetaryAmount(21, 0); - } - }); - return conversionService; - } - - @Bean - public ConversionService conversionService2() { - return DefaultConversionService.getSharedInstance(); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SiteMemberRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SiteMemberRepository.java deleted file mode 100644 index 8ab929ea6..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SiteMemberRepository.java +++ /dev/null @@ -1,30 +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.conversion; - -import org.springframework.data.neo4j.integration.conversion.domain.SiteMember; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Adam George - */ -@Repository -public interface SiteMemberRepository extends Neo4jRepository { - - // no additional repository methods - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringBigIntegerToBooleanConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringBigIntegerToBooleanConverter.java deleted file mode 100644 index c8dd9a6bc..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringBigIntegerToBooleanConverter.java +++ /dev/null @@ -1,33 +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.conversion; - -import java.math.BigInteger; - -import org.springframework.core.convert.converter.Converter; - -/** - * Nonsensical Spring converter for test purposes - * - * @author Luanne Misquitta - */ -public class SpringBigIntegerToBooleanConverter implements Converter { - - @Override - public Boolean convert(BigInteger source) { - return source.intValue() > 100; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringBooleanToBigIntegerConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringBooleanToBigIntegerConverter.java deleted file mode 100644 index a7c5238b3..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringBooleanToBigIntegerConverter.java +++ /dev/null @@ -1,36 +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.conversion; - -import java.math.BigInteger; - -import org.springframework.core.convert.converter.Converter; - -/** - * Nonsensical Spring converter for testing purposes - * - * @author Luanne Misquitta - */ -public class SpringBooleanToBigIntegerConverter implements Converter { - - @Override - public BigInteger convert(Boolean source) { - if (source) { - return BigInteger.valueOf(101); - } - return BigInteger.valueOf(1); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringByteArrayToIntegerConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringByteArrayToIntegerConverter.java deleted file mode 100644 index cdea5e2b3..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringByteArrayToIntegerConverter.java +++ /dev/null @@ -1,31 +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.conversion; - -import org.springframework.core.convert.converter.Converter; - -/** - * Nonsensical spring converter from a byte[] to an Integer, for test purposes - * - * @author Luanne Misquitta - */ -public class SpringByteArrayToIntegerConverter implements Converter { - - @Override - public Integer convert(byte[] source) { - return source.length; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringIntegerToByteArrayConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringIntegerToByteArrayConverter.java deleted file mode 100644 index 8faff4e5b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringIntegerToByteArrayConverter.java +++ /dev/null @@ -1,31 +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.conversion; - -import org.springframework.core.convert.converter.Converter; - -/** - * Nonsensical spring converter from a byte[] to an Integer, for test purposes - * - * @author Luanne Misquitta - */ -public class SpringIntegerToByteArrayConverter implements Converter { - - @Override - public byte[] convert(Integer source) { - return new byte[source]; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringIntegerToMonetaryAmountConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringIntegerToMonetaryAmountConverter.java deleted file mode 100644 index 72a285775..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringIntegerToMonetaryAmountConverter.java +++ /dev/null @@ -1,28 +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.conversion; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; - -public class SpringIntegerToMonetaryAmountConverter implements Converter { - - @Override - public MonetaryAmount convert(Integer source) { - return source != null ? new MonetaryAmount(source.intValue() / 100, source.intValue() % 100) : null; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringLongToMonetaryAmountConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringLongToMonetaryAmountConverter.java deleted file mode 100644 index 9d6ad369e..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringLongToMonetaryAmountConverter.java +++ /dev/null @@ -1,28 +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.conversion; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; - -public class SpringLongToMonetaryAmountConverter implements Converter { - - @Override - public MonetaryAmount convert(Long source) { - return source != null ? new MonetaryAmount(source.intValue() / 100, source.intValue() % 100) : null; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToIntegerConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToIntegerConverter.java deleted file mode 100644 index 0b70bc815..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToIntegerConverter.java +++ /dev/null @@ -1,28 +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.conversion; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; - -public class SpringMonetaryAmountToIntegerConverter implements Converter { - - @Override - public Integer convert(MonetaryAmount source) { - return source != null ? (int) source.getAmountAsSubUnits() : null; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToLongConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToLongConverter.java deleted file mode 100644 index c1201f715..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToLongConverter.java +++ /dev/null @@ -1,28 +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.conversion; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; - -public class SpringMonetaryAmountToLongConverter implements Converter { - - @Override - public Long convert(MonetaryAmount source) { - return source != null ? (long) source.getAmountAsSubUnits() : null; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToNumberConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToNumberConverter.java deleted file mode 100644 index 78a353232..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToNumberConverter.java +++ /dev/null @@ -1,28 +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.conversion; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; - -public class SpringMonetaryAmountToNumberConverter implements Converter { - - @Override - public Number convert(MonetaryAmount source) { - return source != null ? source.getAmountAsSubUnits() : null; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToNumberConverterFactory.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToNumberConverterFactory.java deleted file mode 100644 index 11b61f983..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringMonetaryAmountToNumberConverterFactory.java +++ /dev/null @@ -1,47 +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.conversion; - -import org.springframework.core.convert.TypeDescriptor; -import org.springframework.core.convert.converter.ConditionalConverter; -import org.springframework.core.convert.converter.Converter; -import org.springframework.core.convert.converter.ConverterFactory; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; - -/** - * Not a properly-implemented factory, but it does serve the purpose of helping to verify that converters defined for - * abstract supertypes can still be used correctly. - * - * @author Adam George - */ -public class SpringMonetaryAmountToNumberConverterFactory - implements ConverterFactory, ConditionalConverter { - - private final SpringMonetaryAmountToIntegerConverter wrappedConverter = new SpringMonetaryAmountToIntegerConverter(); - - @Override - public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) { - return MonetaryAmount.class.isAssignableFrom(sourceType.getType()) - && Number.class.isAssignableFrom(targetType.getType()); - } - - @SuppressWarnings("unchecked") - @Override - public Converter getConverter(Class targetType) { - return (Converter) this.wrappedConverter; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringNumberToMonetaryAmountConverter.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringNumberToMonetaryAmountConverter.java deleted file mode 100644 index 59368ea2b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/SpringNumberToMonetaryAmountConverter.java +++ /dev/null @@ -1,28 +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.conversion; - -import org.springframework.core.convert.converter.Converter; -import org.springframework.data.neo4j.integration.conversion.domain.MonetaryAmount; - -public class SpringNumberToMonetaryAmountConverter implements Converter { - - @Override - public MonetaryAmount convert(Number source) { - return source != null ? new MonetaryAmount(source.intValue() / 100, source.intValue() % 100) : null; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/JavaElement.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/JavaElement.java deleted file mode 100644 index 3e46a2859..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/JavaElement.java +++ /dev/null @@ -1,60 +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.conversion.domain; - -import java.lang.annotation.ElementType; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.typeconversion.Convert; - -/** - * Models an element of the Java programming language, although more importantly contains an enum that isn't part of the - * scanned OGM meta-data and therefore tests an important part of the Spring conversion service. - */ -@NodeEntity -public class JavaElement { - - @Id @GeneratedValue private Long identifier; - private String name; - @Convert(graphPropertyType = String.class) private ElementType elementType; - - public Long getIdentifier() { - return identifier; - } - - public void setIdentifier(Long identifier) { - this.identifier = identifier; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ElementType getElementType() { - return elementType; - } - - public void setElementType(ElementType elementType) { - this.elementType = elementType; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/MonetaryAmount.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/MonetaryAmount.java deleted file mode 100644 index 1346e967d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/MonetaryAmount.java +++ /dev/null @@ -1,57 +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.conversion.domain; - -public class MonetaryAmount { - - private final int amount; - - public MonetaryAmount(int pounds, int pence) { - this.amount = pounds * 100 + pence; - } - - public int getAmountAsSubUnits() { - return this.amount; - } - - @Override - public int hashCode() { - final int prime = 17; - int result = 1; - result = prime * result + (amount ^ (amount >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof MonetaryAmount)) - return false; - - MonetaryAmount other = (MonetaryAmount) obj; - return this.amount == other.amount; - } - - @Override - public String toString() { - int pence = this.amount % 100; - return "£" + (this.amount / 100) + "." + (pence < 10 ? "0" + pence : pence); - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/PensionPlan.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/PensionPlan.java deleted file mode 100644 index c88861fd3..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/PensionPlan.java +++ /dev/null @@ -1,64 +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.conversion.domain; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.typeconversion.Convert; - -/** - * @author Adam George - * @author Luanne Misquitta - * @author Michael J. Simons - */ -@NodeEntity -public class PensionPlan { - - @Id @GeneratedValue private Long pensionPlanId; - - @Convert(graphPropertyType = Integer.class) private MonetaryAmount fundValue; - - @Convert(graphPropertyType = SiteMember.class) // nonsensical conversion for test purposes - private JavaElement javaElement; - - private String providerName; - - public PensionPlan(MonetaryAmount fundValue, String providerName) { - this.fundValue = fundValue; - this.providerName = providerName; - } - - public Long getPensionPlanId() { - return pensionPlanId; - } - - public String getProviderName() { - return providerName; - } - - public MonetaryAmount getFundValue() { - return fundValue; - } - - public JavaElement getJavaElement() { - return javaElement; - } - - public void setJavaElement(JavaElement javaElement) { - this.javaElement = javaElement; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/SiteMember.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/SiteMember.java deleted file mode 100644 index 46182ebbc..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/conversion/domain/SiteMember.java +++ /dev/null @@ -1,66 +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.conversion.domain; - -import java.math.BigInteger; -import java.math.RoundingMode; -import java.util.List; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.Property; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.neo4j.ogm.typeconversion.ByteArrayBase64Converter; - -/** - * @author Adam George - * @author Luanne Misquitta - * @author Michael J. Simons - */ -public class SiteMember { - - @Id @GeneratedValue private Long id; - - @Convert(ByteArrayBase64Converter.class) private byte[] profilePictureData; - - private BigInteger years; - - @Property(name = "rounding") private List roundingModes; - - public byte[] getProfilePictureData() { - return this.profilePictureData; - } - - public void setProfilePictureData(byte[] profilePictureData) { - this.profilePictureData = profilePictureData; - } - - public BigInteger getYears() { - return years; - } - - public void setYears(BigInteger years) { - this.years = years; - } - - public List getRoundingModes() { - return roundingModes; - } - - public void setRoundingModes(List roundingModes) { - this.roundingModes = roundingModes; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/Neo4jPersistentPropertyTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/Neo4jPersistentPropertyTests.java deleted file mode 100644 index 787fbe03d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/Neo4jPersistentPropertyTests.java +++ /dev/null @@ -1,49 +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.mapping; - -import static org.assertj.core.api.Assertions.*; - -import org.junit.Test; -import org.neo4j.ogm.metadata.MetaData; -import org.springframework.data.neo4j.domain.sample.NodeWithUUIDAsId; -import org.springframework.data.neo4j.domain.sample.User; - -/** - * @author Gerrit Meier - * @author Michael J. Simons - */ -public class Neo4jPersistentPropertyTests { - - @Test // DATAGRAPH-1081 - public void detectsOgmVersionAnnotation() { - MetaData metaData = new MetaData("org.springframework.data.neo4j.domain.sample"); - Neo4jMappingContext mappingContext = new Neo4jMappingContext(metaData); - Neo4jPersistentEntity persistentEntity = mappingContext.getPersistentEntity(User.class); - Neo4jPersistentProperty version = persistentEntity.getRequiredPersistentProperty("version"); - assertThat(version.isVersionProperty()).isTrue(); - } - - @Test // DATAGRAPH-1144 - public void shouldDetectExplicitIdFieldsAsIdProperties() { - MetaData metaData = new MetaData("org.springframework.data.neo4j.domain.sample"); - Neo4jMappingContext mappingContext = new Neo4jMappingContext(metaData); - Neo4jPersistentEntity persistentEntity = mappingContext.getPersistentEntity(NodeWithUUIDAsId.class); - Neo4jPersistentProperty idProperty = persistentEntity.getRequiredIdProperty(); - assertThat(idProperty.isIdProperty()); - assertThat(idProperty.getName()).isEqualTo("myNiceId"); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/NamedQueryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/NamedQueryTests.java deleted file mode 100644 index 807006f73..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/NamedQueryTests.java +++ /dev/null @@ -1,110 +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.namedquery; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.neo4j.namedquery.domain.SampleEntityForNamedQuery; -import org.springframework.data.neo4j.namedquery.repo.SampleEntityForNamedQueryRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.*; - -/** - * @author Gerrit Meier - * @author Michael J. Simons - * @author Ihor Dziuba - */ -@ContextConfiguration(classes = { NamedQueryTests.NamedQueryContext.class }) -@RunWith(SpringRunner.class) -@Transactional -public class NamedQueryTests { - - private static final String SAMPLE_ENTITY_NAME = "test"; - - @Autowired private SampleEntityForNamedQueryRepository repository; - - @Test - public void findElementByQueryAnnotation() { - createAndSaveSampleEntity(); - - SampleEntityForNamedQuery titleEntity = repository.getTitleEntity(); - assertThat(titleEntity).isNotNull(); - } - - @Test - public void findElementByDerivedFunction() { - createAndSaveSampleEntity(); - - SampleEntityForNamedQuery titleEntity = repository.findByName(SAMPLE_ENTITY_NAME); - assertThat(titleEntity).isNotNull(); - } - - @Test - public void findElementByNamedQuery() { - createAndSaveSampleEntity(); - - SampleEntityForNamedQuery titleEntity = repository.findByQueryWithoutParameter(); - assertThat(titleEntity).isNotNull(); - } - - @Test - public void findElementByNamedQueryWithParameter() { - createAndSaveSampleEntity(); - - SampleEntityForNamedQuery titleEntity = repository.findByQueryWithParameter(SAMPLE_ENTITY_NAME); - assertThat(titleEntity).isNotNull(); - } - - @Test //DATAGRAPH-1241 - public void findElementsByNamedPagedQueryWithParameter() { - createAndSaveSampleEntity(); - createAndSaveSampleEntity(); - - Page page = repository.findByPagedQueryWithParameter(SAMPLE_ENTITY_NAME, PageRequest.of(0,1)); - assertThat(page.getTotalPages()).isEqualTo(2); - assertThat(page.get().count()).isEqualTo(1); - } - - @Test //DATAGRAPH-1241 - public void findElementsByNamedPagedQueryFailedWithoutCountQuery() { - createAndSaveSampleEntity(); - createAndSaveSampleEntity(); - - assertThatIllegalArgumentException() - .isThrownBy(() -> repository.findByPagedQueryWithoutCountQuery(SAMPLE_ENTITY_NAME, PageRequest.of(0,1))) - .withMessage("Must specify a count query to get pagination info."); - } - - private void createAndSaveSampleEntity() { - SampleEntityForNamedQuery entity = new SampleEntityForNamedQuery(); - entity.setName(SAMPLE_ENTITY_NAME); - repository.save(entity); - } - - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.namedquery.domain", - repositoryPackages = "org.springframework.data.neo4j.namedquery.repo") - @ComponentScan({ "org.springframework.data.neo4j.namedquery" }) - static class NamedQueryContext { - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/domain/SampleEntityForNamedQuery.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/domain/SampleEntityForNamedQuery.java deleted file mode 100644 index 65b4c0831..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/domain/SampleEntityForNamedQuery.java +++ /dev/null @@ -1,38 +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.namedquery.domain; - -import org.neo4j.ogm.annotation.NodeEntity; - -@NodeEntity -public class SampleEntityForNamedQuery { - - private Long id; - - private String name; - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/repo/SampleEntityForNamedQueryRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/repo/SampleEntityForNamedQueryRepository.java deleted file mode 100644 index 5e7aa3e85..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/namedquery/repo/SampleEntityForNamedQueryRepository.java +++ /dev/null @@ -1,40 +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.namedquery.repo; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.namedquery.domain.SampleEntityForNamedQuery; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.repository.query.Param; - -public interface SampleEntityForNamedQueryRepository extends Neo4jRepository { - - @Query("MATCH (e) WHERE e.name='test' RETURN e") - SampleEntityForNamedQuery getTitleEntity(); - - SampleEntityForNamedQuery findByName(String name); - - SampleEntityForNamedQuery findByQueryWithoutParameter(); - - SampleEntityForNamedQuery findByQueryWithParameter(@Param("name") String name); - - Page findByPagedQueryWithParameter(@Param("name") String name, Pageable pageable); - - Page findByPagedQueryWithoutCountQuery(@Param("name") String name, Pageable pageable); - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/NativeTypesContextConfiguration.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/NativeTypesContextConfiguration.java deleted file mode 100644 index 8e3cdc07a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/NativeTypesContextConfiguration.java +++ /dev/null @@ -1,40 +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.nativetypes; - -import org.neo4j.harness.ServerControls; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; - -/** - * Shared configuration for all tests involving native, spatial types. - * - * @author Gerrit Meier - * @author Michael J. Simons - */ -@Configuration -@Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.nativetypes") -class NativeTypesContextConfiguration { - - @Bean - org.neo4j.ogm.config.Configuration neo4jOGMConfiguration(ServerControls neo4jTestServer) { - return new org.neo4j.ogm.config.Configuration.Builder() // - .uri(neo4jTestServer.boltURI().toString()) // - .useNativeTypes() // - .build(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialConversionTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialConversionTests.java deleted file mode 100644 index 43a093261..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialConversionTests.java +++ /dev/null @@ -1,147 +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.nativetypes; - -import static org.apache.webbeans.util.Asserts.assertNotNull; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.data.Offset.offset; - -import lombok.Builder; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.driver.Driver; -import org.neo4j.driver.Session; -import org.neo4j.driver.Transaction; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Metrics; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.examples.restaurants.domain.Restaurant; -import org.springframework.data.neo4j.examples.restaurants.repo.RestaurantRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * Useful links: https://maps.google.com/maps?q=55.612191,12.994823 where q -> latLong - *

- * https://maps.google.com/maps?q=37.61649,-122.38681 - *

- * https://www.latlong.net/Show-Latitude-Longitude.html - */ -@ContextConfiguration(classes = { SpatialPersistenceContextConfiguration.class }) -@RunWith(SpringRunner.class) -public class SpatialConversionTests { - - @Autowired - private SpatialDomainRepository repository; - - @Autowired - private RestaurantRepository restaurantRepository; - - @Autowired - private SessionFactory sessionFactory; - - @Builder - static class ParamHolder { - String name; - double latitude; - double longitude; - - Map toParameterMap() { - Map parameters = new HashMap<>(); - parameters.put("name", this.name); - parameters.put("latitude", this.latitude); - parameters.put("longitude", this.longitude); - return parameters; - } - } - - private static final ParamHolder NEO_HQ = ParamHolder.builder().latitude(55.612191).longitude(12.994823) - .name("Neo4j HQ").build(); - private static final ParamHolder CLARION = ParamHolder.builder().latitude(55.607726).longitude(12.994243) - .name("Clarion").build(); - private static final ParamHolder MINC = ParamHolder.builder().latitude(55.611496).longitude(12.994039).name("Minc") - .build(); - - @Test - public void shouldReadAndWriteSpringDataGeoPoints() { - - // The SDN Points have been converted this way by org.springframework.data.neo4j.conversion.PointConverter - Point sdnPoint = new Point(NEO_HQ.latitude, NEO_HQ.longitude); - - SpatialDomain domainObject = new SpatialDomain(); - domainObject.setSdnPoint(sdnPoint); - domainObject.setSdnPoints(Collections.singletonList(sdnPoint)); - domainObject.setMorePoints(new Point[] { sdnPoint }); - - domainObject = repository.save(domainObject); - - SpatialDomain reloadedDomainObject = repository.findById(domainObject.getId()).get(); - - assertThat(reloadedDomainObject.getSdnPoint()).isEqualTo(sdnPoint); - assertThat(reloadedDomainObject.getSdnPoints()).hasSize(1).first().isEqualTo(sdnPoint); - assertThat(reloadedDomainObject.getMorePoints()).hasSize(1).containsExactly(sdnPoint); - } - - - @Test - public void findByPointShouldWorkWhenConvertedToNative() { - - Driver driver = sessionFactory.unwrap(Driver.class); - try (Session session = driver.session(); Transaction transaction = session.beginTransaction()) { - - for (ParamHolder useNativePoints : Arrays.asList(NEO_HQ, CLARION)) { - - transaction.run( - "CREATE (n:SpatialDomain {name: $name, sdnPoint: point({latitude: $latitude, longitude: $longitude})})", - useNativePoints.toParameterMap()); - } - transaction.run("CREATE (n:SpatialDomain {name: $name, latitude: $latitude, longitude: $longitude})", - MINC.toParameterMap()); - - transaction.commit(); - } - - List result = repository.findBySdnPointNear(new Distance(60.0 / 1000.0, Metrics.KILOMETERS), - new Point(55.611883, 12.994608)); - assertThat(result).hasSize(2).extracting(SpatialDomain::getName).containsExactlyInAnyOrder("Neo4j HQ", "Minc"); - } - - @Test - public void registeredOldConverterShouldStillWork() { - Restaurant restaurant = new Restaurant("San Francisco International Airport (SFO)", new Point(37.61649, -122.38681), - 94128); - restaurantRepository.save(restaurant); - - List results = restaurantRepository.findByNameAndLocationNear( - "San Francisco International Airport (SFO)", new Distance(150, Metrics.KILOMETERS), new Point(37.6, -122.3)); - - assertNotNull(results); - assertThat(results.size()).isEqualTo(1); - Restaurant found = results.get(0); - assertNotNull(found.getLocation()); - assertThat(found.getLocation().getX()).isCloseTo(37.61649, offset(0d)); - assertThat(found.getLocation().getY()).isCloseTo(-122.38681, offset(0d)); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialDomain.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialDomain.java deleted file mode 100644 index 756b720d1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialDomain.java +++ /dev/null @@ -1,119 +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.nativetypes; - -import java.util.List; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.types.spatial.CartesianPoint2d; -import org.neo4j.ogm.types.spatial.CartesianPoint3d; -import org.neo4j.ogm.types.spatial.GeographicPoint2d; -import org.neo4j.ogm.types.spatial.GeographicPoint3d; -import org.springframework.data.geo.Point; - -@NodeEntity -public class SpatialDomain { - - @Id - @GeneratedValue - private Long id; - - private String name; - - private GeographicPoint2d geographicPoint2d; - - private GeographicPoint3d geographicPoint3d; - - private CartesianPoint2d cartesianPoint2d; - - private CartesianPoint3d cartesianPoint3d; - - private Point sdnPoint; - - private List sdnPoints; - - private Point[] morePoints; - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public GeographicPoint2d getGeographicPoint2d() { - return geographicPoint2d; - } - - public void setGeographicPoint2d(GeographicPoint2d geographicPoint2d) { - this.geographicPoint2d = geographicPoint2d; - } - - public GeographicPoint3d getGeographicPoint3d() { - return geographicPoint3d; - } - - public void setGeographicPoint3d(GeographicPoint3d geographicPoint3d) { - this.geographicPoint3d = geographicPoint3d; - } - - public CartesianPoint2d getCartesianPoint2d() { - return cartesianPoint2d; - } - - public void setCartesianPoint2d(CartesianPoint2d cartesianPoint2d) { - this.cartesianPoint2d = cartesianPoint2d; - } - - public CartesianPoint3d getCartesianPoint3d() { - return cartesianPoint3d; - } - - public void setCartesianPoint3d(CartesianPoint3d cartesianPoint3d) { - this.cartesianPoint3d = cartesianPoint3d; - } - - public Point getSdnPoint() { - return sdnPoint; - } - - public void setSdnPoint(Point sdnPoint) { - this.sdnPoint = sdnPoint; - } - - public List getSdnPoints() { - return sdnPoints; - } - - public void setSdnPoints(List sdnPoints) { - this.sdnPoints = sdnPoints; - } - - public Point[] getMorePoints() { - return morePoints; - } - - public void setMorePoints(Point[] morePoints) { - this.morePoints = morePoints; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialDomainRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialDomainRepository.java deleted file mode 100644 index 2c833eba7..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialDomainRepository.java +++ /dev/null @@ -1,46 +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.nativetypes; - -import org.neo4j.ogm.types.spatial.CartesianPoint2d; -import org.neo4j.ogm.types.spatial.CartesianPoint3d; -import org.neo4j.ogm.types.spatial.GeographicPoint2d; -import org.neo4j.ogm.types.spatial.GeographicPoint3d; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Point; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -import java.util.List; - -public interface SpatialDomainRepository extends Neo4jRepository { - List findByGeographicPoint2d(GeographicPoint2d geographicPoint2d); - - List findByGeographicPoint3d(GeographicPoint3d geographicPoint3d); - - List findByCartesianPoint2d(CartesianPoint2d cartesianPoint2d); - - List findByCartesianPoint3d(CartesianPoint3d cartesianPoint3d); - - List findByCartesianPoint2dNear(Distance distance, CartesianPoint2d cartesianPoint2d); - - List findByCartesianPoint3dNear(Distance distance, CartesianPoint3d cartesianPoint3d); - - List findByGeographicPoint2dNear(Distance distance, GeographicPoint2d geographicPoint2d); - - List findByGeographicPoint3dNear(Distance distance, GeographicPoint3d office); - - List findBySdnPointNear(Distance distance, Point aPoint); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialFindByTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialFindByTests.java deleted file mode 100644 index 259b352f2..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialFindByTests.java +++ /dev/null @@ -1,96 +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.nativetypes; - -import static org.assertj.core.api.Assertions.*; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.ogm.types.spatial.CartesianPoint2d; -import org.neo4j.ogm.types.spatial.CartesianPoint3d; -import org.neo4j.ogm.types.spatial.GeographicPoint2d; -import org.neo4j.ogm.types.spatial.GeographicPoint3d; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Gerrit Meier - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = NativeTypesContextConfiguration.class) -public class SpatialFindByTests { - - @Autowired - private SpatialDomainRepository repository; - - private SpatialDomain spatialDomain; - - @Before - public void setUpDomainObject() { - repository.deleteAll(); - - spatialDomain = new SpatialDomain(); - GeographicPoint2d geographicPoint2d = new GeographicPoint2d(1, 2); - GeographicPoint3d geographicPoint3d = new GeographicPoint3d(3, 4, 5); - CartesianPoint2d cartesianPoint2d = new CartesianPoint2d(6, 7); - CartesianPoint3d cartesianPoint3d = new CartesianPoint3d(8, 9, 10); - - spatialDomain.setGeographicPoint2d(geographicPoint2d); - spatialDomain.setGeographicPoint3d(geographicPoint3d); - spatialDomain.setCartesianPoint2d(cartesianPoint2d); - spatialDomain.setCartesianPoint3d(cartesianPoint3d); - - repository.save(spatialDomain); - } - - @Test - public void findByGeographicPoint2d() { - GeographicPoint2d geographicPoint2d = new GeographicPoint2d(1, 2); - - List result = repository.findByGeographicPoint2d(geographicPoint2d); - assertThat(result).hasSize(1); - } - - @Test - public void findByGeographicPoint3d() { - GeographicPoint3d geographicPoint3d = new GeographicPoint3d(3, 4, 5); - - List result = repository.findByGeographicPoint3d(geographicPoint3d); - assertThat(result).hasSize(1); - } - - @Test - public void findByCartesianPoint2d() { - CartesianPoint2d cartesianPoint2d = new CartesianPoint2d(6, 7); - - List result = repository.findByCartesianPoint2d(cartesianPoint2d); - assertThat(result).hasSize(1); - } - - @Test - public void findByCartesianPoint3d() { - CartesianPoint3d cartesianPoint3d = new CartesianPoint3d(8, 9, 10); - - List result = repository.findByCartesianPoint3d(cartesianPoint3d); - assertThat(result).hasSize(1); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialNearTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialNearTests.java deleted file mode 100644 index 670859293..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialNearTests.java +++ /dev/null @@ -1,147 +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.nativetypes; - -import static org.assertj.core.api.Assertions.*; - -import java.util.List; - -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.ogm.types.spatial.CartesianPoint2d; -import org.neo4j.ogm.types.spatial.CartesianPoint3d; -import org.neo4j.ogm.types.spatial.GeographicPoint2d; -import org.neo4j.ogm.types.spatial.GeographicPoint3d; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Metrics; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Gerrit Meier - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = NativeTypesContextConfiguration.class) -public class SpatialNearTests { - - @Autowired - private SpatialDomainRepository repository; - - @Test - public void findByNearCartesianPoint2d() { - SpatialDomain spatialDomain = new SpatialDomain(); - spatialDomain.setCartesianPoint2d(new CartesianPoint2d(1, 2)); - repository.save(spatialDomain); - List result = repository.findByCartesianPoint2dNear(new Distance(2, Metrics.NEUTRAL), - new CartesianPoint2d(2, 2)); - assertThat(result).hasSize(1); - } - - @Test - public void findByNearCartesianPoint2dNoMatch() { - SpatialDomain spatialDomain = new SpatialDomain(); - spatialDomain.setCartesianPoint2d(new CartesianPoint2d(1, 2)); - repository.save(spatialDomain); - List result = repository.findByCartesianPoint2dNear(new Distance(2, Metrics.NEUTRAL), - new CartesianPoint2d(20, 20)); - assertThat(result).hasSize(0); - } - - @Test - public void findByNearCartesianPoint3d() { - SpatialDomain spatialDomain = new SpatialDomain(); - spatialDomain.setCartesianPoint3d(new CartesianPoint3d(1, 2, 3)); - repository.save(spatialDomain); - List result = repository.findByCartesianPoint3dNear(new Distance(2, Metrics.NEUTRAL), - new CartesianPoint3d(2, 2, 2)); - assertThat(result).hasSize(1); - } - - @Test - public void findByNearCartesianPoint3dNoMatch() { - SpatialDomain spatialDomain = new SpatialDomain(); - spatialDomain.setCartesianPoint3d(new CartesianPoint3d(1, 2, 3)); - repository.save(spatialDomain); - List result = repository.findByCartesianPoint3dNear(new Distance(2, Metrics.NEUTRAL), - new CartesianPoint3d(20, 20, 20)); - assertThat(result).hasSize(0); - } - - @Test - public void findByNearGeographicPoint2d() { - SpatialDomain centralStation = new SpatialDomain(); - - GeographicPoint2d centralStationLocation = new GeographicPoint2d(55.6093093, 13.0004377); - centralStation.setGeographicPoint2d(centralStationLocation); - repository.save(centralStation); - - GeographicPoint2d office = new GeographicPoint2d(55.611851, 12.9949028); - List result = repository.findByGeographicPoint2dNear(new Distance(0.4486, Metrics.KILOMETERS), - office); - assertThat(result).hasSize(1); - } - - @Test - public void findByNearGeographicPoint2dNoMatch() { - SpatialDomain centralStation = new SpatialDomain(); - - GeographicPoint2d centralStationLocation = new GeographicPoint2d(55.6093093, 13.0004377); - centralStation.setGeographicPoint2d(centralStationLocation); - repository.save(centralStation); - - GeographicPoint2d office = new GeographicPoint2d(55.611851, 12.9949028); - List result = repository.findByGeographicPoint2dNear(new Distance(0.4485, Metrics.KILOMETERS), - office); - assertThat(result).hasSize(0); - } - - @Test - public void findByNearGeographicPoint3d() { - SpatialDomain centralStation = new SpatialDomain(); - - GeographicPoint3d centralStationLocation = new GeographicPoint3d(55.6093093, 13.0004377, -5); - centralStation.setGeographicPoint3d(centralStationLocation); - repository.save(centralStation); - - GeographicPoint3d office = new GeographicPoint3d(55.611851, 12.9949028, 15); - List result = repository.findByGeographicPoint3dNear(new Distance(0.4489591, Metrics.KILOMETERS), - office); - assertThat(result).hasSize(1); - } - - @Test - public void findByNearGeographicPoint3dNoMatch() { - SpatialDomain centralStation = new SpatialDomain(); - - GeographicPoint3d centralStationLocation = new GeographicPoint3d(55.6093093, 13.0004377, -5); - centralStation.setGeographicPoint3d(centralStationLocation); - repository.save(centralStation); - - GeographicPoint3d office = new GeographicPoint3d(55.611851, 12.9949028, 15); - List result = repository.findByGeographicPoint3dNear(new Distance(0.448950, Metrics.KILOMETERS), - office); - assertThat(result).hasSize(0); - } - - @After - public void cleanUp() { - repository.deleteAll(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialPersistenceContextConfiguration.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialPersistenceContextConfiguration.java deleted file mode 100644 index e8d23bbdf..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/SpatialPersistenceContextConfiguration.java +++ /dev/null @@ -1,48 +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.nativetypes; - -import org.neo4j.harness.ServerControls; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; - -/** - * Shared configuration for all tests involving native, spatial types. - * - * @author Gerrit Meier - * @author Michael J. Simons - */ -@Configuration -@Neo4jIntegrationTest( - domainPackages = { "org.springframework.data.neo4j.nativetypes", - "org.springframework.data.neo4j.examples.restaurants.domain" }, - repositoryPackages = { "org.springframework.data.neo4j.nativetypes", - "org.springframework.data.neo4j.examples.restaurants.repo" }) -@ComponentScan("org.springframework.data.neo4j.examples.restaurants") -class SpatialPersistenceContextConfiguration { - - @Bean - org.neo4j.ogm.config.Configuration neo4jOGMConfiguration(ServerControls serverControls) { - return new org.neo4j.ogm.config.Configuration.Builder() // - .uri(serverControls.boltURI().toString()) // - .useNativeTypes() // - .verifyConnection(true) - .build(); - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeDomain.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeDomain.java deleted file mode 100644 index ca6340302..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeDomain.java +++ /dev/null @@ -1,110 +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.nativetypes; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.Period; -import java.time.temporal.TemporalAmount; -import java.util.Date; -import java.util.List; - -@NodeEntity -public class TimeDomain { - @Id - @GeneratedValue - private Long id; - - private LocalDate localDate; - private LocalDateTime localDateTime; - private Date date; - private Duration duration; - private Period period; - private TemporalAmount temporalAmount; - - private Duration[] arrayOfDurations; - - private List listOfDurations; - - public LocalDate getLocalDate() { - return localDate; - } - - public void setLocalDate(LocalDate localDate) { - this.localDate = localDate; - } - - public LocalDateTime getLocalDateTime() { - return localDateTime; - } - - public void setLocalDateTime(LocalDateTime localDateTime) { - this.localDateTime = localDateTime; - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - public Duration getDuration() { - return duration; - } - - public void setDuration(Duration duration) { - this.duration = duration; - } - - public Period getPeriod() { - return period; - } - - public void setPeriod(Period period) { - this.period = period; - } - - public TemporalAmount getTemporalAmount() { - return temporalAmount; - } - - public void setTemporalAmount(TemporalAmount temporalAmount) { - this.temporalAmount = temporalAmount; - } - - public Duration[] getArrayOfDurations() { - return arrayOfDurations; - } - - public void setArrayOfDurations(Duration[] arrayOfDurations) { - this.arrayOfDurations = arrayOfDurations; - } - - public List getListOfDurations() { - return listOfDurations; - } - - public void setListOfDurations(List listOfDurations) { - this.listOfDurations = listOfDurations; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeDomainRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeDomainRepository.java deleted file mode 100644 index 43a790856..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeDomainRepository.java +++ /dev/null @@ -1,40 +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.nativetypes; - -import org.springframework.data.neo4j.repository.Neo4jRepository; - -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.Period; -import java.time.temporal.TemporalAmount; -import java.util.Date; -import java.util.List; - -public interface TimeDomainRepository extends Neo4jRepository { - List findByDate(Date date); - - List findByLocalDate(LocalDate localDate); - - List findByLocalDateTime(LocalDateTime localDateTime); - - List findByPeriod(Period period); - - List findByDuration(Duration duration); - - List findByTemporalAmount(TemporalAmount temporalAmount); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeFindByTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeFindByTests.java deleted file mode 100644 index e990aef2a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/nativetypes/TimeFindByTests.java +++ /dev/null @@ -1,114 +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.nativetypes; - -import static org.assertj.core.api.Assertions.*; - -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.Period; -import java.time.temporal.TemporalAmount; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = NativeTypesContextConfiguration.class) -public class TimeFindByTests { - - @Autowired - private TimeDomainRepository repository; - - private TimeDomain timeDomain; - private Date date; - private LocalDate localDate; - private LocalDateTime localDateTime; - private Period period; - private TemporalAmount temporalAmount; - private Duration duration; - - @Before - public void setUpDomainObject() { - repository.deleteAll(); - - timeDomain = new TimeDomain(); - - date = new Date(); - localDate = LocalDate.now(); - localDateTime = LocalDateTime.now(); - period = Period.ofMonths(2); - temporalAmount = period; - duration = Duration.ofHours(3); - - timeDomain.setDate(date); - timeDomain.setLocalDate(localDate); - timeDomain.setLocalDateTime(localDateTime); - - timeDomain.setPeriod(period); - timeDomain.setDuration(duration); - - timeDomain.setTemporalAmount(temporalAmount); - - timeDomain.setArrayOfDurations(new Duration[]{Duration.ofMinutes(23)}); - timeDomain.setListOfDurations(Collections.singletonList(Duration.ofMinutes(42))); - - repository.save(timeDomain); - } - - @Test - public void findByDate() { - List result = repository.findByDate(date); - assertThat(result).hasSize(1); - } - - @Test - public void findByLocalDate() { - List result = repository.findByLocalDate(localDate); - assertThat(result).hasSize(1); - } - - @Test - public void findByLocalDateTime() { - List result = repository.findByLocalDateTime(localDateTime); - assertThat(result).hasSize(1); - } - - @Test - public void findByPeriod() { - List result = repository.findByPeriod(period); - assertThat(result).hasSize(1); - } - - @Test - public void findByDuration() { - List result = repository.findByDuration(duration); - assertThat(result).hasSize(1); - } - - @Test - public void findByTemporalAmount() { - List result = repository.findByTemporalAmount(temporalAmount); - assertThat(result).hasSize(1); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedQueryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedQueryTests.java deleted file mode 100644 index 77a63b43d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedQueryTests.java +++ /dev/null @@ -1,754 +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.queries; - -import static org.assertj.core.api.Assertions.*; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.harness.ServerControls; -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; -import org.springframework.data.neo4j.examples.movies.domain.Cinema; -import org.springframework.data.neo4j.examples.movies.domain.Director; -import org.springframework.data.neo4j.examples.movies.domain.TempMovie; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.EntityWrappingQueryResult; -import org.springframework.data.neo4j.examples.movies.repo.CinemaRepository; -import org.springframework.data.neo4j.examples.movies.repo.DirectorRepository; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * @author Luanne Misquitta - * @author Mark Angrish - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@RunWith(SpringRunner.class) -public class DerivedQueryTests { - - @Autowired private ServerControls neo4jTestServer; - - @Autowired private Session session; - - @Autowired private UserRepository userRepository; - - @Autowired private CinemaRepository cinemaRepository; - - @Autowired private DirectorRepository directorRepository; - - @Autowired private TransactionTemplate transactionTemplate; - - @Before - public void clearDatabase() { - neo4jTestServer.graph().execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - private void executeUpdate(String cypher) { - neo4jTestServer.graph().execute(cypher); - } - - @Test - public void shouldFindUsersByName() { - executeUpdate("CREATE (m:User:Person {name:'Michal'})<-[:FRIEND_OF]-(a:User:Person {name:'Adam'})"); - - Collection users = userRepository.findByName("Michal"); - Iterator iterator = users.iterator(); - assertThat(iterator.hasNext()).isTrue(); - User user = iterator.next(); - assertThat(user.getName()).isEqualTo("Michal"); - assertThat(user.getFriends().size()).isEqualTo(1); - assertThat(user.getFriends().iterator().next().getName()).isEqualTo("Adam"); - assertThat(iterator.hasNext()).isFalse(); - } - - @Test - public void shouldFindUsersByMiddleName() { - executeUpdate("CREATE (m:User:Person {middleName:'Joseph'})<-[:FRIEND_OF]-(a:User:Person {middleName:'Mary', name: 'Joseph'})"); - - Collection users = userRepository.findByMiddleName("Joseph"); - Iterator iterator = users.iterator(); - assertThat(iterator.hasNext()).isTrue(); - User user = iterator.next(); - assertThat(user.getMiddleName()).isEqualTo("Joseph"); - assertThat(user.getFriends().size()).isEqualTo(1); - User friend = user.getFriends().iterator().next(); - assertThat(friend.getMiddleName()).isEqualTo("Mary"); - assertThat(friend.getName()).isEqualTo("Joseph"); - assertThat(iterator.hasNext()).isFalse(); - } - - @Test // DATAGRAPH-628 - public void shouldFindNodeEntitiesWithLabels() { - executeUpdate( - "CREATE (u:User:Person {name:'Michal'}) CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'}) CREATE (u)-[:VISITED]->(p)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Collection cinemas = cinemaRepository.findByName("Picturehouse"); - Iterator iterator = cinemas.iterator(); - assertThat(iterator.hasNext()).isTrue(); - Cinema cinema = iterator.next(); - assertThat(cinema.getName()).isEqualTo("Picturehouse"); - assertThat(cinema.getVisited().size()).isEqualTo(1); - assertThat(cinema.getVisited().iterator().next().getName()) - .isEqualTo("Michal"); - assertThat(iterator.hasNext()).isFalse(); - - List theatres = cinemaRepository.findByLocation("London"); - assertThat(theatres.size()).isEqualTo(2); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - } - }); - } - - @Test - public void shouldUseDepthOnCollectionFinder() { - executeUpdate( - "CREATE (u:User {name:'Michal'}) CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'}) CREATE (u)-[:VISITED]->(p)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - - List theatres = cinemaRepository.findByLocation("London", 0); - assertThat(theatres.size()).isEqualTo(2); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - assertThat(theatres.get(0).getBlockbusterOfTheWeek()).isNull(); - assertThat(theatres.get(0).getVisited().isEmpty()).isTrue(); - } - }); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntitiesMultipleAndedProperties() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r)"); - - List theatres = cinemaRepository.findByNameAndLocation("Ritzy", "London"); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.get(0).getVisited().iterator().next().getName()) - .isEqualTo("Michal"); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntititiesMultipleOredProperties() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r)"); - - List theatres = cinemaRepository.findByNameOrLocation("Ritzy", "London"); - assertThat(theatres.size()).isEqualTo(2); - } - - @Test // DATAGRAPH-629 - public void shouldReturnNoResultsCorrectly() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London'}) CREATE (r:Theatre {name:'Ritzy', city:'London'})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r)"); - - Collection theatres = cinemaRepository.findByName("Does not exist"); - assertThat(theatres.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntititiesWithComparisonOperators() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List theatres = cinemaRepository.findByCapacityGreaterThan(3000); - assertThat(theatres.size()).isEqualTo(2); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - - theatres = cinemaRepository.findByCapacityGreaterThan(6000); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.get(0).getName()).isEqualTo("Ritzy"); - - theatres = cinemaRepository.findByCapacityLessThan(8000); - assertThat(theatres.size()).isEqualTo(2); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - - theatres = cinemaRepository.findByCapacityLessThan(7000); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.get(0).getName()).isEqualTo("Picturehouse"); - } - }); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntititiesWithMultipleComparisonOperatorsAnded() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) CREATE (m:Theatre {name:'Regal', city:'Bombay', capacity: 4500})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List theatres = cinemaRepository.findByLocationAndCapacityGreaterThan("London", 3000); - assertThat(theatres.size()).isEqualTo(2); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - - theatres = cinemaRepository.findByCapacityLessThanAndLocation(6000, "Bombay"); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.get(0).getName()).isEqualTo("Regal"); - } - }); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntititiesWithMultipleComparisonOperatorsOred() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) CREATE (m:Theatre {name:'Regal', city:'Bombay', capacity: 9000})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List theatres = cinemaRepository.findByLocationOrCapacityLessThan("London", 100); - assertThat(theatres.size()).isEqualTo(2); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - - theatres = cinemaRepository.findByCapacityGreaterThanOrLocation(8000, "Paris"); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.get(0).getName()).isEqualTo("Regal"); - } - }); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntititiesWithNestedProperty() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r)"); - - List theatres = cinemaRepository.findByVisitedName("Michal"); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - } - - @Test - public void shouldFindNodeEntititiesWithDeepNestedProperty() { - executeUpdate("CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r) CREATE (m1:Movie {name:'Speed'})" - + " CREATE (g:Genre {name:'Thriller'}) CREATE (u)-[:INTERESTED]->(g)"); - - List theatres = cinemaRepository.findByVisitedInterestedName("Thriller"); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntititiesWithBaseAndNestedProperty() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) CREATE (m:Theatre {name:'Regal', city:'Bombay', capacity: 5000})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r) CREATE (u)-[:VISITED]->(m)"); - - List theatres = cinemaRepository.findByLocationAndVisitedName("London", "Michal"); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - } - - @Test(expected = UnsupportedOperationException.class) // DATAGRAPH-662 - public void shouldFindNodeEntititiesWithBaseOrNestedProperty() { - executeUpdate( - "CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) CREATE (m:Theatre {name:'The Old Vic', city:'London', capacity: 5000})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:VISITED]->(r) CREATE (u)-[:VISITED]->(m)"); - - List theatres = cinemaRepository.findByLocationOrVisitedName("P", "Michal"); - assertThat(theatres.size()).isEqualTo(2); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - // assertTrue(theatres.contains(new Cinema("Picturehouse"))); - assertThat(theatres.contains(new Cinema("The Old Vic"))).isTrue(); - } - - @Test // DATAGRAPH-632 - public void shouldFindNodeEntitiesWithNestedRelationshipEntityProperty() { - executeUpdate( - "CREATE (m1:Movie {title:'Speed'}) CREATE (m2:Movie {title:'The Matrix'}) CREATE (m:Movie {title:'Chocolat'})" - + " CREATE (u:User:Person {name:'Michal'}) CREATE (u1:User:Person {name:'Vince'}) " - + " CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2) CREATE (u1)-[:RATED {stars:3}]->(m)"); - - List users = userRepository.findByRatingsStars(3); - assertThat(users.size()).isEqualTo(2); - assertThat(users.contains(new User("Michal"))).isTrue(); - assertThat(users.contains(new User("Vince"))).isTrue(); - } - - @Test // DATAGRAPH-629, DATAGRAPH-705 - public void shouldFindNodeEntititiesWithTwoNestedPropertiesAndedAcrossDifferentRelatedNodeEntities() { - executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) " - + " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " + " CREATE (u:User {name:'Michal'}) " - + " CREATE (u)-[:VISITED]->(r) CREATE (u)-[:VISITED]->(p)" + " CREATE (m1:Movie {name:'San Andreas'}) " - + " CREATE (m2:Movie {name:'Pitch Perfect 2'})" + " CREATE (p)-[:BLOCKBUSTER]->(m1)" - + " CREATE (r)-[:BLOCKBUSTER]->(m2)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List theatres = cinemaRepository.findByVisitedNameAndBlockbusterOfTheWeekName("Michal", "San Andreas"); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - - theatres = cinemaRepository.findByVisitedNameAndBlockbusterOfTheWeekName("Michal", "Tomorrowland"); - assertThat(theatres.size()).isEqualTo(0); - } - }); - } - - @Test(expected = UnsupportedOperationException.class) // DATAGRAPH-662 - public void shouldFindNodeEntititiesWithTwoNestedPropertiesOred() { - executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) " - + " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " + " CREATE (u:User {name:'Michal'}) " - + " CREATE (u)-[:VISITED]->(r) CREATE (u)-[:VISITED]->(p)" + " CREATE (m1:Movie {title:'San Andreas'}) " - + " CREATE (m2:Movie {title:'Pitch Perfect 2'})" + " CREATE (p)-[:BLOCKBUSTER]->(m1)" - + " CREATE (r)-[:BLOCKBUSTER]->(m2)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List theatres = cinemaRepository.findByVisitedNameOrBlockbusterOfTheWeekName("Michal", "San Andreas"); - assertThat(theatres.size()).isEqualTo(2); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - assertThat(theatres.contains(new Cinema("Ritzy"))).isTrue(); - - theatres = cinemaRepository.findByVisitedNameOrBlockbusterOfTheWeekName("Vince", "Tomorrowland"); - assertThat(theatres.size()).isEqualTo(0); - } - }); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntititiesWithMultipleNestedPropertiesAnded() { - executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) " - + " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " - + " CREATE (u:User {name:'Michal', middleName:'M'}) CREATE (u1:User {name:'Vince', middleName:'M'}) " - + " CREATE (u)-[:VISITED]->(p) CREATE (u1)-[:VISITED]->(r)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List theatres = cinemaRepository.findByVisitedNameAndVisitedMiddleName("Michal", "M"); - assertThat(theatres.size()).isEqualTo(1); - assertThat(theatres.contains(new Cinema("Picturehouse"))).isTrue(); - - theatres = cinemaRepository.findByVisitedNameAndVisitedMiddleName("Vince", "V"); - assertThat(theatres.size()).isEqualTo(0); - } - }); - } - - @Test // DATAGRAPH-629 - public void shouldFindNodeEntititiesWithRelationshipEntityAndNestedProperty() { - executeUpdate( - "CREATE (m1:Movie {title:'Speed'}) CREATE (m2:Movie {title:'The Matrix'}) CREATE (m:Movie {title:'Chocolat'})" - + " CREATE (u:User:Person {name:'Michal'}) CREATE (u1:User:Person {name:'Vince'}) CREATE (g:Genre {name:'Thriller'}) CREATE (u)-[:INTERESTED]->(g) " - + " CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2) CREATE (u1)-[:RATED {stars:3}]->(m)"); - - List users = userRepository.findByRatingsStarsAndInterestedName(3, "Thriller"); - assertThat(users.size()).isEqualTo(1); - assertThat(users.contains(new User("Michal"))).isTrue(); - } - - @Test // Relates to DATAGRAPH-601 and, to an extent, DATAGRAPH-761 - public void shouldFindNodeEntitiesByRegularExpressionMatchingOnPropertiesInDerivedFinderMethods() { - executeUpdate("CREATE (:Theatre {name:'Odeon', city:'Preston'}), " + "(:Theatre {name:'Vue', city:'Dumfries'}), " - + "(:Theatre {name:'PVR', city:'Mumbai'}) "); - - // ideally, I'd name this to be "findWhereNameMatches" or "findByNameMatching" - List cinemas = cinemaRepository.findByNameMatches("^[Vv].+$"); - assertThat(cinemas.size()).as("The wrong number of cinemas was returned") - .isEqualTo(1); - assertThat(cinemas.get(0).getLocation()).as("An unexpected cinema was retrieved") - .isEqualTo("Dumfries"); - } - - @Test // DATAGRAPH-761 - public void shouldMatchNodeEntitiesUsingCaseInsensitiveLikeWithWildcards() { - executeUpdate("CREATE (:Theatre {name:'IMAX', city:'Chesterfield'}), " - + "(:Theatre {name:'Odeon', city:'Manchester'}), " + "(:Theatre {name:'IMAX', city:'Edinburgh'}) "); - - List cinemas = cinemaRepository.findByLocationLike("*chest*"); - assertThat(cinemas.size()).as("The wrong number of cinemas was returned") - .isEqualTo(2); - } - - @Test // DATAGRAPH-761 - public void shouldMatchNodeEntitiesUsingLikeWithWildcardsAndSpecialCharacters() { - executeUpdate("CREATE (:Theatre {name:'IMAX', city:'Kolkata (Calcutta)'}), " - + "(:Theatre {name:'PVR', city:'Bengaluru (Bangalore)'}), " - + "(:Theatre {name:'Metro Big Cinema', city:'Mumbai (Bombay)'}) "); - - List indianCinemas = cinemaRepository.findByLocationLike("*(B*"); - assertThat(indianCinemas.size()).as("The wrong number of cinemas was returned") - .isEqualTo(2); - } - - @Test // DATAGRAPH-761 - public void shouldMatchNodeEntitiesUsingNotLikeWithAsteriskWildcards() { - executeUpdate("CREATE (:User:Person {name:'Jeff'}), " + "(:User:Person {name:'Jeremy'}), " + "(:User:Person {name:'Alan'})"); - - List nonMatchingUsers = userRepository.findByNameIsNotLike("Je*"); - assertThat(nonMatchingUsers.size()).as("The wrong number of users was returned") - .isEqualTo(1); - assertThat(nonMatchingUsers.get(0).getName()).as("The wrong user was returned") - .isEqualTo("Alan"); - } - - @Test // DATAGRAPH-787 - public void shouldFindDirectorsByName() { - executeUpdate( - "CREATE (m:User:Person {name:'Michal'})<-[:FRIEND_OF]-(a:User:Person {name:'Adam'}) CREATE (d:Director:Person {name:'Vince'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Collection directors = directorRepository.findByName("Vince"); - Iterator iterator = directors.iterator(); - assertThat(iterator.hasNext()).isTrue(); - Director director = iterator.next(); - assertThat(director.getName()).isEqualTo("Vince"); - assertThat(iterator.hasNext()).isFalse(); - - directors = directorRepository.findByName("Michal"); - iterator = directors.iterator(); - assertThat(iterator.hasNext()).isFalse(); - } - }); - } - - @Test // DATAGRAPH-744 - public void shouldFindUserWithCustomDepth() { - executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) " - + " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " + " CREATE (u:User {name:'Michal'}) " - + " CREATE (u)-[:VISITED]->(r) CREATE (u)-[:VISITED]->(p)" + " CREATE (m1:Movie {name:'San Andreas'}) " - + " CREATE (m2:Movie {name:'Pitch Perfect 2'})" + " CREATE (p)-[:BLOCKBUSTER]->(m1)" - + " CREATE (r)-[:BLOCKBUSTER]->(m2)" + " CREATE (u)-[:RATED {stars :3}]->(m1)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Cinema cinema = cinemaRepository.findByName("Picturehouse", 0); - assertThat(cinema).isNotNull(); - assertThat(cinema.getName()).isEqualTo("Picturehouse"); - assertThat(cinema.getVisited().size()).isEqualTo(0); - assertThat(cinema.getBlockbusterOfTheWeek()).isEqualTo(null); - - cinema = cinemaRepository.findByName("Picturehouse", 1); - assertThat(cinema).isNotNull(); - assertThat(cinema.getName()).isEqualTo("Picturehouse"); - assertThat(cinema.getVisited().size()).isEqualTo(1); - assertThat(cinema.getVisited().iterator().next().getRatings().size()) - .isEqualTo(0); - assertThat(cinema.getBlockbusterOfTheWeek().getName()) - .isEqualTo("San Andreas"); - - cinema = cinemaRepository.findByName("Picturehouse", 2); - assertThat(cinema).isNotNull(); - assertThat(cinema.getName()).isEqualTo("Picturehouse"); - assertThat(cinema.getVisited().size()).isEqualTo(1); - assertThat(cinema.getVisited().iterator().next().getRatings().size()) - .isEqualTo(1); - assertThat(cinema.getBlockbusterOfTheWeek().getName()) - .isEqualTo("San Andreas"); - } - }); - } - - @Test // DATAGRAPH-744 - public void shouldFindUsersByNameWithStaticDepth() { - executeUpdate( - "CREATE (m:User:Person {name:'Michal', surname:'Bachman'})<-[:FRIEND_OF]-(a:User:Person {name:'Adam', surname:'George'})"); - - User user = userRepository.findBySurname("Bachman"); - assertThat(user).isNotNull(); - assertThat(user.getName()).isEqualTo("Michal"); - assertThat(user.getSurname()).isEqualTo("Bachman"); - assertThat(user.getFriends().size()).isEqualTo(0); - } - - @Test // DATAGRAPH-864 - public void shouldSupportLiteralMapsInQueryResults() { - executeUpdate( - "CREATE (m1:Movie {title:'Speed'}) CREATE (m2:Movie {title:'The Matrix'}) CREATE (m:Movie {title:'Chocolat'})" - + " CREATE (u:User:Person {name:'Michal'}) CREATE (u1:User:Person {name:'Vince'}) " - + " CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2) CREATE (u1)-[:RATED {stars:3}]->(m)"); - - List result = userRepository.findRatingsWithLiteralMap(); - assertThat(result).isNotNull(); - assertThat(result.size()).isEqualTo(2); - EntityWrappingQueryResult row = result.get(0); - if (row.getUser().getName().equals("Vince")) { - assertThat(row.getLiteralMap().size()).isEqualTo(1); - assertThat(row.getLiteralMap().iterator().next().get("movietitle")) - .isEqualTo("Chocolat"); - assertThat(row.getLiteralMap().iterator().next().get("stars")).isEqualTo(3L); - } else { - assertThat(row.getLiteralMap().size()).isEqualTo(2); - } - } - - @Test // DATAGRAPH-876 - public void shouldAllowMultiThreadedDerivedFinderExecution() throws InterruptedException { - int numThreads = 3; - executeUpdate( - "CREATE (m:User {name:'Michal', surname:'Bachman'}), (a:User {name:'Adam', surname:'George'}), (l:User {name:'Luanne', surname:'Misquitta'})"); - - String[] firstNames = new String[] { "Michal", "Adam", "Luanne" }; - String[] lastNames = new String[] { "Bachman", "George", "Misquitta" }; - - ExecutorService executor = Executors.newFixedThreadPool(numThreads); - CountDownLatch latch = new CountDownLatch(numThreads); - - for (int i = 0; i < numThreads; i++) { - executor.submit(new DerivedQueryRunner(latch, firstNames[i], lastNames[i])); - } - latch.await(); // pause until the count reaches 0 - - // force termination of all threads - executor.shutdownNow(); - } - - @Test // DATAGRAPH-680 - @Transactional - public void shouldPageDerivedFinderQueries() { - for (int i = 0; i < 10; i++) { - userRepository.save(new User("A", "B")); - } - userRepository.save(new User("A", "C")); - - Pageable pageable = PageRequest.of(0, 4); - Page page = userRepository.findByNameAndSurname("A", "B", pageable); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.getTotalElements()).isEqualTo(10); - assertThat(page.getNumber()).isEqualTo(0); - assertThat(page.isFirst()).isTrue(); - assertThat(page.isLast()).isFalse(); - assertThat(page.hasNext()).isTrue(); - - page = userRepository.findByNameAndSurname("A", "B", page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.getTotalElements()).isEqualTo(10); - assertThat(page.getNumber()).isEqualTo(1); - assertThat(page.isFirst()).isFalse(); - assertThat(page.isLast()).isFalse(); - assertThat(page.hasNext()).isTrue(); - - page = userRepository.findByNameAndSurname("A", "B", page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(2); - assertThat(page.getTotalElements()).isEqualTo(10); - assertThat(page.getNumber()).isEqualTo(2); - assertThat(page.isFirst()).isFalse(); - assertThat(page.isLast()).isTrue(); - assertThat(page.hasNext()).isFalse(); - - page = userRepository.findByNameAndSurname("A", "B", PageRequest.of(0, 10)); - assertThat(page.getNumberOfElements()).isEqualTo(10); - assertThat(page.getTotalElements()).isEqualTo(10); - assertThat(page.getNumber()).isEqualTo(0); - assertThat(page.isFirst()).isTrue(); - assertThat(page.isLast()).isTrue(); - assertThat(page.hasNext()).isFalse(); - } - - @Test // DATAGRAPH-680 - @Transactional - public void shouldSliceDerivedFinderQueries() { - for (int i = 0; i < 10; i++) { - User user = new User("A"); - user.rate(new TempMovie("Temp"), 5, "just okay"); - userRepository.save(user); - } - userRepository.save(new User("A", "C")); - - Pageable pageable = PageRequest.of(0, 4); - Slice page = userRepository.findByNameAndRatingsStars("A", 5, pageable); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.hasNext()).isTrue(); - - page = userRepository.findByNameAndRatingsStars("A", 5, page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.hasNext()).isTrue(); - - page = userRepository.findByNameAndRatingsStars("A", 5, page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(2); - assertThat(page.hasNext()).isFalse(); - - page = userRepository.findByNameAndRatingsStars("A", 5, PageRequest.of(0, 10)); - assertThat(page.getNumberOfElements()).isEqualTo(10); - assertThat(page.hasNext()).isFalse(); - } - - @Test // DATAGRAPH-1286 - public void findAllByIdShouldSupportPageableParameter() { - - List ids = new ArrayList<>(); - for (int i = 0; i < 10; i++) { - User u = new User("U" + i); - userRepository.save(u); - ids.add(u.getId()); - } - - // Just make sure stuff exists and OGM correctly uses id(n) instead of n.id :( - Optional randomUser = userRepository.findById(ids.get(ids.size() - 2)); - assertThat(randomUser).isPresent().map(User::getName).hasValue("U8"); - - // Assert findAllById works _at all_ - Iterable allUsers = userRepository.findAllById(ids); - assertThat(allUsers).hasSize(ids.size()); - - Pageable pageable = PageRequest.of(0, 2); - Page page = userRepository.findAllByIdIn(ids.subList(0, 4), pageable); - assertThat(page.getSize()).isEqualTo(2); - assertThat(page.getContent()).hasSize(2); - assertThat(page.hasNext()).isTrue(); - } - - @Test // DATAGRAPH-1286 - public void findByIdInInDerivedQueryMethodShouldWork() { - - List ids = new ArrayList<>(); - for (int i = 0; i < 10; i++) { - User u = new User("U" + i); - userRepository.save(u); - ids.add(u.getId()); - } - - List users = userRepository.findAllByIdInAndNameLike(ids.subList(0, 4), "U*"); - assertThat(users).hasSize(4); - } - - @Test // DATAGRAPH-1286 - public void findByIdEqualsInDerivedQueryMethodShouldWork() { - - List ids = new ArrayList<>(); - for (int i = 0; i < 10; i++) { - User u = new User("U" + i); - userRepository.save(u); - ids.add(u.getId()); - } - - List users = userRepository.findAllByIdAndName(ids.get(2), "U2"); - assertThat(users).hasSize(1); - } - - @Test // DATAGRAPH-1093 - public void shouldFindNodeEntitiesByAttributeIgnoringCase() { - executeUpdate("CREATE (:Director:Person {name:'Patty Jenkins'})\n" + // - " ,(:Director:Person {name:'Marry Harron'})\n" + // - " ,(m1:Movie {title:'Speed'})\n" + // - " ,(m2:Movie {title:'The Matrix'})\n" + // - " ,(m3:Movie {title:'Chocolat'})\n" + // - " ,(g:Genre {name:'Thriller'})\n" + // - " ,(u1:User:Person {name:'Michal'})\n" + // - " ,(u1)-[:INTERESTED]->(g)\n" + " ,(u1)-[:RATED {stars:3}]->(m1)\n" + // - " ,(u1)-[:RATED {stars:4}]->(m2)\n" + // - " ,(u2:User {name:'Vince'})\n" + // - " ,(u1)-[:RATED {stars:3}]->(m3)"); - - Collection directors = directorRepository.findByName("paTTY jenKins"); - assertThat(directors).isEmpty(); - - // Ignore case for attribute Director#name set to ALWAYS - directors = directorRepository.findByNameIgnoreCase("paTTY jenKins"); - assertThat(directors).hasSize(1).extracting(Director::getName).containsExactly("Patty Jenkins"); - - List users = userRepository.findByRatingsStarsAndInterestedName(3, "THRILLER"); - assertThat(users).isEmpty(); - - // Ignore case for attribute Director#name set to ALWAYS - users = userRepository.findByRatingsStarsAndInterestedNameIgnoreCase(3, "THRILLER"); - assertThat(users).hasSize(1).extracting(User::getName).containsExactly("Michal"); - - // Ignore case for both Rating#stars and Genre#name to WHEN_POSSIBLE - users = userRepository.findByRatingsStarsAndInterestedNameAllIgnoreCase(3, "THRILLER"); - assertThat(users).hasSize(1).extracting(User::getName).containsExactly("Michal"); - - // Ignore case for Rating#stars set to ALWAYS - assertThatExceptionOfType(InvalidDataAccessApiUsageException.class) - .isThrownBy(() -> userRepository.findByRatingsStarsIgnoreCase(3)) - .withMessageStartingWith("Unable to ignore case of int types, the property 'ratings' must reference a String"); - } - - @Test // DATAGRAPH-1190 - public void shouldFindNodeByNameContainingAndIgnoreCase() { - - String userName = "ABCD"; - User user = new User(userName); - userRepository.save(user); - - User foundUser = userRepository.findByNameContainingIgnoreCase("bc").iterator().next(); - assertThat(foundUser).isNotNull(); - assertThat(foundUser.getName()).isEqualTo(userName); - } - - class DerivedQueryRunner implements Runnable { - - private final CountDownLatch latch; - private final String firstName; - private final String lastName; - - public DerivedQueryRunner(CountDownLatch latch, String firstName, String lastName) { - this.latch = latch; - this.firstName = firstName; - this.lastName = lastName; - } - - @Override - public void run() { - try { - User user = userRepository.findBySurname(lastName); - assertThat(user).isNotNull(); - assertThat(user.getName()).isEqualTo(firstName); - assertThat(user.getSurname()).isEqualTo(lastName); - } finally { - latch.countDown(); - } - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedRelationshipEntityQueryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedRelationshipEntityQueryTests.java deleted file mode 100644 index e8874cd3e..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/DerivedRelationshipEntityQueryTests.java +++ /dev/null @@ -1,405 +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.queries; - -import java.util.Collections; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.examples.movies.domain.Rating; -import org.springframework.data.neo4j.examples.movies.domain.TempMovie; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.repo.RatingRepository; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Luanne Misquitta - * @author Mark Angrish - * @author Vince Bickers - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@RunWith(SpringRunner.class) -@Transactional -public class DerivedRelationshipEntityQueryTests { - - @Autowired private GraphDatabaseService graphDatabaseService; - - @Autowired private UserRepository userRepository; - - @Autowired private RatingRepository ratingRepository; - - @Before - public void clearDatabase() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Test - public void shouldFindREFromCustomQuery() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - - userRepository.save(critic); - - Rating rating = ratingRepository.findRatingByUserAndTempMovie(critic.getId(), film.getId()); - assertThat(rating).isNotNull(); - assertThat(rating).as("The loaded rating shouldn't be null").isNotNull(); - assertThat(rating.getStars()) - .as("The relationship properties weren't saved correctly") - .isEqualTo(filmRating.getStars()); - assertThat(rating.getMovie().getName()) - .as("The rated film wasn't saved correctly").isEqualTo(film.getName()); - assertThat(rating.getUser().getId()).as("The critic wasn't saved correctly") - .isEqualTo(critic.getId()); - } - - @Test // DATAGRAPH-629 - public void shouldFindREWithSingleProperty() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - - userRepository.save(critic); - - List ratings = ratingRepository.findByStars(2); - assertThat(ratings).isNotNull(); - Rating loadedRating = ratings.get(0); - assertThat(loadedRating).as("The loaded rating shouldn't be null").isNotNull(); - assertThat(loadedRating.getStars()) - .as("The relationship properties weren't saved correctly") - .isEqualTo(filmRating.getStars()); - assertThat(loadedRating.getMovie().getName()) - .as("The rated film wasn't saved correctly").isEqualTo(film.getName()); - assertThat(loadedRating.getUser().getId()).as("The critic wasn't saved correctly") - .isEqualTo(critic.getId()); - } - - @Test // DATAGRAPH-629 - public void shouldFindREWithMultiplePropertiesAnded() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - List ratings = ratingRepository.findByStarsAndRatingTimestamp(2, 1000); - assertThat(ratings).isNotNull(); - Rating loadedRating = ratings.get(0); - assertThat(loadedRating).as("The loaded rating shouldn't be null").isNotNull(); - assertThat(loadedRating.getStars()) - .as("The relationship properties weren't saved correctly") - .isEqualTo(filmRating.getStars()); - assertThat(loadedRating.getMovie().getName()) - .as("The rated film wasn't saved correctly").isEqualTo(film.getName()); - assertThat(loadedRating.getUser().getId()).as("The critic wasn't saved correctly") - .isEqualTo(critic.getId()); - - ratings = ratingRepository.findByStarsAndRatingTimestamp(2, 2000); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-629 - public void shouldFindREWithMultiplePropertiesOred() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - List ratings = ratingRepository.findByStarsOrRatingTimestamp(5, 1000); - assertThat(ratings).isNotNull(); - Rating loadedRating = ratings.get(0); - assertThat(loadedRating).as("The loaded rating shouldn't be null").isNotNull(); - assertThat(loadedRating.getStars()) - .as("The relationship properties weren't saved correctly") - .isEqualTo(filmRating.getStars()); - assertThat(loadedRating.getMovie().getName()) - .as("The rated film wasn't saved correctly").isEqualTo(film.getName()); - assertThat(loadedRating.getUser().getId()).as("The critic wasn't saved correctly") - .isEqualTo(critic.getId()); - - ratings = ratingRepository.findByStarsAndRatingTimestamp(5, 2000); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-629 - public void shouldFindREWithMultiplePropertiesDifferentComparisonOperatorsAnded() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - List ratings = ratingRepository.findByStarsAndRatingTimestampLessThan(2, 2000); - assertThat(ratings).isNotNull(); - Rating loadedRating = ratings.get(0); - assertThat(loadedRating).as("The loaded rating shouldn't be null").isNotNull(); - assertThat(loadedRating.getStars()) - .as("The relationship properties weren't saved correctly") - .isEqualTo(filmRating.getStars()); - assertThat(loadedRating.getMovie().getName()) - .as("The rated film wasn't saved correctly").isEqualTo(film.getName()); - assertThat(loadedRating.getUser().getId()).as("The critic wasn't saved correctly") - .isEqualTo(critic.getId()); - - ratings = ratingRepository.findByStarsAndRatingTimestamp(2, 3000); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-629 - public void shouldFindREWithMultiplePropertiesDifferentComparisonOperatorsOred() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - List ratings = ratingRepository.findByStarsOrRatingTimestampGreaterThan(5, 500); - assertThat(ratings).isNotNull(); - Rating loadedRating = ratings.get(0); - assertThat(loadedRating).as("The loaded rating shouldn't be null").isNotNull(); - assertThat(loadedRating.getStars()) - .as("The relationship properties weren't saved correctly") - .isEqualTo(filmRating.getStars()); - assertThat(loadedRating.getMovie().getName()) - .as("The rated film wasn't saved correctly").isEqualTo(film.getName()); - assertThat(loadedRating.getUser().getId()).as("The critic wasn't saved correctly") - .isEqualTo(critic.getId()); - - ratings = ratingRepository.findByStarsAndRatingTimestamp(5, 2000); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-632 - public void shouldFindRelEntitiesWithNestedStartNodeProperty() { - graphDatabaseService.execute( - "CREATE (m1:Movie {name:'Speed'}) CREATE (m2:Movie {name:'The Matrix'}) CREATE (m:Movie {name:'Chocolat'})" - + " CREATE (u:User {name:'Michal'}) CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2)"); - - List ratings = ratingRepository.findByUserName("Michal"); - assertThat(ratings.size()).isEqualTo(2); - Collections.sort(ratings); - assertThat(ratings.get(0).getMovie().getName()).isEqualTo("Speed"); - assertThat(ratings.get(1).getMovie().getName()).isEqualTo("The Matrix"); - } - - @Test // DATAGRAPH-632 - public void shouldFindRelEntitiesWithNestedEndNodeProperty() { - graphDatabaseService.execute( - "CREATE (m1:Movie {name:'Finding Dory'}) CREATE (m2:Movie {name:'Captain America'}) CREATE (m:Movie {name:'X-Men'})" - + " CREATE (u:User {name:'Vince'}) CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2)"); - - List ratings = ratingRepository.findByMovieName("Captain America"); - assertThat(ratings.size()).isEqualTo(1); - assertThat(ratings.get(0).getUser().getName()).isEqualTo("Vince"); - assertThat(ratings.get(0).getMovie().getName()).isEqualTo("Captain America"); - assertThat(ratings.get(0).getStars()).isEqualTo(4); - - ratings = ratingRepository.findByMovieName("X-Men"); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-632 - public void shouldFindRelEntitiesWithBothStartEndNestedProperty() { - graphDatabaseService.execute( - "CREATE (m1:Movie {name:'Independence Day: Resurgence'}) CREATE (m2:Movie {name:'The Conjuring 2'}) CREATE (m:Movie {name:'The BFG'})" - + " CREATE (u:User {name:'Daniela'}) CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2)"); - - List ratings = ratingRepository.findByUserNameAndMovieName("Daniela", "Independence Day: Resurgence"); - assertThat(ratings.size()).isEqualTo(1); - assertThat(ratings.get(0).getUser().getName()).isEqualTo("Daniela"); - assertThat(ratings.get(0).getMovie().getName()) - .isEqualTo("Independence Day: Resurgence"); - assertThat(ratings.get(0).getStars()).isEqualTo(3); - - ratings = ratingRepository.findByUserNameAndMovieName("Daniela", "The BFG"); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-632 - public void shouldFindRelEntitiesWithBaseAndNestedStartNodePropertyAnded() { - graphDatabaseService.execute( - "CREATE (m1:Movie {name:'The Shallows'}) CREATE (m2:Movie {name:'Central Intelligence'}) CREATE (m:Movie {name:'Now you see me'})" - + " CREATE (u:User {name:'Luanne'}) CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2)"); - - List ratings = ratingRepository.findByUserNameAndStars("Luanne", 3); - assertThat(ratings.size()).isEqualTo(1); - assertThat(ratings.get(0).getUser().getName()).isEqualTo("Luanne"); - assertThat(ratings.get(0).getMovie().getName()).isEqualTo("The Shallows"); - assertThat(ratings.get(0).getStars()).isEqualTo(3); - - ratings = ratingRepository.findByUserNameAndStars("Luanne", 1); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test(expected = UnsupportedOperationException.class) // DATAGRAPH-662 - public void shouldFindRelEntitiesWithBaseAndNestedStartNodePropertyOred() { - graphDatabaseService.execute( - "CREATE (m1:Movie {name:'Swiss Army Man'}) CREATE (m2:Movie {name:'Me Before You'}) CREATE (m:Movie {name:'X-Men Apocalypse'})" - + " CREATE (u:User {name:'Mark'}) CREATE (u2:User {name:'Adam'}) " - + " CREATE (u)-[:RATED {stars:2}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2)" - + " CREATE (u2)-[:RATED {stars:3}]->(m)"); - - List ratings = ratingRepository.findByStarsOrUserName(3, "Mark"); - assertThat(ratings.size()).isEqualTo(3); - Collections.sort(ratings); - assertThat(ratings.get(0).getMovie().getName()).isEqualTo("Swiss Army Man"); - assertThat(ratings.get(1).getMovie().getName()).isEqualTo("X-Men Apocalypse"); - assertThat(ratings.get(2).getMovie().getName()).isEqualTo("Me Before You"); - - ratings = ratingRepository.findByStarsOrUserName(0, "Vince"); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-632 - public void shouldFindRelEntitiesWithBaseAndNestedEndNodeProperty() { - graphDatabaseService.execute( - "CREATE (m1:Movie {name:'Our Kind of Traitor'}) CREATE (m2:Movie {name:'Teenage Mutant Ninja Turtles'}) CREATE (m:Movie {name:'Zootopia'})" - + " CREATE (u:User {name:'Chris'}) CREATE (u2:User {name:'Katerina'}) " - + " CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2)" - + " CREATE (u2)-[:RATED {stars:4}]->(m2)"); - - List ratings = ratingRepository.findByStarsAndMovieName(4, "Teenage Mutant Ninja Turtles"); - assertThat(ratings.size()).isEqualTo(2); - Collections.sort(ratings); - assertThat(ratings.get(0).getUser().getName()).isEqualTo("Chris"); - assertThat(ratings.get(1).getUser().getName()).isEqualTo("Katerina"); - - ratings = ratingRepository.findByStarsAndMovieName(5, "Teenage Mutant Ninja Turtles"); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-632 - public void shouldFindRelEntitiesWithBaseAndBothStartEndNestedProperty() { - graphDatabaseService.execute( - "CREATE (m1:Movie {name:'The Jungle Book'}) CREATE (m2:Movie {name:'The Angry Birds Movie'}) CREATE (m:Movie {name:'Alice Through The Looking Glass'})" - + " CREATE (u:User {name:'Alessandro'}) CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2)"); - - List ratings = ratingRepository.findByUserNameAndMovieNameAndStars("Alessandro", "The Jungle Book", 3); - assertThat(ratings.size()).isEqualTo(1); - assertThat(ratings.get(0).getUser().getName()).isEqualTo("Alessandro"); - assertThat(ratings.get(0).getMovie().getName()).isEqualTo("The Jungle Book"); - assertThat(ratings.get(0).getStars()).isEqualTo(3); - - ratings = ratingRepository.findByUserNameAndMovieNameAndStars("Colin", "Speed", 0); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-632 - public void shouldFindRelEntitiesWithTwoStartNodeNestedProperties() { - graphDatabaseService.execute( - "CREATE (m1:Movie {name:'Batman v Superman'}) CREATE (m2:Movie {name:'Genius'}) CREATE (m:Movie {name:'Home'})" - + " CREATE (u:User {name:'David', middleName:'M'}) CREATE (u2:User {name:'Martin', middleName:'M'}) " - + " CREATE (u)-[:RATED {stars:3}]->(m1) CREATE (u)-[:RATED {stars:4}]->(m2)" - + " CREATE (u2)-[:RATED {stars:4}]->(m2)"); - - List ratings = ratingRepository.findByUserNameAndUserMiddleName("David", "M"); - assertThat(ratings.size()).isEqualTo(2); - Collections.sort(ratings); - assertThat(ratings.get(0).getUser().getName()).isEqualTo("David"); - assertThat(ratings.get(0).getMovie().getName()).isEqualTo("Batman v Superman"); - assertThat(ratings.get(1).getUser().getName()).isEqualTo("David"); - assertThat(ratings.get(1).getMovie().getName()).isEqualTo("Genius"); - - ratings = ratingRepository.findByUserNameAndUserMiddleName("David", "V"); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-813 - public void shouldDeleteAndReturnDeletedIds() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - List ratingIds = ratingRepository.deleteByStarsOrRatingTimestampGreaterThan(2, 500); - assertThat(ratingIds.get(0)).isEqualTo(filmRating.getId()); - assertThat(ratingIds.size()).isEqualTo(1); - - List ratings = ratingRepository.findByStarsAndRatingTimestamp(2, 2000); - assertThat(ratings.size()).isEqualTo(0); - } - - @Test // DATAGRAPH-813 - public void shouldCountByStars() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - long starredRatings = ratingRepository.countByStars(2); - assertThat(starredRatings).isEqualTo(1L); - - } - - @Test // DATAGRAPH-813 - public void shouldRemoveByUserNameAndReturnCountOfDeletedObjects() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - long countRemovedObjects = ratingRepository.removeByUserName("Gary"); - assertThat(countRemovedObjects).isEqualTo(1L); - - } - - @Test // DATAGRAPH-813 - public void shouldCountNothingWithNonMatchingFilter() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - long countRemovedObjects = ratingRepository.removeByUserName("Bill"); - assertThat(countRemovedObjects).isEqualTo(0L); - } - - @Test // DATAGRAPH-813 - public void shouldDeleteNothingWithNonMatchingFilter() { - User critic = new User("Gary"); - TempMovie film = new TempMovie("Fast and Furious XVII"); - Rating filmRating = critic.rate(film, 2, "They've made far too many of these films now!"); - filmRating.setRatingTimestamp(1000); - - userRepository.save(critic); - - List deletedIds = ratingRepository.deleteByStarsOrRatingTimestampGreaterThan(3, 2000); - assertThat(deletedIds.size()).isEqualTo(0L); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/Java8SupportTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/Java8SupportTests.java deleted file mode 100644 index 5250f6226..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/Java8SupportTests.java +++ /dev/null @@ -1,96 +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.queries; - -import java.util.Collection; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.harness.ServerControls; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.examples.movies.domain.Cinema; -import org.springframework.data.neo4j.examples.movies.repo.CinemaStreamingRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@RunWith(SpringRunner.class) -@Transactional -public class Java8SupportTests { - - @Autowired private ServerControls neo4jTestServer; - - @Autowired private CinemaStreamingRepository cinemaRepository; - - @Before - public void setup() { - neo4jTestServer.graph().execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - - String[] names = new String[] { "Picturehouse", "Regal", "Ritzy", "Metro", "Inox", "PVR", "Cineplex", "Landmark", - "Rainbow", "Movietime" }; - for (String name : names) { - Cinema cinema = new Cinema(name); - cinema.setLocation("London"); - cinema.setCapacity(500); - cinemaRepository.save(cinema); - } - } - - @Test - public void shouldFindOptionalCinema() { - Optional cinema = cinemaRepository.findByName("Picturehouse", 1); - assertThat(cinema.isPresent()).isTrue(); - assertThat(cinema.get().getName()).isEqualTo("Picturehouse"); - - cinema = cinemaRepository.findByName("ZZZ", 1); - assertThat(cinema.isPresent()).isFalse(); - } - - @Test - public void shouldStreamCinemas() { - Stream allCinemas = cinemaRepository.getAllCinemas(); - assertThat(allCinemas.count()).isEqualTo(10); - } - - @Test - public void shouldStreamCinemasWithSort() { - Collection allCinemas = cinemaRepository.getCinemasSortedByName(Sort.by("n.name")) - .collect(Collectors.toList()); - - assertThat(allCinemas.size()).isEqualTo(10); - assertThat(allCinemas.iterator().next().getName()).isEqualTo("Cineplex"); - } - - @Test - public void shouldGetCinemasAsync() { - cinemaRepository.getAllCinemasAsync().thenAccept(cinemas -> { - assertThat(cinemas.size()).isEqualTo(10); - cinemas.forEach(cinema -> assertThat(cinema.getName()).isNotNull()); - }); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/MoviesContextConfiguration.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/MoviesContextConfiguration.java deleted file mode 100644 index d6438df87..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/MoviesContextConfiguration.java +++ /dev/null @@ -1,27 +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.queries; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; - -/** - * @author Michael J. Simons - */ -@Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.examples.movies.domain", - repositoryPackages = "org.springframework.data.neo4j.examples.movies.repo") -@ComponentScan("org.springframework.data.neo4j.examples.movies.service") -public class MoviesContextConfiguration {} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/PagedQueryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/PagedQueryTests.java deleted file mode 100644 index 4bdd675fd..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/PagedQueryTests.java +++ /dev/null @@ -1,548 +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.queries; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.harness.ServerControls; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.examples.movies.domain.Cinema; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.CinemaQueryResult; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.CinemaQueryResultInterface; -import org.springframework.data.neo4j.examples.movies.repo.CinemaRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * See DATAGRAPH-680 - * @author Luanne Misquitta - * @author Jasper Blues - * @author Mark Angrish - * @author Nicolas Mervaillie - * @author Ihor Dziuba - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@RunWith(SpringRunner.class) -public class PagedQueryTests { - - @Autowired private ServerControls neo4jTestServer; - - @Autowired private CinemaRepository cinemaRepository; - - @Autowired private TransactionTemplate transactionTemplate; - - @Before - public void init() { - neo4jTestServer.graph().execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - public void setup() { - String[] names = new String[] { "Picturehouse", "Regal", "Ritzy", "Metro", "Inox", "PVR", "Cineplex", "Landmark", - "Rainbow", "Movietime" }; - for (String name : names) { - Cinema cinema = new Cinema(name); - cinema.setLocation("London"); - cinema.setCapacity(500); - cinemaRepository.save(cinema); - } - } - - private void executeUpdate(String cypher) { - neo4jTestServer.graph().execute(cypher); - } - - @Test - @Transactional - public void shouldFindPagedCinemas() { - setup(); - Pageable pageable = PageRequest.of(0, 3); - Page page = cinemaRepository.getPagedCinemas(pageable); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); - - page = cinemaRepository.getPagedCinemas(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); - - page = cinemaRepository.getPagedCinemas(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); - - page = cinemaRepository.getPagedCinemas(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(1); - assertThat(page.hasNext()).isFalse(); - } - - @Test(expected = IllegalArgumentException.class) - @Transactional - public void shouldThrowExceptionIfCountQueryAbsent() { - setup(); - Pageable pageable = PageRequest.of(0, 3); - cinemaRepository.getPagedCinemasWithoutCountQuery(pageable); - } - - /** - * Repeats shouldFindPagedCinemas for query results - concrete classes. - */ - @Test // DATAGRAPH-893 - @Transactional - public void shouldFindPagedQueryResults() { - setup(); - Pageable pageable = PageRequest.of(0, 3); - Page page = cinemaRepository.getPagedCinemaQueryResults(pageable); - - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - // FIXME : bug here - content is always null - // assertNotNull(page.getContent().get(0).getName()); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - - page = cinemaRepository.getPagedCinemaQueryResults(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - - page = cinemaRepository.getPagedCinemaQueryResults(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - - page = cinemaRepository.getPagedCinemaQueryResults(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(1); - assertThat(page.hasNext()).isFalse(); - } - - @Test // DATAGRAPH-893 - @Transactional - public void shouldFindSlicedQueryResults() { - setup(); - Pageable pageable = PageRequest.of(0, 3); - Slice page = cinemaRepository.getSlicedCinemaQueryResults(pageable); - - assertThat(page.getNumberOfElements()).isEqualTo(3); - // FIXME : bug here - content is always null - // assertNotNull(page.getContent().get(0).getName()); - assertThat(page.hasNext()).isTrue(); - - page = cinemaRepository.getSlicedCinemaQueryResults(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - - page = cinemaRepository.getSlicedCinemaQueryResults(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - - page = cinemaRepository.getSlicedCinemaQueryResults(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(1); - assertThat(page.hasNext()).isFalse(); - } - - /** - * Repeats shouldFindPagedCinemas for query results - interfaces * @see DATAGRAPH-893 - */ - @Test - @Transactional - public void shouldFindPagedQueryInterfaceResults() { - setup(); - Pageable pageable = PageRequest.of(0, 3); - Page page = cinemaRepository.getPagedCinemaQueryResultInterfaces(pageable); - - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - // FIXME : bug here - content is always null - // assertNotNull(page.getContent().get(0).getName()); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - - page = cinemaRepository.getPagedCinemaQueryResultInterfaces(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - - page = cinemaRepository.getPagedCinemaQueryResultInterfaces(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(3); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - - page = cinemaRepository.getPagedCinemaQueryResultInterfaces(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(1); - assertThat(page.hasNext()).isFalse(); - } - - @Test - @Transactional - public void shouldUseQueryParametersInCountQuery() { - setup(); - Pageable pageable = PageRequest.of(0, 5); - Page page = cinemaRepository.getPagedCinemasByCityWithPageCount("London", pageable); - assertThat(page.getNumberOfElements()).isEqualTo(5); - assertThat(page.getTotalElements()).isEqualTo(10); // With a count query, the total elements should equal the number - // returned by the count query - assertThat(page.hasNext()).isTrue(); - - page = cinemaRepository.getPagedCinemasByCityWithPageCount("London", page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(5); - assertThat(page.getTotalElements()).isEqualTo(10); // With a count query, the total elements should equal the number - // returned by the count query - assertThat(page.hasNext()).isFalse(); // with a count query, the next page calculation is correct - } - - @Test - @Transactional - public void shouldFindSlicedCinemas() { - setup(); - Pageable pageable = PageRequest.of(0, 3); - Slice slice = cinemaRepository.getSlicedCinemasByName(pageable); - assertThat(slice.getContent().get(0).getName()).isNotNull(); - assertThat(slice.getNumberOfElements()).isEqualTo(3); - assertThat(slice.hasNext()).isTrue(); - - slice = cinemaRepository.getSlicedCinemasByName(slice.nextPageable()); - assertThat(slice.getNumberOfElements()).isEqualTo(3); - assertThat(slice.hasNext()).isTrue(); - - slice = cinemaRepository.getSlicedCinemasByName(slice.nextPageable()); - assertThat(slice.getNumberOfElements()).isEqualTo(3); - assertThat(slice.hasNext()).isTrue(); - - slice = cinemaRepository.getSlicedCinemasByName(slice.nextPageable()); - assertThat(slice.getNumberOfElements()).isEqualTo(1); - assertThat(slice.hasNext()).isFalse(); - } - - @Test - @Transactional - public void shouldCorrectlyCalculateWhetherNextSliceExists() { - setup(); - Pageable pageable = PageRequest.of(0, 5); - Slice slice = cinemaRepository.getSlicedCinemasByName(pageable); - assertThat(slice.getNumberOfElements()).isEqualTo(5); - assertThat(slice.hasNext()).isTrue(); - - slice = cinemaRepository.getSlicedCinemasByName(slice.nextPageable()); - assertThat(slice.getNumberOfElements()).isEqualTo(5); - assertThat(slice.hasNext()).isFalse(); - } - - @Test // DATAGRAPH-887 - @Transactional - public void shouldFindPagedAndSortedCinemas() { - setup(); - Pageable pageable = PageRequest.of(0, 4, Sort.by("name").ascending()); - - Page page = cinemaRepository.findByLocation("London", pageable); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); - assertThat(page.getContent().get(0).getName()).isEqualTo("Cineplex"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Inox"); - assertThat(page.getContent().get(2).getName()).isEqualTo("Landmark"); - assertThat(page.getContent().get(3).getName()).isEqualTo("Metro"); - - page = cinemaRepository.findByLocation("London", page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); - assertThat(page.getContent().get(0).getName()).isEqualTo("Movietime"); - assertThat(page.getContent().get(1).getName()).isEqualTo("PVR"); - assertThat(page.getContent().get(2).getName()).isEqualTo("Picturehouse"); - assertThat(page.getContent().get(3).getName()).isEqualTo("Rainbow"); - - page = cinemaRepository.findByLocation("London", page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(2); - assertThat(page.hasNext()).isFalse(); - assertThat(page.getTotalElements()).isEqualTo(10); - assertThat(page.getContent().get(0).getName()).isEqualTo("Regal"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Ritzy"); - } - - @Test // DATAGRAPH-887 - public void shouldSortPageWhenNestedPropertyIsInvolved() { - executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) " - + "CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " - + "CREATE (m:Theatre {name:'Picturehouse', city:'London', capacity: 5000}) " - + "CREATE (u:User {name:'Michal'}) " + "CREATE (u)-[:VISITED]->(r) " + "CREATE (u)-[:VISITED]->(m)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Page page = cinemaRepository.findByLocationAndVisitedName("London", "Michal", - PageRequest.of(0, 1, Sort.Direction.DESC, "name")); - assertThat(page.getNumberOfElements()).isEqualTo(1); - assertThat(page.getContent().get(0).getName()).isEqualTo("Ritzy"); - - page = cinemaRepository.findByLocationAndVisitedName("London", "Michal", - PageRequest.of(1, 1, Sort.Direction.DESC, "name")); - assertThat(page.getNumberOfElements()).isEqualTo(1); - assertThat(page.getContent().get(0).getName()).isEqualTo("Picturehouse"); - } - }); - } - - @Test // DATAGRAPH-887 - public void shouldSortPageByNestedPropertyIsInvolved() { - executeUpdate("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) " - + "CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " - + "CREATE (m:Theatre {name:'Regal', city:'Bombay', capacity: 5000}) " + "CREATE (u:User {name:'Michal'}) " - + "CREATE (u)-[:VISITED]->(r) " + "CREATE (u)-[:VISITED]->(m)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Page page = cinemaRepository.findByVisitedName("Michal", - PageRequest.of(0, 1, Sort.Direction.ASC, "location")); - assertThat(page.getNumberOfElements()).isEqualTo(1); - assertThat(page.getContent().get(0).getName()).isEqualTo("Regal"); - - page = cinemaRepository.findByVisitedName("Michal", PageRequest.of(1, 1, Sort.Direction.DESC, "location")); - assertThat(page.getNumberOfElements()).isEqualTo(1); - assertThat(page.getContent().get(0).getName()).isEqualTo("Regal"); - } - }); - } - - @Test // DATAGRAPH-887 - @Transactional - public void shouldFindSortedCinemas() { - setup(); - Sort sort = Sort.by(Sort.Direction.ASC, "name"); - List cinemas = cinemaRepository.findByLocation("London", sort); - assertThat(cinemas.size()).isEqualTo(10); - assertThat(cinemas.get(0).getName()).isEqualTo("Cineplex"); - assertThat(cinemas.get(1).getName()).isEqualTo("Inox"); - assertThat(cinemas.get(2).getName()).isEqualTo("Landmark"); - assertThat(cinemas.get(3).getName()).isEqualTo("Metro"); - assertThat(cinemas.get(4).getName()).isEqualTo("Movietime"); - assertThat(cinemas.get(5).getName()).isEqualTo("PVR"); - assertThat(cinemas.get(6).getName()).isEqualTo("Picturehouse"); - assertThat(cinemas.get(7).getName()).isEqualTo("Rainbow"); - assertThat(cinemas.get(8).getName()).isEqualTo("Regal"); - assertThat(cinemas.get(9).getName()).isEqualTo("Ritzy"); - } - - @Test // DATAGRAPH-887 - @Transactional - public void shouldFindPagedAndSortedCinemasByCapacity() { - setup(); - - Pageable pageable = PageRequest.of(0, 4, Sort.by("name").ascending()); - - Page page = cinemaRepository.findByCapacity(500, pageable); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.getContent().get(0).getName()).isEqualTo("Cineplex"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Inox"); - assertThat(page.getContent().get(2).getName()).isEqualTo("Landmark"); - assertThat(page.getContent().get(3).getName()).isEqualTo("Metro"); - - pageable = PageRequest.of(1, 4, Sort.Direction.ASC, "name"); - page = cinemaRepository.findByCapacity(500, pageable); - assertThat(page.getContent().size()).isEqualTo(4); - assertThat(page.getContent().get(0).getName()).isEqualTo("Movietime"); - assertThat(page.getContent().get(1).getName()).isEqualTo("PVR"); - assertThat(page.getContent().get(2).getName()).isEqualTo("Picturehouse"); - assertThat(page.getContent().get(3).getName()).isEqualTo("Rainbow"); - - pageable = PageRequest.of(2, 4, Sort.Direction.ASC, "name"); - page = cinemaRepository.findByCapacity(500, pageable); - assertThat(page.getContent().size()).isEqualTo(2); - assertThat(page.getContent().get(0).getName()).isEqualTo("Regal"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Ritzy"); - } - - @Test // DATAGRAPH-653 - @Transactional - public void shouldFindPagedCinemasSortedWithCustomQuery() { - setup(); - Pageable pageable = PageRequest.of(0, 4, Sort.by("n.name").ascending()); - - Page page = cinemaRepository.getPagedCinemas(pageable); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - assertThat(page.getContent().get(0).getName()).isEqualTo("Cineplex"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Inox"); - assertThat(page.getContent().get(2).getName()).isEqualTo("Landmark"); - assertThat(page.getContent().get(3).getName()).isEqualTo("Metro"); - - page = cinemaRepository.getPagedCinemas(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - assertThat(page.getContent().get(0).getName()).isEqualTo("Movietime"); - assertThat(page.getContent().get(1).getName()).isEqualTo("PVR"); - assertThat(page.getContent().get(2).getName()).isEqualTo("Picturehouse"); - assertThat(page.getContent().get(3).getName()).isEqualTo("Rainbow"); - - page = cinemaRepository.getPagedCinemas(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(2); - assertThat(page.hasNext()).isFalse(); - assertThat(page.getTotalElements()).isEqualTo(10); // this should not be relied on as incorrect as the total elements is an - // estimate - assertThat(page.getContent().get(0).getName()).isEqualTo("Regal"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Ritzy"); - } - - @Test // DATAGRAPH-653 - @Transactional - public void shouldFindSlicedCinemasSortedWithCustomQuery() { - setup(); - Pageable pageable = PageRequest.of(0, 4, Sort.by("n.name").ascending()); - - Slice slice = cinemaRepository.getSlicedCinemasByName(pageable); - assertThat(slice.getNumberOfElements()).isEqualTo(4); - assertThat(slice.hasNext()).isTrue(); - assertThat(slice.getContent().get(0).getName()).isEqualTo("Cineplex"); - assertThat(slice.getContent().get(1).getName()).isEqualTo("Inox"); - assertThat(slice.getContent().get(2).getName()).isEqualTo("Landmark"); - assertThat(slice.getContent().get(3).getName()).isEqualTo("Metro"); - - slice = cinemaRepository.getSlicedCinemasByName(slice.nextPageable()); - assertThat(slice.getNumberOfElements()).isEqualTo(4); - assertThat(slice.hasNext()).isTrue(); - assertThat(slice.getContent().get(0).getName()).isEqualTo("Movietime"); - assertThat(slice.getContent().get(1).getName()).isEqualTo("PVR"); - assertThat(slice.getContent().get(2).getName()).isEqualTo("Picturehouse"); - assertThat(slice.getContent().get(3).getName()).isEqualTo("Rainbow"); - - slice = cinemaRepository.getSlicedCinemasByName(slice.nextPageable()); - assertThat(slice.getNumberOfElements()).isEqualTo(2); - assertThat(slice.hasNext()).isFalse(); - assertThat(slice.getContent().get(0).getName()).isEqualTo("Regal"); - assertThat(slice.getContent().get(1).getName()).isEqualTo("Ritzy"); - } - - @Test // DATAGRAPH-653 - @Transactional - public void shouldFindCinemasSortedByNameWithCustomQuery() { - setup(); - Sort sort = Sort.by(Sort.Direction.ASC, "n.name"); - List cinemas = cinemaRepository.getCinemasSortedByName(sort); - assertThat(cinemas.size()).isEqualTo(10); - assertThat(cinemas.get(0).getName()).isEqualTo("Cineplex"); - assertThat(cinemas.get(1).getName()).isEqualTo("Inox"); - assertThat(cinemas.get(2).getName()).isEqualTo("Landmark"); - assertThat(cinemas.get(3).getName()).isEqualTo("Metro"); - assertThat(cinemas.get(4).getName()).isEqualTo("Movietime"); - assertThat(cinemas.get(5).getName()).isEqualTo("PVR"); - assertThat(cinemas.get(6).getName()).isEqualTo("Picturehouse"); - assertThat(cinemas.get(7).getName()).isEqualTo("Rainbow"); - assertThat(cinemas.get(8).getName()).isEqualTo("Regal"); - assertThat(cinemas.get(9).getName()).isEqualTo("Ritzy"); - } - - @Test // DATAGRAPH-1290 - @Transactional - public void shouldFindPagedCinemasSortedCaseInsensitiveWithCustomQuery() { - setup(); - Sort sort = Sort.by(Sort.Order.asc("n.name").ignoreCase()); - Pageable pageable = PageRequest.of(0, 4, sort); - - Page page = cinemaRepository.getPagedCinemas(pageable); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getContent().get(0).getName()).isEqualTo("Cineplex"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Inox"); - assertThat(page.getContent().get(2).getName()).isEqualTo("Landmark"); - assertThat(page.getContent().get(3).getName()).isEqualTo("Metro"); - - page = cinemaRepository.getPagedCinemas(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(4); - assertThat(page.hasNext()).isTrue(); - assertThat(page.getContent().get(0).getName()).isEqualTo("Movietime"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Picturehouse"); - assertThat(page.getContent().get(2).getName()).isEqualTo("PVR"); - assertThat(page.getContent().get(3).getName()).isEqualTo("Rainbow"); - - page = cinemaRepository.getPagedCinemas(page.nextPageable()); - assertThat(page.getNumberOfElements()).isEqualTo(2); - assertThat(page.hasNext()).isFalse(); - assertThat(page.getContent().get(0).getName()).isEqualTo("Regal"); - assertThat(page.getContent().get(1).getName()).isEqualTo("Ritzy"); - } - - @Test // DATAGRAPH-1290 - @Transactional - public void shouldFindSlicedCinemasSortedCaseInsensitiveWithCustomQuery() { - setup(); - Sort sort = Sort.by(Sort.Order.asc("n.name").ignoreCase()); - Pageable pageable = PageRequest.of(0, 4, sort); - - Slice slice = cinemaRepository.getSlicedCinemasByName(pageable); - assertThat(slice.getNumberOfElements()).isEqualTo(4); - assertThat(slice.hasNext()).isTrue(); - assertThat(slice.getContent().get(0).getName()).isEqualTo("Cineplex"); - assertThat(slice.getContent().get(1).getName()).isEqualTo("Inox"); - assertThat(slice.getContent().get(2).getName()).isEqualTo("Landmark"); - assertThat(slice.getContent().get(3).getName()).isEqualTo("Metro"); - - slice = cinemaRepository.getSlicedCinemasByName(slice.nextPageable()); - assertThat(slice.getNumberOfElements()).isEqualTo(4); - assertThat(slice.hasNext()).isTrue(); - assertThat(slice.getContent().get(0).getName()).isEqualTo("Movietime"); - assertThat(slice.getContent().get(1).getName()).isEqualTo("Picturehouse"); - assertThat(slice.getContent().get(2).getName()).isEqualTo("PVR"); - assertThat(slice.getContent().get(3).getName()).isEqualTo("Rainbow"); - - slice = cinemaRepository.getSlicedCinemasByName(slice.nextPageable()); - assertThat(slice.getNumberOfElements()).isEqualTo(2); - assertThat(slice.hasNext()).isFalse(); - assertThat(slice.getContent().get(0).getName()).isEqualTo("Regal"); - assertThat(slice.getContent().get(1).getName()).isEqualTo("Ritzy"); - } - - @Test // DATAGRAPH-1290 - @Transactional - public void shouldFindCinemasSortedCaseInsensitiveByNameWithCustomQuery() { - setup(); - Sort sort = Sort.by(Sort.Order.asc("n.name").ignoreCase()); - List cinemas = cinemaRepository.getCinemasSortedByName(sort); - assertThat(cinemas.size()).isEqualTo(10); - assertThat(cinemas.get(0).getName()).isEqualTo("Cineplex"); - assertThat(cinemas.get(1).getName()).isEqualTo("Inox"); - assertThat(cinemas.get(2).getName()).isEqualTo("Landmark"); - assertThat(cinemas.get(3).getName()).isEqualTo("Metro"); - assertThat(cinemas.get(4).getName()).isEqualTo("Movietime"); - assertThat(cinemas.get(5).getName()).isEqualTo("Picturehouse"); - assertThat(cinemas.get(6).getName()).isEqualTo("PVR"); - assertThat(cinemas.get(7).getName()).isEqualTo("Rainbow"); - assertThat(cinemas.get(8).getName()).isEqualTo("Regal"); - assertThat(cinemas.get(9).getName()).isEqualTo("Ritzy"); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ProjectionTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ProjectionTests.java deleted file mode 100644 index 96b06464a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ProjectionTests.java +++ /dev/null @@ -1,129 +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.queries; - -import static org.assertj.core.api.Assertions.*; -import static org.springframework.test.context.TestExecutionListeners.MergeMode.*; - -import java.util.List; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.harness.ServerControls; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Sort; -import org.springframework.data.neo4j.examples.movies.domain.CinemaAndBlockbuster; -import org.springframework.data.neo4j.examples.movies.domain.CinemaAndBlockbusterName; -import org.springframework.data.neo4j.examples.movies.repo.CinemaRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestContext; -import org.springframework.test.context.TestExecutionListener; -import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@TestExecutionListeners(listeners = ProjectionTests.PrepareAndCleanDatabase.class, mergeMode = MERGE_WITH_DEFAULTS) -@RunWith(SpringRunner.class) -public class ProjectionTests { - - static class PrepareAndCleanDatabase implements TestExecutionListener { - public void beforeTestClass(TestContext testContext) { - - GraphDatabaseService graphDatabaseService = testContext.getApplicationContext().getBean(ServerControls.class) - .graph(); - - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - graphDatabaseService.execute("CREATE (p:Theatre {name:'Picturehouse', city:'London', capacity:5000}) " - + " CREATE (r:Theatre {name:'Ritzy', city:'London', capacity: 7500}) " + " CREATE (u:User {name:'Michal'}) " - + " CREATE (u)-[:VISITED]->(r) CREATE (u)-[:VISITED]->(p)" + " CREATE (m1:Movie {name:'San Andreas'}) " - + " CREATE (m2:Movie {name:'Pitch Perfect 2'})" + " CREATE (p)-[:BLOCKBUSTER]->(m1)" - + " CREATE (p)-[:SHOWS]->(m1)" + " CREATE (p)-[:SHOWS]->(m2)" + " CREATE (r)-[:BLOCKBUSTER]->(m2)" - + " CREATE (r)-[:SHOWS]->(m1)" + " CREATE (r)-[:SHOWS]->(m2)" + " CREATE (u)-[:RATED {stars :3}]->(m1)"); - } - - @Override - public void afterTestClass(TestContext testContext) { - GraphDatabaseService graphDatabaseService = testContext.getApplicationContext().getBean(ServerControls.class) - .graph(); - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - } - - @Autowired private CinemaRepository cinemaRepository; - - @Test - @Transactional - public void shouldFindCinemasWithoutRatings() { - - List theatres = cinemaRepository.findByNameLike("Picture*"); - - assertThat(theatres).hasSize(1); - CinemaAndBlockbuster cinema = theatres.get(0); - assertThat(cinema.getName()).isEqualTo("Picturehouse"); - assertThat(cinema.getLocation()).isEqualTo("London"); - assertThat(cinema.getBlockbusterOfTheWeek().getName()).isEqualTo("San Andreas"); - assertThat(cinema.getBlockbusterOfTheWeek().getRatings()).isEmpty(); - } - - @Test - @Transactional - public void shouldFindCinemasOrderByWithoutRatings() { - - List theatres = cinemaRepository.findByNameLike("*", Sort.by(Sort.Direction.ASC, "name")); - - assertThat(theatres).hasSize(2); - assertThat(theatres).extracting("name").containsExactly("Picturehouse", "Ritzy"); - CinemaAndBlockbuster cinema = theatres.get(0); - assertThat(cinema.getLocation()).isEqualTo("London"); - assertThat(cinema.getBlockbusterOfTheWeek().getName()).isEqualTo("San Andreas"); - assertThat(cinema.getBlockbusterOfTheWeek().getRatings()).isEmpty(); - - theatres = cinemaRepository.findByNameLike("*", Sort.by(Sort.Direction.DESC, "name")); - - assertThat(theatres).hasSize(2); - assertThat(theatres).extracting("name").containsExactly("Ritzy", "Picturehouse"); - } - - @Test - @Transactional - public void shouldFindCinemasWithoutUsersAndCustomDepth() { - - List cinemas = cinemaRepository.findByNameLike("Picture*", 0); - - assertThat(cinemas).hasSize(1); - CinemaAndBlockbuster cinema = cinemas.get(0); - assertThat(cinema.getName()).isEqualTo("Picturehouse"); - assertThat(cinema.getBlockbusterOfTheWeek()).isNull(); - } - - @Test - @Transactional - public void shouldFindCinemaWithOpenProjection() { - - List cinemas = cinemaRepository.findByNameStartingWith("P"); - - assertThat(cinemas).hasSize(1); - CinemaAndBlockbusterName c1 = cinemas.get(0); - assertThat(c1.getName()).isEqualTo("Picturehouse"); - assertThat(c1.blockBusterOfTheWeekName()).isEqualTo("San Andreas"); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryIntegrationTests.java deleted file mode 100644 index 94cbb8096..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryIntegrationTests.java +++ /dev/null @@ -1,729 +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.queries; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.time.Year; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.harness.ServerControls; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.neo4j.examples.movies.domain.Rating; -import org.springframework.data.neo4j.examples.movies.domain.TempMovie; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.EntityWrappingQueryResult; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.Gender; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.RichUserQueryResult; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.UserQueryResult; -import org.springframework.data.neo4j.examples.movies.domain.queryresult.UserQueryResultObject; -import org.springframework.data.neo4j.examples.movies.repo.UnmanagedUserPojo; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.data.Offset.offset; - -/** - * @author Vince Bickers - * @author Luanne Misquitta - * @author Mark Angrish - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@RunWith(SpringRunner.class) -public class QueryIntegrationTests { - - @Autowired private ServerControls neo4jTestServer; - - @Autowired private UserRepository userRepository; - - @Autowired private TransactionTemplate transactionTemplate; - - @Before - public void clearDatabase() { - neo4jTestServer.graph().execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - private void executeUpdate(String cypher) { - neo4jTestServer.graph().execute(cypher); - } - - @Test - public void shouldFindArbitraryGraph() { - executeUpdate("CREATE " + "(dh:Movie {name:'Die Hard'}), " + "(fe:Movie {name: 'The Fifth Element'}), " - + "(bw:User {name: 'Bruce Willis'}), " + "(ar:User {name: 'Alan Rickman'}), " - + "(mj:User {name: 'Milla Jovovich'}), " + "(mj)-[:ACTED_IN]->(fe), " + "(ar)-[:ACTED_IN]->(dh), " - + "(bw)-[:ACTED_IN]->(dh), " + "(bw)-[:ACTED_IN]->(fe)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List> graph = userRepository.getGraph(); - assertThat(graph).isNotNull(); - int i = 0; - for (Map properties : graph) { - i++; - assertThat(properties).isNotNull(); - } - assertThat(i).isEqualTo(2); - } - }); - } - - @Test - public void shouldFindScalarValues() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List ids = userRepository.getUserIds(); - assertThat(ids.size()).isEqualTo(2); - - List nodeIds = userRepository.getUserNodeIds(); - assertThat(nodeIds.size()).isEqualTo(2); - } - }); - } - - @Test - public void shouldFindUserByName() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByName("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameUsingSpElWithObject() { - executeUpdate("CREATE (m:User {name:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameUsingSpElWithObject(new User("Michal")); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameUsingSpElWithIndex() { - executeUpdate("CREATE (m:User {name:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameUsingSpElWithIndex("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameUsingSpElWithIndexColon() { - executeUpdate("CREATE (m:User {name:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameUsingSpElWithIndexColon("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByAgeUsingSpElWithGenericSpElExpression() { - executeUpdate("CREATE (m:User {age:10, name:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameUsingSpElWithSpElExpression(); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameAndMiddleNameUsingSpElWithObject() { - executeUpdate("CREATE (m:User {name:'Michal', middleName:'Hans'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User userForSearch = new User("Michal"); - userForSearch.setMiddleName("Hans"); - User user = userRepository.findUserByNameAndMiddleNameUsingSpElWithObject(userForSearch); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameUsingSpElWithValue() { - executeUpdate("CREATE (m:User {name:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameAndMiddleNameUsingSpElWithValue(); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameAndSurnameUsingSpElIndexAndPlaceholderWithOneParameter() { - executeUpdate("CREATE (m:User {name:'Michal', surname:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameAndSurnameUsingSpElIndexAndPlaceholderWithOneParameter("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameAndSurnameUsingSpElPropertyAndPlaceholderWithOneParameter() { - executeUpdate("CREATE (m:User {name:'Michal', surname:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameAndSurnameUsingSpElPropertyAndPlaceholderWithOneParameter("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameAndSurnameUsingSpElPropertyAndIndexWithOneParameter() { - executeUpdate("CREATE (m:User {name:'Michal', surname:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameAndSurnameUsingSpElPropertyAndIndexWithOneParameter("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameAndSurnameUsingSpElPropertyTwice() { - executeUpdate("CREATE (m:User {name:'Michal', surname:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameAndSurnameUsingSpElPropertyTwice("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameAndSurnameUsingSpElPropertyAndSpElIndex() { - executeUpdate("CREATE (m:User {name:'Michal', surname:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameAndSurnameUsingSpElPropertyAndSpElIndex("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUserByNameUsingNativeIndexAndNameAndSpElNameAndSpElIndex() { - executeUpdate("CREATE (m:User {name:'Michal'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameUsingNativeIndexAndNameAndSpElNameAndSpElIndex("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindTotalUsers() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - int users = userRepository.findTotalUsers(); - assertThat(2).isEqualTo(users); - } - }); - } - - @Test - public void shouldFindUsers() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Collection users = userRepository.getAllUsers(); - assertThat(2).isEqualTo(users.size()); - } - }); - } - - @Test - public void shouldFindUserByNameWithNamedParam() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameWithNamedParam("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test // DATAGRAPH-1135 - public void namedParameterShouldWorkWithouthAtParamsInAtQueryMethods() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User user = userRepository.findUserByNameWithNamedParamWithoutParamAnnotation("Michal"); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test - public void shouldFindUsersAsProperties() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Iterable> users = userRepository.getUsersAsProperties(); - assertThat(users).isNotNull(); - int i = 0; - for (Map properties : users) { - i++; - assertThat(properties).isNotNull(); - } - assertThat(i).isEqualTo(2); - } - }); - } - - @Test // DATAGRAPH-698, DATAGRAPH-861 - public void shouldFindUsersAndMapThemToConcreteQueryResultObjectCollection() { - executeUpdate( - "CREATE (g:User {name:'Gary', age:32}), (s:User {name:'Sheila', age:29}), (v:User {name:'Vince', age:66})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - assertThat(userRepository.findTotalUsers()) - .as("There should be some users in the database").isEqualTo(3); - - Iterable expected = Arrays.asList(new UserQueryResult("Sheila", 29), - new UserQueryResult("Gary", 32), new UserQueryResult("Vince", 66)); - - Iterable queryResult = userRepository.retrieveAllUsersAndTheirAges(); - assertThat(queryResult).as("The query result shouldn't be null") - .isNotNull(); - assertThat(queryResult).isEqualTo(expected); - for (UserQueryResult userQueryResult : queryResult) { - assertThat(userQueryResult.getUserId()).isNotNull(); - assertThat(userQueryResult.getId()).isNotNull(); - } - } - }); - } - - /** - * This limitation about not handling unmanaged types may be addressed after M2 if there's demand for it. - */ - @Test(expected = InvalidDataAccessApiUsageException.class) - public void shouldThrowMappingExceptionIfQueryResultTypeIsNotManagedInMappingMetadata() { - executeUpdate("CREATE (:User {name:'Colin'}), (:User {name:'Jeff'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - // NB: UnmanagedUserPojo is not scanned with the other domain classes - UnmanagedUserPojo queryResult = userRepository.findIndividualUserAsDifferentObject("Jeff"); - assertThat(queryResult).as("The query result shouldn't be null") - .isNotNull(); - assertThat(queryResult.getName()).isEqualTo("Jeff"); - } - }); - } - - @Test - public void shouldFindUsersAndMapThemToProxiedQueryResultInterface() { - executeUpdate( - "CREATE (:User {name:'Morne', age:30}), (:User {name:'Abraham', age:31}), (:User {name:'Virat', age:27})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - UserQueryResultObject result = userRepository.findIndividualUserAsProxiedObject("Abraham"); - assertThat(result).as("The query result shouldn't be null").isNotNull(); - assertThat(result.getName()).as("The wrong user was returned") - .isEqualTo("Abraham"); - assertThat(result.getAgeOfUser()).as("The wrong user was returned") - .isEqualTo(31); - } - }); - } - - @Test - public void shouldRetrieveUsersByGenderAndConvertToCorrectTypes() { - executeUpdate( - "CREATE (:User {name:'David Warner', gender:'MALE'}), (:User {name:'Shikhar Dhawan', gender:'MALE'}), " - + "(:User {name:'Sarah Taylor', gender:'FEMALE', account: '3456789', yearOfBirth: 1979, deposits:['12345.6','45678.9']})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Iterable usersByGender = userRepository.findUsersByGender(Gender.FEMALE); - assertThat(usersByGender).as("The resultant users list shouldn't be null") - .isNotNull(); - - Iterator userIterator = usersByGender.iterator(); - assertThat(userIterator.hasNext()).isTrue(); - RichUserQueryResult userQueryResult = userIterator.next(); - assertThat(userQueryResult.getUserGender()).isEqualTo(Gender.FEMALE); - assertThat(userQueryResult.getUserName()).isEqualTo("Sarah Taylor"); - assertThat(userQueryResult.getYearOfBirth()).isEqualTo(Year.of(1979)); - assertThat(userQueryResult.getUserAccount()) - .isEqualTo(BigInteger.valueOf(3456789)); - assertThat(userQueryResult.getUserDeposits()) - .isEqualTo(new BigDecimal[] {BigDecimal.valueOf(12345.6), BigDecimal.valueOf(45678.9)}); - assertThat(userIterator.hasNext()).isFalse(); - } - }); - } - - @Test // DATAGRAPH-694 - public void shouldSubstituteUserId() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User michal = userRepository.findUserByName("Michal"); - assertThat(michal).isNotNull(); - User user = userRepository.loadUserById(michal); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test // DATAGRAPH-694 - public void shouldSubstituteNamedParamUserId() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - User michal = userRepository.findUserByName("Michal"); - assertThat(michal).isNotNull(); - User user = userRepository.loadUserByNamedId(michal); - assertThat(user.getName()).isEqualTo("Michal"); - } - }); - } - - @Test // DATAGRAPH-727 - public void shouldFindIterableUsers() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Iterable users = userRepository.getAllUsersIterable(); - int count = 0; - for (User user : users) { - count++; - } - assertThat(count).isEqualTo(2); - } - }); - } - - @Test // DATAGRAPH-772 - public void shouldAllowNullParameters() { - executeUpdate("CREATE (m:User {name:'Michal'})<-[:FRIEND_OF]-(a:User {name:'Adam'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - userRepository.setNamesNull(null); - Iterable users = userRepository.findAll(); - for (User u : users) { - assertThat(u.getName()).isNull(); - } - } - }); - } - - @Test // DATAGRAPH-772 - public void shouldMapNullsToQueryResults() { - executeUpdate("CREATE (g:User), (s:User)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - assertThat(userRepository.findTotalUsers()) - .as("There should be some users in the database").isEqualTo(2); - - Iterable expected = Arrays.asList(new UserQueryResult(null, 0), new UserQueryResult(null, 0)); - - Iterable queryResult = userRepository.retrieveAllUsersAndTheirAges(); - assertThat(queryResult).as("The query result shouldn't be null") - .isNotNull(); - assertThat(queryResult).isEqualTo(expected); - for (UserQueryResult userQueryResult : queryResult) { - assertThat(userQueryResult.getUserId()).isNotNull(); - } - } - }); - } - - @Test // DATAGRAPH-700 - public void shouldMapNodeEntitiesIntoQueryResultObjects() { - executeUpdate("CREATE (:User {name:'Abraham'}), (:User {name:'Barry'}), (:User {name:'Colin'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - EntityWrappingQueryResult wrappedUser = userRepository.findWrappedUserByName("Barry"); - assertThat(wrappedUser).as("The loaded wrapper object shouldn't be null") - .isNotNull(); - assertThat(wrappedUser.getUser()) - .as("The enclosed user shouldn't be null").isNotNull(); - assertThat(wrappedUser.getUser().getName()).isEqualTo("Barry"); - } - }); - } - - @Test // DATAGRAPH-700 - public void shouldMapNodeCollectionsIntoQueryResultObjects() { - executeUpdate( - "CREATE (d:User {name:'Daniela'}), (e:User {name:'Ethan'}), (f:User {name:'Finn'}), (d)-[:FRIEND_OF]->(e), (d)-[:FRIEND_OF]->(f)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - EntityWrappingQueryResult result = userRepository.findWrappedUserAndFriendsDepth1("Daniela"); - assertThat(result).as("The result shouldn't be null").isNotNull(); - assertThat(result.getUser()).as("The enclosed user shouldn't be null") - .isNotNull(); - assertThat(result.getUser().getName()).isEqualTo("Daniela"); - assertThat(result.getFriends().size()).isEqualTo(2); - List friends = new ArrayList<>(); - for (User u : result.getFriends()) { - friends.add(u.getName()); - } - assertThat(friends.contains("Ethan")).isTrue(); - assertThat(friends.contains("Finn")).isTrue(); - // we expect friends to be mapped since the relationships were returned - assertThat(result.getUser().getFriends().size()).isEqualTo(2); - } - }); - } - - @Test // DATAGRAPH-700 - public void shouldMapRECollectionsIntoQueryResultObjects() { - executeUpdate( - "CREATE (g:User {name:'Gary'}), (sw:Movie {name: 'Star Wars: The Force Awakens'}), (hob:Movie {name:'The Hobbit: An Unexpected Journey'}), (g)-[:RATED {stars : 5}]->(sw), (g)-[:RATED {stars: 4}]->(hob) "); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - EntityWrappingQueryResult result = userRepository.findWrappedUserAndRatingsByName("Gary"); - assertThat(result).as("The loaded wrapper object shouldn't be null") - .isNotNull(); - assertThat(result.getUser()).as("The enclosed user shouldn't be null") - .isNotNull(); - assertThat(result.getUser().getName()).isEqualTo("Gary"); - assertThat(result.getRatings().size()).isEqualTo(2); - for (Rating rating : result.getRatings()) { - if (rating.getStars() == 4) { - assertThat(rating.getMovie().getName()) - .isEqualTo("The Hobbit: An Unexpected Journey"); - } else { - assertThat(rating.getMovie().getName()) - .isEqualTo("Star Wars: The Force Awakens"); - } - } - - assertThat(result.getAvgRating()).isCloseTo(4.5f, offset(0f)); - assertThat(result.getMovies().length).isEqualTo(2); - List titles = new ArrayList<>(); - for (TempMovie movie : result.getMovies()) { - titles.add(movie.getName()); - } - assertThat(titles.contains("The Hobbit: An Unexpected Journey")).isTrue(); - assertThat(titles.contains("Star Wars: The Force Awakens")).isTrue(); - } - }); - } - - @Test // DATAGRAPH-700 - public void shouldMapRelationshipCollectionsWithDepth0IntoQueryResultObjects() { - executeUpdate( - "CREATE (i:User {name:'Ingrid'}), (j:User {name:'Jake'}), (k:User {name:'Kate'}), (i)-[:FRIEND_OF]->(j), (i)-[:FRIEND_OF]->(k)"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - EntityWrappingQueryResult result = userRepository.findWrappedUserAndFriendsDepth0("Ingrid"); - assertThat(result).as("The result shouldn't be null").isNotNull(); - assertThat(result.getUser()).as("The enclosed user shouldn't be null") - .isNotNull(); - assertThat(result.getUser().getName()).isEqualTo("Ingrid"); - assertThat(result.getFriends().size()).isEqualTo(2); - List friends = new ArrayList<>(); - for (User u : result.getFriends()) { - friends.add(u.getName()); - } - assertThat(friends.contains("Kate")).isTrue(); - assertThat(friends.contains("Jake")).isTrue(); - // we do not expect friends to be mapped since the relationships were not returned - assertThat(result.getUser().getFriends().size()).isEqualTo(0); - } - }); - } - - @Test // DATAGRAPH-700 - public void shouldReturnMultipleQueryResultObjects() { - executeUpdate( - "CREATE (g:User {name:'Gary'}), (h:User {name:'Harry'}), (sw:Movie {name: 'Star Wars: The Force Awakens'}), (hob:Movie {name:'The Hobbit: An Unexpected Journey'}), (g)-[:RATED {stars : 5}]->(sw), (g)-[:RATED {stars: 4}]->(hob), (h)-[:RATED {stars: 3}]->(hob) "); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - List results = userRepository.findAllUserRatings(); - assertThat(results.size()).isEqualTo(2); - EntityWrappingQueryResult result = results.get(0); - - assertThat(result).as("The loaded wrapper object shouldn't be null") - .isNotNull(); - assertThat(result.getUser()).as("The enclosed user shouldn't be null") - .isNotNull(); - assertThat(result.getUser().getName()).isEqualTo("Harry"); - assertThat(result.getRatings().size()).isEqualTo(1); - Rating rating = result.getRatings().get(0); - assertThat(rating.getMovie().getName()) - .isEqualTo("The Hobbit: An Unexpected Journey"); - assertThat(rating.getStars()).isEqualTo(3); - assertThat(result.getAvgRating()).isCloseTo(3f, offset(0f)); - assertThat(result.getMovies().length).isEqualTo(1); - assertThat(result.getMovies()[0].getName()) - .isEqualTo("The Hobbit: An Unexpected Journey"); - - result = results.get(1); - assertThat(result).as("The loaded wrapper object shouldn't be null") - .isNotNull(); - assertThat(result.getUser()).as("The enclosed user shouldn't be null") - .isNotNull(); - assertThat(result.getUser().getName()).isEqualTo("Gary"); - for (Rating r : result.getRatings()) { - if (r.getStars() == 4) { - assertThat(r.getMovie().getName()) - .isEqualTo("The Hobbit: An Unexpected Journey"); - } else { - assertThat(r.getMovie().getName()) - .isEqualTo("Star Wars: The Force Awakens"); - } - } - - assertThat(result.getAvgRating()).isCloseTo(4.5f, offset(0f)); - assertThat(result.getMovies().length).isEqualTo(2); - List titles = new ArrayList<>(); - for (TempMovie movie : result.getMovies()) { - titles.add(movie.getName()); - } - assertThat(titles.contains("The Hobbit: An Unexpected Journey")).isTrue(); - assertThat(titles.contains("Star Wars: The Force Awakens")).isTrue(); - } - }); - } - - @Test // DATAGRAPH-700 - public void shouldMapEntitiesToProxiedQueryResultInterface() { - executeUpdate( - "CREATE (:User {name:'Morne', age:30}), (:User {name:'Abraham', age:31}), (:User {name:'Virat', age:27})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - UserQueryResultObject result = userRepository.findWrappedUserAsProxiedObject("Abraham"); - assertThat(result).as("The query result shouldn't be null").isNotNull(); - assertThat(result.getUser()).as("The mapped user shouldn't be null") - .isNotNull(); - assertThat(result.getUser().getName()).as("The wrong user was returned") - .isEqualTo("Abraham"); - assertThat(result.getAgeOfUser()).as("The wrong user was returned") - .isEqualTo(31); - } - }); - } - - @Test // DATAGRAPH-860 - public void shouldMapEmptyNullCollectionsToQueryResultInterface() { - executeUpdate("CREATE (g:User {name:'Gary'})"); - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - EntityWrappingQueryResult result = userRepository.findAllRatingsNull(); - assertThat(result).isNotNull(); - assertThat(result.getAllRatings().size()).isEqualTo(0); - } - }); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryResultIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryResultIntegrationTests.java deleted file mode 100644 index e0dc6164e..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryResultIntegrationTests.java +++ /dev/null @@ -1,82 +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.queries; - -import static org.assertj.core.api.Assertions.*; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Transaction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.queries.ogmgh551.AnotherThing; -import org.springframework.data.neo4j.queries.ogmgh551.ThingRepository; -import org.springframework.data.neo4j.queries.ogmgh551.ThingResult; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -/** - * Those tests might have also fitted in {@link QueryReturnTypesTests} and {@link QueryIntegrationTests}, but those use - * a very example like domain model, so we rather use a generic issue model here. - * - * @author Michael J. Simons - */ -@ContextConfiguration(classes = { QueryResultIntegrationTests.ContextConfig.class }) -@RunWith(SpringRunner.class) -@Transactional -public class QueryResultIntegrationTests { - - @Autowired - private GraphDatabaseService graphDatabaseService; - - @Autowired - private ThingRepository thingRepository; - - @Before - public void prepareTestDa() { - - try (Transaction tx = graphDatabaseService.beginTx()) { - graphDatabaseService - .execute("unwind range(1,10) as x with x create (n:ThingEntity {name: 'Thing ' + x}) return n"); - tx.success(); - } - } - - @Test - public void queryResultsShouldWorkWithNestedObjectsFromMap() { - - List thingResults = this.thingRepository.findResults(); - assertThat(thingResults).hasSize(1); - - ThingResult thingResult = thingResults.get(0); - assertThat(thingResult.getSomething()).isEqualTo("das ist ein Test"); - assertThat(thingResult.getThings()) - .hasSize(10) - .extracting(AnotherThing::getName) - .allSatisfy(s -> s.startsWith("Thing")); - } - - @Configuration - @Neo4jIntegrationTest(repositoryPackages = "org.springframework.data.neo4j.queries.ogmgh551", domainPackages = "org.springframework.data.neo4j.queries.ogmgh551") - static class ContextConfig { - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryReturnTypesTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryReturnTypesTests.java deleted file mode 100644 index 0529d92d6..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/QueryReturnTypesTests.java +++ /dev/null @@ -1,120 +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.queries; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.ogm.model.QueryStatistics; -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.examples.galaxy.GalaxyContextConfiguration; -import org.springframework.data.neo4j.examples.galaxy.domain.World; -import org.springframework.data.neo4j.examples.galaxy.repo.WorldRepository; -import org.springframework.data.neo4j.queries.ogmgh552.Thing; -import org.springframework.data.neo4j.queries.ogmgh552.ThingRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; - -/** - * @author Vince Bickers - * @author Luanne Misquitta - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - * @author Michael J. Simons - */ -@ContextConfiguration(classes = GalaxyContextConfiguration.class) -@RunWith(SpringRunner.class) -@Transactional -public class QueryReturnTypesTests { - - @Autowired GraphDatabaseService graphDatabaseService; - - @Autowired TransactionTemplate transactionTemplate; - - @Autowired WorldRepository worldRepository; - - @Autowired Session session; - - @Autowired ThingRepository thingRepository; - - @Before - public void clearDatabase() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Test - public void shouldCallExecuteWhenPrimitiveVoidReturnTypeOnQuery() { - - World world = new World("Tatooine", 0); - - worldRepository.save(world); - worldRepository.touchAllWorlds(); - - session.clear(); - world = worldRepository.findById(world.getId()).get(); - assertThat(world.getUpdated()).isNotNull(); - } - - @Test - public void queryResultsAndEntitiesMappedToTheSameSimpleTypeShouldNotBeMixedUp() { - - List result = this.thingRepository.findAllTheThings(); - assertThat(result).hasSize(1).extracting(Thing::getNotAName).containsExactly("NOT A NAME!!!"); - } - - @Test // DATAGRAPH-704 - public void shouldCallExecuteWhenVoidReturnTypeOnQuery() { - - World tatooine = new World("Tatooine", 0); - World dagobah = new World("Dagobah", 0); - - tatooine.addRocketRouteTo(dagobah); - - worldRepository.save(tatooine); - worldRepository.touchAllWorlds(); - - session.clear(); - tatooine = worldRepository.findById(tatooine.getId()).get(); - - assertThat(tatooine.getUpdated()).isNotNull(); - assertThat(tatooine.getReachableByRocket().size()).isEqualTo(1); - - for (World world : tatooine.getReachableByRocket()) { - assertThat(world.getUpdated()).isNotNull(); - } - } - - @Test - public void shouldReturnStatisticsIfRequested() { - - World tatooine = new World("Tatooine", 0); - - worldRepository.save(tatooine); - - QueryStatistics stats = worldRepository.touchAllWorldsWithStatistics().queryStatistics(); - - assertThat(stats.getPropertiesSet()).isEqualTo(1); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/StoredProceduresTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/StoredProceduresTests.java deleted file mode 100644 index 4607aecad..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/StoredProceduresTests.java +++ /dev/null @@ -1,120 +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.queries; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.ThreadLocalRandom; -import java.util.stream.Stream; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.driver.Config; -import org.neo4j.driver.GraphDatabase; -import org.neo4j.harness.ServerControls; -import org.neo4j.harness.TestServerBuilders; -import org.neo4j.ogm.drivers.bolt.driver.BoltDriver; -import org.neo4j.ogm.session.SessionFactory; -import org.neo4j.procedure.Mode; -import org.neo4j.procedure.Name; -import org.neo4j.procedure.Procedure; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.queries.stored_procedures.DocumentEntity; -import org.springframework.data.neo4j.queries.stored_procedures.DocumentRepository; -import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author Michael J. Simons - */ -@ContextConfiguration(classes = { StoredProceduresTests.ContextConfig.class }) -@RunWith(SpringRunner.class) -public class StoredProceduresTests { - - private static final Config driverConfig = Config.builder().withoutEncryption().build(); - - private static ServerControls serverControls; - private static URI boltURI; - - @BeforeClass - public static void initializeNeo4j() { - - serverControls = TestServerBuilders.newInProcessBuilder().withProcedure(ApocLovesSwitch.class).newServer(); - boltURI = serverControls.boltURI(); - } - - @Autowired private DocumentRepository documentRepository; - - @Test // DATAGRAPH-1134 - public void atQueryMethodShouldIgnoreResultsOfStoredProceduresWhenMappedToNull() { - documentRepository.callApocProcedureAndIgnoreResult(); - } - - @AfterClass - public static void tearDownNeo4j() { - serverControls.close(); - } - - public static class ApocLovesSwitch { - @Procedure(name = "apoc.periodic.iterate", mode = Mode.WRITE) - public Stream iterate(@Name("cypherIterate") String cypherIterate, - @Name("cypherAction") String cypherAction, @Name("config") Map config) { - return Stream.of(new BatchAndTotalResult()); - } - } - - public static class BatchAndTotalResult { - public final long batches; - public final long total; - public final long timeTaken; - - public BatchAndTotalResult() { - - ThreadLocalRandom random = ThreadLocalRandom.current(); - this.batches = random.nextLong(); - this.total = random.nextLong(); - this.timeTaken = random.nextLong(); - } - } - - @Configuration - @ComponentScan(basePackageClasses = DocumentEntity.class) - @EnableNeo4jRepositories(basePackageClasses = DocumentRepository.class) - @EnableTransactionManagement - static class ContextConfig { - - @Bean - public PlatformTransactionManager transactionManager() { - return new Neo4jTransactionManager(sessionFactory()); - } - - @Bean - public SessionFactory sessionFactory() { - - return new SessionFactory(new BoltDriver(GraphDatabase.driver(boltURI, driverConfig)), - DocumentEntity.class.getName()); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/AnotherThing.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/AnotherThing.java deleted file mode 100644 index 7826043dc..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/AnotherThing.java +++ /dev/null @@ -1,32 +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.queries.ogmgh551; - -/** - * @author Michael J. Simons - */ -public class AnotherThing { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingEntity.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingEntity.java deleted file mode 100644 index ec35a0c94..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingEntity.java +++ /dev/null @@ -1,52 +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.queries.ogmgh551; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * @author Michael J. Simons - */ -@NodeEntity -public class ThingEntity { - @Id @GeneratedValue - private Long id; - - private String name; - - public ThingEntity(String name) { - this.name = name; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} - diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingRepository.java deleted file mode 100644 index e14663887..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingRepository.java +++ /dev/null @@ -1,29 +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.queries.ogmgh551; - -import java.util.List; - -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Michael J. Simons - */ -public interface ThingRepository extends Neo4jRepository { - @Query("MATCH (t:ThingEntity) RETURN 'das ist ein Test' as something, collect({name: t.name}) as things") - List findResults(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingResult.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingResult.java deleted file mode 100644 index 222fed38a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh551/ThingResult.java +++ /dev/null @@ -1,38 +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.queries.ogmgh551; - -import java.util.List; - -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * @author Michael J. Simons - */ -@QueryResult -public class ThingResult { - private String something; - - public String getSomething() { - return something; - } - - private List things; - - public List getThings() { - return things; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/Thing.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/Thing.java deleted file mode 100644 index 42ff69d23..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/Thing.java +++ /dev/null @@ -1,30 +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.queries.ogmgh552; - -import org.springframework.data.neo4j.annotation.QueryResult; - -/** - * @author Michael J. Simons - */ -@QueryResult -public class Thing { - private String notAName; - - public String getNotAName() { - return notAName; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/ThingEntity.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/ThingEntity.java deleted file mode 100644 index 9a58d014a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/ThingEntity.java +++ /dev/null @@ -1,32 +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.queries.ogmgh552; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * @author Michael J. Simons - */ -@NodeEntity("Thing") -public class ThingEntity { - @Id @GeneratedValue - private Long id; - - private String name; -} - diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/ThingRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/ThingRepository.java deleted file mode 100644 index 51851b054..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/ogmgh552/ThingRepository.java +++ /dev/null @@ -1,30 +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.queries.ogmgh552; - -import java.util.List; - -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Michael J. Simons - */ -public interface ThingRepository extends Neo4jRepository { - - @Query("return 'NOT A NAME!!!' as notAName") - List findAllTheThings(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/stored_procedures/DocumentRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/stored_procedures/DocumentRepository.java deleted file mode 100644 index f8dbd61e1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/stored_procedures/DocumentRepository.java +++ /dev/null @@ -1,29 +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.queries.stored_procedures; - -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Michael J. Simons - */ -public interface DocumentRepository extends Neo4jRepository { - @Query("CALL apoc.periodic.iterate('MATCH (d:Document) RETURN d', " - + "'SET d.thisIsAProperty = 0'" - + ", {batchSize:200, parallel:false, iterateList:true}) ") - public void callApocProcedureAndIgnoreResult(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/ProgrammaticRepositoryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/ProgrammaticRepositoryTests.java deleted file mode 100644 index c63b1e9ad..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/ProgrammaticRepositoryTests.java +++ /dev/null @@ -1,214 +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.repositories; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.neo4j.test.GraphDatabaseServiceAssert.assertThat; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.StreamSupport; - -import org.assertj.core.api.Assertions; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.neo4j.harness.ServerControls; -import org.neo4j.harness.TestServerBuilders; -import org.neo4j.ogm.config.Configuration; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.data.neo4j.repositories.domain.Movie; -import org.springframework.data.neo4j.repositories.domain.User; -import org.springframework.data.neo4j.repositories.repo.MovieRepository; -import org.springframework.data.neo4j.repositories.repo.UserRepository; -import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactory; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.data.repository.core.support.RepositoryFactorySupport; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * @author Michal Bachman - * @author Luanne Misquitta - * @author Mark Angrish - * @author Vince Bickers - * @author Michael J. Simons - */ -public class ProgrammaticRepositoryTests { - - private static ServerControls serverControls; - private static SessionFactory sessionFactory; - private static TransactionTemplate transactionTemplate; - - private MovieRepository movieRepository; - private Session session; - - @BeforeClass - public static void oneTimeSetUp() { - serverControls = TestServerBuilders.newInProcessBuilder().newServer(); - - Configuration configuration = new Configuration.Builder() // - .uri(serverControls.boltURI().toString()) // - .build(); - sessionFactory = new SessionFactory(configuration, "org.springframework.data.neo4j.repositories.domain"); - - PlatformTransactionManager platformTransactionManager = new Neo4jTransactionManager(sessionFactory); - transactionTemplate = new TransactionTemplate(platformTransactionManager); - } - - @AfterClass - public static void shutdownTestServer() { - - if (sessionFactory != null) { - sessionFactory.close(); - sessionFactory = null; - } - - if (serverControls != null) { - serverControls.close(); - serverControls = null; - } - } - - @Before - public void init() { - session = sessionFactory.openSession(); - session.purgeDatabase(); - } - - @Test - public void canInstantiateRepositoryProgrammatically() { - - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - RepositoryFactorySupport factory = new Neo4jRepositoryFactory(session); - - movieRepository = factory.getRepository(MovieRepository.class); - - Movie movie = new Movie("PF"); - movieRepository.save(movie); - } - }); - - Map params = new HashMap<>(); - params.put("title", "PF"); - assertThat(serverControls.graph()).containsNode("MATCH (n:Movie) WHERE n.title = $title RETURN n", params); - - assertThat(StreamSupport.stream(movieRepository.findAll().spliterator(), false) - .count()).isEqualTo(1); - } - - @Test // DATAGRAPH-847 - public void shouldBeAbleToDeleteAllViaRepository() { - - RepositoryFactorySupport factory = new Neo4jRepositoryFactory(session); - - UserRepository userRepository = factory.getRepository(UserRepository.class); - - User userA = new User("A"); - User userB = new User("B"); - userRepository.save(userA); - userRepository.save(userB); - - assertThat(userRepository.count()).isEqualTo(2); - - userRepository.deleteAll(); - assertThat(userRepository.count()).isEqualTo(0); - } - - @Test // DATAGRAPH-813 - public void shouldDeleteUserByNameAndReturnCountOfDeletedUsers() { - - RepositoryFactorySupport factory = new Neo4jRepositoryFactory(session); - - UserRepository userRepository = factory.getRepository(UserRepository.class); - - User userA = new User("A"); - userA.setName("A"); - - userRepository.save(userA); - assertThat(userRepository.count()).isEqualTo(1); - - assertThat(userRepository.deleteByName("A")).isEqualTo(new Long(1)); - assertThat(userRepository.count()).isEqualTo(0); - } - - @Test // DATAGRAPH-813 - public void shouldDeleteUserByNameAndReturnListOfDeletedUserIds() { - - RepositoryFactorySupport factory = new Neo4jRepositoryFactory(session); - - UserRepository userRepository = factory.getRepository(UserRepository.class); - - User userA = new User("A"); - User userAClone = new User("A"); - - userRepository.save(userA); - userRepository.save(userAClone); - - assertThat(userRepository.count()).isEqualTo(2); - - List deletedUserIds = userRepository.removeByName("A"); - assertThat(deletedUserIds.size()).isEqualTo(2); - - Assertions.assertThat(deletedUserIds).containsExactlyInAnyOrder(userA.getId(), userAClone.getId()); - - assertThat(userRepository.count()).isEqualTo(0); - } - - @Test - public void shouldBeAbleToDeleteUserWithRelationships() { - - RepositoryFactorySupport factory = new Neo4jRepositoryFactory(session); - - UserRepository userRepository = factory.getRepository(UserRepository.class); - - User userA = new User("A"); - User userB = new User("B"); - - userA.getFriends().add(userB); - userB.getFriends().add(userA); - - userRepository.save(userA); - - assertThat(userRepository.count()).isEqualTo(2); - - userRepository.deleteByName("A"); - - assertThat(userRepository.count()).isEqualTo(1); - } - - @Test // DATAGRAPH-813 - public void shouldCountUserByName() { - - RepositoryFactorySupport factory = new Neo4jRepositoryFactory(session); - - UserRepository userRepository = factory.getRepository(UserRepository.class); - - User userA = new User("A"); - userA.setName("A"); - - userRepository.save(userA); - - assertThat(userRepository.countByName("A")).isEqualTo(new Long(1)); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/RepoScanningTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/RepoScanningTests.java deleted file mode 100644 index afb280d64..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/RepoScanningTests.java +++ /dev/null @@ -1,71 +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.repositories; - -import static org.springframework.data.neo4j.test.GraphDatabaseServiceAssert.*; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.repositories.domain.User; -import org.springframework.data.neo4j.repositories.repo.UserRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Michal Bachman - * @author Mark Angrish - * @author Michael J. Simons - */ -@ContextConfiguration(classes = RepoScanningTests.PersistenceContextInTheSamePackage.class) -@RunWith(SpringRunner.class) -public class RepoScanningTests { - - @Autowired private GraphDatabaseService graphDatabaseService; - - @Autowired private UserRepository userRepository; - - @Before - public void clearDatabase() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Test - public void enableNeo4jRepositoriesShouldScanSelfPackageByDefault() { - - User user = new User("Michal"); - userRepository.save(user); - - Map params = new HashMap<>(); - params.put("name", user.getName()); - - assertThat(graphDatabaseService) - .containsNode("MATCH (n:User {name: $name}) RETURN n", params) - .withId(user.getId()); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.repositories.domain") - static class PersistenceContextInTheSamePackage {} - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/RepositoryDefinitionTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/RepositoryDefinitionTests.java deleted file mode 100644 index 27b1c5b2d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/RepositoryDefinitionTests.java +++ /dev/null @@ -1,87 +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.repositories; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.data.neo4j.test.GraphDatabaseServiceAssert.*; - -import java.util.HashMap; -import java.util.Map; -import java.util.stream.StreamSupport; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.repositories.domain.Movie; -import org.springframework.data.neo4j.repositories.repo.MovieRepository; -import org.springframework.data.neo4j.test.GraphDatabaseServiceAssert; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionCallbackWithoutResult; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * @author Michal Bachman - * @author Mark Angrish - * @author Michael J. Simons - */ -@ContextConfiguration(classes = RepositoryDefinitionTests.RepositoriesTestContext.class) -@RunWith(SpringRunner.class) -public class RepositoryDefinitionTests { - - @Autowired private GraphDatabaseService graphDatabaseService; - - @Autowired private TransactionTemplate transactionTemplate; - - @Autowired private MovieRepository movieRepository; - - @Before - public void clearDatabase() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Test - public void shouldProxyAndAutoImplementRepositoryDefinitionAnnotatedRepo() { - transactionTemplate.execute(new TransactionCallbackWithoutResult() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - Movie movie = new Movie("PF"); - movieRepository.save(movie); - - assertThat(StreamSupport - .stream(movieRepository.findAll().spliterator(), false).count()) - .isEqualTo(1); - } - }); - - Map params = new HashMap<>(); - params.put("title", "PF"); - GraphDatabaseServiceAssert.assertThat(graphDatabaseService) - .containsNode("MATCH (n:Movie) WHERE n.title = $title RETURN n", params); - - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.repositories.domain", - repositoryPackages = "org.springframework.data.neo4j.repositories.repo") - static class RepositoriesTestContext {} - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/domain/Movie.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/domain/Movie.java deleted file mode 100644 index eb55d281c..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/domain/Movie.java +++ /dev/null @@ -1,35 +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.repositories.domain; - -/** - * @author Michal Bachman - */ -public class Movie { - - private Long id; - private String title; - - public Movie() {} - - public Movie(String title) { - this.title = title; - } - - public String getTitle() { - return title; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/domain/User.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/domain/User.java deleted file mode 100644 index 894fe5eec..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/domain/User.java +++ /dev/null @@ -1,58 +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.repositories.domain; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Michal Bachman - * @author Vince Bickers - */ -public class User { - - private Long id; - private String name; - - private List friends = new ArrayList<>(); - - public User() {} - - public Long getId() { - return this.id; - } - - public User(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getFriends() { - return friends; - } - - public void setFriends(List friends) { - this.friends = friends; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/repo/MovieRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/repo/MovieRepository.java deleted file mode 100644 index 5423133ca..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/repo/MovieRepository.java +++ /dev/null @@ -1,30 +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.repositories.repo; - -import org.springframework.data.neo4j.repositories.domain.Movie; -import org.springframework.data.repository.RepositoryDefinition; - -/** - * @author Michal Bachman - */ -@RepositoryDefinition(domainClass = Movie.class, idClass = Long.class) -public interface MovieRepository { - - S save(S entity); - - Iterable findAll(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/repo/UserRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/repo/UserRepository.java deleted file mode 100644 index 2830ff35f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/repo/UserRepository.java +++ /dev/null @@ -1,46 +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.repositories.repo; - -import java.util.List; - -import org.springframework.data.neo4j.repositories.domain.User; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - * @author Vince Bickers - */ -@Repository -public interface UserRepository extends Neo4jRepository { - - /* - * @see DATAGRAPH-813 - */ - Long deleteByName(String name); // return a count of deleted objects by name - - /* - * @see DATAGRAPH-813 - */ - List removeByName(String name); // remove users by name and return an iterable of the removed users' ids - - /* - * @see DATAGRAPH-813 - */ - Long countByName(String name); // return a count of objects with name - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/support/GraphRepositoryFactoryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/support/GraphRepositoryFactoryTests.java deleted file mode 100644 index 184aa3c2d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repositories/support/GraphRepositoryFactoryTests.java +++ /dev/null @@ -1,97 +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.repositories.support; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -import java.io.Serializable; -import java.util.Optional; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.neo4j.ogm.session.Session; -import org.springframework.aop.framework.Advised; -import org.springframework.data.neo4j.mapping.MetaDataProvider; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactory; -import org.springframework.data.neo4j.repository.support.SimpleNeo4jRepository; -import org.springframework.transaction.annotation.Transactional; - -/** - * Unit tests for {@code GraphRepositoryFactory}. - * - * @author Vince Bickers - * @author Luanne Misquitta - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - * @author Michael J. Simons - */ -public class GraphRepositoryFactoryTests { - - Neo4jRepositoryFactory factory; - - @Before - public void setUp() { - - Session session = mock(Session.class, withSettings().extraInterfaces(MetaDataProvider.class)); - factory = new Neo4jRepositoryFactory(session, null); - } - - /** - * Assert that the instance created for the standard configuration is a valid {@code UserRepository}. - * - * @throws Exception - */ - @Test - public void setsUpBasicInstanceCorrectly() throws Exception { - assertThat(factory.getRepository(ObjectRepository.class)).isNotNull(); - } - - @Test - public void allowsCallingOfObjectMethods() { - - ObjectRepository repository = factory.getRepository(ObjectRepository.class); - - repository.hashCode(); - repository.toString(); - repository.equals(repository); - } - - @Test - public void usesConfiguredRepositoryBaseClass() { - factory.setRepositoryBaseClass(CustomNeo4jRepository.class); - ObjectRepository repository = factory.getRepository(ObjectRepository.class); - assertThat(((Advised) repository).getTargetClass()) - .isEqualTo(CustomNeo4jRepository.class); - } - - private interface ObjectRepository extends Neo4jRepository { - - @Override - @Transactional - Optional findById(Long id); - } - - static class CustomNeo4jRepository extends SimpleNeo4jRepository { - - public CustomNeo4jRepository(Class clazz, Session session) { - super(clazz, session); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/Contact.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/Contact.java deleted file mode 100644 index 95e65fc43..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/Contact.java +++ /dev/null @@ -1,46 +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.repository; - -import java.util.UUID; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.Index; -import org.neo4j.ogm.annotation.NodeEntity; - -/** - * Created by markangrish on 24/03/2017. - */ -@NodeEntity -public abstract class Contact { - - @Id @GeneratedValue protected Long id; - - @Index(unique = true) private String uuid; - - public Contact() { - this.uuid = UUID.randomUUID().toString(); - } - - public Long getId() { - return id; - } - - public String getUuid() { - return uuid; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/ContactRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/ContactRepository.java deleted file mode 100644 index 64ba383a1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/ContactRepository.java +++ /dev/null @@ -1,23 +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.repository; - -/** - * Created by markangrish on 24/03/2017. - */ -public interface ContactRepository extends Neo4jRepository { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/MultipleSessionFactorySupportTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/MultipleSessionFactorySupportTests.java deleted file mode 100644 index 798c30961..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/MultipleSessionFactorySupportTests.java +++ /dev/null @@ -1,259 +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.repository; - -import static org.assertj.core.api.Assertions.*; -import static org.assertj.core.api.Assumptions.*; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.read.ListAppender; - -import java.util.List; -import java.util.stream.Collectors; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runner.RunWith; -import org.junit.runners.model.Statement; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Transaction; -import org.neo4j.harness.ServerControls; -import org.neo4j.harness.TestServerBuilders; -import org.neo4j.ogm.session.Neo4jSession; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.examples.friends.domain.Friendship; -import org.springframework.data.neo4j.examples.friends.domain.Person; -import org.springframework.data.neo4j.examples.friends.repo.FriendshipRepository; -import org.springframework.data.neo4j.examples.restaurants.domain.Diner; -import org.springframework.data.neo4j.examples.restaurants.domain.Restaurant; -import org.springframework.data.neo4j.examples.restaurants.repo.RestaurantRepository; -import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.util.ReflectionUtils; - -/** - * @author Michael J. Simons - */ -@ContextConfiguration(classes = { MultipleSessionFactorySupportTests.BaseConfiguration.class, - MultipleSessionFactorySupportTests.FriendsConfiguration.class, - MultipleSessionFactorySupportTests.RestaurantsConfiguration.class }) -@RunWith(SpringRunner.class) -public class MultipleSessionFactorySupportTests { - - @Rule - public final LoggerRule loggerRule = new LoggerRule(); - - private static final String BEAN_NAME_FRIENDS_SESSION_FACTORY = "sessionFactoryFriends"; - private static final String BEAN_NAME_FRIENDS_TX_MANAGER = "txManagerFriends"; - - private static final String BEAN_NAME_RESTAURANTS_SESSION_FACTORY = "sessionFactoryRestaurants"; - private static final String BEAN_NAME_RESTAURANTS_TX_MANAGER = "txManagerRestaurants"; - - private static final String PACKAGE_FOR_DOMAIN_OF_INSTANCE1 = "org.springframework.data.neo4j.examples.friends"; - private static final String PACKAGE_FOR_DOMAIN_OF_INSTANCE2 = "org.springframework.data.neo4j.examples.restaurants"; - - private static final String QUERY_COUNT_PERSON_NODES = "MATCH (n:Person) RETURN count(n) as cnt"; - private static final String QUERY_COUNT_DINER_NODES = "MATCH (n:Diner) RETURN count(n) as cnt"; - - private static final boolean neo4jOgm324Plus = ReflectionUtils.findMethod(Neo4jSession.class, "determineLabelsOrTypeForLoading", Class.class) != null; - - private static ServerControls instance1; - - private static ServerControls instance2; - - @Autowired @Qualifier(BEAN_NAME_FRIENDS_SESSION_FACTORY) private Session friendsSession; - - @Autowired private FriendshipRepository friendshipRepository; - - @Autowired @Qualifier(BEAN_NAME_RESTAURANTS_SESSION_FACTORY) private Session restaurantsSession; - - @Autowired private RestaurantRepository restaurantRepository; - - @BeforeClass - public static void initializeDatabase() { - - instance1 = TestServerBuilders.newInProcessBuilder().newServer(); - instance2 = TestServerBuilders.newInProcessBuilder().newServer(); - } - - @Test // DATAGRAPH-1094 - public void sessionsShouldUseCorrectMappingContext() { - - assumeThat(neo4jOgm324Plus) - .withFailMessage("This tests is only valid for Neo4j-OGM prior to 3.2.4") - .isFalse(); - - assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> friendsSession.loadAll(Restaurant.class)); - assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> restaurantsSession.loadAll(Person.class)); - } - - @Test // DATAGRAPH-1094 DATAGRAPH-1274 - public void sessionsShouldUseCorrectMappingContext324() { - - assumeThat(neo4jOgm324Plus) - .withFailMessage("This tests is only valid for Neo4j-OGM 3.2.4+") - .isTrue(); - - assertThat(friendsSession.loadAll(Restaurant.class)).isEmpty(); - assertThat(restaurantsSession.loadAll(Person.class)).isEmpty(); - - assertThat(loggerRule.getFormattedMessages()) - .anyMatch(s -> s.contains("Unable to find database label for entity org.springframework.data.neo4j.examples.restaurants.domain.Restaurant : no results will be returned.")) - .anyMatch(s -> s.contains("Unable to find database label for entity org.springframework.data.neo4j.examples.friends.domain.Person : no results will be returned.")); - } - - @Test // DATAGRAPH-1094 - public void repositoriesShouldUseCorrectSessionFactory() { - - this.friendshipRepository.save(buildFriendship()); - this.restaurantRepository.save(openRestaurant()); - - assertThat(this.friendsSession.loadAll(Person.class)).hasSize(2); - assertThat(this.restaurantsSession.loadAll(Diner.class)).hasSize(2); - - assertThat(executeCountQuery(QUERY_COUNT_PERSON_NODES, instance1.graph())).isEqualTo(2L); - assertThat(executeCountQuery(QUERY_COUNT_PERSON_NODES, instance2.graph())).isEqualTo(0L); - assertThat(executeCountQuery(QUERY_COUNT_DINER_NODES, instance1.graph())).isEqualTo(0L); - assertThat(executeCountQuery(QUERY_COUNT_DINER_NODES, instance2.graph())).isEqualTo(2L); - } - - @AfterClass - public static void tearDownDatabase() { - instance1.close(); - instance2.close(); - } - - private Friendship buildFriendship() { - - Person person1 = new Person(); - person1.setFirstName("Homer"); - person1.setLastName("Simpson"); - - Person person2 = new Person(); - person2.setFirstName("Lenny"); - person2.setLastName("Leonard"); - - return new Friendship(person1, person2); - } - - private Restaurant openRestaurant() { - - Restaurant restaurant = new Restaurant("The Restaurant at the End of the Universe", "A nice place."); - restaurant.addRegularDiner(new Diner()); - restaurant.addRegularDiner(new Diner()); - return restaurant; - } - - private long executeCountQuery(String countQuery, GraphDatabaseService onInstance) { - - try (Transaction tx = onInstance.beginTx()) { - long result = (long) onInstance.execute(countQuery).next().get("cnt"); - tx.success(); - return result; - } - } - - @Configuration - @EnableTransactionManagement - static class BaseConfiguration {} - - @Configuration - @EnableNeo4jRepositories(sessionFactoryRef = BEAN_NAME_FRIENDS_SESSION_FACTORY, - transactionManagerRef = BEAN_NAME_FRIENDS_TX_MANAGER, basePackages = PACKAGE_FOR_DOMAIN_OF_INSTANCE1) - static class FriendsConfiguration { - - @Bean(BEAN_NAME_FRIENDS_TX_MANAGER) - public PlatformTransactionManager transactionManager() { - return new Neo4jTransactionManager(sessionFactory()); - } - - @Bean(BEAN_NAME_FRIENDS_SESSION_FACTORY) - public SessionFactory sessionFactory() { - - org.neo4j.ogm.config.Configuration ogmConfiguration = new org.neo4j.ogm.config.Configuration.Builder() - .uri(instance1.boltURI().toString()).build(); - return new SessionFactory(ogmConfiguration, PACKAGE_FOR_DOMAIN_OF_INSTANCE1 + ".domain"); - } - } - - @Configuration - @EnableNeo4jRepositories(sessionFactoryRef = BEAN_NAME_RESTAURANTS_SESSION_FACTORY, - transactionManagerRef = BEAN_NAME_RESTAURANTS_TX_MANAGER, basePackages = PACKAGE_FOR_DOMAIN_OF_INSTANCE2) - static class RestaurantsConfiguration { - - @Bean(BEAN_NAME_RESTAURANTS_TX_MANAGER) - public PlatformTransactionManager transactionManager() { - return new Neo4jTransactionManager(sessionFactory()); - } - - @Bean(BEAN_NAME_RESTAURANTS_SESSION_FACTORY) - public SessionFactory sessionFactory() { - - org.neo4j.ogm.config.Configuration ogmConfiguration = new org.neo4j.ogm.config.Configuration.Builder() - .uri(instance2.boltURI().toString()).build(); - return new SessionFactory(ogmConfiguration, PACKAGE_FOR_DOMAIN_OF_INSTANCE2 + ".domain"); - } - } - - static class LoggerRule implements TestRule { - - private final ListAppender listAppender = new ListAppender<>(); - private final ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger( - ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); - - @Override - public Statement apply(Statement base, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - setup(); - base.evaluate(); - teardown(); - } - }; - } - - private void setup() { - logger.addAppender(listAppender); - listAppender.start(); - } - - private void teardown() { - listAppender.stop(); - listAppender.list.clear(); - logger.detachAppender(listAppender); - } - - public List getFormattedMessages() { - return listAppender.list.stream().map(e -> e.getFormattedMessage()).collect(Collectors.toList()); - } - - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/Neo4jRepositoryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/Neo4jRepositoryTests.java deleted file mode 100644 index b7f081905..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/Neo4jRepositoryTests.java +++ /dev/null @@ -1,105 +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.repository; - -import java.util.Arrays; -import java.util.Optional; -import java.util.UUID; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.domain.sample.NodeWithUUIDAsId; -import org.springframework.data.neo4j.domain.sample.SampleEntity; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = Neo4jRepositoryTests.Config.class) -@Transactional -public class Neo4jRepositoryTests { - - @Autowired SampleEntityRepository repository; - - @Autowired NodeWithUUIDAsIdRepository nodeWithUUIDAsIdRepository; - - @Test - public void testCrudOperationsForCompoundKeyEntity() throws Exception { - - SampleEntity entity = new SampleEntity("foo", "bar"); - repository.save(entity); - assertThat(repository.existsById(entity.getId())).isTrue(); - assertThat(repository.count()).isEqualTo(1L); - - Optional optional = repository.findById(entity.getId()); - assertThat(optional.isPresent()).isTrue(); - optional.ifPresent(actual -> assertThat(actual).isEqualTo(entity)); - - repository.deleteAll(Arrays.asList(entity)); - assertThat(repository.count()).isEqualTo(0L); - } - - @Test // DATAGRAPH-1144 - public void explicitIdsWithCustomTypesShouldWork() throws Exception { - - NodeWithUUIDAsId entity = new NodeWithUUIDAsId("someProperty"); - nodeWithUUIDAsIdRepository.save(entity); - - assertThat(nodeWithUUIDAsIdRepository.existsById(entity.getMyNiceId())).isTrue(); - assertThat(nodeWithUUIDAsIdRepository.count()).isEqualTo(1L); - - Optional retrievedEntity = nodeWithUUIDAsIdRepository.findById(entity.getMyNiceId()); - assertThat(retrievedEntity.isPresent()).isTrue(); - assertThat(retrievedEntity.get()).isEqualTo(entity); - - nodeWithUUIDAsIdRepository.deleteAll(Arrays.asList(entity)); - assertThat(nodeWithUUIDAsIdRepository.count()).isEqualTo(0L); - } - - @Test // DATAGRAPH-1286 - public void findByIdEqualsInDerivedQueryMethodShouldWork() { - - NodeWithUUIDAsId entity = new NodeWithUUIDAsId("someProperty"); - nodeWithUUIDAsIdRepository.save(entity); - - Optional retrievedEntity = nodeWithUUIDAsIdRepository - .findOneByMyNiceIdAndSomeProperty(entity.getMyNiceId(), entity.getSomeProperty()); - assertThat(retrievedEntity.isPresent()).isTrue(); - assertThat(retrievedEntity.get()).isEqualTo(entity); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.domain.sample") - static class Config {} -} - -interface SampleEntityRepository extends Neo4jRepository {} - -interface NodeWithUUIDAsIdRepository extends Neo4jRepository { - - Optional findOneByMyNiceIdAndSomeProperty(UUID id, String someProperty); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/CdiExtensionTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/CdiExtensionTests.java deleted file mode 100644 index 7f59251e1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/CdiExtensionTests.java +++ /dev/null @@ -1,105 +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.repository.cdi; - -import java.util.Optional; - -import javax.enterprise.inject.se.SeContainer; -import javax.enterprise.inject.se.SeContainerInitializer; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.neo4j.harness.ServerControls; -import org.neo4j.harness.TestServerBuilders; -import org.springframework.data.neo4j.examples.friends.domain.Person; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration tests for {@link org.springframework.data.neo4j.repository.cdi.Neo4jCdiRepositoryExtension}. - * - * @author Mark Paluch - * @author Michael J. Simons - */ -public class CdiExtensionTests { - - static ServerControls neo4jTestServer; - static SeContainer container; - - @BeforeClass - public static void setUp() { - - neo4jTestServer = TestServerBuilders.newInProcessBuilder().newServer(); - - // Prevent the Jersey extension to interact with the InitialContext - System.setProperty("com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager", "true"); - - container = SeContainerInitializer.newInstance() // - .disableDiscovery() // - .addPackages(RepositoryClient.class) // - .initialize(); - } - - @AfterClass - public static void tearDown() throws Exception { - container.close(); - neo4jTestServer.close(); - } - - @Test // DATAGRAPH-879, DATAGRAPH-1028 - public void regularRepositoryShouldWork() { - - RepositoryClient client = container.select(RepositoryClient.class).get(); - CdiPersonRepository repository = client.repository; - - assertThat(repository).isNotNull(); - - Person person = null; - Person result = null; - - repository.deleteAll(); - - person = new Person(); - person.setFirstName("Homer"); - person.setLastName("Simpson"); - - result = repository.save(person); - - assertThat(result).isNotNull(); - Long resultId = result.getId(); - Optional lookedUpPerson = repository.findByLastName(person.getLastName()); - assertThat(lookedUpPerson.isPresent()).isTrue(); - lookedUpPerson.ifPresent(actual -> assertThat(actual.getId()).isEqualTo(resultId)); - } - - @Test // DATAGRAPH-879, DATAGRAPH-1028 - public void repositoryWithQualifiersShouldWork() { - - RepositoryClient client = container.select(RepositoryClient.class).get(); - client.qualifiedPersonRepository.deleteAll(); - - assertThat(client.qualifiedPersonRepository.count()).isEqualTo(0); - } - - @Test // DATAGRAPH-879, DATAGRAPH-1028 - public void repositoryWithCustomImplementationShouldWork() { - - RepositoryClient client = container.select(RepositoryClient.class).get(); - - assertThat(client.samplePersonRepository.returnOne()).isEqualTo(1); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/CdiPersonRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/CdiPersonRepository.java deleted file mode 100644 index c257e14d3..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/CdiPersonRepository.java +++ /dev/null @@ -1,35 +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.repository.cdi; - -import java.util.Optional; - -import org.springframework.data.neo4j.examples.friends.domain.Person; -import org.springframework.data.repository.Repository; - -/** - * @author Mark Paluch - * @author Jens Schauder - * @see DATAGRAPH-879 - */ -public interface CdiPersonRepository extends Repository { - - void deleteAll(); - - Person save(Person person); - - Optional findByLastName(String lastname); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiProducer.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiProducer.java deleted file mode 100644 index b97bb412f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/Neo4jCdiProducer.java +++ /dev/null @@ -1,61 +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.repository.cdi; - -import javax.enterprise.inject.Disposes; -import javax.enterprise.inject.Produces; -import javax.inject.Singleton; - -import org.neo4j.ogm.config.Configuration; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.data.neo4j.examples.friends.domain.Person; - -/** - * Simple component exposing a {@link org.neo4j.ogm.session.Session} as CDI bean. See DATAGRAPH-879. - * - * @author Mark Paluch - * @author Michael J. Simons - */ -class Neo4jCdiProducer { - - @Produces - @Singleton - SessionFactory createSessionFactorySession() { - - Configuration configuration = new Configuration.Builder() - .uri(CdiExtensionTests.neo4jTestServer.boltURI().toString()).build(); - return new SessionFactory(configuration, getClass().getPackage().getName(), Person.class.getPackage().getName()); - } - - void close(@Disposes SessionFactory sessionFactory) { - sessionFactory.close(); - } - - @Produces - @Singleton - Session createSession(SessionFactory sessionFactory) { - return sessionFactory.openSession(); - } - - @Produces - @Singleton - @PersonDB - @OtherQualifier - Session createQualifiedSession(SessionFactory sessionFactory) { - return createSession(sessionFactory); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/Neo4jRepositoryExtensionTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/Neo4jRepositoryExtensionTests.java deleted file mode 100644 index 6bf137f8e..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/Neo4jRepositoryExtensionTests.java +++ /dev/null @@ -1,78 +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.repository.cdi; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.ProcessBean; - -import org.junit.Before; -import org.junit.Test; -import org.neo4j.ogm.session.Session; -import org.springframework.test.util.ReflectionTestUtils; - -/** - * @author Mark Angrish - */ -public class Neo4jRepositoryExtensionTests { - - Bean session; - - @Before - @SuppressWarnings("unchecked") - public void setUp() { - - Set types = Collections.singleton((Type) Session.class); - - session = mock(Bean.class); - when(session.getTypes()).thenReturn(types); - } - - @Test - public void registersSession() { - - Neo4jCdiRepositoryExtension extension = new Neo4jCdiRepositoryExtension(); - extension.processBean(createSessionBeanMock(session)); - - assertSessionRegistered(extension, session); - } - - @SuppressWarnings("unchecked") - private static void assertSessionRegistered(Neo4jCdiRepositoryExtension extension, Bean em) { - - Map, Bean> sessions = (Map, Bean>) ReflectionTestUtils - .getField(extension, "sessions"); - assertThat(sessions.size()).isEqualTo(1); - assertThat(sessions.values()).contains(em); - } - - @SuppressWarnings("unchecked") - private static ProcessBean createSessionBeanMock(Bean bean) { - - ProcessBean mock = mock(ProcessBean.class); - when(mock.getBean()).thenReturn(bean); - - return mock; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/OtherQualifier.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/OtherQualifier.java deleted file mode 100644 index 7713b9733..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/OtherQualifier.java +++ /dev/null @@ -1,34 +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.repository.cdi; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * @author Mark Paluch - * @see DATAGRAPH-879 - */ -@Qualifier -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) -@interface OtherQualifier { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/PersonDB.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/PersonDB.java deleted file mode 100644 index 8e7eebe90..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/PersonDB.java +++ /dev/null @@ -1,34 +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.repository.cdi; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * @author Mark Paluch - * @see DATAGRAPH-879 - */ -@Qualifier -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER }) -@interface PersonDB { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/QualifiedPersonRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/QualifiedPersonRepository.java deleted file mode 100644 index b0d9b095d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/QualifiedPersonRepository.java +++ /dev/null @@ -1,29 +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.repository.cdi; - -import org.springframework.data.neo4j.examples.friends.domain.Person; -import org.springframework.data.repository.CrudRepository; - -/** - * @author Mark Paluch - * @see DATAGRAPH-879 - */ -@OtherQualifier -@PersonDB -public interface QualifiedPersonRepository extends CrudRepository { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/RepositoryClient.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/RepositoryClient.java deleted file mode 100644 index baf47db9f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/RepositoryClient.java +++ /dev/null @@ -1,31 +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.repository.cdi; - -import javax.inject.Inject; - -/** - * @author Mark Paluch - * @see DATAGRAPH-879 - */ -class RepositoryClient { - - @Inject CdiPersonRepository repository; - - @OtherQualifier @PersonDB @Inject QualifiedPersonRepository qualifiedPersonRepository; - - @Inject SamplePersonRepository samplePersonRepository; -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonFragment.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonFragment.java deleted file mode 100644 index 0f3b2adbd..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonFragment.java +++ /dev/null @@ -1,25 +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.repository.cdi; - -/** - * @author Mark Paluch - * @see DATAGRAPH-879 - */ -interface SamplePersonFragment { - - int returnOne(); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonFragmentImpl.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonFragmentImpl.java deleted file mode 100644 index d9a6eeb87..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonFragmentImpl.java +++ /dev/null @@ -1,28 +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.repository.cdi; - -/** - * @author Mark Paluch - * @see DATAGRAPH-879 - */ -class SamplePersonFragmentImpl implements SamplePersonFragment { - - @Override - public int returnOne() { - return 1; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonRepository.java deleted file mode 100644 index 565496970..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/cdi/SamplePersonRepository.java +++ /dev/null @@ -1,27 +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.repository.cdi; - -import org.springframework.data.neo4j.examples.friends.domain.Person; -import org.springframework.data.repository.Repository; - -/** - * @author Mark Paluch - * @see DATAGRAPH-879 - */ -public interface SamplePersonRepository extends Repository, SamplePersonFragment { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrarTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrarTests.java deleted file mode 100644 index ef4e713a6..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrarTests.java +++ /dev/null @@ -1,65 +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.repository.config; - -import java.util.Arrays; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.core.env.StandardEnvironment; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.type.AnnotationMetadata; -import org.springframework.core.type.StandardAnnotationMetadata; -import org.springframework.data.neo4j.repository.sample.UserRepository; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Unit test for {@link Neo4jRepositoriesRegistrar}. - * - * @author Mark Angrish - */ -public class Neo4jRepositoriesRegistrarTests { - - BeanDefinitionRegistry registry; - AnnotationMetadata metadata; - - @Before - public void setUp() { - - metadata = new StandardAnnotationMetadata(Config.class, true); - registry = new DefaultListableBeanFactory(); - } - - @Test - public void configuresRepositoriesCorrectly() { - - Neo4jRepositoriesRegistrar registrar = new Neo4jRepositoriesRegistrar(); - registrar.setResourceLoader(new DefaultResourceLoader()); - registrar.setEnvironment(new StandardEnvironment()); - registrar.registerBeanDefinitions(metadata, registry); - - Iterable names = Arrays.asList(registry.getBeanDefinitionNames()); - assertThat(names).contains("userRepository"); - } - - @EnableNeo4jRepositories(basePackageClasses = UserRepository.class) - class Config { - - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtensionTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtensionTests.java deleted file mode 100644 index a5ba7d200..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtensionTests.java +++ /dev/null @@ -1,173 +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.repository.config; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; -import static org.springframework.data.neo4j.repository.config.Neo4jRepositoryConfigurationExtension.*; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Set; - -import org.junit.Test; -import org.neo4j.ogm.metadata.ClassInfo; -import org.neo4j.ogm.metadata.MetaData; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.RuntimeBeanReference; -import org.springframework.beans.factory.support.DefaultListableBeanFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.core.env.StandardEnvironment; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import org.springframework.core.type.StandardAnnotationMetadata; -import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource; -import org.springframework.data.repository.config.RepositoryConfigurationExtension; - -/** - * Unit tests for {@link Neo4jRepositoryConfigurationExtension}. - * - * @author Mark Angrish - * @author Mark Paluch - * @author Gerrit Meier - * @author Michael J. Simons - */ -public class Neo4jRepositoryConfigurationExtensionTests { - - private static final String CUSTOM_SESSION_FACTORY_BEAN_NAME = "mySessionFactory"; - private static final String GENERATED_SESSION_BEAN_NAME = "org.springframework.data.neo4j.transaction.SharedSessionCreator#0"; - private static final String CUSTOM_SESSION_BEAN_NAME = "mySession"; - private static final String CUSTOM_MAPPING_CONTEXT_BEAN_NAME = "myMappingContext"; - - @Test - public void shouldRegisterSessionFactoryUnderDefaultName() { - - DefaultListableBeanFactory factory = getBeanRegistry(new StandardAnnotationMetadata(Config.class, true)); - - Iterable names = Arrays.asList(factory.getBeanDefinitionNames()); - - assertThat(names).contains(DEFAULT_SESSION_FACTORY_BEAN_NAME); - } - - @Test // DATAGRAPH-1094 - public void shouldRegisterSharedSessionUnderDefaultName() { - - DefaultListableBeanFactory factory = getBeanRegistry(new StandardAnnotationMetadata(Config.class, true)); - - Iterable names = Arrays.asList(factory.getBeanDefinitionNames()); - - assertThat(names).contains(GENERATED_SESSION_BEAN_NAME); - } - - @Test // DATAGRAPH-1094 - public void shouldUseConfiguredSessionBeanName() { - assertThat(getBeanRegistry(new StandardAnnotationMetadata(CustomSessionBeanConfig.class, true)) - .containsBeanDefinition(CUSTOM_SESSION_BEAN_NAME)).isTrue(); - } - - @Test // DATAGRAPH-1094 - public void shouldUseConfiguredMappingContextBeanName() { - assertThat(getBeanRegistry(new StandardAnnotationMetadata(CustomMappingContextBeanConfig.class, true)) - .containsBeanDefinition(CUSTOM_MAPPING_CONTEXT_BEAN_NAME)).isTrue(); - } - - @Test - public void sessionFactoryBeanNameDefaultsToSessionFactory() { - - BeanDefinition beanDefinition = getBeanRegistry(new StandardAnnotationMetadata(Config.class, true)) - .getBeanDefinition(GENERATED_SESSION_BEAN_NAME); - - RuntimeBeanReference sessionFactoryBean = (RuntimeBeanReference) beanDefinition.getConstructorArgumentValues() - .getIndexedArgumentValue(0, RuntimeBeanReference.class).getValue(); - - String sessionFactoryBeanName = sessionFactoryBean.getBeanName(); - - assertThat(sessionFactoryBeanName).isEqualTo(DEFAULT_SESSION_FACTORY_BEAN_NAME); - } - - @Test - public void customSessionFactoryBeanNameWillGetUsed() { - - BeanDefinition beanDefinition = getBeanRegistry(new StandardAnnotationMetadata(CustomSessionRefConfig.class, true)) - .getBeanDefinition(GENERATED_SESSION_BEAN_NAME); - - RuntimeBeanReference sessionFactoryBean = (RuntimeBeanReference) beanDefinition.getConstructorArgumentValues() - .getIndexedArgumentValue(0, RuntimeBeanReference.class).getValue(); - - String sessionFactoryBeanName = sessionFactoryBean.getBeanName(); - - assertThat(sessionFactoryBeanName).isEqualTo(CUSTOM_SESSION_FACTORY_BEAN_NAME); - } - - @Test - public void guardsAgainstNullJavaTypesReturnedFromNeo4jMetaData() throws Exception { - - ApplicationContext context = mock(ApplicationContext.class); - SessionFactory sessionFactory = mock(SessionFactory.class); - MetaData metaData = mock(MetaData.class); - ClassInfo classInfo = mock(ClassInfo.class); - - Set managedTypes = Collections.singleton(classInfo); - - when(context.getBean(any(String.class), eq(SessionFactory.class))).thenReturn(sessionFactory); - when(sessionFactory.metaData()).thenReturn(metaData); - when(metaData.persistentEntities()).thenReturn(managedTypes); - when(classInfo.name()).thenReturn("Test"); - - Neo4jMappingContextFactoryBean factoryBean = new Neo4jMappingContextFactoryBean( - Neo4jRepositoryConfigurationExtension.DEFAULT_SESSION_FACTORY_BEAN_NAME); - factoryBean.setApplicationContext(context); - - factoryBean.createInstance().afterPropertiesSet(); - } - - private DefaultListableBeanFactory getBeanRegistry(final StandardAnnotationMetadata metadata) { - - AnnotationConfigApplicationContext factory = new AnnotationConfigApplicationContext(); - - factory.registerBean(DEFAULT_SESSION_FACTORY_BEAN_NAME, SessionFactory.class, "dummypackage"); - - RepositoryConfigurationExtension extension = new Neo4jRepositoryConfigurationExtension(); - AnnotationRepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(metadata, - EnableNeo4jRepositories.class, new PathMatchingResourcePatternResolver(), new StandardEnvironment(), factory); - extension.registerBeansForRoot(factory, configurationSource); - - return (DefaultListableBeanFactory) factory.getBeanFactory(); - } - - @EnableNeo4jRepositories(considerNestedRepositories = true) - private static class Config { - - } - - @EnableNeo4jRepositories(sessionFactoryRef = CUSTOM_SESSION_FACTORY_BEAN_NAME) - private static class CustomSessionRefConfig { - - } - - @EnableNeo4jRepositories(sessionBeanName = CUSTOM_SESSION_BEAN_NAME) - private static class CustomSessionBeanConfig { - - } - - @EnableNeo4jRepositories(mappingContextBeanName = CUSTOM_MAPPING_CONTEXT_BEAN_NAME) - private static class CustomMappingContextBeanConfig { - - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/RepositoriesJavaConfigTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/RepositoriesJavaConfigTests.java deleted file mode 100644 index 28f3f1c52..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/config/RepositoriesJavaConfigTests.java +++ /dev/null @@ -1,58 +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.repository.config; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.domain.sample.User; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.data.repository.support.Repositories; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Integration test for the combination of JavaConfig and an {@link Repositories} wrapper. - * - * @author Mark Angrish - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = RepositoriesJavaConfigTests.Config.class) -public class RepositoriesJavaConfigTests { - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.domain.sample", - repositoryPackages = "org.springframework.data.neo4j.repository.sample") - static class Config { - @Bean - public Repositories repositories(ApplicationContext context) { - return new Repositories(context); - } - } - - @Autowired Repositories repositories; - - @Test - public void neo4jRepositoriesShouldBeRegistered() { - assertThat(repositories.hasRepositoryFor(User.class)).isTrue(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/GraphQueryExecutionTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/GraphQueryExecutionTests.java deleted file mode 100644 index 57d45acdb..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/GraphQueryExecutionTests.java +++ /dev/null @@ -1,74 +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.repository.query; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.*; -import static org.mockito.Mockito.anyMap; -import static org.mockito.Mockito.anyString; -import static org.mockito.Mockito.eq; - -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.HashMap; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.neo4j.ogm.session.Session; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.neo4j.domain.sample.User; -import org.springframework.data.projection.ProjectionFactory; -import org.springframework.data.projection.SpelAwareProxyProjectionFactory; -import org.springframework.data.repository.Repository; -import org.springframework.data.repository.core.support.DefaultRepositoryMetadata; -import org.springframework.util.ReflectionUtils; - -@RunWith(MockitoJUnitRunner.class) -public class GraphQueryExecutionTests { - - @Mock private Session sessionMock; - - private Method method = ReflectionUtils.findMethod(UserRepository.class, "findByFirstname", String.class, - Pageable.class); - private ProjectionFactory factory = new SpelAwareProxyProjectionFactory(); - - @Test - public void pagedExecutionShouldNotGenerateCountQueryIfQueryReportedNoResults() { - - when(sessionMock.query(eq(User.class), anyString(), anyMap())).thenReturn(Collections. emptyList()); - - GraphQueryMethod queryMethod = new GraphQueryMethod(method, new DefaultRepositoryMetadata(UserRepository.class), - factory); - GraphParameterAccessor accessor = new GraphParametersParameterAccessor(queryMethod, - new Object[] { "", PageRequest.of(0, 1) }); - GraphQueryExecution.PagedExecution execution = new GraphQueryExecution.PagedExecution(sessionMock, accessor); - Query query = new Query("", "noop", new HashMap<>()); - execution.execute(query, User.class); - - verify(sessionMock).query(eq(User.class), anyString(), anyMap()); - verify(sessionMock, never()).queryForObject(eq(Integer.class), any(String.class), anyMap()); - } - - interface UserRepository extends Repository { - - Page findByFirstname(String firstname, Pageable pageable); - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/filter/DistanceComparisonBuilderTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/filter/DistanceComparisonBuilderTests.java deleted file mode 100644 index 5b3574a83..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/filter/DistanceComparisonBuilderTests.java +++ /dev/null @@ -1,41 +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.repository.query.filter; - -import static org.assertj.core.api.Assertions.*; -import static org.assertj.core.data.Percentage.*; -import static org.springframework.data.neo4j.repository.query.filter.DistanceComparisonBuilder.*; - -import org.junit.Test; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Metrics; - -public class DistanceComparisonBuilderTests { - @Test - public void calculateDistanceInMeterShouldWork() { - - Distance distance; - - distance = new Distance(1, Metrics.KILOMETERS); - assertThat(calculateDistanceInMeter(distance)).isCloseTo(1000.0, withPercentage(0.001)); - - distance = new Distance(1, Metrics.MILES); - assertThat(calculateDistanceInMeter(distance)).isCloseTo(1609.34, withPercentage(0.001)); - - distance = new Distance(1, Metrics.NEUTRAL); - assertThat(calculateDistanceInMeter(distance)).isEqualTo(1.0); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/MinimalRelationshipEntityMappingTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/MinimalRelationshipEntityMappingTest.java deleted file mode 100644 index 33344fbe0..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/MinimalRelationshipEntityMappingTest.java +++ /dev/null @@ -1,85 +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.repository.relcentric; - -import static org.assertj.core.api.Assertions.*; - -import java.util.Collections; -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.repository.relcentric.app.Actor; -import org.springframework.data.neo4j.repository.relcentric.app.Movie; -import org.springframework.data.neo4j.repository.relcentric.app.Role; -import org.springframework.data.neo4j.repository.relcentric.app.RoleRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = MinimalRelationshipEntityMappingTest.Config.class) -public class MinimalRelationshipEntityMappingTest { - - @Autowired RoleRepository repository; - - @Autowired private TransactionTemplate transactionTemplate; - - @Autowired SessionFactory sessionFactory; - - @Test // DATAGRAPH-1275, OGM-GH-607 - public void verifyUpdateOfRelationshipEntity() { - - long id = transactionTemplate.execute(status -> { - Actor actor = new Actor("A1"); - Movie movie = new Movie("M1"); - Role role = new Role("R1", actor, movie); - return repository.save(role).getId(); - }); - - Iterable> results = sessionFactory.openSession() - .query("MATCH (m:Movie) <- [:ACTS_IN] - (:Actor {name: 'A1'}) RETURN collect(m.name) as titles", - Collections.emptyMap()).queryResults(); - assertThat(results).hasSize(1); - assertThat(results).first() - .satisfies(m -> assertThat((String[]) m.get("titles")).containsOnly("M1")); - - transactionTemplate.execute(status -> { - Role role = repository.findById(id).get(); - role.setMovie(new Movie("M2")); - return repository.save(role).getId(); - }); - - results = sessionFactory.openSession() - .query("MATCH (m:Movie) <- [:ACTS_IN] - (:Actor {name: 'A1'}) RETURN collect(m.name) as titles", - Collections.emptyMap()).queryResults(); - assertThat(results).hasSize(1); - assertThat(results).first() - .satisfies(m -> assertThat((String[]) m.get("titles")).containsOnly("M2")); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.repository.relcentric.app") - static class Config { - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Actor.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Actor.java deleted file mode 100644 index 6baa5cbf7..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Actor.java +++ /dev/null @@ -1,50 +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.repository.relcentric.app; - -import java.util.ArrayList; -import java.util.List; - -import org.neo4j.ogm.annotation.Relationship; - -/** - * @author Michael J. Simons - */ -public class Actor { - - public Long id; - String name; - - @Relationship(type = "ACTS_IN") - private List roles = new ArrayList<>(); - - public Actor() { - } - - public Actor(String name) { - this.name = name; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } -} - - diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Movie.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Movie.java deleted file mode 100644 index e71fb1d4d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Movie.java +++ /dev/null @@ -1,33 +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.repository.relcentric.app; - - -/** - * @author Michael J. Simons - */ -public class Movie { - - private Long id; - private String name; - - public Movie() { - } - - public Movie(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Role.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Role.java deleted file mode 100644 index d19c02db9..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/Role.java +++ /dev/null @@ -1,57 +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.repository.relcentric.app; - -import org.neo4j.ogm.annotation.EndNode; -import org.neo4j.ogm.annotation.RelationshipEntity; -import org.neo4j.ogm.annotation.StartNode; - -/** - * @author Michael J. Simons - */ -@RelationshipEntity(type = "ACTS_IN") -public class Role { - - private Long id; - private String played; - - @StartNode - private Actor actor; - - @EndNode - private Movie movie; - - public Role() { - } - - public Role(String character, Actor actor, Movie movie) { - played = character; - this.actor = actor; - this.movie = movie; - } - - public Long getId() { - return id; - } - - public Movie getMovie() { - return movie; - } - - public void setMovie(Movie movie) { - this.movie = movie; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/RoleRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/RoleRepository.java deleted file mode 100644 index 2208b2fc2..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/relcentric/app/RoleRepository.java +++ /dev/null @@ -1,24 +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.repository.relcentric.app; - -import org.springframework.data.neo4j.repository.Neo4jRepository; - -/** - * @author Michael J. Simons - */ -public interface RoleRepository extends Neo4jRepository { -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/sample/UserRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/sample/UserRepository.java deleted file mode 100644 index bd9df923a..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/sample/UserRepository.java +++ /dev/null @@ -1,78 +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.repository.sample; - -import java.util.List; -import java.util.Optional; - -import org.springframework.data.neo4j.annotation.Query; -import org.springframework.data.neo4j.domain.sample.User; -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.transaction.annotation.Transactional; - -/** - * Repository interface for {@code User}s. - * - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - */ -public interface UserRepository extends Neo4jRepository { - - /** - * Retrieve users by their lastname. The finder {@literal User.findByLastname} is declared in - * {@literal META-INF/orm.xml} . - * - * @param lastname - * @return all users with the given lastname - */ - List findByLastname(String lastname); - - /** - * Redeclaration of {@link CrudRepository#findOne(java.io.Serializable)} to change transaction configuration. - */ - @Override - @Transactional - Optional findById(Long primaryKey); - - /** - * Redeclaration of {@link CrudRepository#delete(java.io.Serializable)}. to make sure the transaction configuration of - * the original method is considered if the redeclaration does not carry a {@link Transactional} annotation. - */ - @Override - void deleteById(Long id); - - /** - * Retrieve users by their email address. The finder {@literal User.findByEmailAddress} is declared as annotation at - * {@code User}. - * - * @param emailAddress - * @return the user with the given email address - */ - User findByEmailAddress(String emailAddress); - - /** - * Retrieves a user by its username using the query annotated to the method. - * - * @param emailAddress - * @return - */ - @Query("MATCH (n:User{emailAddress:$emailAddress}) return n") - @Transactional(readOnly = true) - User findByAnnotatedQuery(@Param("emailAddress") String emailAddress); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/DefaultTransactionDisablingIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/DefaultTransactionDisablingIntegrationTests.java deleted file mode 100644 index 0657e791f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/DefaultTransactionDisablingIntegrationTests.java +++ /dev/null @@ -1,84 +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.repository.support; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.neo4j.domain.sample.User; -import org.springframework.data.neo4j.repository.sample.UserRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.*; - -/** - * Integration tests for disabling default transactions using JavaConfig. - * - * @author Mark Angrish - * @author Jens Schauder - * @author Michael J. Simons - */ -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = DefaultTransactionDisablingIntegrationTests.Config.class) -public class DefaultTransactionDisablingIntegrationTests { - - @Autowired UserRepository repository; - @Autowired TransactionalRepositoryTests.DelegatingTransactionManager txManager; - - @Test - public void considersExplicitConfigurationOnRepositoryInterface() { - - repository.findById(1L); - - assertThat(txManager.getDefinition().isReadOnly()).isFalse(); - } - - @Test - public void doesNotUseDefaultTransactionsOnNonRedeclaredMethod() { - - repository.findAll(PageRequest.of(0, 10)); - - assertThat(txManager.getDefinition()).isNull(); - } - - @Test - public void persistingAnEntityShouldThrowExceptionDueToMissingTransaction() { - - assertThatExceptionOfType(InvalidDataAccessApiUsageException.class) - .isThrownBy(() -> repository.save(new User())) - .withCauseInstanceOf(IllegalStateException.class); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.domain.sample", - repositoryPackages = "org.springframework.data.neo4j.repository.sample", - transactionManagerRef = "delegatingTransactionManager", enableDefaultTransactions = false) - static class Config { - - @Bean - public TransactionalRepositoryTests.DelegatingTransactionManager delegatingTransactionManager( - Neo4jTransactionManager neo4jTransactionManager) { - return new TransactionalRepositoryTests.DelegatingTransactionManager(neo4jTransactionManager); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslatorIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslatorIntegrationTests.java deleted file mode 100644 index d170e08f6..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslatorIntegrationTests.java +++ /dev/null @@ -1,82 +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.repository.support; - - -import java.time.Year; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.harness.ServerControls; -import org.neo4j.ogm.config.AutoIndexMode; -import org.neo4j.ogm.exception.core.InvalidPropertyFieldException; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.convert.ConversionService; -import org.springframework.core.convert.support.DefaultConversionService; -import org.springframework.dao.TypeMismatchDataAccessException; -import org.springframework.data.neo4j.domain.invalid.EntityWithInvalidProperty; -import org.springframework.data.neo4j.domain.invalid.EntityWithInvalidPropertyRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.*; - -/** - * @author Michael J. Simons - * @soundtrack Opeth - Blackwater Park - */ -@ContextConfiguration(classes = Neo4jPersistenceExceptionTranslatorIntegrationTests.ContextConfiguration.class) -@RunWith(SpringRunner.class) -public class Neo4jPersistenceExceptionTranslatorIntegrationTests { - - @Autowired - private EntityWithInvalidPropertyRepository repository; - - @Test - public void invalidPropertyFieldExceptionShouldBeTranslated() { - - assertThatExceptionOfType(TypeMismatchDataAccessException.class) - .isThrownBy(() -> repository - .save(new EntityWithInvalidProperty(Year.of(2018)))) - .withCauseInstanceOf(InvalidPropertyFieldException.class) - .withMessageContaining("'org.springframework.data.neo4j.domain.invalid.EntityWithInvalidProperty#year' is not persistable as property but has not been marked as transient."); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.domain.invalid", - repositoryPackages = "org.springframework.data.neo4j.domain.invalid") - static class ContextConfiguration { - - // Turn off Autoindex Manager to avoid eager entity scanning - @Bean - org.neo4j.ogm.config.Configuration neo4jOGMConfiguration(ServerControls neo4jTestServer) { - return new org.neo4j.ogm.config.Configuration.Builder() // - .uri(neo4jTestServer.boltURI().toString()) // - .autoIndex(AutoIndexMode.NONE.getName()) // - .build(); - } - - // Eager entity scanning is also triggered without a Spring conversion service - @Bean - public ConversionService conversionService() { - return DefaultConversionService.getSharedInstance(); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBeanTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBeanTests.java deleted file mode 100644 index 6aaa77401..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBeanTests.java +++ /dev/null @@ -1,88 +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.repository.support; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.ListableBeanFactory; -import org.springframework.data.mapping.context.MappingContext; -import org.springframework.data.neo4j.mapping.MetaDataProvider; -import org.springframework.data.neo4j.repository.ContactRepository; - -/** - * @author Mark Angrish - * @author Mark Paluch - * @author Michael J. Simons - */ -@RunWith(MockitoJUnitRunner.class) -public class Neo4jRepositoryFactoryBeanTests { - - Neo4jRepositoryFactoryBean factoryBean; - - @Mock ListableBeanFactory beanFactory; - - @Mock MappingContext context; - - @Before - @SuppressWarnings("unchecked") - public void setUp() { - - Session session = mock(Session.class, withSettings().extraInterfaces(MetaDataProvider.class)); - - // Setup standard factory configuration - factoryBean = new Neo4jRepositoryFactoryBean(ContactRepository.class); - factoryBean.setSession(session); - factoryBean.setMappingContext(context); - } - - /** - * Assert that the instance created for the standard configuration is a valid {@code UserRepository}. - * - * @throws Exception - */ - @Test - public void setsUpBasicInstanceCorrectly() throws Exception { - - factoryBean.setBeanFactory(beanFactory); - factoryBean.afterPropertiesSet(); - - assertThat(factoryBean.getObject()).isNotNull(); - } - - @Test(expected = IllegalArgumentException.class) - public void requiresListableBeanFactory() throws Exception { - - factoryBean.setBeanFactory(mock(BeanFactory.class)); - } - - /** - * Assert that the factory rejects calls to {@code Neo4jRepositoryFactoryBean#setRepositoryInterface(Class)} with - * {@literal null} or any other parameter instance not implementing {@code Repository}. - */ - @Test(expected = IllegalArgumentException.class) - public void preventsNullRepositoryInterface() { - - factoryBean = new Neo4jRepositoryFactoryBean(null); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepositoryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepositoryTests.java deleted file mode 100644 index bb7b7d8df..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepositoryTests.java +++ /dev/null @@ -1,159 +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.repository.support; - -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; -import org.neo4j.ogm.cypher.query.Pagination; -import org.neo4j.ogm.cypher.query.SortOrder; -import org.neo4j.ogm.session.Session; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; - -public class SimpleNeo4jRepositoryTests { - - private final Session sessionMock = mock(Session.class); - private final PageRequest oneElementPageRequest = PageRequest.of(0, 1); - private final PageRequest twoElementPageRequest = PageRequest.of(0, 2); - - private SimpleNeo4jRepository repository = new SimpleNeo4jRepository<>(Object.class, sessionMock); - - @Test - public void pageCorrectForOneElementPageWithOneResult() { - int expectedElementsOnPage = 1; - int amountOfElementsInDatabase = 1; - int expectedPageCount = 1; - - Page page = loadPage(oneElementPageRequest, amountOfElementsInDatabase); - - assertThat(page.getNumberOfElements()).isEqualTo(expectedElementsOnPage); - assertThat(page.getTotalPages()).isEqualTo(expectedPageCount); - assertThat(page.getTotalElements()).isEqualTo(amountOfElementsInDatabase); - - verify(sessionMock).countEntitiesOfType(eq(Object.class)); - } - - @Test - public void pageCorrectForOneElementPageWithTwoResults() { - int expectedElementsOnPage = 1; - int amountOfElementsInDatabase = 2; - int expectedPageCount = 2; - - Page page = loadPage(oneElementPageRequest, amountOfElementsInDatabase); - - assertThat(page.getNumberOfElements()).isEqualTo(expectedElementsOnPage); - assertThat(page.getTotalPages()).isEqualTo(expectedPageCount); - assertThat(page.getTotalElements()).isEqualTo(amountOfElementsInDatabase); - - verify(sessionMock).countEntitiesOfType(eq(Object.class)); - } - - @Test - public void pageCorrectForMoreThanOneElementPageWithOneResult() { - int expectedElementsOnPage = 1; - int amountOfElementsInDatabase = 1; - int expectedPageCount = 1; - - Page page = loadPage(twoElementPageRequest, amountOfElementsInDatabase); - - assertThat(page.getNumberOfElements()).isEqualTo(expectedElementsOnPage); - assertThat(page.getTotalPages()).isEqualTo(expectedPageCount); - assertThat(page.getTotalElements()).isEqualTo(amountOfElementsInDatabase); - } - - @Test - public void pageCorrectForMoreThanOneElementPageWithTwoResults() { - int expectedElementsOnPage = 2; - int amountOfElementsInDatabase = 2; - int expectedPageCount = 1; - - Page page = loadPage(twoElementPageRequest, amountOfElementsInDatabase); - - assertThat(page.getNumberOfElements()).isEqualTo(expectedElementsOnPage); - assertThat(page.getTotalPages()).isEqualTo(expectedPageCount); - assertThat(page.getTotalElements()).isEqualTo(amountOfElementsInDatabase); - - verify(sessionMock).countEntitiesOfType(eq(Object.class)); - } - - @Test - public void pageCorrectForSecondPage() { - int expectedElementsOnPage = 1; - int amountOfElementsInDatabase = 3; - int expectedPageCount = 2; - - PageRequest twoElementPageRequestPageTwo = PageRequest.of(1, 2); - Page page = loadPage(twoElementPageRequestPageTwo, amountOfElementsInDatabase); - - assertThat(page.getNumberOfElements()).isEqualTo(expectedElementsOnPage); - assertThat(page.getTotalPages()).isEqualTo(expectedPageCount); - assertThat(page.getTotalElements()).isEqualTo(amountOfElementsInDatabase); - } - - @Test - public void pageCorrectForEmptyPage() { - int expectedElementsOnPage = 0; - int amountOfElementsInDatabase = 3; - int expectedPageCount = 2; - - PageRequest twoElementPageRequestPageThree = PageRequest.of(2, 2); - Page page = loadPage(twoElementPageRequestPageThree, amountOfElementsInDatabase); - - assertThat(page.getNumberOfElements()).isEqualTo(expectedElementsOnPage); - assertThat(page.getTotalPages()).isEqualTo(expectedPageCount); - assertThat(page.getTotalElements()).isEqualTo(amountOfElementsInDatabase); - } - - @Test - public void pageCorrectForMiddlePageRequest() { - int expectedElementsOnPage = 2; - int amountOfElementsInDatabase = 5; - int expectedPageCount = 3; - - PageRequest twoElementPageRequestPageThree = PageRequest.of(1, 2); - Page page = loadPage(twoElementPageRequestPageThree, amountOfElementsInDatabase); - - assertThat(page.getNumberOfElements()).isEqualTo(expectedElementsOnPage); - assertThat(page.getTotalPages()).isEqualTo(expectedPageCount); - assertThat(page.getTotalElements()).isEqualTo(amountOfElementsInDatabase); - } - - private Page loadPage(PageRequest requestedPage, long amountOfElementsInDatabase) { - prepareSessionMock(requestedPage, amountOfElementsInDatabase); - return repository.findAll(requestedPage); - } - - private void prepareSessionMock(PageRequest requestedPage, long amountOfElementsInDatabase) { - List databaseResult = new ArrayList<>(); - - long countOfElementsOnCurrentPage = Math.min(requestedPage.getPageSize(), - amountOfElementsInDatabase - (requestedPage.getPageSize() * requestedPage.getPageNumber())); - - for (int i = 0; i < countOfElementsOnCurrentPage; i++) { - databaseResult.add("entry"); - } - - doReturn(databaseResult).when(sessionMock).loadAll(eq(Object.class), any(SortOrder.class), any(Pagination.class), - anyInt()); - doReturn(amountOfElementsInDatabase).when(sessionMock).countEntitiesOfType(eq(Object.class)); - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/TransactionalRepositoryTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/TransactionalRepositoryTests.java deleted file mode 100644 index 974aa3904..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/support/TransactionalRepositoryTests.java +++ /dev/null @@ -1,162 +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.repository.support; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.domain.sample.User; -import org.springframework.data.neo4j.repository.sample.UserRepository; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionException; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionTemplate; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Mark Angrish - * @author Jens Schauder - * @author Michael J. Simons - */ -@ContextConfiguration(classes = TransactionalRepositoryTests.Config.class) -@RunWith(SpringRunner.class) -public class TransactionalRepositoryTests { - - @Autowired GraphDatabaseService graphDatabaseService; - @Autowired TransactionTemplate transactionTemplate; - - @Autowired UserRepository repository; - @Autowired DelegatingTransactionManager transactionManager; - - @Before - public void setUp() { - - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - transactionManager.resetCount(); - } - - @After - public void tearDown() { - - repository.deleteAll(); - } - - @Test - public void simpleManipulatingOperation() { - - repository.save(new User("foo", "bar", "foo@bar.de")); - assertThat(transactionManager.getTransactionRequests()).isEqualTo(1); - } - - @Test - public void unannotatedFinder() { - - repository.findByEmailAddress("foo@bar.de"); - assertThat(transactionManager.getTransactionRequests()).isEqualTo(0); - } - - @Test - public void invokeTransactionalFinder() { - - repository.findByAnnotatedQuery("foo@bar.de"); - assertThat(transactionManager.getTransactionRequests()).isEqualTo(1); - } - - @Test - public void invokeRedeclaredMethod() { - - repository.findById(1L); - assertThat(transactionManager.getDefinition().isReadOnly()).isFalse(); - } - - @Test - public void invokeRedeclaredDeleteMethodWithoutTransactionDeclaration() { - - User user = repository.save(new User("foo", "bar", "foo@bar.de")); - repository.deleteById(user.getId()); - - assertThat(transactionManager.getDefinition().isReadOnly()).isFalse(); - } - - static class DelegatingTransactionManager implements PlatformTransactionManager { - - private PlatformTransactionManager txManager; - private int transactionRequests; - private TransactionDefinition definition; - - public DelegatingTransactionManager(PlatformTransactionManager txManager) { - - this.txManager = txManager; - } - - public void commit(TransactionStatus status) throws TransactionException { - - txManager.commit(status); - } - - public TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException { - - this.transactionRequests++; - this.definition = definition; - - return txManager.getTransaction(definition); - } - - public int getTransactionRequests() { - - return transactionRequests; - } - - public TransactionDefinition getDefinition() { - - return definition; - } - - public void resetCount() { - - this.transactionRequests = 0; - this.definition = null; - } - - public void rollback(TransactionStatus status) throws TransactionException { - - txManager.rollback(status); - } - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.domain.sample", - transactionManagerRef = "delegatingTransactionManager", - repositoryPackages = "org.springframework.data.neo4j.repository.sample") - static class Config { - - @Bean - public DelegatingTransactionManager delegatingTransactionManager(Neo4jTransactionManager neo4jTransactionManager) { - return new DelegatingTransactionManager(neo4jTransactionManager); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/TemplateApplicationEventTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/TemplateApplicationEventTests.java deleted file mode 100644 index 854231acf..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/TemplateApplicationEventTests.java +++ /dev/null @@ -1,112 +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.template; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.events.EventPublisher; -import org.springframework.data.neo4j.events.Neo4jModificationEventListener; -import org.springframework.data.neo4j.examples.movies.domain.Actor; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Test to assert the behaviour of {@link Session}'s interaction with Spring application events. - * - * @author Adam George - * @author Mark Angrish - * @author Michael J. Simons - */ -@ContextConfiguration(classes = TemplateApplicationEventTests.DataManipulationEventConfiguration.class) -@RunWith(SpringRunner.class) -public class TemplateApplicationEventTests { - - @Autowired private Session session; - - @Autowired private Neo4jModificationEventListener eventListener; - - @Test - @Transactional - public void shouldCreateTemplateAndPublishAppropriateApplicationEventsOnSaveAndOnDelete() { - assertThat(this.session).as("The Neo4jTemplate wasn't autowired into this test") - .isNotNull(); - - Actor entity = new Actor(); - entity.setName("John Abraham"); - - assertThat(this.eventListener.receivedPreSaveEvent()).isFalse(); - assertThat(this.eventListener.receivedPostSaveEvent()).isFalse(); - this.session.save(entity); - assertThat(this.eventListener.receivedPreSaveEvent()).isTrue(); - - assertThat(this.eventListener.getPreSaveEvent().getSource().getObject()) - .isSameAs(entity); - assertThat(this.eventListener.receivedPostSaveEvent()).isTrue(); - assertThat(this.eventListener.getPostSaveEvent().getSource().getObject()) - .isSameAs(entity); - - assertThat(this.eventListener.receivedPreDeleteEvent()).isFalse(); - assertThat(this.eventListener.receivedPostDeleteEvent()).isFalse(); - this.session.delete(entity); - assertThat(this.eventListener.receivedPreDeleteEvent()).isTrue(); - assertThat(this.eventListener.getPreDeleteEvent().getSource().getObject()) - .isSameAs(entity); - assertThat(this.eventListener.receivedPostDeleteEvent()).isTrue(); - assertThat(this.eventListener.getPostDeleteEvent().getSource().getObject()) - .isSameAs(entity); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.examples.movies.domain") - static class DataManipulationEventConfiguration { - - @Bean - public BeanPostProcessor sessionFactoryPostProcessor(EventPublisher eventPublisher) { - return new BeanPostProcessor() { - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof SessionFactory) { - ((SessionFactory) bean).register(eventPublisher); - } - return null; - } - }; - } - - @Bean - public EventPublisher eventPublisher(ApplicationEventPublisher applicationEventPublisher) { - return new EventPublisher(applicationEventPublisher); - } - - @Bean - public Neo4jModificationEventListener eventListener() { - return new Neo4jModificationEventListener(); - } - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/TestNeo4jEventListener.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/TestNeo4jEventListener.java deleted file mode 100644 index 499d968a9..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/template/TestNeo4jEventListener.java +++ /dev/null @@ -1,43 +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.template; - -import org.neo4j.ogm.session.event.Event; -import org.springframework.data.neo4j.events.ModificationEvent; - -/** - * Spring {@code ApplicationListener} used to capture {@link Event}s that occur during a test run. Note that this is - * abstract because you're supposed to create an anonymous subclass to handle event type 'E' when you use it. This - * ensures Spring doesn't just send {@link Event}s to everything regardless. - * - * @author Adam George - */ -public abstract class TestNeo4jEventListener { - - private ModificationEvent event; - - public void onApplicationEvent(E event) { - this.event = event; - } - - public boolean hasReceivedAnEvent() { - return this.event != null; - } - - public ModificationEvent getEvent() { - return event; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/CloseServerControlsAfterTestClassTestExecutionListener.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/CloseServerControlsAfterTestClassTestExecutionListener.java deleted file mode 100644 index eb806e783..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/CloseServerControlsAfterTestClassTestExecutionListener.java +++ /dev/null @@ -1,44 +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.test; - -import static org.springframework.data.neo4j.test.Neo4jTestServerConfiguration.*; - -import org.neo4j.harness.ServerControls; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.TestContext; -import org.springframework.test.context.support.AbstractTestExecutionListener; - -/** - * This tests execution listener takes care of closing Neo4j when the test context gets removed. - * The shutdown hook will not apply until the JVM ends, so the tests won't close Neo4j even with - * {@link org.springframework.test.annotation.DirtiesContext} on them. Therefor we do this manually. - * As our doing actually also does dirty the context, we mark it accordingly. - * - * @author Michael J. Simons - */ -class CloseServerControlsAfterTestClassTestExecutionListener extends AbstractTestExecutionListener { - - @Override - public void afterTestClass(TestContext testContext) { - - ApplicationContext applicationContext = testContext.getApplicationContext(); - if (applicationContext.containsBean(NEO4J_TEST_SERVER_BEAN_NAME)) { - ((ServerControls) applicationContext.getBean(NEO4J_TEST_SERVER_BEAN_NAME)).close(); - testContext.markApplicationContextDirty(null); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/GraphDatabaseServiceAssert.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/GraphDatabaseServiceAssert.java deleted file mode 100644 index 00c62c548..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/GraphDatabaseServiceAssert.java +++ /dev/null @@ -1,61 +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.test; - -import java.util.Collections; -import java.util.Map; - -import org.assertj.core.api.AbstractAssert; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Result; -import org.neo4j.graphdb.Transaction; - -/** - * @author Michael J. Simons - */ -public class GraphDatabaseServiceAssert extends AbstractAssert { - - GraphDatabaseServiceAssert(GraphDatabaseService graphDatabaseService) { - super(graphDatabaseService, GraphDatabaseServiceAssert.class); - } - - public static GraphDatabaseServiceAssert assertThat(GraphDatabaseService actual) { - return new GraphDatabaseServiceAssert(actual); - } - - public NodeAssert containsNode(String matchStatement) { - return containsNode(matchStatement, Collections.emptyMap()); - } - - public NodeAssert containsNode(String matchStatement, Map params) { - - isNotNull(); - - NodeAssert nodeAssert; - try (Transaction tx = actual.beginTx(); Result result = actual.execute(matchStatement, params)) { - - if (!result.hasNext()) { - tx.failure(); - failWithMessage("Graph should contain node matched by <%s> didn't.", matchStatement); - } - - tx.success(); - nodeAssert = new NodeAssert((Node) result.next().get("n")); - } - return nodeAssert; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/Neo4jIntegrationTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/Neo4jIntegrationTest.java deleted file mode 100644 index 70e76c078..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/Neo4jIntegrationTest.java +++ /dev/null @@ -1,89 +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.test; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.context.annotation.Import; -import org.springframework.core.annotation.AliasFor; -import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; -import org.springframework.data.repository.config.DefaultRepositoryBaseClass; - -/** - * This is an internal annotation to provide the minimum setup for an integration test against a Neo4j instance running - * through the Neo4j test harness. It is not meant to be used outside SDN.
- *
- * It turns on {@link EnableNeo4jRepositories Neo4j repositories} as well as - * {@link org.springframework.transaction.annotation.EnableTransactionManagement transaction management} and provides an - * injectable {@link org.neo4j.graphdb.GraphDatabaseService graph database service} for manipulating data.
- * If a test provides a custom {@link org.neo4j.ogm.config.Configuration configuration bean} it takes precedence over - * the one that is created by default.
- * The default is to test SDN via Bolt-Transport. That can be changed in a dedicaded test setup by providing a system - * property name {@code integration-test-mode} with one of the following values: - * - *
- *     -Dintegration-test-mode=BOLT
- *     -Dintegration-test-mode=EMBEDDED
- *     -Dintegration-test-mode=HTTP
- * 
- * - * Be aware that those setup require the presence of the corresponding OGM transport on the classpath. Tests that test - * features specific to a transport (like Bookmarks, only available for Bolt) or native types (Only available for Bolt - * and Embedded) should create their own {@link org.neo4j.ogm.config.Configuration Configuration}-bean. - * - * @author Michael J. Simons - * @since 5.2 - * @soundtrack Die Ärzte - Nach uns die Sintflut - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@EnableNeo4jRepositories -@Import({ SessionFactoryRegistrar.class, Neo4jTestServerConfiguration.class }) -public @interface Neo4jIntegrationTest { - - enum IntegrationTestMode { - BOLT, HTTP, EMBEDDED - } - - /** - * @return The list of domain packages to be passed on to the {@link org.neo4j.ogm.session.SessionFactory}. - */ - String[] domainPackages(); - - /** - * @return The list of packages to scan for {@link org.springframework.data.neo4j.repository.Neo4jRepository Neo4j - * repositories}. - */ - @AliasFor(annotation = EnableNeo4jRepositories.class, attribute = "basePackages") - String[] repositoryPackages() default {}; - - @AliasFor(annotation = EnableNeo4jRepositories.class, attribute = "repositoryBaseClass") - Class repositoryBaseClass() default DefaultRepositoryBaseClass.class; - - @AliasFor(annotation = EnableNeo4jRepositories.class, attribute = "considerNestedRepositories") - boolean considerNestedRepositories() default false; - - @AliasFor(annotation = EnableNeo4jRepositories.class, attribute = "transactionManagerRef") - String transactionManagerRef() default "transactionManager"; - - @AliasFor(annotation = EnableNeo4jRepositories.class, attribute = "enableDefaultTransactions") - boolean enableDefaultTransactions() default true; -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/Neo4jTestServerConfiguration.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/Neo4jTestServerConfiguration.java deleted file mode 100644 index 005588435..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/Neo4jTestServerConfiguration.java +++ /dev/null @@ -1,117 +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.test; - -import java.util.Optional; - -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.harness.ServerControls; -import org.neo4j.harness.TestServerBuilders; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ConfigurationCondition; -import org.springframework.core.type.AnnotatedTypeMetadata; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest.IntegrationTestMode; -import org.springframework.data.neo4j.transaction.Neo4jTransactionManager; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * This class represents the configuration of a Spring Data Neo4j integration test. - * - * @author Michael J. Simons - * @since 5.2 - * @soundtrack Die Ärzte - Nach uns die Sintflut - */ -@Configuration -@EnableTransactionManagement -class Neo4jTestServerConfiguration { - - static final String NEO4J_TEST_SERVER_BEAN_NAME = "neo4jTestServer"; - - @Bean(name = NEO4J_TEST_SERVER_BEAN_NAME) - ServerControls neo4jTestServer() { - return TestServerBuilders.newInProcessBuilder().newServer(); - } - - @Bean - GraphDatabaseService graphDatabaseService(ServerControls neo4jTestServer) { - return neo4jTestServer.graph(); - } - - @Bean - @Conditional(OnMissingOGMConfigurationCondition.class) - org.neo4j.ogm.config.Configuration neo4jOGMConfiguration(ServerControls neo4jTestServer) { - - // @Value isn't used on purpose. Some tests interfere with the conversion services and - // it would be much more effort to use Springs system property integration and SpEL than - // this manual setup. - IntegrationTestMode integrationTestMode = Optional.ofNullable(System.getProperty("integration-test-mode")) - .map(IntegrationTestMode::valueOf).orElse(IntegrationTestMode.BOLT); - - String uri; - switch (integrationTestMode) { - case BOLT: - uri = neo4jTestServer.boltURI().toString(); - break; - case HTTP: - uri = neo4jTestServer.httpURI().toString(); - break; - case EMBEDDED: - uri = null; // This is on purpose, the configuration than uses embedded. - break; - default: - throw new UnsupportedOperationException("Unsupported mode for integration tests: " + integrationTestMode); - } - - return new org.neo4j.ogm.config.Configuration.Builder() // - .uri(uri) // - .build(); - } - - @Bean - public PlatformTransactionManager transactionManager(SessionFactory sessionFactory) { - return new Neo4jTransactionManager(sessionFactory); - } - - @Bean - public TransactionTemplate transactionTemplate(PlatformTransactionManager transactionManager) { - return new TransactionTemplate(transactionManager); - } - - static class OnMissingOGMConfigurationCondition implements ConfigurationCondition { - - @Override - public ConfigurationPhase getConfigurationPhase() { - return ConfigurationPhase.REGISTER_BEAN; - } - - @Override - public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) { - - ObjectProvider objectProvider = conditionContext.getBeanFactory() - .getBeanProvider(org.neo4j.ogm.config.Configuration.class); - - boolean configurationAvailable = objectProvider.getIfUnique() != null; - return !configurationAvailable; - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/NodeAssert.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/NodeAssert.java deleted file mode 100644 index a2d1ef5fd..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/NodeAssert.java +++ /dev/null @@ -1,39 +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.test; - -import org.assertj.core.api.AbstractAssert; -import org.neo4j.graphdb.Node; - -/** - * @author Michael J. Simons - */ -public class NodeAssert extends AbstractAssert { - NodeAssert(Node node) { - super(node, NodeAssert.class); - } - - public NodeAssert withId(long id) { - - isNotNull(); - - if (actual.getId() != id) { - failWithMessage("The node's id should be <%d> but was <%d>.", id, actual.getId()); - } - - return this; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/SessionFactoryRegistrar.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/SessionFactoryRegistrar.java deleted file mode 100644 index 4d608c56e..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/SessionFactoryRegistrar.java +++ /dev/null @@ -1,52 +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.test; - -import java.util.Map; - -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; -import org.springframework.core.type.AnnotationMetadata; - -/** - * Helper for programmatically creating a {@link SessionFactory session factory} using a well defined - * {@link org.neo4j.ogm.config.Configuration configuration} and a list of domain packages from the - * {@link Neo4jIntegrationTest}-annotation. - * - * @author Michael J. Simons - * @since 5.2 - * @soundtrack Die Ärzte - Nach uns die Sintflut - */ -class SessionFactoryRegistrar implements ImportBeanDefinitionRegistrar { - - @Override - public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, - BeanDefinitionRegistry beanDefinitionRegistry) { - - Map t = annotationMetadata.getAnnotationAttributes(Neo4jIntegrationTest.class.getName()); - - AbstractBeanDefinition sessionFactoryDefinition = BeanDefinitionBuilder // - .rootBeanDefinition(SessionFactory.class) // - .addConstructorArgReference("neo4jOGMConfiguration") // - .addConstructorArgValue(t.get("domainPackages")) // - .getBeanDefinition(); - - beanDefinitionRegistry.registerBeanDefinition("sessionFactory", sessionFactoryDefinition); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/package-info.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/package-info.java deleted file mode 100644 index fa3230c64..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/test/package-info.java +++ /dev/null @@ -1,19 +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. - */ -/** - * Test support: Spring Context configuration and similar. - */ -package org.springframework.data.neo4j.test; diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/BookmarkTransactionTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/BookmarkTransactionTests.java deleted file mode 100644 index a881ef349..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/BookmarkTransactionTests.java +++ /dev/null @@ -1,144 +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.transaction; - -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; - -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.neo4j.driver.AuthTokens; -import org.neo4j.driver.Bookmark; -import org.neo4j.driver.Driver; -import org.neo4j.driver.GraphDatabase; -import org.neo4j.driver.SessionConfig; -import org.neo4j.driver.internal.InternalBookmark; -import org.neo4j.harness.ServerControls; -import org.neo4j.harness.TestServerBuilders; -import org.neo4j.ogm.drivers.bolt.driver.BoltDriver; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; -import org.springframework.data.neo4j.annotation.EnableBookmarkManagement; -import org.springframework.data.neo4j.bookmark.BookmarkManager; -import org.springframework.data.neo4j.bookmark.CaffeineBookmarkManager; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.service.UserService; -import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -/** - * @author Frantisek Hartman - * @author Michael J. Simons - */ -@ContextConfiguration(classes = BookmarkTransactionTests.BookmarkConfiguration.class) -@RunWith(SpringRunner.class) -public class BookmarkTransactionTests { - - @Autowired private BookmarkManager bookmarkManager; - - @Autowired private Driver nativeDriver; - - @Autowired private UserService userService; - - @Test - public void operationsShouldStoreBookmarkAndUseBookmarkShouldReuseBookmark() throws Exception { - - ArgumentCaptor configArgumentCaptor = ArgumentCaptor.forClass(SessionConfig.class); - - userService.saveWithTxAnnotationOnInterface(new User()); - - Collection bookmarks = bookmarkManager.getBookmarks(); - assertThat(bookmarks).isNotEmpty(); - - @SuppressWarnings("unused") - Collection users = userService.getAllUsersWithBookmark(); - - Mockito.verify(nativeDriver, times(2)).session(configArgumentCaptor.capture()); - List bookmarksInDriver = configArgumentCaptor.getAllValues().stream() - .flatMap(sc -> StreamSupport.stream(sc.bookmarks().spliterator(), false)) - .collect(Collectors.toList()); - - assertThat(bookmarksInDriver).containsAll( - bookmarks.stream().map(InternalBookmark::parse).collect(Collectors.toList())); - - } - - @Test - public void operationsShouldReplaceOlderBookmarks() throws Exception { - userService.saveWithTxAnnotationOnInterface(new User()); - Collection bookmarks = bookmarkManager.getBookmarks(); - assertThat(bookmarks).isNotEmpty(); - - userService.saveWithTxAnnotationOnInterface(new User()); - userService.getAllUsersWithBookmark(); - - assertThat(bookmarkManager.getBookmarks()).isNotEmpty(); - assertThat(bookmarkManager.getBookmarks()).doesNotContainAnyElementsOf(bookmarks); - } - - @Configuration - @EnableTransactionManagement - @EnableBookmarkManagement - @EnableNeo4jRepositories(basePackages = "org.springframework.data.neo4j.examples.movies.repo") - @ComponentScan(value = "org.springframework.data.neo4j.examples.movies.service") - static class BookmarkConfiguration { - - @Bean - ServerControls neo4jTestServer() { - return TestServerBuilders.newInProcessBuilder().newServer(); - } - - @Bean - public Driver nativeDriver(ServerControls neo4jTestServer) { - return spy(GraphDatabase.driver(neo4jTestServer.boltURI(), AuthTokens.none())); - } - - @Bean - org.neo4j.ogm.driver.Driver neo4jOGMDriver(Driver nativeDriver) { - return new BoltDriver(nativeDriver); - } - - @Bean - SessionFactory sessionFactory(org.neo4j.ogm.driver.Driver neo4jOGMDriver) { - return new SessionFactory(neo4jOGMDriver, "org.springframework.data.neo4j.examples.movies.domain"); - } - - @Bean - public PlatformTransactionManager transactionManager(SessionFactory sessionFactory) { - return new Neo4jTransactionManager(sessionFactory); - } - - @Bean - @Scope - public BookmarkManager bookmarkManager() { - return new CaffeineBookmarkManager(); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/ExtendedTransactionsTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/ExtendedTransactionsTests.java deleted file mode 100644 index 6b1bae6de..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/ExtendedTransactionsTests.java +++ /dev/null @@ -1,150 +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.transaction; - -import java.util.Iterator; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.data.neo4j.transaction.service.ServiceA; -import org.springframework.data.neo4j.transaction.service.ServiceB; -import org.springframework.data.neo4j.transaction.service.WrapperService; -import org.springframework.test.annotation.Rollback; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -/** - * See StackOverFlow - * and DATAGRAPH-602 - * - * @author: Vince Bickers - * @author Michael J. Simons - */ -@ContextConfiguration(classes = ExtendedTransactionsTests.ApplicationConfig.class) -@RunWith(SpringRunner.class) -public class ExtendedTransactionsTests { - - @Autowired GraphDatabaseService graphDatabaseService; - - @Autowired ServiceA serviceA; - - @Autowired ServiceB serviceB; - - @Autowired WrapperService wrapperService; - - @Before - public void clearDatabase() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @Test - public void shouldRollbackSuccessThenFail() { - - try { - wrapperService.composeSuccessThenFail(); - fail("should have thrown exception"); - } catch (Exception e) { - assertThat(e.getLocalizedMessage()) - .isEqualTo("Deliberately throwing exception"); - assertThat(countNodes()).isEqualTo(0); - } - } - - @Test - @Transactional - @Rollback - public void shouldCommitSuccessSuccess() { - - try { - wrapperService.composeSuccessThenSuccess(); - assertThat(countNodes()).isEqualTo(2); - } catch (Exception e) { - fail("should not have thrown exception"); - } - } - - @Test - public void shouldRollbackFailThenSuccess() { - try { - wrapperService.composeFailThenSuccess(); - fail("should have thrown exception"); - } catch (Exception e) { - assertThat(e.getLocalizedMessage()) - .isEqualTo("Deliberately throwing exception"); - assertThat(countNodes()).isEqualTo(0); - } - } - - @Test - public void shouldRollbackFailThenFail() { - try { - wrapperService.composeFailThenFail(); - fail("should have thrown exception"); - } catch (Exception e) { - assertThat(e.getLocalizedMessage()) - .isEqualTo("Deliberately throwing exception"); - assertThat(countNodes()).isEqualTo(0); - } - } - - @Test - public void shouldRollbackWithCheckedException() { - try { - wrapperService.rollbackWithCheckedException(); - fail("should have thrown exception"); - } catch (Exception e) { - assertThat(e.getLocalizedMessage()) - .isEqualTo("Deliberately throwing exception"); - assertThat(countNodes()).isEqualTo(0); - } - } - - @Test - public void shouldRollbackRepositoryMethodOnCheckedException() { - try { - serviceA.run(); - } catch (Exception e) { - assertThat(serviceB.getBilbo()).isNull(); - } - } - - private int countNodes() { - Iterator iterator = wrapperService.fetch().iterator(); - int i = 0; - while (iterator.hasNext()) { - iterator.next(); - i++; - } - return i; - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.transaction.domain", - repositoryPackages = "org.springframework.data.neo4j.transaction.repo") - @ComponentScan("org.springframework.data.neo4j.transaction.service") - static class ApplicationConfig {} -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/MapPropertiesTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/MapPropertiesTests.java deleted file mode 100644 index 7a6f76927..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/MapPropertiesTests.java +++ /dev/null @@ -1,131 +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.transaction; - -import static org.assertj.core.api.Assertions.*; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.data.neo4j.transaction.domain.ThreadInfo; -import org.springframework.data.neo4j.transaction.repo.ThreadInfoRepository; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MapPropertiesTests.ApplicationConfig.class) -@RunWith(SpringRunner.class) -public class MapPropertiesTests { - - @Autowired - private ThreadInfoRepository threadInfoRepository; - - @Autowired - private ThreadInfoService threadInfoService; - - @Autowired - private TransactionTemplate transactionTemplate; - - @Test // DATAGRAPH-1247 and OGM GH-655 - public void mapPropertiesShouldBeDeletable() { - - for (Map clearedMap : new Map[] { - Collections.emptyMap(), - new HashMap(), - null, - }) { - Long threadInfoId = transactionTemplate.execute(t -> { - ThreadInfo threadInfo = new ThreadInfo(); - threadInfo.getServiceRelationship().put("a", 1L); - threadInfoRepository.save(threadInfo); - return threadInfo.getId(); - }); - - transactionTemplate.executeWithoutResult((status) -> { - ThreadInfo threadInfo = threadInfoRepository.findById(threadInfoId).get(); - assertThat(threadInfo.getServiceRelationship()).containsEntry("a", 1L); - - if (clearedMap == Collections.EMPTY_MAP) { - threadInfo.getServiceRelationship().clear(); - } else { - threadInfo.setServiceRelationship(clearedMap); - } - - threadInfoRepository.save(threadInfo); - }); - - ThreadInfo threadInfo = threadInfoRepository.findById(threadInfoId).get(); - assertThat(threadInfo.getServiceRelationship()).isEmpty(); - } - } - - @Test // DATAGRAPH-1247 and OGM GH-655 - public void mapPropertiesShouldBeDeletableInsideDeclarativeTransactions() { - Long threadInfoId = transactionTemplate.execute(t -> { - ThreadInfo threadInfo = new ThreadInfo(); - threadInfo.getServiceRelationship().put("a", 1L); - threadInfoRepository.save(threadInfo); - return threadInfo.getId(); - }); - - threadInfoService.recommendedWayOfDoingComplexUpdates(threadInfoId); - - ThreadInfo threadInfo = threadInfoRepository.findById(threadInfoId).get(); - assertThat(threadInfo.getServiceRelationship()).isEmpty(); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.transaction.domain", - repositoryPackages = "org.springframework.data.neo4j.transaction.repo") - @EnableTransactionManagement - static class ApplicationConfig { - @Bean - public ThreadInfoService threadInfoService(ThreadInfoRepository threadInfoRepository) { - return new ThreadInfoService(threadInfoRepository); - } - } - - static class ThreadInfoService { - private final ThreadInfoRepository threadInfoRepository; - - public ThreadInfoService(ThreadInfoRepository threadInfoRepository) { - this.threadInfoRepository = threadInfoRepository; - } - - @Transactional - public void recommendedWayOfDoingComplexUpdates(Long id) { - - this.threadInfoRepository.findById(id).ifPresent(threadInfo -> { - threadInfo.setMethod("The method"); - threadInfo.setServiceRelationship(Collections.emptyMap()); - - threadInfoRepository.save(threadInfo); - }); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/Neo4jTransactionManagerTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/Neo4jTransactionManagerTests.java deleted file mode 100644 index 194aba41d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/Neo4jTransactionManagerTests.java +++ /dev/null @@ -1,435 +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.transaction; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -import static org.mockito.BDDMockito.*; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.neo4j.ogm.model.Result; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.neo4j.ogm.transaction.Transaction; -import org.springframework.transaction.CannotCreateTransactionException; -import org.springframework.transaction.UnexpectedRollbackException; -import org.springframework.transaction.support.TransactionCallback; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.transaction.support.TransactionTemplate; - -/** - * @author Mark Angrish - */ -public class Neo4jTransactionManagerTests { - - private SessionFactory sf; - - private Session session; - - private Transaction tx; - - private Neo4jTransactionManager tm; - - private TransactionTemplate tt; - - @Before - public void setUp() throws Exception { - sf = mock(SessionFactory.class); - session = mock(Session.class); - tx = mock(Transaction.class); - - tm = new Neo4jTransactionManager(sf); - tt = new TransactionTemplate(tm); - - given(session.getTransaction()).willReturn(tx); - given(sf.openSession()).willReturn(session); - - tm.setSessionFactory(sf); - tt.setTransactionManager(tm); - } - - @After - public void tearDown() throws Exception { - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); - assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); - assertThat(TransactionSynchronizationManager.isCurrentTransactionReadOnly()) - .isFalse(); - assertThat(TransactionSynchronizationManager.isActualTransactionActive()) - .isFalse(); - } - - @Test - public void testFailBegin() throws Exception { - - given(session.beginTransaction(any(Transaction.Type.class), anyCollection())).willThrow(RuntimeException.class); - given(session.getTransaction()).willReturn(null); - - try { - tt.execute(status -> { - return null; - }); - fail("Should not have executed"); - } catch (CannotCreateTransactionException ex) { - // expected - } - } - - @Test - public void testTransactionCommit() throws Exception { - - final List list = new ArrayList(); - HashMap entry = new HashMap<>(); - entry.put("test", "test"); - list.add(entry); - - Result res = mock(Result.class); - - given(session.query("some query string", Collections. emptyMap())).willReturn(res); - given(res.queryResults()).willReturn(list); - - assertThat(!TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization already has a thread bound session") - .isTrue(); - assertThat(!TransactionSynchronizationManager.isSynchronizationActive()) - .as("Synchronizations not active").isTrue(); - - Object result = tt.execute((TransactionCallback) status -> { - assertThat(TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization doesn't have a thread bound session") - .isTrue(); - assertThat(TransactionSynchronizationManager.isCurrentTransactionReadOnly()) - .isFalse(); - assertThat(TransactionSynchronizationManager.isActualTransactionActive()) - .isTrue(); - Session session = ((SessionHolder) TransactionSynchronizationManager.getResource(sf)).getSession(); - return session.query("some query string", Collections. emptyMap()).queryResults(); - }); - - assertThat(result == list).as("Incorrect result list").isTrue(); - assertThat(!TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization still has a thread bound session") - .isTrue(); - assertThat(!TransactionSynchronizationManager.isSynchronizationActive()) - .as("Synchronizations not active").isTrue(); - - verify(session).beginTransaction(any(Transaction.Type.class), anyCollection()); - verify(tx).commit(); - verify(tx).close(); - } - - @Test - public void testTransactionRollback() throws Exception { - - assertThat(!TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization already has a thread bound session") - .isTrue(); - assertThat(!TransactionSynchronizationManager.isSynchronizationActive()) - .as("Synchronizations not active").isTrue(); - - try { - tt.execute(status -> { - assertThat(TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization doesn't have a thread bound session") - .isTrue(); - throw new RuntimeException("application exception"); - }); - fail("Should have thrown RuntimeException"); - } catch (RuntimeException ex) { - // expected - } - - assertThat(!TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization still has a thread bound session") - .isTrue(); - assertThat(!TransactionSynchronizationManager.isSynchronizationActive()) - .as("Synchronizations not active").isTrue(); - - verify(session).beginTransaction(any(Transaction.Type.class), anyCollection()); - verify(tx).rollback(); - verify(tx).close(); - } - - @Test - public void testTransactionRollbackOnly() throws Exception { - - assertThat(!TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization already has a thread bound session") - .isTrue(); - - tt.execute(status -> { - assertThat(TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization doesn't have a thread bound session") - .isTrue(); - status.setRollbackOnly(); - return null; - }); - - assertThat(!TransactionSynchronizationManager.hasResource(sf)) - .as("Transaction Synchronization still has a thread bound session") - .isTrue(); - - verify(session).beginTransaction(any(Transaction.Type.class), anyCollection()); - verify(tx).rollback(); - verify(tx).close(); - } - - @Test - public void testParticipatingTransactionWithCommit() throws Exception { - final List l = new ArrayList(); - l.add("test"); - - Object result = tt.execute(status -> tt.execute((TransactionCallback) status1 -> l)); - assertThat(result == l).as("Correct result list").isTrue(); - - verify(session).beginTransaction(any(Transaction.Type.class), anyCollection()); - verify(tx).commit(); - verify(tx).close(); - } - - @Test - public void testParticipatingTransactionWithRollback() throws Exception { - - try { - tt.execute(status -> tt.execute(status1 -> { - throw new RuntimeException("application exception"); - })); - fail("Should have thrown RuntimeException"); - } catch (RuntimeException ex) { - // expected - } - - verify(session).beginTransaction(any(Transaction.Type.class), anyCollection()); - verify(tx).rollback(); - verify(tx).close(); - } - - @Test - @Ignore - public void testParticipatingTransactionWithRollbackOnly() throws Exception { - - try { - tt.execute(status -> tt.execute(status1 -> { - status1.setRollbackOnly(); - return null; - })); - fail("Should have thrown UnexpectedRollbackException"); - } catch (UnexpectedRollbackException ex) { - // expected - } - - verify(session).beginTransaction(any(Transaction.Type.class), anyCollection()); - verify(tx).rollback(); - verify(tx).close(); - } - - // - // @Test - // public void testTransactionCommitWithPreBound() throws Exception { - // tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE); - // final List l = new ArrayList(); - // l.add("test"); - // assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); - // TransactionSynchronizationManager.bindResource(sf, new SessionHolder(session)); - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // - // Object result = tt.execute(new TransactionCallback() { - // @Override - // public Object doInTransaction(TransactionStatus status) { - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sf); - // assertTrue("Has thread transaction", sessionHolder.getSession().getTransaction() != null); - // Session sess = ((SessionHolder) TransactionSynchronizationManager.getResource(sf)).getSession(); - // assertEquals(session, sess); - // return l; - // } - // }); - // assertTrue("Correct result list", result == l); - // - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sf); - // assertTrue("Hasn't thread transaction", sessionHolder.getSession().getTransaction() == null); - // TransactionSynchronizationManager.unbindResource(sf); - // assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); - // - // verify(tx).commit(); - // } - // - // @Test - // public void testTransactionRollbackWithPreBound() throws Exception { - // - // final Transaction tx1 = mock(Transaction.class); - // final Transaction tx2 = mock(Transaction.class); - // - // given(session.beginTransaction()).willReturn(tx1, tx2); - // - // tm.setSessionFactory(sf); - // assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); - // TransactionSynchronizationManager.bindResource(sf, new SessionHolder(session)); - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // - // try { - // tt.execute(new TransactionCallbackWithoutResult() { - // @Override - // public void doInTransactionWithoutResult(TransactionStatus status) { - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sf); - // assertEquals(tx1, sessionHolder.getSession().getTransaction()); - // tt.execute(new TransactionCallbackWithoutResult() { - // @Override - // public void doInTransactionWithoutResult(TransactionStatus status) { - // status.setRollbackOnly(); - // Session sess = ((SessionHolder) TransactionSynchronizationManager.getResource(sf)).getSession(); - // assertEquals(session, sess); - // } - // }); - // } - // }); - // fail("Should have thrown UnexpectedRollbackException"); - // } - // catch (UnexpectedRollbackException ex) { - // // expected - // } - // - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sf); - // assertTrue("Hasn't thread transaction", sessionHolder.getSession().getTransaction() == null); - // assertTrue("Not marked rollback-only", !sessionHolder.isRollbackOnly()); - // - // tt.execute(new TransactionCallbackWithoutResult() { - // @Override - // public void doInTransactionWithoutResult(TransactionStatus status) { - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.getResource(sf); - // assertEquals(tx2, sessionHolder.getSession().getTransaction()); - // Session sess = ((SessionHolder) TransactionSynchronizationManager.getResource(sf)).getSession(); - // assertEquals(session, sess); - // } - // }); - // - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // assertTrue("Hasn't thread transaction", sessionHolder.getSession().getTransaction() == null); - // TransactionSynchronizationManager.unbindResource(sf); - // assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); - // - // verify(tx1).rollback(); - // verify(tx2).commit(); - // InOrder ordered = inOrder(session); - // ordered.verify(session).clear(); - // } - // - // - // @Test - // public void testTransactionCommitWithNonExistingDatabase() throws Exception { - // tm.setSessionFactory(sf); - // tm.afterPropertiesSet(); - // TransactionTemplate tt = new TransactionTemplate(tm); - // tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE); - // tt.setTimeout(10); - // assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf)); - // assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); - // - // try { - // tt.execute(new TransactionCallback() { - // @Override - // public Object doInTransaction(TransactionStatus status) { - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // Session session = ((SessionHolder) TransactionSynchronizationManager.getResource(sf)).getSession(); - // return session.query("from java.lang.Object", Collections.emptyMap()).queryResults(); - // } - // }); - // fail("Should have thrown CannotCreateTransactionException"); - // } - // catch (CannotCreateTransactionException ex) { - // // expected - // } - // - // assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf)); - // assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); - // } - // - // @Test - // public void testTransactionCommitWithPreBoundSessionAndNonExistingDatabase() throws Exception { - // tm.setSessionFactory(sf); - // tm.afterPropertiesSet(); - // tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE); - // tt.setTimeout(10); - // assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf)); - // assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); - // - // Session session = sf.openSession(); - // TransactionSynchronizationManager.bindResource(sf, new SessionHolder(session)); - // try { - // tt.execute(new TransactionCallback() { - // @Override - // public Object doInTransaction(TransactionStatus status) { - // assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf)); - // Session session = ((SessionHolder) TransactionSynchronizationManager.getResource(sf)).getSession(); - // return session.query("from java.lang.Object", Collections.emptyMap()).queryResults(); - // } - // }); - // fail("Should have thrown CannotCreateTransactionException"); - // } - // catch (CannotCreateTransactionException ex) { - // // expected - // SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sf); - // assertFalse(holder.isSynchronizedWithTransaction()); - // } - // finally { - // TransactionSynchronizationManager.unbindResource(sf); - // } - // - // assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf)); - // assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive()); - // } - // - // - // @Test - // public void testTransactionCommitWithRollbackException() { - // willThrow(new RuntimeException()).given(tx).commit(); - // - // final List l = new ArrayList<>(); - // l.add("test"); - // - // assertTrue(!TransactionSynchronizationManager.hasResource(sf)); - // assertTrue(!TransactionSynchronizationManager.isSynchronizationActive()); - // - // try { - // Object result = tt.execute(new TransactionCallback() { - // @Override - // public Object doInTransaction(TransactionStatus status) { - // assertTrue(TransactionSynchronizationManager.hasResource(sf)); - // return l; - // } - // }); - // assertSame(l, result); - // } catch (TransactionSystemException tse) { - // // expected - // assertTrue(tse.getCause() instanceof RuntimeException); - // } - // - // assertTrue(!TransactionSynchronizationManager.hasResource(sf)); - // assertTrue(!TransactionSynchronizationManager.isSynchronizationActive()); - // } - // -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/SessionFactoryUtilsTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/SessionFactoryUtilsTests.java deleted file mode 100644 index 109092050..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/SessionFactoryUtilsTests.java +++ /dev/null @@ -1,82 +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.transaction; - -import org.junit.Test; -import org.neo4j.ogm.exception.CypherException; -import org.neo4j.ogm.exception.core.BaseClassNotFoundException; -import org.springframework.core.NestedRuntimeException; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.neo4j.exception.UncategorizedNeo4jException; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Mark Angrish - * @author Michael J. Simons - */ -public class SessionFactoryUtilsTests { - - @Test - public void translateMappingException() { - BaseClassNotFoundException bcnfe = new BaseClassNotFoundException("Classname"); - DataAccessException translatedException = SessionFactoryUtils.convertOgmAccessException(bcnfe); - expectExceptionWithCauseMessage(translatedException, InvalidDataAccessApiUsageException.class, null); - } - - @Test - public void translateToDataIntegrityException() { - CypherException ce = new CypherException("Neo.ClientError.Schema.ConstraintValidationFailed", - "Cypher Exception caused by:"); - DataAccessException translatedException = SessionFactoryUtils.convertOgmAccessException(ce); - expectExceptionWithCauseMessage(translatedException, DataIntegrityViolationException.class, null); - } - - @Test - public void translateToUncategorizedNeo4jException() { - - CypherException ce = new CypherException("A.New.Neo.Error", "Cypher Exception caused by:"); - - DataAccessException translatedException = SessionFactoryUtils.convertOgmAccessException(ce); - - expectExceptionWithCauseMessage(translatedException, UncategorizedNeo4jException.class); - } - - @Test - public void translateUnsupportedException() { - - RuntimeException exception = new RuntimeException(); - assertThat(SessionFactoryUtils.convertOgmAccessException(exception)).isNull(); - } - - private static void expectExceptionWithCauseMessage(NestedRuntimeException e, - Class type) { - expectExceptionWithCauseMessage(e, type, null); - } - - private static void expectExceptionWithCauseMessage(NestedRuntimeException e, - Class type, String message) { - - assertThat(e).isInstanceOf(type); - - if (message != null) { - assertThat(e.getRootCause()).isNotNull(); - assertThat(e.getRootCause().getMessage()).contains(message); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/SharedSessionCreatorTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/SharedSessionCreatorTests.java deleted file mode 100644 index 7f1093b0e..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/SharedSessionCreatorTests.java +++ /dev/null @@ -1,51 +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.transaction; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; - -import org.junit.Test; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; - -/** - * Unit tests for {@link SharedSessionCreator}. - * - * @author Mark Angrish - */ -public class SharedSessionCreatorTests { - - @Test - public void proxyingWorksIfInfoReturnsNullSessionInterface() { - SessionFactory sessionFactory = mock(SessionFactory.class); - assertThat(SharedSessionCreator.createSharedSession(sessionFactory)).isNotNull(); - } - - @Test(expected = IllegalStateException.class) - public void transactionRequiredExceptionOnPersist() { - SessionFactory sessionFactory = mock(SessionFactory.class); - Session session = SharedSessionCreator.createSharedSession(sessionFactory); - session.save(new Object()); - } - - @Test(expected = IllegalStateException.class) - public void transactionRequiredExceptionOnDelete() { - SessionFactory sessionFactory = mock(SessionFactory.class); - Session session = SharedSessionCreator.createSharedSession(sessionFactory); - session.delete(new Object()); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionIntegrationTests.java deleted file mode 100644 index 60732e8a1..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionIntegrationTests.java +++ /dev/null @@ -1,86 +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.transaction; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.event.TransactionData; -import org.neo4j.graphdb.event.TransactionEventHandler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; -import org.springframework.data.neo4j.examples.movies.service.UserService; -import org.springframework.data.neo4j.queries.MoviesContextConfiguration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * @author Michal Bachman - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@RunWith(SpringRunner.class) -public class TransactionIntegrationTests { - - @Autowired private GraphDatabaseService graphDatabaseService; - - @Autowired private UserRepository userRepository; - - @Autowired private UserService userService; - - private TransactionEventHandler.Adapter handler; - - @Before - public void populateDatabase() { - handler = new TransactionEventHandler.Adapter() { - @Override - public Object beforeCommit(TransactionData data) throws Exception { - throw new TransactionInterceptException("Deliberate testing exception"); - } - }; - graphDatabaseService.registerTransactionEventHandler(handler); - } - - @After - public void cleanupHandler() { - graphDatabaseService.unregisterTransactionEventHandler(handler); - } - - @Test(expected = Exception.class) - public void whenImplicitTransactionFailsNothingShouldBeCreated() { - userRepository.save(new User("Michal")); - } - - @Test(expected = Exception.class) - public void whenExplicitTransactionFailsNothingShouldBeCreated() { - userService.saveWithTxAnnotationOnInterface(new User("Michal")); - } - - @Test(expected = Exception.class) - public void whenExplicitTransactionFailsNothingShouldBeCreated2() { - userService.saveWithTxAnnotationOnImpl(new User("Michal")); - } - - static class TransactionInterceptException extends Exception { - - public TransactionInterceptException(String msg) { - super(msg); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionRollbackTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionRollbackTests.java deleted file mode 100644 index f189ddf2d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionRollbackTests.java +++ /dev/null @@ -1,115 +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.transaction; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Transaction; -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.examples.movies.domain.User; -import org.springframework.data.neo4j.examples.movies.repo.UserRepository; -import org.springframework.data.neo4j.examples.movies.service.UserService; -import org.springframework.data.neo4j.queries.MoviesContextConfiguration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.transaction.AfterTransaction; -import org.springframework.test.context.transaction.TestTransaction; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.support.TransactionTemplate; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -/** - * See DATAGRAPH-967 DATAGRAPH-997 DATAGRAPH-995 DATAGRAPH-989 DATAGRAPH-952. - * - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -@ContextConfiguration(classes = MoviesContextConfiguration.class) -@RunWith(SpringRunner.class) -public class TransactionRollbackTests { - - @Autowired private GraphDatabaseService graphDatabaseService; - - @Autowired private UserRepository userRepository; - - @Autowired private UserService userService; - - @Autowired private Session session; - - @Autowired private TransactionTemplate transactionTemplate; - - @Before - public void clearDatabase() { - graphDatabaseService.execute("MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE r, n"); - } - - @AfterTransaction - public void checkOgmTransactionIsCleanedup() { - assertThat(session.getTransaction()).isNull(); - } - - @Test - public void queryErrorShouldRollbackAndThrowDataAccessException() { - - try { - transactionTemplate.execute((TransactionStatus tx) -> { - User user = new User("foo"); - userRepository.save(user); - try { - userRepository.invalidQuery(); - } finally { - assertThat(TestTransaction.isFlaggedForRollback()).isTrue(); - } - return null; - }); - fail("Should have thrown DataAccessException"); - } catch (Exception e) { - // expected - } - assertThat(TestTransaction.isActive()).isFalse(); - try (Transaction tx = graphDatabaseService.beginTx()) { - assertThat(graphDatabaseService.getAllNodes().iterator().hasNext()).isFalse(); - tx.success(); - } - } - - @Test // GH-10098 - @Ignore("When an error occurs when doing a request, Neo rollbacks. See https://github.com/neo4j/neo4j/issues/10098") - public void catchedExceptionShouldNotRollback() { - - transactionTemplate.execute((TransactionStatus tx) -> { - userRepository.save(new User("foo")); - try { - userRepository.invalidQuery(); - fail("Should have failed because of invalid query"); - } catch (Exception e) { - assertThat(TestTransaction.isActive()).isTrue(); - } - userRepository.save(new User("bar")); - return null; - }); - try (Transaction tx = graphDatabaseService.beginTx()) { - assertThat(graphDatabaseService.getAllNodes().stream().count()).isEqualTo(2); - tx.success(); - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionalEventListenerTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionalEventListenerTests.java deleted file mode 100644 index c2c8e5608..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/TransactionalEventListenerTests.java +++ /dev/null @@ -1,570 +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.transaction; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -import static org.springframework.transaction.event.TransactionPhase.*; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.event.EventListener; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.event.TransactionalEventListener; -import org.springframework.transaction.event.TransactionalEventListenerFactory; -import org.springframework.transaction.support.AbstractPlatformTransactionManager; -import org.springframework.transaction.support.DefaultTransactionStatus; -import org.springframework.transaction.support.TransactionCallback; -import org.springframework.transaction.support.TransactionSynchronizationAdapter; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.transaction.support.TransactionTemplate; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; - -/** - * These tests are copied from the - * spring framework transactional event listener tests and modified to work with a version of the - * Neo4jTransactionManager. - * - * See DATAGRAPH-883 - * - * @author Mark Angrish - * @author Michael J. Simons - */ -public class TransactionalEventListenerTests { - - private ConfigurableApplicationContext context; - - private EventCollector eventCollector; - - private TransactionTemplate transactionTemplate = new TransactionTemplate(new CallCountingTransactionManager()); - - @Before - public void closeContext() { - if (this.context != null) { - this.context.close(); - } - } - - @Test - public void immediately() { - load(ImmediateTestListener.class); - this.transactionTemplate.execute(status -> { - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "test"); - TransactionalEventListenerTests.this.getEventCollector().assertTotalEventsCount(1); - return null; - }); - getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "test"); - getEventCollector().assertTotalEventsCount(1); - } - - @Test - public void immediatelyImpactsCurrentTransaction() { - load(ImmediateTestListener.class, BeforeCommitTestListener.class); - try { - this.transactionTemplate.execute(status -> { - TransactionalEventListenerTests.this.getContext().publishEvent("FAIL"); - fail("Should have thrown an exception at this point"); - return null; - }); - } catch (IllegalStateException e) { - assertThat(e.getMessage().contains("Test exception")).isTrue(); - assertThat(e.getMessage().contains(EventCollector.IMMEDIATELY)).isTrue(); - } - getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "FAIL"); - getEventCollector().assertTotalEventsCount(1); - } - - @Test - public void afterCompletionCommit() { - load(AfterCompletionTestListener.class); - this.transactionTemplate.execute(status -> { - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - return null; - }); - getEventCollector().assertEvents(EventCollector.AFTER_COMPLETION, "test"); - getEventCollector().assertTotalEventsCount(1); // After rollback not invoked - } - - @Test - public void afterCompletionRollback() { - load(AfterCompletionTestListener.class); - this.transactionTemplate.execute(status -> { - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - status.setRollbackOnly(); - return null; - }); - getEventCollector().assertEvents(EventCollector.AFTER_COMPLETION, "test"); - getEventCollector().assertTotalEventsCount(1); // After rollback not invoked - } - - @Test - public void afterCommit() { - load(AfterCompletionExplicitTestListener.class); - this.transactionTemplate.execute(status -> { - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - return null; - }); - getEventCollector().assertEvents(EventCollector.AFTER_COMMIT, "test"); - getEventCollector().assertTotalEventsCount(1); // After rollback not invoked - } - - @Test - public void afterCommitWithTransactionalComponentListenerProxiedViaDynamicProxy() { - load(AfterCompletionTestListener.class, TransactionalComponentTestListener.class); - this.transactionTemplate.execute(status -> { - TransactionalEventListenerTests.this.getContext().publishEvent("SKIP"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - return null; - }); - getEventCollector().assertNoEventReceived(); - } - - @Test - public void afterRollback() { - load(AfterCompletionExplicitTestListener.class); - this.transactionTemplate.execute(status -> { - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - status.setRollbackOnly(); - return null; - }); - getEventCollector().assertEvents(EventCollector.AFTER_ROLLBACK, "test"); - getEventCollector().assertTotalEventsCount(1); // After commit not invoked - } - - @Test - public void beforeCommit() { - load(BeforeCommitTestListener.class); - this.transactionTemplate.execute(status -> { - TransactionSynchronizationManager.registerSynchronization(new EventTransactionSynchronization(10) { - @Override - public void beforeCommit(boolean readOnly) { - getEventCollector().assertNoEventReceived(); // Not seen yet - } - }); - TransactionSynchronizationManager.registerSynchronization(new EventTransactionSynchronization(20) { - @Override - public void beforeCommit(boolean readOnly) { - getEventCollector().assertEvents(EventCollector.BEFORE_COMMIT, "test"); - getEventCollector().assertTotalEventsCount(1); - } - }); - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - return null; - }); - getEventCollector().assertEvents(EventCollector.BEFORE_COMMIT, "test"); - getEventCollector().assertTotalEventsCount(1); - } - - @Test - public void beforeCommitWithException() { // Validates the custom synchronization is invoked - load(BeforeCommitTestListener.class); - try { - this.transactionTemplate.execute(status -> { - TransactionSynchronizationManager.registerSynchronization(new EventTransactionSynchronization(10) { - @Override - public void beforeCommit(boolean readOnly) { - throw new IllegalStateException("test"); - } - }); - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - return null; - }); - fail("Should have thrown an exception"); - } catch (IllegalStateException e) { - // Test exception - ignore - } - getEventCollector().assertNoEventReceived(); // Before commit not invoked - } - - @Test - public void regularTransaction() { - load(ImmediateTestListener.class, BeforeCommitTestListener.class, AfterCompletionExplicitTestListener.class); - this.transactionTemplate.execute(new TransactionCallback() { - @Override - public Object doInTransaction(TransactionStatus status) { - TransactionSynchronizationManager.registerSynchronization(new EventTransactionSynchronization(10) { - @Override - public void beforeCommit(boolean readOnly) { - getEventCollector().assertTotalEventsCount(1); // Immediate event - getEventCollector().assertEvents(EventCollector.IMMEDIATELY, "test"); - } - }); - TransactionSynchronizationManager.registerSynchronization(new EventTransactionSynchronization(20) { - @Override - public void beforeCommit(boolean readOnly) { - getEventCollector().assertEvents(EventCollector.BEFORE_COMMIT, "test"); - getEventCollector().assertTotalEventsCount(2); - } - }); - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertTotalEventsCount(1); - return null; - } - }); - getEventCollector().assertEvents(EventCollector.AFTER_COMMIT, "test"); - getEventCollector().assertTotalEventsCount(3); // Immediate, before commit, after commit - } - - @Test - public void noTransaction() { - load(BeforeCommitTestListener.class, AfterCompletionTestListener.class, AfterCompletionExplicitTestListener.class); - this.context.publishEvent("test"); - getEventCollector().assertTotalEventsCount(0); - } - - @Test - public void noTransactionWithFallbackExecution() { - load(FallbackExecutionTestListener.class); - this.context.publishEvent("test"); - this.eventCollector.assertEvents(EventCollector.BEFORE_COMMIT, "test"); - this.eventCollector.assertEvents(EventCollector.AFTER_COMMIT, "test"); - this.eventCollector.assertEvents(EventCollector.AFTER_ROLLBACK, "test"); - this.eventCollector.assertEvents(EventCollector.AFTER_COMPLETION, "test"); - getEventCollector().assertTotalEventsCount(4); - } - - @Test - public void conditionFoundOnTransactionalEventListener() { - load(ImmediateTestListener.class); - this.transactionTemplate.execute(new TransactionCallback() { - @Override - public Object doInTransaction(TransactionStatus status) { - TransactionalEventListenerTests.this.getContext().publishEvent("SKIP"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - return null; - } - }); - getEventCollector().assertNoEventReceived(); - } - - @Test - public void afterCommitMetaAnnotation() throws Exception { - load(AfterCommitMetaAnnotationTestListener.class); - this.transactionTemplate.execute(new TransactionCallback() { - @Override - public Object doInTransaction(TransactionStatus status) { - TransactionalEventListenerTests.this.getContext().publishEvent("test"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - return null; - } - }); - getEventCollector().assertEvents(EventCollector.AFTER_COMMIT, "test"); - getEventCollector().assertTotalEventsCount(1); - } - - @Test - public void conditionFoundOnMetaAnnotation() { - load(AfterCommitMetaAnnotationTestListener.class); - this.transactionTemplate.execute(new TransactionCallback() { - @Override - public Object doInTransaction(TransactionStatus status) { - TransactionalEventListenerTests.this.getContext().publishEvent("SKIP"); - TransactionalEventListenerTests.this.getEventCollector().assertNoEventReceived(); - return null; - } - }); - getEventCollector().assertNoEventReceived(); - } - - protected EventCollector getEventCollector() { - return eventCollector; - } - - protected ConfigurableApplicationContext getContext() { - return context; - } - - private void load(Class... classes) { - List> allClasses = new ArrayList<>(); - allClasses.add(BasicConfiguration.class); - allClasses.addAll(Arrays.asList(classes)); - doLoad(allClasses.toArray(new Class[allClasses.size()])); - } - - private void doLoad(Class... classes) { - this.context = new AnnotationConfigApplicationContext(classes); - this.eventCollector = this.context.getBean(EventCollector.class); - } - - @Configuration - static class BasicConfiguration { - - @Bean // set automatically with tx management - public TransactionalEventListenerFactory transactionalEventListenerFactory() { - return new TransactionalEventListenerFactory(); - } - - @Bean - public EventCollector eventCollector() { - return new EventCollector(); - } - } - - @EnableTransactionManagement - @Configuration - static class TransactionalConfiguration { - - @Bean - public CallCountingTransactionManager transactionManager() { - return new CallCountingTransactionManager(); - } - } - - static class EventCollector { - - public static final String IMMEDIATELY = "IMMEDIATELY"; - - public static final String BEFORE_COMMIT = "BEFORE_COMMIT"; - - public static final String AFTER_COMPLETION = "AFTER_COMPLETION"; - - public static final String AFTER_COMMIT = "AFTER_COMMIT"; - - public static final String AFTER_ROLLBACK = "AFTER_ROLLBACK"; - - public static final String[] ALL_PHASES = { IMMEDIATELY, BEFORE_COMMIT, AFTER_COMMIT, AFTER_ROLLBACK }; - - private final MultiValueMap events = new LinkedMultiValueMap<>(); - - public void addEvent(String phase, Object event) { - this.events.add(phase, event); - } - - public List getEvents(String phase) { - List v; - return (((v = events.get(phase)) != null) || events.containsKey(phase)) ? v : Collections.emptyList(); - } - - public void assertNoEventReceived(String... phases) { - if (phases.length == 0) { // All values if none set - phases = ALL_PHASES; - } - for (String phase : phases) { - List eventsForPhase = getEvents(phase); - assertThat(eventsForPhase).describedAs("Expected no events for phase '" + phase + "' " + "but got " + eventsForPhase + ":").isEmpty(); - } - } - - public void assertEvents(String phase, Object... expected) { - List actual = getEvents(phase); - assertThat(actual).describedAs("wrong number of events for phase '" + phase + "'").hasSameSizeAs(expected).containsAnyOf(expected); - } - - public void assertTotalEventsCount(int number) { - int size = 0; - for (Map.Entry> entry : this.events.entrySet()) { - size += entry.getValue().size(); - } - assertThat(size).describedAs("Wrong number of total events (" + this.events.size() + ") " + "registered phase(s)").isEqualTo(number); - } - } - - static abstract class BaseTransactionalTestListener { - - static final String FAIL_MSG = "FAIL"; - - @Autowired private EventCollector eventCollector; - - public void handleEvent(String phase, String data) { - this.eventCollector.addEvent(phase, data); - if (FAIL_MSG.equals(data)) { - throw new IllegalStateException("Test exception on phase '" + phase + "'"); - } - } - } - - @Component - static class ImmediateTestListener extends BaseTransactionalTestListener { - - @EventListener(condition = "!'SKIP'.equals(#data)") - public void handleImmediately(String data) { - handleEvent(EventCollector.IMMEDIATELY, data); - } - } - - @Component - static class AfterCompletionTestListener extends BaseTransactionalTestListener { - - @TransactionalEventListener(phase = AFTER_COMPLETION) - public void handleAfterCompletion(String data) { - handleEvent(EventCollector.AFTER_COMPLETION, data); - } - } - - @Component - static class AfterCompletionExplicitTestListener extends BaseTransactionalTestListener { - - @TransactionalEventListener(phase = AFTER_COMMIT) - public void handleAfterCommit(String data) { - handleEvent(EventCollector.AFTER_COMMIT, data); - } - - @TransactionalEventListener(phase = AFTER_ROLLBACK) - public void handleAfterRollback(String data) { - handleEvent(EventCollector.AFTER_ROLLBACK, data); - } - } - - @Transactional - @Component - static interface TransactionalComponentTestListenerInterface { - - // Cannot use #data in condition due to dynamic proxy. - @TransactionalEventListener(condition = "!'SKIP'.equals(#p0)") - void handleAfterCommit(String data); - } - - static class TransactionalComponentTestListener extends BaseTransactionalTestListener - implements TransactionalComponentTestListenerInterface { - - @Override - public void handleAfterCommit(String data) { - handleEvent(EventCollector.AFTER_COMMIT, data); - } - } - - @Component - static class BeforeCommitTestListener extends BaseTransactionalTestListener { - - @TransactionalEventListener(phase = BEFORE_COMMIT) - @Order(15) - public void handleBeforeCommit(String data) { - handleEvent(EventCollector.BEFORE_COMMIT, data); - } - } - - @Component - static class FallbackExecutionTestListener extends BaseTransactionalTestListener { - - @TransactionalEventListener(phase = BEFORE_COMMIT, fallbackExecution = true) - public void handleBeforeCommit(String data) { - handleEvent(EventCollector.BEFORE_COMMIT, data); - } - - @TransactionalEventListener(phase = AFTER_COMMIT, fallbackExecution = true) - public void handleAfterCommit(String data) { - handleEvent(EventCollector.AFTER_COMMIT, data); - } - - @TransactionalEventListener(phase = AFTER_ROLLBACK, fallbackExecution = true) - public void handleAfterRollback(String data) { - handleEvent(EventCollector.AFTER_ROLLBACK, data); - } - - @TransactionalEventListener(phase = AFTER_COMPLETION, fallbackExecution = true) - public void handleAfterCompletion(String data) { - handleEvent(EventCollector.AFTER_COMPLETION, data); - } - } - - @TransactionalEventListener(phase = AFTER_COMMIT, condition = "!'SKIP'.equals(#p0)") - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.RUNTIME) - @interface AfterCommitEventListener { - - } - - @Component - static class AfterCommitMetaAnnotationTestListener extends BaseTransactionalTestListener { - - @AfterCommitEventListener - public void handleAfterCommit(String data) { - handleEvent(EventCollector.AFTER_COMMIT, data); - } - } - - static class EventTransactionSynchronization extends TransactionSynchronizationAdapter { - - private final int order; - - EventTransactionSynchronization(int order) { - this.order = order; - } - - @Override - public int getOrder() { - return order; - } - } - - @SuppressWarnings("serial") - static class CallCountingTransactionManager extends AbstractPlatformTransactionManager { - - public TransactionDefinition lastDefinition; - public int begun; - public int commits; - public int rollbacks; - public int inflight; - - @Override - protected Object doGetTransaction() { - return new Object(); - } - - @Override - protected void doBegin(Object transaction, TransactionDefinition definition) { - this.lastDefinition = definition; - ++begun; - ++inflight; - } - - @Override - protected void doCommit(DefaultTransactionStatus status) { - ++commits; - --inflight; - } - - @Override - protected void doRollback(DefaultTransactionStatus status) { - ++rollbacks; - --inflight; - } - - public void clear() { - begun = commits = rollbacks = inflight = 0; - } - - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/domain/ThreadInfo.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/domain/ThreadInfo.java deleted file mode 100644 index 9eb50421b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/domain/ThreadInfo.java +++ /dev/null @@ -1,70 +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.transaction.domain; - -import java.util.HashMap; -import java.util.Map; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.Index; -import org.neo4j.ogm.annotation.Properties; - -/** - * @author Michael J. Simons - */ -public class ThreadInfo { - @Id - @GeneratedValue - private Long id; - @Index - private String name; - @Index(unique = true) - private String method; - @Properties - private Map serviceRelationship = new HashMap<>(); - - public ThreadInfo() { - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getMethod() { - return method; - } - - public void setMethod(String method) { - this.method = method; - } - - public Map getServiceRelationship() { - return serviceRelationship; - } - - public void setServiceRelationship(Map serviceRelationship) { - this.serviceRelationship = serviceRelationship; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/domain/User.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/domain/User.java deleted file mode 100644 index 2dfd63dac..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/domain/User.java +++ /dev/null @@ -1,55 +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.transaction.domain; - -import org.neo4j.ogm.annotation.Transient; - -/** - * @author Michal Bachman - */ -public class User { - - private Long id; - private String name; - @Transient private String species; - - public User() {} - - public Long id() { - return this.id; - } - - public User(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getSpecies() { - return species; - } - - public void setSpecies(String species) { - this.species = species; - } - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/repo/ThreadInfoRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/repo/ThreadInfoRepository.java deleted file mode 100644 index d52031b87..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/repo/ThreadInfoRepository.java +++ /dev/null @@ -1,27 +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.transaction.repo; - -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.neo4j.transaction.domain.ThreadInfo; -import org.springframework.stereotype.Repository; - -/** - * @author Michael J. Simons - */ -@Repository -public interface ThreadInfoRepository extends Neo4jRepository { -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/repo/UserRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/repo/UserRepository.java deleted file mode 100644 index 5fa7560dc..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/repo/UserRepository.java +++ /dev/null @@ -1,31 +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.transaction.repo; - -import java.util.Collection; - -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.neo4j.transaction.domain.User; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - */ -@Repository -public interface UserRepository extends Neo4jRepository { - - Collection findUserByName(String name); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/BusinessService.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/BusinessService.java deleted file mode 100644 index 49ff254e0..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/BusinessService.java +++ /dev/null @@ -1,60 +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.transaction.service; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.neo4j.ogm.session.Session; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author: Vince Bickers - * @author Mark Angrish - */ -@Component -public class BusinessService { - - @Autowired private Session session; - - @Transactional - public void successMethodInTransaction() { - insert(); - } - - @Transactional // throws unchecked exception - public void failMethodInTransaction() { - insert(); - throw new RuntimeException("Deliberately throwing exception"); - } - - // transactional only from service wrapper, throws checked exception - public void throwsException() throws Exception { - insert(); - throw new Exception("Deliberately throwing exception"); - } - - public void insert() { - session.query("CREATE (node {name: 'n'})", Collections.EMPTY_MAP); - } - - public Iterable> fetch() { - return session.query("MATCH (n) RETURN n.name", new HashMap()); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/ServiceA.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/ServiceA.java deleted file mode 100644 index 441b65e4f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/ServiceA.java +++ /dev/null @@ -1,43 +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.transaction.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.transaction.domain.User; -import org.springframework.data.neo4j.transaction.repo.UserRepository; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author vince - */ -@Component -public class ServiceA { - - @Autowired private UserRepository userRepository; - - @Autowired private ServiceB serviceB; - - @Transactional(rollbackFor = Exception.class) - public void run() throws Exception { - saveBilbo(); - serviceB.update(); - } - - public User saveBilbo() { - return userRepository.save(new User("Bilbo baggins")); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/ServiceB.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/ServiceB.java deleted file mode 100644 index 57d717e44..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/ServiceB.java +++ /dev/null @@ -1,47 +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.transaction.service; - -import java.util.Collection; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.transaction.domain.User; -import org.springframework.data.neo4j.transaction.repo.UserRepository; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author vince - */ -@Component -public class ServiceB { - - @Autowired private UserRepository userRepository; - - @Transactional(rollbackFor = Exception.class) - public void update() throws Exception { - getBilbo(); - throw new Exception(); - } - - public User getBilbo() { - Collection userList = userRepository.findUserByName("Bilbo Baggins"); - if (userList.iterator().hasNext()) { - return userList.iterator().next(); - } - return null; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/WrapperService.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/WrapperService.java deleted file mode 100644 index 64347494d..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/transaction/service/WrapperService.java +++ /dev/null @@ -1,65 +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.transaction.service; - -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -/** - * @author: Vince Bickers - */ -@Component -public class WrapperService { - - @Autowired BusinessService businessService; - - @Transactional - public void composeSuccessThenFail() { - businessService.successMethodInTransaction(); - businessService.failMethodInTransaction(); - } - - @Transactional - public void composeSuccessThenSuccess() { - businessService.successMethodInTransaction(); - businessService.successMethodInTransaction(); - } - - @Transactional - public void composeFailThenSuccess() { - businessService.failMethodInTransaction(); - businessService.successMethodInTransaction(); - } - - @Transactional - public void composeFailThenFail() { - businessService.failMethodInTransaction(); - businessService.failMethodInTransaction(); - } - - @Transactional(rollbackFor = Exception.class) - public void rollbackWithCheckedException() throws Exception { - businessService.throwsException(); - } - - @Transactional(readOnly = true) - public Iterable> fetch() { - return businessService.fetch(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/WebIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/WebIntegrationTests.java deleted file mode 100644 index a0351588f..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/WebIntegrationTests.java +++ /dev/null @@ -1,183 +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.web; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.neo4j.test.Neo4jIntegrationTest; -import org.springframework.data.neo4j.web.domain.User; -import org.springframework.data.neo4j.web.repo.UserRepository; -import org.springframework.data.neo4j.web.support.OpenSessionInViewInterceptor; -import org.springframework.mock.web.MockHttpSession; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.result.MockMvcResultMatchers; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -/** - * @author Michal Bachman - * @author Mark Angrish - * @author Michael J. Simons - */ -@WebAppConfiguration -@ContextConfiguration(classes = WebIntegrationTests.WebAppContext.class) -@RunWith(SpringRunner.class) -public class WebIntegrationTests { - - @Autowired private UserRepository userRepository; - - @Autowired private WebApplicationContext wac; - - private MockMvc mockMvc; - - private User adam; - - private User daniela; - - private User michal; - - private User vince; - - @Transactional - @Before - public void setUp() { - - this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); - - adam = new User("Adam"); - daniela = new User("Daniela"); - michal = new User("Michal"); - vince = new User("Vince"); - - adam.befriend(daniela); - daniela.befriend(michal); - michal.befriend(vince); - - // see the @Ignored test below. This doesn't appear to use the same - // transaction definition as the one created in the test method, even though the tx manager is the same. - // consequently the tx definition created by the test method is replaced and the test fails. - - // reason: repository is marked as transactional. However, if we remove the @Transactional - // from the repo and make the test class transactional, the test method - // shouldNotShareSessionBetweenRequestsWithDifferentSession() fails, because the session is bound - // to the transaction - - userRepository.save(adam); - } - - @Test - public void shouldNotShareSessionBetweenRequestsWithDifferentSession() throws Exception { - mockMvc.perform(get("/user/{uuid}/friends", adam.getUuid())).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Daniela")); - - mockMvc.perform(get("/user/{uuid}/friends", vince.getUuid())).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Michal")); - } - - @Test - public void shouldShareSessionBetweenRequestsDuringSameSession() throws Exception { - MockHttpSession session = new MockHttpSession(); - - mockMvc.perform(get("/user/{uuid}/immediateFriends", adam.getUuid()).session(session)).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Daniela")); - - mockMvc.perform(get("/user/{uuid}/immediateFriends", daniela.getUuid()).session(session)).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Adam Michal")); - - mockMvc.perform(get("/user/{uuid}/immediateFriends", michal.getUuid()).session(session)).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Daniela Vince")); - - mockMvc.perform(get("/user/{uuid}/immediateFriends", vince.getUuid()).session(session)).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Michal")); - } - - @Test - public void shouldNotShareSessionBetweenMultiThreadedRequests() throws Exception { - ExecutorService executor = Executors.newFixedThreadPool(10); - for (int i = 0; i < 100; i++) { - final int j = i; - executor.submit(new Runnable() { - @Override - public void run() { - if (j % 2 == 0) { - try { - mockMvc.perform(get("/user/{uuid}/friends", adam.getUuid())).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Daniela")); - } catch (Exception e) { - throw new RuntimeException(e); - } - } else { - - try { - mockMvc.perform(get("/user/{uuid}/friends", vince.getUuid())).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Michal")); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - }); - } - - executor.shutdown(); - executor.awaitTermination(1, TimeUnit.MINUTES); - } - - @Configuration - @Neo4jIntegrationTest(domainPackages = "org.springframework.data.neo4j.web.domain", - repositoryPackages = "org.springframework.data.neo4j.web.repo") - @ComponentScan({ "org.springframework.data.neo4j.web.controller", "org.springframework.data.neo4j.web.service" }) - @EnableWebMvc - static class WebAppContext { - - @Bean - public OpenSessionInViewInterceptor openSessionInViewInterceptor(SessionFactory sessionFactory) { - OpenSessionInViewInterceptor openSessionInViewInterceptor = new OpenSessionInViewInterceptor(); - openSessionInViewInterceptor.setSessionFactory(sessionFactory); - return openSessionInViewInterceptor; - } - - @Bean - public WebMvcConfigurer webMvcConfigurer(OpenSessionInViewInterceptor openSessionInViewInterceptor) { - return new WebMvcConfigurer() { - @Override - public void addInterceptors(InterceptorRegistry registry) { - registry.addWebRequestInterceptor(openSessionInViewInterceptor); - } - }; - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/XmlApplicationContextWebIntegrationTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/XmlApplicationContextWebIntegrationTests.java deleted file mode 100644 index e665ebd32..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/XmlApplicationContextWebIntegrationTests.java +++ /dev/null @@ -1,148 +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.web; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.web.domain.User; -import org.springframework.data.neo4j.web.repo.UserRepository; -import org.springframework.mock.web.MockHttpSession; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.result.MockMvcResultMatchers; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - -/** - * @author Michal Bachman - * @author Mark Angrish - */ -@ContextConfiguration(locations = "/xml-based-configuration-applicationContext.xml") -@WebAppConfiguration -@RunWith(SpringRunner.class) -@Ignore("Make this work with new infrastructure test code.") -public class XmlApplicationContextWebIntegrationTests { - - @Autowired private UserRepository userRepository; - - @Autowired private WebApplicationContext wac; - - private MockMvc mockMvc; - - private User adam; - - private User daniela; - - private User michal; - - private User vince; - - @Before - public void setUp() { - - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); - - adam = new User("Adam"); - daniela = new User("Daniela"); - michal = new User("Michal"); - vince = new User("Vince"); - - adam.befriend(daniela); - daniela.befriend(michal); - michal.befriend(vince); - - // see the @Ignored test below. This doesn't appear to use the same - // transaction definition as the one created in the test method, even though the tx manager is the same. - // consequently the tx definition created by the test method is replaced and the test fails. - - // reason: repository is marked as transactional. However, if we remove the @Transactional - // from the repo and make the test class transactional, the test method - // shouldNotShareSessionBetweenRequestsWithDifferentSession() fails, because the session is bound - // to the transaction - - userRepository.save(adam); - } - - @Test - public void shouldNotShareSessionBetweenRequestsWithDifferentSession() throws Exception { - mockMvc.perform(get("/user/{uuid}/friends", adam.getUuid())).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Daniela")); - - mockMvc.perform(get("/user/{uuid}/friends", vince.getUuid())).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Michal")); - } - - @Test - public void shouldShareSessionBetweenRequestsDuringSameSession() throws Exception { - MockHttpSession session = new MockHttpSession(); - - mockMvc.perform(get("/user/{uuid}/immediateFriends", adam.getUuid()).session(session)).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Daniela")); - - mockMvc.perform(get("/user/{uuid}/immediateFriends", daniela.getUuid()).session(session)).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Adam Michal")); - - mockMvc.perform(get("/user/{uuid}/immediateFriends", michal.getUuid()).session(session)).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Daniela Vince")); - - mockMvc.perform(get("/user/{uuid}/immediateFriends", vince.getUuid()).session(session)).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Michal")); - } - - @Test - public void shouldNotShareSessionBetweenMultiThreadedRequests() throws Exception { - ExecutorService executor = Executors.newFixedThreadPool(10); - for (int i = 0; i < 100; i++) { - final int j = i; - executor.submit(new Runnable() { - @Override - public void run() { - if (j % 2 == 0) { - try { - mockMvc.perform(get("/user/{uuid}/friends", adam.getUuid())).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Daniela")); - } catch (Exception e) { - throw new RuntimeException(e); - } - } else { - - try { - mockMvc.perform(get("/user/{uuid}/friends", vince.getUuid())).andExpect(status().isOk()) - .andExpect(MockMvcResultMatchers.content().string("Michal")); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - }); - } - - executor.shutdown(); - executor.awaitTermination(1, TimeUnit.MINUTES); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/controller/UserController.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/controller/UserController.java deleted file mode 100644 index 2ed9a69cd..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/controller/UserController.java +++ /dev/null @@ -1,83 +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.web.controller; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; - -import javax.servlet.http.HttpSession; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.web.domain.User; -import org.springframework.data.neo4j.web.service.UserService; -import org.springframework.stereotype.Controller; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * @author Michal Bachman - * @author Mark ANgrish - */ -@Controller -public class UserController { - - @Autowired private UserService userService; - - @RequestMapping(value = "/user/{uuid}/friends") - @ResponseBody - @Transactional - public String listFriends(@PathVariable UUID uuid, HttpSession session) { - User user = userService.getUserByUuid(uuid); - - if (user == null) { - return "No such user!"; - } - - StringBuilder result = new StringBuilder(); - for (User friend : userService.getNetwork(user)) { - result.append(friend.getName()).append(" "); - } - - return result.toString().trim(); - } - - @RequestMapping(value = "/user/{uuid}/immediateFriends") - @ResponseBody - @Transactional - public String listImmediateFriends(@PathVariable UUID uuid, HttpSession session) { - User user = userService.getUserByUuid(uuid); - - if (user == null) { - return "No such user!"; - } - - List friends = new ArrayList<>(); - for (User friend : user.getFriends()) { - friends.add(friend.getName()); - } - Collections.sort(friends); - - StringBuilder result = new StringBuilder(); - for (String friend : friends) { - result.append(friend).append(" "); - } - return result.toString().trim(); - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/Cinema.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/Cinema.java deleted file mode 100644 index bfc53ec71..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/Cinema.java +++ /dev/null @@ -1,60 +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.web.domain; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.Index; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Relationship; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.neo4j.ogm.typeconversion.UuidStringConverter; - -/** - * @author Michal Bachman - * @author Mark Angrish - */ -@NodeEntity -public class Cinema { - - @Id @GeneratedValue private Long id; - - @Convert(UuidStringConverter.class) @Index(unique = true) private UUID uuid; - - private String name; - - @Relationship(direction = Relationship.INCOMING) private Set visited; - - public Cinema() {} - - public Cinema(String name) { - this.visited = new HashSet<>(); - this.uuid = UUID.randomUUID(); - this.name = name; - } - - public void addVisitor(User user) { - visited.add(user); - } - - public String getName() { - return name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/Genre.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/Genre.java deleted file mode 100644 index b4e97ac68..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/Genre.java +++ /dev/null @@ -1,58 +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.web.domain; - -import java.util.UUID; - -import org.neo4j.ogm.annotation.GeneratedValue; -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.Index; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.neo4j.ogm.typeconversion.UuidStringConverter; - -/** - * @author Michal Bachman - * @author Mark Angrish - */ -@NodeEntity -public class Genre { - - @Id @GeneratedValue private Long id; - - @Convert(UuidStringConverter.class) @Index(unique = true) private UUID uuid; - - private String name; - - public Genre() {} - - public Genre(String name) { - this.uuid = UUID.randomUUID(); - this.name = name; - } - - public Long getId() { - return id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/User.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/User.java deleted file mode 100644 index 50dc59562..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/User.java +++ /dev/null @@ -1,82 +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.web.domain; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -import org.neo4j.ogm.annotation.Id; -import org.neo4j.ogm.annotation.Index; -import org.neo4j.ogm.annotation.NodeEntity; -import org.neo4j.ogm.annotation.Relationship; -import org.neo4j.ogm.annotation.typeconversion.Convert; -import org.neo4j.ogm.typeconversion.UuidStringConverter; - -/** - * @author Michal Bachman - * @author Mark Angrish - * @author Michael J. Simons - */ -@NodeEntity -public class User { - - @Id @Convert(UuidStringConverter.class) @Index(unique = true) private UUID uuid; - - private String name; - - private Collection interested; - - @Relationship(type = "FRIEND_OF", direction = Relationship.UNDIRECTED) private Set friends; - - public User() {} - - public User(String name) { - this.interested = new HashSet<>(); - this.friends = new HashSet<>(); - this.uuid = UUID.randomUUID(); - this.name = name; - } - - public void interestedIn(Genre genre) { - interested.add(genre); - } - - public void notInterestedIn(Genre genre) { - interested.remove(genre); - } - - public void befriend(User user) { - friends.add(user); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Collection getFriends() { - return friends; - } - - public UUID getUuid() { - return uuid; - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/repo/GenreRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/repo/GenreRepository.java deleted file mode 100644 index bda1e21f3..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/repo/GenreRepository.java +++ /dev/null @@ -1,31 +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.web.repo; - -import java.util.UUID; - -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.neo4j.web.domain.Genre; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - * @author Mark Angrish - */ -@Repository -public interface GenreRepository extends Neo4jRepository { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/repo/UserRepository.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/repo/UserRepository.java deleted file mode 100644 index a31c34dc6..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/repo/UserRepository.java +++ /dev/null @@ -1,32 +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.web.repo; - -import java.util.UUID; - -import org.springframework.data.neo4j.repository.Neo4jRepository; -import org.springframework.data.neo4j.web.domain.User; -import org.springframework.stereotype.Repository; - -/** - * @author Michal Bachman - * @author Mark Angrish - * @author Michael J. Simons - */ -@Repository -public interface UserRepository extends Neo4jRepository { - -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/service/UserService.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/service/UserService.java deleted file mode 100644 index a78144a1c..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/service/UserService.java +++ /dev/null @@ -1,31 +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.web.service; - -import java.util.Collection; -import java.util.UUID; - -import org.springframework.data.neo4j.web.domain.User; - -/** - * @author Michal Bachman - */ -public interface UserService { - - User getUserByUuid(UUID uuid); - - Collection getNetwork(User user); -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/service/UserServiceImpl.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/service/UserServiceImpl.java deleted file mode 100644 index bb8b17d3b..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/service/UserServiceImpl.java +++ /dev/null @@ -1,66 +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.web.service; - -import java.util.Collection; -import java.util.Comparator; -import java.util.Set; -import java.util.TreeSet; -import java.util.UUID; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.neo4j.web.domain.User; -import org.springframework.data.neo4j.web.repo.UserRepository; -import org.springframework.stereotype.Service; - -/** - * @author Michal Bachman - * @author Mark Angrish - * @author Mark Paluch - * @author Jens Schauder - */ -@Service -public class UserServiceImpl implements UserService { - - @Autowired private UserRepository userRepository; - - @Override - public User getUserByUuid(UUID uuid) { - return userRepository.findById(uuid).get(); - } - - @Override - public Collection getNetwork(User user) { - Set network = new TreeSet<>(new Comparator() { - @Override - public int compare(User u1, User u2) { - return u1.getName().compareTo(u2.getName()); - } - }); - buildNetwork(user, network); - network.remove(user); - return network; - } - - private void buildNetwork(User user, Set network) { - for (User friend : user.getFriends()) { - if (!network.contains(friend)) { - network.add(friend); - buildNetwork(friend, network); - } - } - } -} diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/support/OpenSessionInViewTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/support/OpenSessionInViewTests.java deleted file mode 100644 index b5cdb7cc2..000000000 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/support/OpenSessionInViewTests.java +++ /dev/null @@ -1,391 +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.web.support; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.*; - -import java.io.IOException; -import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicInteger; - -import javax.servlet.AsyncEvent; -import javax.servlet.AsyncListener; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.neo4j.ogm.session.Session; -import org.neo4j.ogm.session.SessionFactory; -import org.springframework.core.task.SimpleAsyncTaskExecutor; -import org.springframework.mock.web.MockAsyncContext; -import org.springframework.mock.web.MockFilterConfig; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockServletContext; -import org.springframework.mock.web.PassThroughFilterChain; -import org.springframework.transaction.support.TransactionSynchronizationManager; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.request.ServletWebRequest; -import org.springframework.web.context.request.async.AsyncWebRequest; -import org.springframework.web.context.request.async.StandardServletAsyncWebRequest; -import org.springframework.web.context.request.async.WebAsyncManager; -import org.springframework.web.context.request.async.WebAsyncUtils; -import org.springframework.web.context.support.StaticWebApplicationContext; - -/** - * @author Mark Angrish - */ -public class OpenSessionInViewTests { - - private Session session; - - private SessionFactory sessionFactory; - - private MockHttpServletRequest request; - - private MockHttpServletResponse response; - - private ServletWebRequest webRequest; - - @Before - public void setUp() throws Exception { - sessionFactory = mock(SessionFactory.class); - session = mock(Session.class); - - given(sessionFactory.openSession()).willReturn(session); - - this.request = new MockHttpServletRequest(); - this.request.setAsyncSupported(true); - this.response = new MockHttpServletResponse(); - this.webRequest = new ServletWebRequest(this.request); - } - - @After - public void tearDown() throws Exception { - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); - assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); - assertThat(TransactionSynchronizationManager.isCurrentTransactionReadOnly()) - .isFalse(); - assertThat(TransactionSynchronizationManager.isActualTransactionActive()) - .isFalse(); - } - - @Test - public void testOpenSessionInViewInterceptor() throws Exception { - OpenSessionInViewInterceptor interceptor = new OpenSessionInViewInterceptor(); - interceptor.setSessionFactory(this.sessionFactory); - - MockServletContext sc = new MockServletContext(); - MockHttpServletRequest request = new MockHttpServletRequest(sc); - - interceptor.preHandle(new ServletWebRequest(request)); - assertThat(TransactionSynchronizationManager.hasResource(this.sessionFactory)) - .isTrue(); - - // check that further invocations simply participate - interceptor.preHandle(new ServletWebRequest(request)); - - interceptor.preHandle(new ServletWebRequest(request)); - interceptor.postHandle(new ServletWebRequest(request), null); - interceptor.afterCompletion(new ServletWebRequest(request), null); - - interceptor.postHandle(new ServletWebRequest(request), null); - interceptor.afterCompletion(new ServletWebRequest(request), null); - - interceptor.preHandle(new ServletWebRequest(request)); - interceptor.postHandle(new ServletWebRequest(request), null); - interceptor.afterCompletion(new ServletWebRequest(request), null); - - interceptor.postHandle(new ServletWebRequest(request), null); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isTrue(); - - interceptor.afterCompletion(new ServletWebRequest(request), null); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - } - - @Test - public void testOpenSessionInViewInterceptorAsyncScenario() throws Exception { - - // Initial request thread - - OpenSessionInViewInterceptor interceptor = new OpenSessionInViewInterceptor(); - interceptor.setSessionFactory(sessionFactory); - - given(sessionFactory.openSession()).willReturn(this.session); - - interceptor.preHandle(this.webRequest); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isTrue(); - - AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response); - WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.webRequest); - asyncManager.setTaskExecutor(new SyncTaskExecutor()); - asyncManager.setAsyncWebRequest(asyncWebRequest); - asyncManager.startCallableProcessing(new Callable() { - @Override - public String call() throws Exception { - return "anything"; - } - }); - - interceptor.afterConcurrentHandlingStarted(this.webRequest); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - - // Async dispatch thread - - interceptor.preHandle(this.webRequest); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isTrue(); - - asyncManager.clearConcurrentResult(); - - // check that further invocations simply participate - interceptor.preHandle(new ServletWebRequest(request)); - - interceptor.preHandle(new ServletWebRequest(request)); - interceptor.postHandle(new ServletWebRequest(request), null); - interceptor.afterCompletion(new ServletWebRequest(request), null); - - interceptor.postHandle(new ServletWebRequest(request), null); - interceptor.afterCompletion(new ServletWebRequest(request), null); - - interceptor.preHandle(new ServletWebRequest(request)); - interceptor.postHandle(new ServletWebRequest(request), null); - interceptor.afterCompletion(new ServletWebRequest(request), null); - - interceptor.postHandle(this.webRequest, null); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isTrue(); - - interceptor.afterCompletion(this.webRequest, null); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - } - - @Test - public void testOpenSessionInViewInterceptorAsyncTimeoutScenario() throws Exception { - - // Initial request thread - - OpenSessionInViewInterceptor interceptor = new OpenSessionInViewInterceptor(); - interceptor.setSessionFactory(sessionFactory); - - given(this.sessionFactory.openSession()).willReturn(this.session); - - interceptor.preHandle(this.webRequest); - assertThat(TransactionSynchronizationManager.hasResource(this.sessionFactory)) - .isTrue(); - - AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response); - WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request); - asyncManager.setTaskExecutor(new SyncTaskExecutor()); - asyncManager.setAsyncWebRequest(asyncWebRequest); - asyncManager.startCallableProcessing(new Callable() { - @Override - public String call() throws Exception { - return "anything"; - } - }); - - interceptor.afterConcurrentHandlingStarted(this.webRequest); - assertThat(TransactionSynchronizationManager.hasResource(this.sessionFactory)) - .isFalse(); - - // Async request timeout - - MockAsyncContext asyncContext = (MockAsyncContext) this.request.getAsyncContext(); - for (AsyncListener listener : asyncContext.getListeners()) { - listener.onTimeout(new AsyncEvent(asyncContext)); - } - for (AsyncListener listener : asyncContext.getListeners()) { - listener.onComplete(new AsyncEvent(asyncContext)); - } - } - - @Test - public void testOpenSessionInViewFilter() throws Exception { - - final SessionFactory factory2 = mock(SessionFactory.class); - final Session manager2 = mock(Session.class); - - given(factory2.openSession()).willReturn(manager2); - - MockServletContext sc = new MockServletContext(); - StaticWebApplicationContext wac = new StaticWebApplicationContext(); - wac.setServletContext(sc); - wac.getDefaultListableBeanFactory().registerSingleton("sessionFactory", sessionFactory); - wac.getDefaultListableBeanFactory().registerSingleton("mySessionFactory", factory2); - wac.refresh(); - sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); - MockHttpServletRequest request = new MockHttpServletRequest(sc); - MockHttpServletResponse response = new MockHttpServletResponse(); - - MockFilterConfig filterConfig = new MockFilterConfig(wac.getServletContext(), "filter"); - MockFilterConfig filterConfig2 = new MockFilterConfig(wac.getServletContext(), "filter2"); - filterConfig2.addInitParameter("sessionFactoryBeanName", "mySessionFactory"); - - final OpenSessionInViewFilter filter = new OpenSessionInViewFilter(); - filter.init(filterConfig); - final OpenSessionInViewFilter filter2 = new OpenSessionInViewFilter(); - filter2.init(filterConfig2); - - final FilterChain filterChain = new FilterChain() { - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isTrue(); - servletRequest.setAttribute("invoked", Boolean.TRUE); - } - }; - - final FilterChain filterChain2 = new FilterChain() { - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) - throws IOException, ServletException { - assertThat(TransactionSynchronizationManager.hasResource(factory2)) - .isTrue(); - filter.doFilter(servletRequest, servletResponse, filterChain); - } - }; - - FilterChain filterChain3 = new PassThroughFilterChain(filter2, filterChain2); - - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - assertThat(TransactionSynchronizationManager.hasResource(factory2)).isFalse(); - filter2.doFilter(request, response, filterChain3); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - assertThat(TransactionSynchronizationManager.hasResource(factory2)).isFalse(); - assertThat(request.getAttribute("invoked")).isNotNull(); - - wac.close(); - } - - @Test - public void testOpenSessionInViewFilterAsyncScenario() throws Exception { - final SessionFactory factory2 = mock(SessionFactory.class); - final Session manager2 = mock(Session.class); - - given(factory2.openSession()).willReturn(manager2); - - MockServletContext sc = new MockServletContext(); - StaticWebApplicationContext wac = new StaticWebApplicationContext(); - wac.setServletContext(sc); - wac.getDefaultListableBeanFactory().registerSingleton("sessionFactory", sessionFactory); - wac.getDefaultListableBeanFactory().registerSingleton("mySessionFactory", factory2); - wac.refresh(); - sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); - - MockFilterConfig filterConfig = new MockFilterConfig(wac.getServletContext(), "filter"); - MockFilterConfig filterConfig2 = new MockFilterConfig(wac.getServletContext(), "filter2"); - filterConfig2.addInitParameter("sessionFactoryBeanName", "mySessionFactory"); - - final OpenSessionInViewFilter filter = new OpenSessionInViewFilter(); - filter.init(filterConfig); - final OpenSessionInViewFilter filter2 = new OpenSessionInViewFilter(); - filter2.init(filterConfig2); - - final AtomicInteger count = new AtomicInteger(0); - - final FilterChain filterChain = new FilterChain() { - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isTrue(); - servletRequest.setAttribute("invoked", Boolean.TRUE); - count.incrementAndGet(); - } - }; - - final AtomicInteger count2 = new AtomicInteger(0); - - final FilterChain filterChain2 = new FilterChain() { - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) - throws IOException, ServletException { - assertThat(TransactionSynchronizationManager.hasResource(factory2)) - .isTrue(); - filter.doFilter(servletRequest, servletResponse, filterChain); - count2.incrementAndGet(); - } - }; - - FilterChain filterChain3 = new PassThroughFilterChain(filter2, filterChain2); - - AsyncWebRequest asyncWebRequest = mock(AsyncWebRequest.class); - given(asyncWebRequest.isAsyncStarted()).willReturn(true); - - WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(this.request); - asyncManager.setTaskExecutor(new SyncTaskExecutor()); - asyncManager.setAsyncWebRequest(asyncWebRequest); - asyncManager.startCallableProcessing(new Callable() { - @Override - public String call() throws Exception { - return "anything"; - } - }); - - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - assertThat(TransactionSynchronizationManager.hasResource(factory2)).isFalse(); - filter2.doFilter(this.request, this.response, filterChain3); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - assertThat(TransactionSynchronizationManager.hasResource(factory2)).isFalse(); - assertThat(count.get()).isEqualTo(1); - assertThat(count2.get()).isEqualTo(1); - assertThat(request.getAttribute("invoked")).isNotNull(); - verify(asyncWebRequest, times(2)).addCompletionHandler(any(Runnable.class)); - verify(asyncWebRequest).addTimeoutHandler(any(Runnable.class)); - verify(asyncWebRequest, times(2)).addCompletionHandler(any(Runnable.class)); - verify(asyncWebRequest).startAsync(); - - // Async dispatch after concurrent handling produces result ... - - reset(asyncWebRequest); - given(asyncWebRequest.isAsyncStarted()).willReturn(false); - - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - assertThat(TransactionSynchronizationManager.hasResource(factory2)).isFalse(); - filter.doFilter(this.request, this.response, filterChain3); - assertThat(TransactionSynchronizationManager.hasResource(sessionFactory)) - .isFalse(); - assertThat(TransactionSynchronizationManager.hasResource(factory2)).isFalse(); - assertThat(count.get()).isEqualTo(2); - assertThat(count2.get()).isEqualTo(2); - - wac.close(); - } - - @SuppressWarnings("serial") - private static class SyncTaskExecutor extends SimpleAsyncTaskExecutor { - - @Override - public void execute(Runnable task, long startTimeout) { - task.run(); - } - } -} diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/shared/KotlinPerson.kt b/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/shared/KotlinPerson.kt deleted file mode 100644 index 0297b9a29..000000000 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/shared/KotlinPerson.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. - * - * 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.neo4j.springframework.data.integration.shared - -import org.neo4j.springframework.data.core.schema.GeneratedValue -import org.neo4j.springframework.data.core.schema.Id -import org.neo4j.springframework.data.core.schema.Node - -/** - * @author Gerrit Meier - */ -@Node -data class KotlinPerson(@Id @GeneratedValue val id: Long, val name: String) diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/shared/KotlinRepository.kt b/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/shared/KotlinRepository.kt deleted file mode 100644 index 4b6d5392b..000000000 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/shared/KotlinRepository.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. - * - * 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.neo4j.springframework.data.integration.shared - -import org.neo4j.springframework.data.repository.Neo4jRepository - -/** - * @author Gerrit Meier - */ -interface KotlinRepository : Neo4jRepository diff --git a/spring-data-neo4j/src/test/kotlin/org/springframework/data/neo4j/integration/constructors/domain/KotlinFriendship.kt b/spring-data-neo4j/src/test/kotlin/org/springframework/data/neo4j/integration/constructors/domain/KotlinFriendship.kt deleted file mode 100644 index 4c0a5c318..000000000 --- a/spring-data-neo4j/src/test/kotlin/org/springframework/data/neo4j/integration/constructors/domain/KotlinFriendship.kt +++ /dev/null @@ -1,33 +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.constructors.domain - -import org.neo4j.ogm.annotation.* - -/** - * @author Nicolas Mervaillie - */ -@RelationshipEntity(type = "IS_FRIEND") -class KotlinFriendship( - @StartNode var personStartNode: Person, - @EndNode var personEndNode: Person) { - - @Id - @GeneratedValue - var id: Long? = null - - var timestamp: Long = 0 -} diff --git a/spring-data-neo4j/src/test/kotlin/org/springframework/data/neo4j/integration/constructors/domain/KotlinPerson.kt b/spring-data-neo4j/src/test/kotlin/org/springframework/data/neo4j/integration/constructors/domain/KotlinPerson.kt deleted file mode 100644 index 8afed993e..000000000 --- a/spring-data-neo4j/src/test/kotlin/org/springframework/data/neo4j/integration/constructors/domain/KotlinPerson.kt +++ /dev/null @@ -1,42 +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.constructors.domain - -import org.neo4j.ogm.annotation.GeneratedValue -import org.neo4j.ogm.annotation.Id -import org.neo4j.ogm.annotation.Index -import org.neo4j.ogm.annotation.NodeEntity -import org.neo4j.ogm.annotation.Relationship - -/** - * @author Nicolas Mervaillie - * @author Michael J. Simons - */ -@NodeEntity -data class KotlinPerson( - @Id var name: String, - @Relationship var friendships: List = ArrayList()) { - -} - -@NodeEntity -data class KotlinDataPerson( - @Id @GeneratedValue var id: Long? = null, - @Index(unique = true) var name: String -) - -// Just a helper to omit the id constructor parameter completely when calling from Java. -fun newDataPerson(name: String) = KotlinDataPerson(name = name) diff --git a/spring-data-neo4j/src/test/resources/META-INF/spring.factories b/spring-data-neo4j/src/test/resources/META-INF/spring.factories deleted file mode 100644 index 6cb3f8489..000000000 --- a/spring-data-neo4j/src/test/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.test.context.TestExecutionListener=org.springframework.data.neo4j.test.CloseServerControlsAfterTestClassTestExecutionListener diff --git a/spring-data-neo4j/src/test/resources/logback-test.xml b/spring-data-neo4j/src/test/resources/logback-test.xml deleted file mode 100644 index e57872721..000000000 --- a/spring-data-neo4j/src/test/resources/logback-test.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - [%t] %d %5p %40.40c:%4L - %m%n - - - - - - - - - - - - - - - - - - diff --git a/spring-data-neo4j/src/test/resources/xml-based-configuration-applicationContext.xml b/spring-data-neo4j/src/test/resources/xml-based-configuration-applicationContext.xml deleted file mode 100644 index 52ebb7b8f..000000000 --- a/spring-data-neo4j/src/test/resources/xml-based-configuration-applicationContext.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - org.springframework.data.neo4j.web.domain - - - - - diff --git a/spring-data-neo4j/template.mf b/spring-data-neo4j/template.mf deleted file mode 100644 index 9356d2541..000000000 --- a/spring-data-neo4j/template.mf +++ /dev/null @@ -1,19 +0,0 @@ -Bundle-SymbolicName: org.springframework.data.neo4j -Bundle-Name: Spring Data Neo4J Support -Bundle-Vendor: Pivotal Software, Inc; Neo Technology, Inc; Graph Aware Ltd. -Bundle-ManifestVersion: 2 -Bundle-Version: ${project.version} -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Import-Package: - sun.reflect;version="0";resolution:=optional -Export-Template: - org.springframework.data.neo4j.*;version="${project.version}" -Import-Template: - javax.enterprise.*;version="${cdi:[=.=.=,+1.0.0)}";resolution:=optional, - org.neo4j.ogm.*;version="+2.1.0";resolution:=optional, - javax.servlet.*;version="0", - org.apache.commons.*;version="0", - org.springframework.*;version="${spring:[=.=.=.=,+1.1.0)}", - org.springframework.data.*;version="${springdata.commons:[=.=.=.=,+1.0.0)}", - org.slf4j.*;version="${slf4j:[=.=.=,+1.0.0)}", - org.w3c.*;version="0" diff --git a/src/main/asciidoc/appendix/build.adoc b/src/main/asciidoc/appendix/build.adoc new file mode 100644 index 000000000..9a05e8ae9 --- /dev/null +++ b/src/main/asciidoc/appendix/build.adoc @@ -0,0 +1,214 @@ +[[building-sdn-rx]] += Building SDN/RX + +== Requirements + +* JDK 13+ (Can be https://openjdk.java.net[OpenJDK] or https://www.oracle.com/technetwork/java/index.html[Oracle JDK]) +* Maven 3.6.2 (We provide the Maven wrapper, see `mvnw` respectively `mvnw.cmd` in the project root; the wrapper downloads the appropriate Maven version automatically) +* A Neo4j 3.5.+ database, either +** running locally +** or indirectly via https://www.testcontainers.org[Testcontainers] and https://www.docker.com[Docker] + +=== About the JDK version + +SDN/RX itself targets JDK 8 release but builds currently on JDK13. +We will track the current release cadence of Java. +Choosing JDK 8 is a decision influenced by various aspects + +* SDN/RX is a Spring Data project. + Spring Data commons baseline is still JDK 8 and so is Spring Frameworks baseline. + Thus it is only natural to keep the JDK 8 baseline. +* While there is an increase of projects started with JDK 11 (which is Oracles current LTS release of Java), + many existing projects are still on JDK 8. + We don't want to lose them as users right from the start. + +All examples (`/examples`) and also benchmarking (`/benchmarks`) will be compiled and run with the latest Java release, though. + +== Running the build + +The following sections are alternatives and roughly sorted by increased effort. + +All builds require a local copy of the project: + +[source,console,subs="verbatim,attributes"] +[[checkout-sdn-rx]] +.Clone SDN/RX +---- +$ git clone git@github.com:neo4j/sdn-rx.git +---- + +Before you proceed, verify your locally installed JDK version. +The output should be similar: + +[source,console,subs="verbatim,attributes"] +[[verify-jdk]] +.Verify your JDK +---- +$ java -version +java version "12.0.1" 2019-04-16 +Java(TM) SE Runtime Environment (build 12.0.1+12) +Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing) +---- + +=== With Docker installed + +==== Using the default image + +If you don't have https://en.wikipedia.org/wiki/Docker_(software)[Docker] installed, head over to https://www.docker.com/products/docker-desktop[Docker Desktop]. +In short, Docker is a tool that helps you running lightweight software images using OS-level virtualization in so called containers. + +Our build uses https://www.testcontainers.org/modules/databases/neo4j/[Testcontainers Neo4j] to bring up a database instance. + +[source,console,subs="verbatim,attributes"] +[[build-default-bash]] +.Build with default settings on Linux / macOS +---- +$ ./mvnw clean verify +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[INFO] Reactor Build Order: +[INFO] +[INFO] Spring Data Neo4j RX [pom] +[INFO] SDN⚡RX [jar] +[INFO] SDN⚡RX Spring Boot Starter Parent [pom] +[INFO] SDN⚡RX Spring Boot Starter Autoconfiguration [jar] +[INFO] SDN⚡RX Spring Boot Starter [jar] +[INFO] SDN⚡RX Examples for Spring Boot [jar] +[INFO] SDN⚡RX Examples Mapping [jar] +... +[INFO] Reactor Summary: +[INFO] +[INFO] Spring Data Neo4j RX 1.0.0-SNAPSHOT ................ SUCCESS [ 5.937 s] +[INFO] SDN⚡RX 1.0.0-SNAPSHOT ............................. SUCCESS [09:37 min] +[INFO] SDN⚡RX Spring Boot Starter Parent 1.0.0-SNAPSHOT .. SUCCESS [ 1.734 s] +[INFO] SDN⚡RX Spring Boot Starter Autoconfiguration 1.0.0-SNAPSHOT SUCCESS [ 57.069 s] +[INFO] SDN⚡RX Spring Boot Starter 1.0.0-SNAPSHOT ......... SUCCESS [ 0.444 s] +[INFO] SDN⚡RX Examples for Spring Boot 999-SNAPSHOT ...... SUCCESS [ 4.055 s] +[INFO] SDN⚡RX Examples Mapping 999-SNAPSHOT .............. SUCCESS [ 0.683 s] +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 10:48 min +[INFO] Finished at: 2019-10-02T15:25:48+02:00 +[INFO] ------------------------------------------------------------------------ +---- + +On a Windows machine, use + +[source,console,subs="verbatim,attributes"] +[[build-default-windows]] +.Build with default settings on Windows +---- +$ mvnw.cmd clean verify +---- + +The output should be similar. + +At the moment, this build tests agains Neo4j 3.5, as 4.0 is not yet available on Docker Hub. +As a consequence, tests requiring a reactive capable database, are skipped, as this is a feature of Neo4j 4.0. + +==== Using another image + +The image version to use can be configured through an environmental variable like this: + +[source,console,subs="verbatim,attributes"] +[[build-other-image]] +.Build using a different Neo4j Docker image +---- +$ SDN_RX_NEO4J_VERSION=3.5.11-enterprise SDN_RX_NEO4J_ACCEPT_COMMERCIAL_EDITION=yes ./mvnw clean verify +---- + +Here we are using 3.5.11 enterprise and also accept the license agreement. + +Consult your operating system or shell manual on how to define environment variables if specifying them inline does not work for you. + +=== Against a locally running database + +WARNING: Running against a locally running database *will* erase its complete content. + +Building against a locally running database is faster, as it does not restart a container each time. +We do this a lot during our development. + +You can get a copy of Neo4j at our https://neo4j.com/download-center/#enterprise[download center] free of charge. +Especially you can get https://neo4j.com/download-center/?ref=blog/#prerelease[the current prelease of Neo4j 4.0], supporting all the reactive features. + +Please download the version applicable to your operating system and follow the instructions to start it. +A required step is to open a browser and go to http://localhost:7474 after you started the database and +change the default password from `neo4j` to something of your liking. + +After that, you can run a complete build by specifying the local `bolt` URL: + +[source,console,subs="verbatim,attributes"] +[[build-using-locally-running-database]] +.Build using a locally running database +---- +$ SDN_RX_NEO4J_URL=bolt://localhost:7687 SDN_RX_NEO4J_PASSWORD=secret ./mvnw clean verify +---- + +== Summary of environment variables controlling the build + +[cols="3,1,3", options="header"] +|=== +|Name|Default value|Meaning + +|`SDN_RX_NEO4J_VERSION` +|3.5.6 +|Version of the Neo4j docker image to use, see https://hub.docker.com/_/neo4j[Neo4j Docker Official Images] + +|`SDN_RX_NEO4J_ACCEPT_COMMERCIAL_EDITION` +|no +|Some tests may require the enterprise edition of Neo4j. + We build and test against the enterprise edition internally, but we won't force you + to accept the license if you don't want to. + +|`SDN_RX_NEO4J_URL` +|not set +|Setting this environment allows connecting to a locally running Neo4j instance. + We use this a lot during development. + +|`SDN_RX_NEO4J_PASSWORD` +|not set +|Password for the `neo4j` user of the instance configured with `SDN_RX_NEO4J_URL`. + +|=== + +NOTE: You need to set both `SDN_RX_NEO4J_URL` and `SDN_RX_NEO4J_PASSWORD` to use a local instance. + +== Checkstyle and friends + +There is no quality gate in place at the moment to ensure that the code/test ratio stays as is, but please consider adding tests to your contributions. + +We have some rather mild checkstyle rules in place, enforcing more or less default Java formatting rules. +Your build will break on formatting errors or something like unused imports. + +=== jQAssistant + +We also use https://jqassistant.org[jQAssistant], a Neo4j-based tool, to verify some aspects of our architecture. +The rules are described with Cypher and your build will break when they are violated: + +include::../../etc/jqassistant/index.adoc[leveloffset=4] + +==== Accessing the jQAssistant database + +jQAssistant uses Neo4j to store information about a project. +To access the database, please build the project as described above. +When the build finishes, execute the following command: + +[source,console,subs="verbatim,attributes"] +[[start-jqassistant]] +.Start jQAssistant +---- +$ ./mvnw -pl org.neo4j.springframework.data:spring-data-neo4j-rx jqassistant:server +---- + +Access the standard Neo4j browser at http://localhost:7474 and a dedicated jQA-Dashboard at http://localhost:7474/jqassistant/dashboard/. + +The scanning and analyzing can be triggered individually, without going through the full verify again: + +[source,console,subs="verbatim,attributes"] +[[scan-with-jqassistant]] +.Manually scan and analyze the main project +---- +$ ./mvnw -pl org.neo4j.springframework.data:spring-data-neo4j-rx jqassistant:scan@jqassistant-scan +$ ./mvnw -pl org.neo4j.springframework.data:spring-data-neo4j-rx jqassistant:analyze@jqassistant-analyze +---- diff --git a/src/main/asciidoc/appendix/conversions.adoc b/src/main/asciidoc/appendix/conversions.adoc new file mode 100644 index 000000000..5a7c30544 --- /dev/null +++ b/src/main/asciidoc/appendix/conversions.adoc @@ -0,0 +1,195 @@ +[[conversions]] += Conversions + +We support a broad range of conversions out of the box. +Find the list of supported cypher types in the official drivers manual: https://neo4j.com/docs/driver-manual/current/cypher-values/[Working with Cypher values]. + +Primitive types of wrapper types are equally supported. + +[cols="3,3,1", options="header"] +|=== +|Domain type|Cypher type|Maps directly to native type + +|`java.lang.Boolean` +|Boolean +|✔ + +|`boolean[]` +|List of Boolean +|✔ + +|`java.lang.Long` +|Integer +|✔ + +|`long[]` +|List of Integer +|✔ + +|`java.lang.Double` +|Float +|✔ + +|`java.lang.String` +|String +|✔ + + +|`java.lang.String[]` +|List of String +|✔ + +|`byte[]` +|ByteArray +|✔ + +|`java.lang.Byte` +|ByteArray with length 1 +| + +|`java.lang.Character` +|String with length 1 +| + +|`char[]` +|List of String with length 1 +| + +|`java.util.Date` +|String formatted as ISO 8601 Date (`yyyy-MM-dd'T'HH:mm:ss.SSSZ`). + Notice the `Z`: SDN/RX will store all `java.util.Date` instances in `UTC`. + If you require the time zone, use a type that supports it (i.e. `ZoneDateTime`) or store the zone as a separate property. +| + +|`double[]` +|List of Float +|✔ + +|`java.lang.Float` +|String +| + +|`float[]` +|List of String +| + +|`java.lang.Integer` +|Integer +| + +|`int[]` +|List of Integer +| + +|`java.util.Locale` +|String formatted as BCP 47 language tag +| + +|`java.lang.Short` +|Integer +| + +|`short[]` +|List of Integer +| + +|`java.math.BigDecimal` +|String +| + +|`java.math.BigInteger` +|String +| + +|`java.time.LocalDate` +|Date +|✔ + +|`java.time.OffsetTime` +|Time +|✔ + +|`java.time.LocalTime` +|LocalTime +|✔ + +|`java.time.ZonedDateTime` +|DateTime +|✔ + +|`java.time.LocalDateTime` +|LocalDateTime +|✔ + +|`java.time.Period` +|Duration +| + +|`java.time.Duration` +|Duration +| + +|`org.neo4j.driver.types.IsoDuration` +|Duration +|✔ + +|`org.neo4j.driver.types.Point` +|Point +|✔ + +|`org.neo4j.springframework.data.types.GeographicPoint2d` +|Point with CRS 4326 +| + +|`org.neo4j.springframework.data.types.GeographicPoint3d` +|Point with CRS 4979 +| + +|`org.neo4j.springframework.data.types.CartesianPoint2d` +|Point with CRS 7203 +| + +|`org.neo4j.springframework.data.types.CartesianPoint3d` +|Point with CRS 9157 +| + +|`org.springframework.data.geo.Point` +|Point with CRS 4326 and x/y corresponding to lat/long +| + +|Instances of `Enum` +|String (The name value of the enum) +| + +|Instances of `Enum[]` +|List of String (The name value of the enum) +| + +|=== + +== Custom conversions + +If you prefer to work with your own types in the entities or as parameters for `@Query` annotated methods, +you can define and provide a custom converter implementation. +First you have to implement a `GenericConverter` and register the types your converter should handle. +For entity property type converters you need to take care of converting your type to *and* from a Neo4j Java Driver `Value`. +If your converter is supposed to work only with custom query methods in the repositories, it is sufficient +to provide the one-way conversion to the `Value` type. + +.Example of a custom converter implementation +[source,java,indent=0] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/conversion/MyCustomTypeConverter.java[tag=custom-converter.implementation] +---- + +To make SDN/RX aware of your converter, it has to be registered in the `Neo4jConversions`. +To do this, you have to create a `@Bean` with the type `org.neo4j.springframework.data.core.convert.Neo4jConversions`. +Otherwise, the `Neo4jConversions` will get created in the background with the internal default converters only. + +.Example of a custom converter implementation +[source,java,indent=0] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/conversion/MyCustomTypeConverter.java[tag=custom-converter.neo4jConversions] +---- + +If you need multiple converters in your application, you can add as many as you need in the `Neo4jConversions` constructor. diff --git a/src/main/asciidoc/appendix/index.adoc b/src/main/asciidoc/appendix/index.adoc new file mode 100644 index 000000000..f7add0d3e --- /dev/null +++ b/src/main/asciidoc/appendix/index.adoc @@ -0,0 +1,15 @@ +:leveloffset: +1 +[[appendix]] += Appendix + +:numbered!: +:leveloffset: +1 +include::conversions.adoc[] +include::sdc-repository-query-keywords-reference.adoc[] +include::sdc-repository-query-return-types-reference.adoc[] +include::neo4j-client.adoc[] +include::query-creation.adoc[] +include::migrating.adoc[] +include::build.adoc[] +:leveloffset: -1 +:leveloffset: -1 diff --git a/src/main/asciidoc/appendix/migrating.adoc b/src/main/asciidoc/appendix/migrating.adoc new file mode 100644 index 000000000..efdce7608 --- /dev/null +++ b/src/main/asciidoc/appendix/migrating.adoc @@ -0,0 +1,137 @@ +[[Migrating]] += Migrating from SDN+OGM to SDN/RX + +== Known issues with past SDN+OGM migrations + +SDN+OGM has had quite a history over the years and we understand that migrating big application systems is neither fun nor something that provides immediate profit. +The main issues we observed when migrating from older versions of Spring Data Neo4j to newer ones are roughly in order the following: + +Having skipped more than one major upgrade:: +While Neo4j-OGM can be used stand-alone, Spring Data Neo4j cannot. +It depends to large extend on the Spring Data and therefore, on the Spring Framework itself, which eventually affects large parts of your application. +Depending on how the application has been structured, that is, how much the any of the framework part leaked into your business code, the more you have to adapt your application. +It get's worse when you have more than one Spring Data module in your application, if you accessed a relational database in the same service layer as your graph database. +Updating two object mapping frameworks is not fun. +Relying on a embedded database configured through Spring Data itself:: +The embedded database in a SDN+OGM project is configured by Neo4j-OGM. +Say you want to upgrade from Neo4j 3.0 to 3.5, you can't without upgrading your whole application. +Why is that? +As you chose to embed a database into your application, you tied yourself into the modules that configure this embedded database. +To have another, embedded database version, you have to upgrade the module that configured it, because the old one does not support the new database. +As there is always a Spring Data version corresponding to Neo4j-OGM, you would have to upgrade that as well. +Spring Data however depends on Spring Framework and than the arguments from the first bullet apply. +Being unsure about which building blocks to include:: +It's not easy to get the terms right. +We wrote the building blocks of an SDN+OGM setting https://michael-simons.github.io/neo4j-sdn-ogm-tips/what_are_the_building_blocks_of_sdn_and_ogm.html[here]. +It may be so that all of them have been added by coincidence and you're dealing with a lof of conflicting dependencies. + +TIP: Backed by those observations, we recommend to make sure you're using only the Bolt or http transport in your current application before switching from SDN+OGM to SDN/RX. +Thus, your application and the access layer of your application is to large extend independent from the databases version. +From that state, consider moving from SDN+OGM to SDN/RX. + +== Prepare the migration from SDN+OGM Lovelace or SDN+OGM Moore to SDN/RX + +NOTE: The _Lovelace_ release train corresponds to SDN 5.1.x and OGM 3.1.x, while the _Moore_ is SDN 5.2.x and OGM 3.2.x. + +First, you must make sure that your application runs against Neo4j in server mode over the Bolt protocol, which means work in two of three cases: + +=== You're on embedded + +You have added `org.neo4j:neo4j-ogm-embedded-driver` and `org.neo4j:neo4j` to you project and starting the database via OGM facilities. +This is no longer supported and you have to setup a standard Neo4j server (both standalone and cluster are supported). + +The above dependencies have to be removed. + +Migrating from the embedded solution is probably the toughest migration, as you need to setup a server, too. +It is however the one that gives you much value in itself: +In the future, you will be able to upgrade the database itself without having to consider your application framework, +and your data access framework as well. + +=== You're using the HTTP transport + +You have added `org.neo4j:neo4j-ogm-http-driver` and configured an url like `http://user:password@localhost:7474`. +The dependency has to be replaced with `org.neo4j:neo4j-ogm-bolt-driver` and you need to configure a Bolt url +like `bolt://localhost:7687` or use the new `neo4j://` scheme, which takes care of routing, too. + +=== You're already using Bolt indirectly + +A default SDN+OGM project uses `org.neo4j:neo4j-ogm-bolt-driver` and thus indirectly, the pure Java Driver. +You can keep your existing URL. + +== Migrating + +Once you have made sure, that your SDN+OGM application works over Bolt as expected, you can start migrating to SDN/RX. + +* Remove all `org.neo4j:neo4j-ogm-*` dependencies +* Remove `org.springframework.data:spring-data-neo4j` +* Configuring SDN/RX through a `org.neo4j.ogm.config.Configuration` bean is not supported, instead of, all configuration of the driver goes through https://github.com/neo4j/neo4j-java-driver-spring-boot-starter[our new starter]. + Any of https://github.com/neo4j/neo4j-java-driver-spring-boot-starter/blob/master/docs/configuration-options.adoc[those properties] can be configured through standard Spring Boot means. + You will especially have to adapt the properties for the url and authentication, see <> + +TIP: You cannot configure SDN/RX through XML. + In case you did this with your SDN+OGM application, make sure you learn about annotation-driven or functional configuration of Spring Applications. + The easiest choice these days is Spring Boot. + With our starter in place, all the necessary bits apart from the connection URL and the authentication is already configured for you. + +[source,properties] +[[migrating-auth]] +.Old and new properties compared +---- +# Old +spring.data.neo4j.embedded.enabled=false # No longer support +spring.data.neo4j.uri=bolt://localhost:7687 +spring.data.neo4j.username=neo4j +spring.data.neo4j.password=secret + +# New +org.neo4j.driver.uri=bolt://localhost:7687 +org.neo4j.driver.authentication.username=neo4j +org.neo4j.driver.authentication.password=secret +---- + +WARNING: Those new properties might change in the future again when SDN/RX and the driver will eventually replace the old setup fully. + +And finally, add the new dependency, see <> for both Gradle and Maven. + +You're than ready to replace annotations: + +[cols="2*", options="header"] +|=== + +|Old +|New + +|`org.neo4j.ogm.annotation.NodeEntity` +|`org.neo4j.springframework.data.core.schema.Node` + +|`org.neo4j.ogm.annotation.GeneratedValue` +|`org.neo4j.springframework.data.core.schema.GeneratedValue` + +|`org.neo4j.ogm.annotation.Id` +|`org.neo4j.springframework.data.core.schema.Id` + +|`org.neo4j.ogm.annotation.Property` +|`org.neo4j.springframework.data.core.schema.Property` + +|`org.neo4j.ogm.annotation.Relationship` +|`org.neo4j.springframework.data.core.schema.Relationship` + +|`org.springframework.data.neo4j.annotation.EnableBookmarkManagement` +|No replacement, not needed + +|`org.springframework.data.neo4j.annotation.UseBookmark` +|No replacement, not needed + +|=== + +NOTE: Several Neo4j-OGM annotations have not yet a corresponding annotation in SDN/RX, some will never have. + We will add to the list above as we support additional features. + +=== Bookmarkmanagement + +Both `@EnableBookmarkManagement` and `@UseBookmark` as well as the `org.springframework.data.neo4j.bookmark.BookmarkManager` +interface and it's only implementation `org.springframework.data.neo4j.bookmark.CaffeineBookmarkManager` are gone and are +not needed anymore. + +SDN/RX uses Bookmarks for all transactions, without configuration. +You can remove the bean declaration of `CaffeineBookmarkManager` as well as the the dependency to `com.github.ben-manes.caffeine:caffeine`. diff --git a/src/main/asciidoc/appendix/neo4j-client.adoc b/src/main/asciidoc/appendix/neo4j-client.adoc new file mode 100644 index 000000000..c1394c0d5 --- /dev/null +++ b/src/main/asciidoc/appendix/neo4j-client.adoc @@ -0,0 +1,360 @@ +[[neo4j-client]] += Neo4jClient + +Spring Data Neo4j⚡RX comes with a Neo4j Client, providing a thin layer on top of Neo4j's Java driver. + +While the https://github.com/neo4j/neo4j-java-driver[plain Java driver] is a very versatile tool +providing an asynchronous API in addition to the imperative and reactive versions, it doesn't +integrate with Spring application level transactions. + +SDN/RX uses the driver through the concept of a idiomatic client as directly as possible. + +The client has the following main goals + +. Integrate into Springs transaction management, for both imperative and reactive scenarios +. Participate in JTA-Transactions if necessary +. Provide a consistent API for both imperative and reactive scenarios +. Don't add any mapping overhead + +SDN/RX relies on all those features and uses them to fulfill its entity mapping features. + +Have a look at the <> for where both the imperative and reactive Neo4 clients are positioned in our stack. + +The Neo4j Client comes in two flavors: + +* `org.neo4j.springframework.data.core.Neo4jClient` +* `org.neo4j.springframework.data.core.ReactiveNeo4jClient` + +While both versions provide an API using the same vocabulary and syntax, they are not API compatible. +Both versions feature the same, fluent API to specify queries, bind parameters and extract results. + +== Imperative or reactive? + +Interactions with a Neo4j Client usually ends with a call to + +* `fetch().one()` +* `fetch().first()` +* `fetch().all()` +* `run()` + +The imperative version will interact at this moment with the database +and get the requested results or summary, wrapped in a `Optional<>` or a `Collection`. + +The reactive version will in contrast return a publisher of the requested type. +Interaction with the database and retrieval of the results will not happen until the publisher is subscribed to. +The publisher can only be subscribed once. + +== Getting an instance of the client + +As with most things in SDN/RX, both clients depend on a configured driver instance. + +[[neo4j-client-create-imperative-client]] +[source,java] +.Creating an instance of the imperative Neo4j client +---- +import org.neo4j.driver.AuthTokens; +import org.neo4j.driver.Driver; +import org.neo4j.driver.GraphDatabase; + +import org.neo4j.springframework.data.core.Neo4jClient; + +public class Demo { + + public static void main(String...args) { + + Driver driver = GraphDatabase + .driver("neo4j://localhost:7687", AuthTokens.basic("neo4j", "secret")); + + Neo4jClient client = Neo4jClient.create(driver); + } +} +---- + +The driver can only open a reactive session against a 4.0 database and will fail with an exception on any lower version. + +[[neo4j-client-create-reactive-client]] +[source,java] +.Creating an instance of the reactive Neo4j client +---- +import org.neo4j.driver.AuthTokens; +import org.neo4j.driver.Driver; +import org.neo4j.driver.GraphDatabase; + +import org.neo4j.springframework.data.core.ReactiveNeo4jClient; + +public class Demo { + + public static void main(String...args) { + + Driver driver = GraphDatabase + .driver("neo4j://localhost:7687", AuthTokens.basic("neo4j", "secret")); + + ReactiveNeo4jClient client = ReactiveNeo4jClient.create(driver); + } +} +---- + +NOTE: Make sure you use the same driver instance for the client as you used for providing a `Neo4jTransactionManager` or `ReactiveNeo4jTransactionManager` +in case you have enabled transactions. +The client won't be able to synchronize transactions if you use another instance of a driver. + +Our Spring Boot starter provide a ready to use bean of the Neo4j Client that fit the environment (imperative or reactive) +and you usually don't have to configure your own instance. + +== Usage + +[[neo4j-client-selecting-the-target-database]] +=== Selecting the target database + +The Neo4j client is well prepared to be used with the multidatabase features of Neo4j 4.0. +The client uses the default database unless you specify otherwise. +The fluent API of the client allows to specify the target database exactly once, after the declaration of the query to execute. +<> demonstrates it with the reactive client: + +[[neo4j-client-reactive-selecting-the-target-database]] +[source,java] +.Selecting the target database +---- +Flux> allActors = client + .query("MATCH (p:Person) RETURN p") + .in("neo4j") // <.> + .fetch() + .all(); +---- +<.> Select the target database in which the query is to be executed. + +=== Specifying queries + +The interaction with the clients starts with a query. +A query can be defined by a plain `String` or a `Supplier`. +The supplier will be evaluated as late as possible and can be provided by any query builder. + +[[neo4j-client-specifying-queries]] +[source,java] +.Specifying a query +---- +Mono> firstActor = client + .query(() -> "MATCH (p:Person) RETURN p") + .fetch() + .first(); +---- + +=== Retrieving results + +As the previous listings shows, the interaction with the client always ends with a call to `fetch` and how many results shall be received. +Both reactive and imperative client offer + +`one()`:: Expect exactly one result from the query +`first()`:: Expect results and return the first record +`all()`:: Retrieve all records returned + +The imperative client returns `Optional` and `Collection` respectively, +while the reactive client returns `Mono` and `Flux`, the later one being executed only if subscribed to. + +If you don't expect any results from your query, than use `run()` after specificity the query. + +[[neo4j-client-reactive-get-result-summaries]] +[source,java] +.Retrieving result summaries in a reactive way +---- +Mono summary = reactiveClient + .query("MATCH (m:Movie) where m.title = 'Aeon Flux' DETACH DELETE m") + .run(); + +summary + .map(ResultSummary::counters) + .subscribe(counters -> + System.out.println(counters.nodesDeleted() + " nodes have been deleted") + ); // <.> +---- +<.> The actual query is triggered here by subscribing to the publisher. + +Please take a moment to compare both listings and understand the difference when the actual query is triggered. + +[[neo4j-client-imperative-get-result-summaries]] +[source,java] +.Retrieving result summaries in a imperative way +---- +ResultSummary resultSummary = imperativeClient + .query("MATCH (m:Movie) where m.title = 'Aeon Flux' DETACH DELETE m") + .run(); // <.> + +SummaryCounters counters = resultSummary.counters(); +System.out.println(counters.nodesDeleted() + " nodes have been deleted") +---- +<.> Here the query is triggered immediate. + +=== Mapping parameters + +Queries can contain named parameters (`$someName`). +The Neo4j client allows comfortable binding to those. + +NOTE: The client doesn't check whether all parameters are bound or whether there are to many values. +That is left to the driver. +However the client prevents you from using a parameter name twice. + +You can either map simple types that the Java driver understands or complex classes. +Please have a look at the https://neo4j.com/docs/driver-manual/current/cypher-values/#driver-neo4j-type-system[drivers manual], to see which simple types are understood. + +[[neo4j-client-mapping-simple-types]] +[source,java] +.Mapping simple types +---- +Map parameters = new HashMap<>(); +parameters.put("name", "Li.*"); + +Flux> directorAndMovies = client + .query( + "MATCH (p:Person) - [:DIRECTED] -> (m:Movie {title: $title}), (p) - [:WROTE] -> (om:Movie) " + + "WHERE p.name =~ $name " + + " AND p.born < $someDate.year " + + "RETURN p, om" + ) + .bind("The Matrix").to("title") // <.> + .bind(LocalDate.of(1979, 9, 21)).to("someDate") + .bindAll(parameters) // <.> + .fetch() + .all(); +---- +<.> There's a fluent API for binding simple types. +<.> Alternatively parameters can be bound via a map of named parameters. + +SDN/RX does a lot of complex mapping and it uses the same API that you can use from the client. + +You can provide a `Function>` for any given domain object like an owner of bicycles in <> +to the Neo4j Client to map those domain objects to parameters the driver can understand. + +[[neo4j-client-domain-example]] +[source,java] +.Example of a domain type +---- +public class Director { + + private final String name; + + private final List movies; + + Director(String name, List movies) { + this.name = name; + this.movies = new ArrayList<>(movies); + } + + public String getName() { + return name; + } + + public List getMovies() { + return Collections.unmodifiableList(movies); + } +} + +public class Movie { + + private final String title; + + public Movie(String title) { + this.title = title; + } + + public String getTitle() { + return title; + } +} +---- + +The mapping function has to fill in all named parameters that might occur in the query like <> shows: + +[[neo4j-client-binder]] +[source,java] +.Using a mapping function for binding domain objects +---- +Director joseph = new Director("Joseph Kosinski", + Arrays.asList(new Movie("Tron Legacy"), new Movie("Top Gun: Maverick"))); + +Mono summary = client + .query("" + + "MERGE (p:Person {name: $name}) " + + "WITH p UNWIND $movies as movie " + + "MERGE (m:Movie {title: movie}) " + + "MERGE (p) - [o:DIRECTED] -> (m) " + ) + .bind(joseph).with(director -> { // <.> + Map mappedValues = new HashMap<>(); + List movies = director.getMovies().stream() + .map(Movie::getTitle).collect(Collectors.toList()); + mappedValues.put("name", director.getName()); + mappedValues.put("movies", movies); + return mappedValues; + }) + .run(); +---- +<.> The with method allows for specifying the binder function. + +=== Working with result objects + +Both clients return collections or publishers of maps (`Map`). +Those maps corresponds exactly with the records that a query might have produced. + +In addition, you can plugin your own `BiFunction` through `fetchAs` to reproduce your domain object. + +[[neo4j-client-reader]] +[source,java] +.Using a mapping function for reading domain objects +---- +Mono lily = client + .query("" + + " MATCH (p:Person {name: $name}) - [:DIRECTED] -> (m:Movie)" + + "RETURN p, collect(m) as movies") + .bind("Lilly Wachowski").to("name") + .fetchAs(Director.class).mappedBy((TypeSystem t, Record record) -> { + List movies = record.get("movies") + .asList(v -> new Movie((v.get("title").asString()))); + return new Director(record.get("name").asString(), movies); + }) + .one(); +---- + +`TypeSystem` gives access to the types the underlying Java driver used to fill the record. + +=== Interacting directly with the driver while using managed transactions + +In case you don't want or don't like the opinionated "client" approach of the `Neo4jClient` or the `ReactiveNeo4jClient`, +you can have the client delegate all interactions with the database to your code. +The interaction after the delegation is slightly different with the imperative and reactive versions of the client. + +The imperative version takes in a `Function>` as a callback. +Returning an empty optional is ok. + +[[neo4j-client-imperative-delegating]] +[source,java] +.Delegate database interaction to an imperative `StatementRunner` +---- +Optional result = client + .delegateTo((StatementRunner runner) -> { + // Do as many interactions as you want + long numberOfNodes = runner.run("MATCH (n) RETURN count(n) as cnt") + .single().get("cnt").asLong(); + return Optional.of(numberOfNodes); + }) + // .in("aDatabase") // <.> + .run(); +---- +<.> The database selection as described in <> is optional. + +The reactive version receives a `RxStatementRunner`. + +[[neo4j-client-reactive-delegating]] +[source,java] +.Delegate database interaction to a reactive `RxStatementRunner` +---- +Mono result = client + .delegateTo((RxStatementRunner runner) -> + Mono.from(runner.run("MATCH (n:Unused) DELETE n").summary()) + .map(ResultSummary::counters) + .map(SummaryCounters::nodesDeleted)) + // .in("aDatabase") // <.> + .run(); +---- +<.> Optional selection of the target database. + +Note that in both <> and <> the types of the runner have only been stated to provide more clarity to reader of this manual. diff --git a/src/main/asciidoc/appendix/query-creation.adoc b/src/main/asciidoc/appendix/query-creation.adoc new file mode 100644 index 000000000..49c9ca885 --- /dev/null +++ b/src/main/asciidoc/appendix/query-creation.adoc @@ -0,0 +1,87 @@ +[[query-creation]] +:doubleUnderscore: __ +:neo4jId: {doubleUnderscore}id{doubleUnderscore} +:neo4jIds: {doubleUnderscore}ids{doubleUnderscore} +:neo4jInternalId: {doubleUnderscore}internalNeo4jId{doubleUnderscore} +:neo4jProperties: {doubleUnderscore}properties{doubleUnderscore} +:neo4jEntities: {doubleUnderscore}entities{doubleUnderscore} +:neo4jLabels: {doubleUnderscore}nodeLabels{doubleUnderscore} + += Query creation + +This chapter is about the technical creation of queries when using SDN/RX's abstraction layers. +There will be some simplifications because we do not discuss every possible case but stick with the general idea behind it. + +== Save + +Beside the `find/load` operations the `save` operation is one of the most used when working with data. +A save operation call in general issues multiple statements against the database to ensure that the resulting graph model matches the given Java model. + +. A union statement will get created that either creates a node, if the node's identifier cannot be found, or updates the node's property if the node itself exists. ++ +(`OPTIONAL MATCH (hlp:Person) WHERE id(hlp) = ${neo4jId} WITH hlp WHERE hlp IS NULL CREATE (n:Person) SET n = ${neo4jProperties} RETURN id(n) UNION MATCH (n) WHERE id(n) = ${neo4jId} SET n = ${neo4jProperties} RETURN id(n)`) + +. If the entity is *not* new all relationships of the first found type at the domain model will get removed from the database. ++ +(`MATCH (startNode)-[rel:Has]->(:Hobby) WHERE id(startNode) = $fromId DELETE rel`) + +. The related entity will get created in the same way as the root entity. ++ +(`OPTIONAL MATCH (hlp:Hobby) WHERE id(hlp) = ${neo4jId} WITH hlp WHERE hlp IS NULL CREATE (n:Hobby) SET n = ${neo4jProperties} RETURN id(n) UNION MATCH (n) WHERE id(n) = ${neo4jId} SET n = ${neo4jProperties} RETURN id(n)`) + +. The relationship itself will get created ++ +(`MATCH (startNode) WHERE id(startNode) = $fromId MATCH (endNode) WHERE id(endNode) = 631 MERGE (startNode)-[:Has]->(endNode)`) + +. If the related entity also has relationships to other entities, the same procedure as in 2. will get started. + +. For the next defined relationship on the root entity start with 2. but replace _first_ with _next_. + + +NOTE: As you can see SDN/RX does its best to keep your graph model in sync with the Java world. + This is one of the reasons why we really advise you to not load, manipulate and save sub-graphs + as this might cause relationships to get removed from the database. + +=== Multiple entities + +The `save` operation is overloaded with the functionality for accepting multiple entities of the same type. +If you are working with generated id values or make use of optimistic locking, every entity will result in a separate `CREATE` call. + +In other cases SDN/RX will create a parameter list with the entity information and provide it with a `MERGE` call. + +`UNWIND ${neo4jEntities} AS entity MERGE (n:Person {customId: entity.${neo4jId}}) SET n = entity.{neo4jProperties} RETURN collect(n.customId) AS ${neo4jIds}` + +and the parameters look like + +`:params {{neo4jEntities}: [{{neo4jId}: 'aa', {neo4jProperties}: {name: "PersonName", theId: "aa"}}, {{neo4jId} 'bb', {neo4jProperties}: {name: "AnotherPersonName", theId: "bb"}}]}` + +== Load + +The `load` documentation will not only show you how the _MATCH_ part of the query looks like but also how the data gets returned. + +The simplest kind of load operation is a `findById` call. +It will match all nodes with the label of the type you queried for and does a filter on the id value. + +`MATCH (n:Person) WHERE id(n) = 1364` + +If there is a custom id provided SDN/RX will use the property you have defined as the id. + +`MATCH (n:Person) WHERE n.customId = 'anId'` + +The data to return is defined as a https://neo4j.com/docs/cypher-manual/current/syntax/maps/#cypher-map-projection[map projection]. + +`RETURN n{.first_name, .personNumber, {neo4jInternalId}: id(n), {neo4jLabels}: labels(n)}` + +As you can see there are two special fields in there: The `{neo4jInternalId}` and the `{neo4jLabels}`. +Both are critical when it comes to mapping the data to Java objects. +The value of the `{neo4jInternalId}` is either `id(n)` or the provided custom id but in the mapping process one known field to refer to has to exist. +The `{neo4jLabels}` ensures that all defined labels on this node can be found and mapped. +This is needed for situations when inheritance is used and you query not for the concrete classes or have relationships defined that only define a super-type. + +Talking about relationships: If you have defined relationships in your entity, they will get added to the returned map as https://neo4j.com/docs/cypher-manual/4.0/syntax/lists/#cypher-pattern-comprehension[pattern comprehensions]. +The above return part will then look like: + +`RETURN n{.first_name, ..., Person_Has_Hobby: [(n)-[:Has]->(n_hobbies:Hobby)|n_hobbies{{neo4jInternalId}: id(n_hobbies), .name, __nodeLabels__: labels(n_hobbies)}]}` + +The map projection and pattern comprehension used by SDN/RX ensures that only the properties and relationships you have defined are getting queried. + diff --git a/src/main/asciidoc/appendix/sdc-repository-query-keywords-reference.adoc b/src/main/asciidoc/appendix/sdc-repository-query-keywords-reference.adoc new file mode 100644 index 000000000..f140b706e --- /dev/null +++ b/src/main/asciidoc/appendix/sdc-repository-query-keywords-reference.adoc @@ -0,0 +1,38 @@ +[[repository-query-keywords]] += Repository query keywords + +The following table lists the keywords supported by the Spring Data Neo4j⚡RX repository query derivation mechanism. + +.Query keywords +[options="header", cols="1,3"] +|=============== +|Logical keyword|Keyword expressions +|`AND`|`And` +|`OR`|`Or` +|`AFTER`|`After`, `IsAfter` +|`BEFORE`|`Before`, `IsBefore` +|`CONTAINING`|`Containing`, `IsContaining`, `Contains` +|`BETWEEN`|`Between`, `IsBetween` +|`ENDING_WITH`|`EndingWith`, `IsEndingWith`, `EndsWith` +|`EXISTS`|`Exists` +|`FALSE`|`False`, `IsFalse` +|`GREATER_THAN`|`GreaterThan`, `IsGreaterThan` +|`GREATER_THAN_EQUALS`|`GreaterThanEqual`, `IsGreaterThanEqual` +|`IN`|`In`, `IsIn` +|`IS`|`Is`, `Equals`, (or no keyword) +|`IS_EMPTY`|`IsEmpty`, `Empty` +|`IS_NOT_EMPTY`|`IsNotEmpty`, `NotEmpty` +|`IS_NOT_NULL`|`NotNull`, `IsNotNull` +|`IS_NULL`|`Null`, `IsNull` +|`LESS_THAN`|`LessThan`, `IsLessThan` +|`LESS_THAN_EQUAL`|`LessThanEqual`, `IsLessThanEqual` +|`LIKE`|`Like`, `IsLike` +|`NEAR`|`Near`, `IsNear` +|`NOT`|`Not`, `IsNot` +|`NOT_IN`|`NotIn`, `IsNotIn` +|`NOT_LIKE`|`NotLike`, `IsNotLike` +|`REGEX`|`Regex`, `MatchesRegex`, `Matches` +|`STARTING_WITH`|`StartingWith`, `IsStartingWith`, `StartsWith` +|`TRUE`|`True`, `IsTrue` +|`WITHIN`|`Within`, `IsWithin` +|=============== diff --git a/src/main/asciidoc/appendix/sdc-repository-query-return-types-reference.adoc b/src/main/asciidoc/appendix/sdc-repository-query-return-types-reference.adoc new file mode 100644 index 000000000..2b6c7dfca --- /dev/null +++ b/src/main/asciidoc/appendix/sdc-repository-query-return-types-reference.adoc @@ -0,0 +1,43 @@ +[[repository-query-return-types]] += Repository query return types + +The following table lists the return types generally supported by SDN/RX repositories. + +.Query return types +[options="header", cols="1,3"] +|=============== +|Return type|Description +|`void`|Denotes no return value. +|Primitives|Java primitives. +|Wrapper types|Java wrapper types. +|`T`|An unique entity. + Expects the query method to return one result at most. If no result is found, `null` is returned. More than one result triggers an `IncorrectResultSizeDataAccessException`. +|`Iterator`|An `Iterator`. +|`Collection`|A `Collection`. +|`List`|A `List`. +|`Optional`|A Java 8 or Guava `Optional`. + Expects the query method to return one result at most. If no result is found, `Optional.empty()` or `Optional.absent()` is returned. More than one result triggers an `IncorrectResultSizeDataAccessException`. +|`Option`|Either a Scala or Vavr `Option` type. + Semantically the same behavior as Java 8's `Optional`, described earlier. +|`Stream`|A Java 8 `Stream`. +|`Streamable`|A convenience extension of `Iterable` that directy exposes methods to stream, map and filter results, concatenate them etc. +|Types that implement `Streamable` and take a `Streamable` constructor or factory method argument|Types that expose a constructor or `….of(…)`/`….valueOf(…)` factory method taking a `Streamable` as argument. + See <> for details. +|Vavr `Seq`, `List`, `Map`, `Set`|Vavr collection types. See <> for details. +|`Future`|A `Future`. + Expects a method to be annotated with `@Async` and requires Spring's asynchronous method execution capability to be enabled. +|`CompletableFuture`|A Java 8 `CompletableFuture`. + Expects a method to be annotated with `@Async` and requires Spring's asynchronous method execution capability to be enabled. +|`ListenableFuture`|A `org.springframework.util.concurrent.ListenableFuture`. + Expects a method to be annotated with `@Async` and requires Spring's asynchronous method execution capability to be enabled. +|`Slice`|A sized chunk of data with an indication of whether there is more data available. + Requires a `Pageable` method parameter. +|`Page`|A `Slice` with additional information, such as the total number of results. + Requires a `Pageable` method parameter. +|`Mono`|A Project Reactor `Mono` emitting zero or one element using reactive repositories. + Expects the query method to return one result at most. + If no result is found, `Mono.empty()` is returned. + More than one result triggers an `IncorrectResultSizeDataAccessException`. +|`Flux`|A Project Reactor `Flux` emitting zero, one, or many elements using reactive repositories. + Queries returning `Flux` can emit also an infinite number of elements. +|=============== diff --git a/src/main/asciidoc/auditing/index.adoc b/src/main/asciidoc/auditing/index.adoc new file mode 100644 index 000000000..30dec5527 --- /dev/null +++ b/src/main/asciidoc/auditing/index.adoc @@ -0,0 +1 @@ +include::sdc-auditing.adoc[leveloffset=+1] diff --git a/src/main/asciidoc/auditing/sdc-auditing.adoc b/src/main/asciidoc/auditing/sdc-auditing.adoc new file mode 100644 index 000000000..e1022f578 --- /dev/null +++ b/src/main/asciidoc/auditing/sdc-auditing.adoc @@ -0,0 +1,71 @@ +[[auditing]] += Auditing + +[[auditing.basics]] +== Basics +Spring Data provides sophisticated support to transparently keep track of who created or changed an entity and when the change happened. +To benefit from that functionality, you have to equip your entity classes with auditing metadata that can be defined either using annotations or by implementing an interface. + +[[auditing.annotations]] +=== Annotation-based Auditing Metadata +We provide `@CreatedBy` and `@LastModifiedBy` to capture the user who created or modified the entity as well as `@CreatedDate` and `@LastModifiedDate` to capture when the change happened. + +.An audited entity +==== +[source, java] +---- +class Customer { + + @CreatedBy + private User user; + + @CreatedDate + private DateTime createdDate; + + // … further properties omitted +} +---- +==== + +As you can see, the annotations can be applied selectively, depending on which information you want to capture. +The annotations capturing when changes were made can be used on properties of type Joda-Time, `DateTime`, legacy Java `Date` and `Calendar`, JDK8 date and time types, and `long` or `Long`. + +[[auditing.interfaces]] +=== Interface-based Auditing Metadata +In case you do not want to use annotations to define auditing metadata, you can let your domain class implement the `Auditable` interface. +It exposes setter methods for all of the auditing properties. + +There is also a convenience base class, `AbstractAuditable`, which you can extend to avoid the need to manually implement the interface methods +Doing so increases the coupling of your domain classes to Spring Data, which might be something you want to avoid. +Usually, the annotation-based way of defining auditing metadata is preferred as it is less invasive and more flexible. + +[[auditing.auditor-aware]] +=== `AuditorAware` + +In case you use either `@CreatedBy` or `@LastModifiedBy`, the auditing infrastructure somehow needs to become aware of the current principal. +To do so, we provide an `AuditorAware` SPI interface that you have to implement to tell the infrastructure who the current user or system interacting with the application is. +The generic type `T` defines what type the properties annotated with `@CreatedBy` or `@LastModifiedBy` have to be. + +The following example shows an implementation of the interface that uses Spring Security's `Authentication` object: + +.Implementation of AuditorAware based on Spring Security +==== +[source, java] +---- +class SpringSecurityAuditorAware implements AuditorAware { + + public Optional getCurrentAuditor() { + + return Optional.ofNullable(SecurityContextHolder.getContext()) + .map(SecurityContext::getAuthentication) + .filter(Authentication::isAuthenticated) + .map(Authentication::getPrincipal) + .map(User.class::cast); + } +} +---- +==== + +The implementation accesses the `Authentication` object provided by Spring Security and looks up the custom `UserDetails` instance +that you have created in your `UserDetailsService` implementation. +We assume here that you are exposing the domain user through the `UserDetails` implementation but that, based on the `Authentication` found, you could also look it up from anywhere. diff --git a/src/main/asciidoc/faq.adoc b/src/main/asciidoc/faq.adoc deleted file mode 100644 index e6449e992..000000000 --- a/src/main/asciidoc/faq.adoc +++ /dev/null @@ -1,61 +0,0 @@ -[[faq]] -[appendix] -= Frequently asked questions - -[qanda] -What is the difference between Neo4j-OGM and Spring Data Neo4j (SDN)?:: - -Spring Data Neo4j (SDN) uses Neo4j-OGM to perform the mapping to and from the database. -OGM can be seen on the same level as a JPA implementation like Hibernate in the context of Spring Data JPA. - -How do I set up my Spring Configuration with Spring WebMVC projects?:: -If you are using a Spring WebMVC application, the following configuration is all that's required: -[source,java] ----- -@Configuration -@EnableWebMvc -@ComponentScan({"org.neo4j.example.web"}) -@EnableNeo4jRepositories("org.neo4j.example.repository") -@EnableTransactionManagement -public class MyWebAppConfiguration extends WebMvcConfigurerAdapter { - - @Bean - public SessionFactory sessionFactory() { - // with domain entity base package(s) - return new SessionFactory("org.neo4j.example.domain"); - } - - @Bean - public Neo4jTransactionManager transactionManager() throws Exception { - return new Neo4jTransactionManager(sessionFactory()); - } -} ----- - -How do I set up my Spring Configuration with a Java Servlet 3.x+ Container project?:: -If you are using a Java Servlet 3.x+ Container, you can configure a Servlet filter with Spring's `AbstractAnnotationConfigDispatcherServletInitializer` like this: -[source,java] ----- -public class MyAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected void customizeRegistration(ServletRegistration.Dynamic registration) { - registration.setInitParameter("throwExceptionIfNoHandlerFound", "true"); - } - - @Override - protected Class[] getRootConfigClasses() { - return new Class[] {ApplicationConfiguration.class} // if you have broken up your configuration, this points to your non web application config/s. - } - - @Override - protected Class[] getServletConfigClasses() { - throw new Class[] {WebConfiguration.class}; // a configuration that extends the WebMvcConfigurerAdapter as seen above. - } - - @Override - protected String[] getServletMappings() { - return new String[] {"/"}; - } -} ----- diff --git a/src/main/asciidoc/faq/faq.adoc b/src/main/asciidoc/faq/faq.adoc new file mode 100644 index 000000000..6c25563f7 --- /dev/null +++ b/src/main/asciidoc/faq/faq.adoc @@ -0,0 +1,216 @@ +[[faq]] += Frequently Asked Questions + +Here are a couple of more frequently asked question in addition to the ones in the <>. + +== Neo4j 4.0 supports multiple databases - How can I use them? + +You can either statically configure the database name or run your own database name provider. +Bear in mind that SDN/RX will not create the databases for you. +You can do this with the help of a https://github.com/michael-simons/neo4j-migrations[migrations tool] +or of course with a simple script upfront. + +=== Statically configured + +Configure the database name to use in your Spring Boot configuration like this +(The same property applies of course for YML or environment based configuration, with Spring Boots conventions applied): + +[source,properties] +---- +org.neo4j.data.database = yourDatabase +---- + +With that configuration in place, all queries generated by all instances of SDN/RX repositories (both reactive and imperative) +and by the `ReactiveNeo4jTemplate` respectively `Neo4jTemplate` will be executed against the database `yourDatabase`. + +=== Dynamically configured + +Provide a bean with the type `Neo4jDatabaseNameProvider` or `ReactiveDatabaseSelectionProvider` depending on the type of your Spring application. + +That bean could use for example Spring's security context to retrieve a tenant. +Here is a working example for an imperative application secured with Spring Security: + +[source,java] +[[faq.databaseSelectionProvider]] +.Neo4jConfig.java +---- +include::../../examples/multi-database/src/main/java/org/neo4j/springframework/data/examples/spring_boot/Neo4jConfig.java[tags=faq.multidatabase] +---- + +NOTE: Be careful that you don't mix up entities retrieved from one database with another database. + The database name is requested for each new transaction, so you might end up with less or more + entities than expected when changing the database name in between calls. + Or worse, you could inevitable store the wrong entities in the wrong database. + +== Do I need specific configuration so that transactions work seamless with a Neo4j Causal Cluster? + +No, you don't. +SDN/RX uses Neo4j Causal Cluster bookmarks internally without any configuration on your side required. +Transactions in the same thread or the same reactive stream following each other will be able to read their previously changed values as you would expect. + +== Do I need to use Neo4j specific annotations? + +No. +You are free to use the following, equivalent Spring Data annotations: + +[cols="4*", options="header"] +|=== + +|SDN/RX Neo4j specific annotation +|Spring Data common annotation +|Purpose +|Difference + +|`org.neo4j.springframework.data.core.schema.Id` +|`org.springframework.data.annotation.Id` +|Marks the annotated attribute as the unique id. +|Specific annotation has no additional features. + +|`org.neo4j.springframework.data.core.schema.Node` +|`org.springframework.data.annotation.Persistent` +|Marks the class as persistent entity. +|`@Node` allows customizing the labels + +|=== + +== How do I use assigned ids? + +Just `@Id` without `@GeneratedValue` and fill your id attribute via a constructor parameter or a setter or _wither_. +See this https://medium.com/neo4j/neo4j-ogm-and-spring-data-neo4j-a55a866df68c[blog post] for some general remarks about finding good ids. + +== How do I use externally generated ids? + +We provide the interface `org.neo4j.springframework.data.core.schema.IdGenerator`. +Implement it anyway you want and configure your implementation like this: + +[source,java] +.ThingWithGeneratedId.java +---- +@Node +public class ThingWithGeneratedId { + + @Id @GeneratedValue(TestSequenceGenerator.class) + private String theId; +} +---- + +If you pass in the name of a class to `@GeneratedValue`, this class must have a no-args default constructor. +You can however use a string as well: + +[source,java] +.ThingWithIdGeneratedByBean.java +---- +@Node +public class ThingWithIdGeneratedByBean { + + @Id @GeneratedValue(generatorRef = "idGeneratingBean") + private String theId; +} +---- + +With that, `idGeneratingBean` refers to a bean in the Spring context. +This might be useful for sequence generating. + +NOTE: Setters are not required on non-final fields for the id. + +[[template-support]] +== Do I have to create repositories for each domain class? + +No. +Have a look at the <> and +find the `Neo4jTemplate` respectively the `ReactiveNeo4jTemplate.` + +Those templates know your domain and provide all necessary basic CRUD methods for retrieving, writing and counting entities. + +This is our canonical movie example with the imperative template: + +[source,java] +[[imperative-template-example]] +.TemplateExampleTest.java +---- +include::../../examples/imperative-web/src/test/java/org/neo4j/springframework/data/examples/spring_boot/TemplateExampleTest.java[tags=faq.template-imperative] +---- + +And here is the reactive version, omitting the setup for brevity: + +[source,java] +[[reactive-template-example]] +.ReactiveTemplateExampleTest.java +---- +include::../../examples/reactive-web/src/test/java/org/neo4j/springframework/data/examples/spring_boot/ReactiveTemplateExampleTest.java[tags=faq.template-reactive] +---- + +== How do I specify parameters in custom queries? + +You do this exactly the same way as in a standard Cypher query issued in the Neo4j Browser or the Cypher-Shell, +with the `$` syntax (from Neo4j 4.0 on upwards, the old `{foo}` syntax for Cypher parameters has been removed from the database); + +[source,java,indent=0] +[[custom-queries-with-parameters]] +.ARepository.java +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/domain_events/ARepository.java[tags=standard-parameter] +---- +<.> Here we are referring to the parameter by its name. + You can also use `$0` etc. instead. + +NOTE: You need to compile your Java 8+ project with `-parameters` to make named parameters + work without further annotations. The Spring Boot Maven and Gradle plugins do this + automatically for you. If this is not feasible for any reason, you can either add + `@Param` and specify the name explicitly or use the parameters index. + +== How do I use Spring Expression Language in custom queries? + +https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#expressions[Spring Expression Language (SpEL)] can be used in custom queries inside `:#{}`. +This is the standard Spring Data way of defining a block of text inside a query that undergoes SpEL evaluation. + +The following example basically defines the same query as above, but uses a `WHERE` clause to avoid even more curly braces: + +[source,java,indent=0] +[[custom-queries-with-spel]] +.ARepository.java +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/domain_events/ARepository.java[tags=spel] +---- + +The SpEL blocked starts with `:#{` and than refers to the given `String` parameters by name (`#pt1`). +Don't confuse this with the above Cypher syntax! +The SpEL expression concatenates both parameters into one single value that is eventually passed on to the <>. +The SpEL block ends with `}`. + +== How do I audit entities? + +All Spring Data annotations are supported. +Those are + +* `org.springframework.data.annotation.CreatedBy` +* `org.springframework.data.annotation.CreatedDate` +* `org.springframework.data.annotation.LastModifiedBy` +* `org.springframework.data.annotation.LastModifiedDate` + +== How do I use "Find by example"? + +"Find by example" is a new feature in SDN/RX. +You instantiate an entity or use an existing one. +With this instance you create an `org.springframework.data.domain.Example`. +If your repository extends `org.neo4j.springframework.data.repository.Neo4jRepository` or `org.neo4j.springframework.data.repository.ReactiveNeo4jRepository`, +you can immediately use the available `findBy` methods taking in an example, like shown in <> + +[source,java] +[[find-by-example-example]] +.findByExample in Action +---- +Example movieExample = Example.of(new MovieEntity("The Matrix", null)); +Flux movies = this.movieRepository.findAll(movieExample); + +movieExample = Example.of( + new MovieEntity("Matrix", null), + ExampleMatcher + .matchingAny() + .withMatcher( + "title", + ExampleMatcher.GenericPropertyMatcher.of(ExampleMatcher.StringMatcher.CONTAINING) + ) +); +movies = this.movieRepository.findAll(movieExample); +---- diff --git a/src/main/asciidoc/faq/index.adoc b/src/main/asciidoc/faq/index.adoc new file mode 100644 index 000000000..9cb44a98d --- /dev/null +++ b/src/main/asciidoc/faq/index.adoc @@ -0,0 +1 @@ +include::faq.adoc[leveloffset=+1] diff --git a/src/main/asciidoc/foreword.adoc b/src/main/asciidoc/foreword.adoc deleted file mode 100644 index c024c1987..000000000 --- a/src/main/asciidoc/foreword.adoc +++ /dev/null @@ -1,32 +0,0 @@ -[[forward]] -= Foreword - -[quote, Rod Johnson, Founder of the Spring Framework] -____ -I'm excited about Spring Data Neo4j for several reasons. - -First, this project is in a very important space. We are in an era of transition. A very few years ago, a relational database was a given for storing nearly all the data in nearly all applications. While relational databases remain important, new application requirements and massive data proliferation have prompted a richer choice of data stores. Graph databases have some very interesting strengths, and Neo4j is proving itself valuable in many applications. It's a choice you should add to your toolbox. - -Second, Spring Data Neo4j is an innovative project, which makes it easy to work with one of the most interesting new data stores. Unfortunately, the proliferation of new data stores has not been matched by innovation in programming models to work with them. Ironically, just after modern ORM mapping made working with relational data in Java relatively easy, the data store disruption occurred, and developers were back to square one: struggling once more with clumsy, low level APIs. Working with most non-relational technologies is overly complex and imposes too much work on developers. Spring Data Neo4j makes working with Neo4j amazingly easy, and therefore has the potential to make you more successful as a developer. Its use of AspectJ to eliminate persistence code from your domain model is truly innovative, and on the cutting edge of today's Java technologies. - -Third, I'm excited about Spring Data Neo4j for personal reasons. I no longer get to write code as often as I would like. My initial convictions that Spring and AspectJ could both make building applications with Neo4j dramatically easier and cross-store object navigation possible gave me an excuse for a much-needed coding binge early in 2010. This led to a prototype of what became Spring Data Neo4j — at times written paired with Emil. I'm sure the vast majority of my code has long since been replaced (probably for the better) by coders who aren't rusty — thanks Michael and Thomas! — but I retain my pleasant memories. - -Finally, Spring Data Neo4j is part of the broader Spring Data project: one of the key areas in which Spring is innovating to help meet new application requirements. I encourage you to explore Spring Data, and — better still — become involved in the community and contribute. - -Enjoy the Spring Data Neo4j book, and happy coding! -____ - - -[quote, Emil Eifrem, CEO of Neo Technology] -____ -"Spring is the most popular middleware on the planet," I thought to myself as I walked up to Rod Johnson in late 2009 at the JAOO conference in Aarhus, Denmark. Rod had just given an introductory presentation about Spring Roo and when he was done I told him "Great talk. You're clearly building a stack for the future. What about support for non-relational databases?" - -We started talking and quickly agreed that NOSQL will play an important role in emerging stacks. Now, a year and half later, Spring Data Neo4j is available in its first stable release and I'm blown away by the result. Never before in any environment, in any programming framework, in any stack, has it been so easy and intuitive to tap into the power of a graph database like Neo4j. It's a testament to the efforts by an awesome team of four hackers from Neo Technology and VMware: Michael Hunger, David Montag, Thomas Risberg and Mark Pollack. - -The Spring framework revolutionized how we all wrote enterprise Java applications and today it's used by millions of enterprise developers. Graph databases also stand out in the NOSQL crowd when it comes to enterprise adoption. You can find graph databases used in areas as diverse as network management, fraud detection, cloud management, anything with social data, geo and location services, master data management, bioinformatics, configuration databases, and much more. - -Spring developers deserve access to the best tools available to solve their problem. Sometimes that's a relational database accessed through JPA. But more often than not, a graph database like Neo4j is the perfect fit for your project. I hope that Spring Data Neo4j will give you access to the power and flexibility of graph databases while retaining the familiar productivity and convenience of the Spring framework. - -Enjoy the Spring Data Neo4j guide book and welcome to the wonderful world of graph databases! -____ - diff --git a/src/main/asciidoc/getting-started/getting-started.adoc b/src/main/asciidoc/getting-started/getting-started.adoc new file mode 100644 index 000000000..f780e67cb --- /dev/null +++ b/src/main/asciidoc/getting-started/getting-started.adoc @@ -0,0 +1,259 @@ +[[getting-started]] += Getting started + +We provide a Spring Boot starter for SDN/RX. +Please include the starter module via your dependency management and configure the bolt URL to use, for example `org.neo4j.driver.uri=bolt://localhost:7687`. +The starter assumes that the server has disabled authentication. +As the SDN/RX starter depends on the starter for the Java Driver, all things regarding configuration said there, apply here as well. +For a reference of the available properties, use your IDEs autocompletion in the `org.neo4j.driver` namespace +or look at the link:{java-driver-starter-href}/blob/master/docs/manual.adoc[dedicated manual]. + +SDN/RX supports + +* The well known and understood imperative programming model (much like Spring Data JDBC or JPA) +* Reactive programming based on https://www.reactive-streams.org[Reactive Streams], including full support for https://spring.io/blog/2019/05/16/reactive-transactions-with-spring[reactive transactions]. + +Those are all included in the same binary. +The reactive programming model requires a 4.0 Neo4j server on the database side and reactive Spring on the other hand. +Have a look at the link:{gh-base}/tree/master/examples[examples directory] for all examples. + +== Prepare the database + +For this example, we stay within the https://neo4j.com/developer/movie-database/[movie graph], +as it comes for free with every Neo4j instance. + +If you don't have a running database but Docker installed, please run: + +[source,console,subs="verbatim,attributes"] +[[start-docker-neo4j]] +.Start a local Neo4j instance inside Docker. +---- +docker run --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/secret' neo4j:{neo4j-version} +---- + +You know can access http://localhost:7474/browser/?cmd=play&arg=movies[http://localhost:7474]. +The above command sets the password of the server to `secret`. +Note the command ready to run in the prompt (`:play movies`). +Execute it to fill your database with some test data. + +== Create a new Spring Boot project + +The easiest way to setup a Spring Boot project is https://start.spring.io[start.spring.io] + (which is integrated in the major IDEs as well, in case you don't want to use the website). + +Select the "Spring Web Starter" to get all the dependencies needed for creating a Spring based web application. +The Spring Initializr will take care of creating a valid project structure for you, +with all the files and settings in place for the selected build tool. + +WARNING: Don't choose Spring Data Neo4j here, as it will get you the previous generation of Spring Data Neo4j including OGM and additional abstraction over the driver. + +You might want to follow https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.2.4.RELEASE&packaging=jar&jvmVersion=1.8&groupId=com.example&artifactId=demo&name=Neo4j%20Spring%20Boot%20Example&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=webflux,actuator[this link for a preconfigured setup]. + +=== Using Maven + +You can issue a _curl_ request against the Spring Initializer to create a basic Maven project: + +[source,bash,subs="verbatim,attributes"] +[[generate-maven-project]] +.Create a basic Maven project with the Spring Initializr +---- +curl https://start.spring.io/starter.tgz \ + -d dependencies=webflux,actuator \ + -d bootVersion={spring-boot-version} \ + -d baseDir=Neo4jSpringBootExample \ + -d name=Neo4j%20SpringBoot%20Example | tar -xzvf - +---- + +This will create a new folder `Neo4jSpringBootExample`. +As this starter is not yet on the initializer, you will have to add the following dependency manually to your `pom.xml`: + +[source,xml,subs="verbatim,attributes"] +[[dependencies-maven]] +.Inclusion of the spring-data-neo4j-rx-spring-boot-starter in a Maven project +---- + + {groupId} + {artifactIdStarter} + {spring-data-neo4j-rx-version} + +---- + +You would also add the dependency manually in case of an existing project. + +=== Using Gradle + +The idea is the same, just generate a Gradle project: + +[source,bash,subs="verbatim,attributes"] +[[generate-gradle-project]] +.Create a basic Gradle project with the Spring Initializr +---- +curl https://start.spring.io/starter.tgz \ + -d dependencies=webflux,actuator \ + -d type=gradle-project \ + -d bootVersion={spring-boot-version} \ + -d baseDir=Neo4jSpringBootExampleGradle \ + -d name=Neo4j%20SpringBoot%20Example | tar -xzvf - +---- + +The dependency for Gradle looks like this and must be added to `build.gradle`: + +[source,groovy,subs="verbatim,attributes"] +.Inclusion of the spring-data-neo4j-rx-spring-boot-starter in a Gradle project +---- +dependencies { + implementation '{groupId}:{artifactIdStarter}:{spring-data-neo4j-rx-version}' +} +---- + +You would also add the dependency manually in case of an existing project. + +== Configure the project + +Now open any of those projects in your favorite IDE. +Find `application.properties` and configure your Neo4j credentials: + +[source,properties] +---- +org.neo4j.driver.uri=bolt://localhost:7687 +org.neo4j.driver.authentication.username=neo4j +org.neo4j.driver.authentication.password=secret +---- + +This is the bare minimum of what you need to connect to a Neo4j instance. + +NOTE: It is not necessary to add any programmatically configuration of the driver when you use this starter. + SDN/RX repositories will be automatically enabled by this starter. + +== Create your domain + +Our domain layer should accomplish two things: + +* Map your graph to objects +* Provide access to those + +=== Example Node-Entity + +SDN/RX fully supports unmodifiable entities, for both Java and `data` classes in Kotlin. +Therefor we will focus on immutable entities here, <> shows a such an entity. + +NOTE: SDN/RX supports all data types the Neo4j Java Driver supports, + see https://neo4j.com/docs/driver-manual/current/cypher-values/#driver-neo4j-type-system[Map Neo4j types to native language types] inside the chapter "The Cypher type system". + Future versions will support additional converters. + +[source,java] +[[movie-entity]] +.MovieEntity.java +---- +include::../../examples/reactive-web/src/main/java/org/neo4j/springframework/data/examples/spring_boot/domain/MovieEntity.java[tags=mapping.annotations] +---- +<.> `@Node` is used to mark this class as a managed entity. + It also is used to configure the Neo4j label. + The label defaults to the name of the class, if you're just using plain `@Node`. +<.> Each entity has to have an id. + The movie class shown here uses the attribute `title` as a unique business key. + If you don't have such a unique key, you can use the combination of `@Id` and `@GeneratedValue` + to configure SDN/RX to use Neo4j's internal id. + We also provide generators for UUIDs. +<.> This shows `@Property` as a way to use a different name for the field than for the graph property. +<.> This defines a relationship to a class of type `PersonEntity` and the relationship type `ACTED_IN` +<.> This is the constructor to be used by your application code. + +As a general remark: Immutable entities using internally generated ids are a bit contradictory, +as SDN/RX needs a way to set the field with the value generated by the database. + +If you don't find a good business key or don't want to use a generator for IDs, here's the same entity using +the internally generated id together with a businesses constructor and a so called _wither_-Method, that is used by SDN/RX: + +[source,java] +[[movie-entity-with-wither]] +.MovieEntity.java +---- +import org.neo4j.springframework.data.core.schema.GeneratedValue; +import org.neo4j.springframework.data.core.schema.Id; +import org.neo4j.springframework.data.core.schema.Node; +import org.neo4j.springframework.data.core.schema.Property; + +import org.springframework.data.annotation.PersistenceConstructor; + +@Node("Movie") +public class MovieEntity { + + @Id @GeneratedValue + private Long id; + + private final String title; + + @Property("tagline") + private final String description; + + public MovieEntity(String title, String description) { // <.> + this.id = null; + this.title = title; + this.description = description; + } + + public MovieEntity withId(Long id) { // <.> + if (this.id.equals(id)) { + return this; + } else { + MovieEntity newObject = new MovieEntity(this.title, this.description); + newObject.id = id; + return newObject; + } + } +} +---- +<.> This is the constructor to be used by your application code. + It sets the id to null, as the field containing the internal id should never be manipulated. +<.> This is a so-called _wither_ for the `id`-attribute. + It creates a new entity and sets the field accordingly, + without modifying the original entity, thus making it immutable. + + +You can of course use SDN/RX with https://kotlinlang.org/[Kotlin] and model your domain with Kotlin's data classes. +https://projectlombok.org/[Project Lombok] is an alternative if you want or need to stay purely within Java. + + +=== Declaring Spring Data repositories + +You basically have two options here: +You can work store agnostic with SDN/RX and make your domain specific extends one of + +* `org.springframework.data.repository.Repository` +* `org.springframework.data.repository.CrudRepository` +* `org.springframework.data.repository.reactive.ReactiveCrudRepository` +* `org.springframework.data.repository.reactive.ReactiveSortingRepository` + +Choose imperative and reactive accordingly. + +WARNING: While technically not prohibited, it is not recommended to mix imperative and reactive database access + in the same application. + We won't support you with scenarios like this. + +The other option is to settle on a store specific implementation and gain all the methods we support out of the box. +The advantage of this approach is also it's biggest disadvantage: Once out, all those methods will be part of your API. +Most of the time it's harder to take something away, than to add stuff afterwards. +Furthermore, using store specifics leaks your store into your domain. +From a performance point of view, there is no penalty. + +A repository fitting to any of the movie entities above looks like this: + +[source,java] +[[movie-repository]] +.MovieRepository.java +---- +include::../../examples/reactive-web/src/main/java/org/neo4j/springframework/data/examples/spring_boot/domain/MovieRepository.java[tags=getting.started] +---- + +This repository can be used in any Spring component like this: + +[source,java] +[[movie-controller]] +.MovieController.java +---- +include::../../examples/reactive-web/src/main/java/org/neo4j/springframework/data/examples/spring_boot/web/MovieController.java[tags=getting.started] +---- + +TIP: Testing reactive code is done with a `reactor.test.StepVerifier`. + Have a look at the corresponding https://projectreactor.io/docs/core/release/reference/#testing[documentation of Project Reactor] or see our example code. diff --git a/src/main/asciidoc/getting-started/index.adoc b/src/main/asciidoc/getting-started/index.adoc new file mode 100644 index 000000000..ccf955933 --- /dev/null +++ b/src/main/asciidoc/getting-started/index.adoc @@ -0,0 +1 @@ +include::getting-started.adoc[leveloffset=+1] diff --git a/src/main/asciidoc/images/SDN-Architecture.png b/src/main/asciidoc/images/SDN-Architecture.png deleted file mode 100644 index 89dba17835b33bfbb064300dc80d2ed524a52045..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 71072 zcmeFZ`9GB3|36-#k`NUkRFY&X+1E<;kUh(g?0aGi29p*lTlVZ^H^yY&hN)!9nq_Qb zOxCfD31h|>%V+d_y`Qh=^Zf^WZ{P3d+bpJILkLCVY&-M19z9#c2?o&sO9AVbh zx^Hyk2wmZkBMe7Q9;c0%a2i~p{W$7tqO=0xy0$DPmX zy-rn2yeAo($>Qqo-P+2>nw%B;jR}35tMg^J5>OUoWt`{AjgJ{xnn7_lnn%xEYW9rB zIBY_)=C9R>GG0EDoZ0KG%Ab*$3YrSU5_lN<5sso9Dkm>JKXUBPpicq)hHcs1M3sw0zrhf^?L*%hhTgYC`R(c-9w~9jcUuZ!;KT6l0)^t3P z?9)D}&A4U9w9>0O|4^IEn)cr9o z{~s{p^yQypconZ))6e)&>xr)IG&bz2>Qh(=(-m)+lbM|Ylh>FbWDH1gZfFy&J0ZZfa`k zkf4@jVC7mK#mT{8Oz>p1$7ngg$H>U2!AAm;{H5L*h=wEg8!3mY-qqIDMvy6W*idjk z2831ioa>AmpX#8*{08aI-_KpTshrw47ft(9>T%fa?(PqmRh_@-u_bwY@Xya-T*AV_ z<;L32zA$i>Nk~Yr@+b!pYZCx0OXpYX9KOfrn%jnKfj}7GD93E*zUWII11ug9xEVhM zCNy`8h={;i!D7Q2|473?+HRhTB%mL1h37- zMHfwE=w59Q*^k@Ryxf|Lim$`^CuOxIzI%5nop{Vyr*WQF!SAUHcV-o3vtJc7g@iy# z*ZMOR>u_n(?v^oJx1ExXhe;>h#Wi=;z|7$`n8uu(OXaRZg(oChwr94~B3OC{f}>*X zetkP@(32!t_o&vxq6vXOywZr~cGQ+n_Qy}ujA>b6{JRo`dx6_tDdGUL0EPlnZ9)Ss z%NEy@dixnoiaen#`{c;JyGg#D4t-B`rQIW|d$%7;t68HD?Gfi=^l!l$Dh&+`4s3o?Wi3 zpr{D6jrWG2w`gI;MQ3^|ptcoYUe;@J%x`aJYwzlHvd{+Q(?%dDygl# zeL-g&t@CM8?Zp@~f9Uq~RRM{mEl+_jBkB`pFY@z49v)k~F6<0uT-ed!%gzYhSqh|* z@R67*X9IV6oW(EgV|~}u)zuk|WDOph0l1{DH`DkEPx5qgaB#RA5Kymnj8e-^&-&i3 z!oi@e08g%0yb7|cOjM(5av>J7YcDH2i)?-wIICdaMB`TB4&Yc@Z~H9* ztS_Q@e`f`m@KesZ%QK1ebcG^|4X#R{pX2Oq4L`*wb-O^NWUx?~#-|Cj373!LPgnx- zKxGS7H`RDA<4S?Jy4xk+XzCl!noTpueIKgNY&+mu9pix1lL`GH-S;iT?1Noge-Pxa zwAB}}&!vbjn3iD{njw-CJjRXyrtm~)omplqb^uP+SiUE;Q1!uj(7nY;gH-Z%JFDvM zudsY-3cbS0DJG@_!Asn$;Jbjq9h;S=g8@zcnxq`RM0#Izf$XLjV~a}Cc{i-bNZGjA zQuE3cCOKDtXyXe!4H~2^!P+(A52Kv=tr_=O<&d7GHv+j`aP1aHJwk`ThUqomw0h_?6{GD)Q#k_^yQ{pF-i z4d*~_fpz2^c z)zQbtC!;W-0d`p<$dyny+YyU=bZlnNlD{Ut@xUtRIa%ki!kvB|*YV%TMGrp`=K8Bv zOj?Z=eCnruo~Uteig^86zPw=}Ez|NOW8Ywnvq8|8M%U-&fG=LiJyMAVJpK6nK`Obb zFoCZni@lmx=4+9-E3_$vTwzh=S*REUl1BVChb>%lDPeJl*OEN3X7~-emlQ z)9PQ7)qulU?2?Xn6|h(&Cxym}Jh%Mx`0hv28J$arHZV&$sl~>p?fj6VxJxl{f@MH5 z08-wx*7#k)*(}zTb?Mi1>*ykgO94D=-lAntEY#_VDn%Ja?7G>sYaZ)Xv1D07Wj;A= zG2$z^8Ey4vG+`2NED=O9As`&*#Ni*E8E0q95 zfKOT>0n@)zue%3Y4oJQq^pQonbyE_BWvy@AK`vB5&rJ}u%hUK)26;g zf&?kvdt#oJD*mfu$w9Etj~_q!G2nD==@T#hRQ-*Qcg1Mh_w-ABL~``V%jg zW@Ty4)>mw0LQ9yget$Z5w;2c52C=&9i2;fQmUIMm zhi|tTW7_>s zG40Vj{2X%TAQ*8iTpJTloTRBOL=WgXH+2iei@R{>-Q0P~c;>@#bFdK)&G7zAJf-#Y zNy=k*0>?eGJYGRa%=K7$1$=?I*x-d)@cmVl8srPI(DcF#Y?*o>LA}M%eJ-!}QY0 z3tXlM!Sr)1B_1&%cHY}aUnpE$HH zBLXFZvVvet^c+0_K zXPhnW%2@{aRJf>gP(5Sr%Kk|T~Qmx6gCkN<4Eka#?D=C&nR`@kAYhZ*6YWJRUk;oUF zONoV%E8C><5kVLsB$%uST&^~x>!T(An$yV*vQq(h(8Ot@Km!*MWpOxUU8yI@{7b;G zTLLiRNB@DJhGuEXt01@g_g@vImVhELdEj;Oy}9XorZ*>{=5X7Bj^X`{ZV573A5OTDbot9p zSK6^u+hs0}-~n|`{Ap%pVAte8vcl;xE%;p+;zrTS3U3d`TLpR>XD;p1+#w!^i$gG# z>+em2PAowq5V4!QhvC~LIflhs%zgd^W{0jjmVwAyz^%1xeINV!Rn%9P=fb{s>sFdn z=W8yNY$&i9NTg?_G!!}O+)S9PuJk3x|k#oPs4ngD`2{ovuSCytSZ|- zpIEroHTCfGip{$X7wV<&RkA;g6tk-JLp|3uLjquWu+0{K6&R_1Zn;l z z*u?`?N>on2C+9D#(f4acC1d=C^f2?ypvHnJpUyK(?ezM!8n$f>=i@SoC2vbC2GHGSBe{*dxZB0bk z-F<5^QP@~1@+#NT9B-DfV5htA(G_)eQRak(jCsjd{!f6ddWVpLEQB2oAGF%3pzpDA z{NRIpdsfIsG|ZJX71C%PbW-*93y%=Jcl4In#WUv2`hsWpg}+$b4m{s?m8)fWX&})w z0&0W$c(<6vb;Ry#8Bn6#*DBxJWfLRGlcOq>KR6RRr<&qTm$%hvDUH`?>6AY&i zCJmr$)jL__sgx|OCL(=Ax4Y>(1nyH%(fWRQD^2@uKCr1X@@C=-#1W_f++f%HN&2N! z(M?`Se7YGK_y%^t6~1H`9aYU<*3tcN?h3Y{M0y^!gs%0p@<15ZHu_!s3wo^YXk=Q0 z_O?cC!P|zu_*;pi)_8SS8cK!baQ?{6X@5F4alAF2vSjRf=dNp? zG0JDLXTLgHn>5;EW^Zw><9P{9{kdy@GvVZ=Guy{b&ol4Je0=qvfxq@} z=OL}WaU8g5B>$h8eouGj(l46*p+iPrzkH}5hc49b%b8(X72+-iVRGo>|8?i@)q@XL z_ZHB3^Y@*Hx6{|q{M3iC5=p;F{rBz1Y@dIY`h|YO{+lL$&;Bn598e|Fuqk%+3Fsjr%8tP&T@vSGpPzwI3UT>V3RS=xs_OMs`G1qOSo`_s>T6sv|En8jTb<^UO7u+9|8vPR zcXF=LJiRmrxxZ>Ve|vjBIce=M$eX@r|2E0L9}7#P61NV!ADR_t4e++lxH&fBVKs^GV};CrNZlZpeu)=fAxy~ zR>M46_u~RwLfZ>{6|wm7=s*K1$r+zD_$C#~8y%Zm*toL1`Qf+=)i)!q6@1@m%j>+w zles;j`8aP-9ZP?U-{S`{K4pcl{RcK%ZVO2#HYRzEW}a{a6)BEno40n?kGNHt`fD+Z zU7WmJc2m4-O(q8H9qk^oV4hjwz_Bw|pP|UzVTn~rJs*2;TUbwpGM5(=p}mv>G}a5aI#CCBAN!E?8t~ z>YaK2nfQ9Av#LB0A=B{FQnQ5mW(xMoWo2z(?}{_>soq9m%weK}T z;NMlkrOivI@1g5Ctq#>9EJ5J&!>NQ>opKtvJ`1yL2N@b}@EAvWiHQPbml8Q@7u%-? z__2~#c3N3n?IJVh*E*3QDc~ZK*NF49)Wa3*7nP7lDVRLi7jj6(-p>_P4*#1mC|oUKl6?Cnyj6A|oU}gD)g#LtMhU!%I zX!X?<1y5Y}agAs^wogS`exwmRq%yiBi^u{duyD$3kf%ma0WK-UA0v0v_ud;XdhN}~ zj(aw5&K%0b^E-P?Ce#$r9ya{q?>Kt*@~`Q#uXpFqC%+LF`?_EddKFkXs$AEi*!*}L z+tN+l`&JNh8}X73F4eII+~rU2lV6KmS^p{|9&43-&K-WU(z?FHfz-_JWP7m1-ce)7 zHlD2%=(r&>Yn|gsc4z{tYy^@@IlZ-}E?jqPT50ZSNo81L8DJafnK1&{6P}f9=0_M8 z1@S|dsA}0bGEhOx2ZFd{7Y<6B-3!!JVIqZ+ zj9T@uMN56RQ3|y)JYb?~!V$R1dOxhY8=8MoxN>`1_iW2vx3fGXqrQ4>RR~^vk?n)Z zFITg=EwDALs!hDzOKcV0*K&6yKhT}9QD)m6wAv4MDW@{YBxcF%G(^>ovc_5jwf-1; z8T3F^vwQa8yS#%spBKO?`ses-q9QHCo#_EM(3{OLh$zC6iJJOyKs7L=7N9c#U0otq zhS)u*e9c!v-;$Lc3h?s=QHS2mu%KBJ>!MGwin(Pwp||?e+08UwN0@TEBI-6}nv;CJhVEM}Xp*IDW9KB+MW7Hb!XzY4S!gPE$A=NG(r zI!KQ4t+H#r%=-OMm%ZMZnX8ea@eXyCIwV|!qW3tCyIQ_=YnGEN3wWGwTQ#~w(L4y@ zUy$k-@vj@6Wv5>q!58|C=D0LTTeSoQ>60BBlmq!i%e2xf2YqZT8U)Q2ayU{H#2CSq zyv-~Nc!LWEpAUj8fLYT#L+`wjr;`oY{B=XKS~GVD7Uf~u6@pEEG&NDyXFj=n@q^oV zxsviVDu2R;3~yo<@}*>c^>+x^MEXp9qT0HxAo*K}e0fbHL^RN)aY9AdCzs20J$DHTYS5TEuv=S9 zH7E!*M@w@j+7O>Cc+L!UU8|Lp?a0i+uZH4PZ=X;KF&&IBXN~zTxv@PYWPw2@*w|Z~ zgeu7lHmVkNqJpVM%@1;|x_4SaG&fREy`CWs9)0SPuVh!>cApgrl`6`C$E8#xQ74Ev zp{C+{{Evq(dRL^V5tp|Hcg zjI2>ft~X(k{vhE3Pny`>WY5)p_1>tmEN=53nwb+t;bMS&qamDG z%j9mR#G3c+lYC5kURVR^=Kkh_hI{Cq<|bsz!__u_6!1gBEq?7_K0ZJ5FP_;`g14LI zEC!(gcj(%YG5ub)Xz9kUu;T@-P3rqMajA(Z9LiWCL7~p<<-zEF0;t8OnY0sn5II}A zeSM{+f6a3j6e3r#w3RGDa&^zXJX#mB9f|Obu5LHO&6W0EN>#KTa{Hn&F;TlR)EzG! zO;qBmc(S>^i{QhD;`~_2^t0e95hYgr;Gq%JBe-g_Z@zQeG-Br6RqXEA@7C^ORhq-Q zQ*~8{#*CkdOp7nX4jRQMy@_gSYKl?m=D|asJ4mW!YMvc^5=tI1Ifi3}j3dkh3?{(h zgIJI6;yzOXsoIsj){?G4ws4LtJIIBG8pLMhv<45cf9-Y;Qjds}5guvWjG);HS4-tW zU#r_p0$z5dB3Go->_mJ>nmX%J7A<<`SLAV>32m&plC7y1ik9sLa6E3 z++0qNAcv+8KP@7KcE1}o#jl36h_|-`C(_H5dl?FnZwSm@{L6pYIs5p!_nt-k*+U2K z%rV^7yS@}ve)m|cIn%oxFAQP1K#h%`Cmr1G?E8*m_t(Qb{^(04Oc%M`N-RY?i|_QC z*;&<$K3vG)TR)X-7L8}nXq>1Wq&}KU*LacJv-<=T2}nI3_pJQ!W|&&!vY$6w=(mrm zadsRh+c z%E9_A)ebs@92E8dJh>d}9L&iv46p6mzPO$ycY zt`J+i^{}^@L|C^z6u#m#ODQZ@g`?)DLwW$N6*^BXQGHW5BDI1WY|Cj^HOHCK!1$oq zaQiSa8?K@y-j!d*^B$7&`msj2*xl4CYK}#SZNS|oZ;mAEPq#4A4m~0k;`lZtOL;gi zd$Tb%#B#Oz8^0JJB%@nglsuW|^Kt6~-Bjb0EVNkC5H8;w@~Y2tE7=^wvk7L2QCW>agg5CCntO5xO$XGBPEdKF!972h7(`)P<=$h9s5bUY_k3u7wz)vR zEA*o4PP1br%<`-Nrs4vRD{#fHK{@gnTVfFO*I~`M*!B?Mwyw(l1~^6s&U#OBbM~GP z;Epp&q!&vRdqaA@H>(;*sg%>-Ydi7hFtL%RV5hDk`bTk~K+K!TR@ZR^ z645-@RIIW&g2>vv(Uezyr3|jT&LS#Pm_mNv@Y3-tzlYR!Y5-u(mOs!0q?&1~=&Lu* zzQn~VXAfM`!bC+foJ>FXjkdrfcC&h^Hj%g^|?elQ6w5_g3Ovb46!pL zkM2b@(c7XOr&FpmRr=Rft=?;PID!UqOl&&hSN39eC+~qu`>Lb{SDv5G!91nm6M+ zZ#)PO2{(9TX<2hU@%SpzLt;~Od#<$jSC1~r{VP5qC`MODgq3M=B|d`O96L{4L274w zg!jdfi1e{uk%Hgq*BWyN_^M3Nna-jZ%Na)QXkUW9gjUlQtmkNZXdOrGyrh!+Oc<+g z|IL^sGtP(cc1!?MWxGG{s%h^#ycwUJ2 zK8rLCJW zRqBU18=8m(Jy;n{m^=(qjc@#-4y-5G?us8Aw?J(b@|!1KbU|J9vkx}Wny%fO$ImHe zdDcAL=t|&kW-1|kKrGpggNQDUR#_K3MQm!Dt3ibbCesDMwV<8lIk72MgLbkw`$KXZ z3IrKnP|^%*z@yB*41b((F{NCzh~$jW6qR8@rY%vzQ9fo0!bNlbIaI z)74kM)%$=N7;>d<34D*n3?HmLrnKAfm^tp`~}Kwu##%$O;2{(*Ob1P^qT+XWjdfdlbdhkRqCmEu9}v01S{mA{{fV z4DA?uh09$stmeEHMC-o!=`dMIElm##gsY62M9}y%8hi^rwt1izsZo1+_QHQmFRjK3 zgBU-%Pve$;>T~f+LvYWrbaKcC#UR^SC}sk)HmzYtL|x*{=8zwf9UC64?gXn;5t|FV z>Wm>0^+W7sD_CUFz-W7o5Lj_PtWecr2hwZ^QSUYeVeA-G7wwmK#2s%1m~^JoUkK z@=Jf}7cVVd)^1*l8tb9uxGWK#NGPFyMMqrw4I{;fZm4l?8hl_s4w+7y(_@lJhE0Zi zvc@s+lj6*Gcds=6WWY*@w>&f(Ng^jJh*dr}_Sw{^-Qve4?KU4T2)cVVFuI4#Dicbr z1yxB*q%JKNMDlz;<5WZ}C)5W&9?n4bMPVS1+P4t55mqL4RSqi?QPv>m5QZ2-@#bEd zJGl&0kg_^>RF?eio0fYceSY^?izAiQJr0T+W>0$A)y@oLg@mC3O3MsF=W8gb|sPjeu^@LyqXQ z=Jr&%YWGJro?9cJ;I6NC*jg3PObA@Th+yoj7;d0^=$WS;{7s|F=K~JTQt{?##WJX} zEq2KQkY=x3*jg?D7T#oJd|D^IXSK;1>yJ518Um-qmS6|V(P(a1xiEep)W*GW!GUj7 z!G`i|;U&iMl~~&L!)0PZpu~p8p+w!!k^I(pb*Is@Fb2PPOF1t4NckZy9J9^=N4^5zD@Z;^#>xTX^R9|4jX_->Z`TefPCy2q&!0OV zjovxA_;ga%`CP3nqMK3!H~-@qV--H5~sA z*35J!$Lx|4utNQcH3hS4Q^%m7rY9|cx%$h>XpA0CsQc!M{iz2)l_iw({n!Nc`Uzzv z8Du&rD~tp%f3^QuV;~xz7A{7e*)QCrg9RrZ3h7CWqsFmnBxypqu(-UzERSkkA%9i2tE6bmOV&6~P zW=gMhWnV7#x?9?~0F)eBp?YUGCdQsSC;)PtT-(9K;hz(85utl=(@wuf{(EVmv8mUidR`@hfs{*C5F z8QZdv{@ubuzkB1(<7IO%uYbJ{tsj|oSYcV@tI9u@JFJV)nr`;GdJm5<{9}9c!L;EJ z^}piL|NiF}ly-dBwxNORe@#Mb4ljY9r2gYY{-PnRh$12@`|nnqGr!K$hR@sa|8qGS zo!~U8hR!eiA@={!^`DR&qMy4m+`ECH)3XXV74w{* zVOx1d)5FX0#?jE&52XzctR5XR9+Kf@fa`yDE2%GNoV}=)lY6ROESFz)xY5{~K1TC7 zR-hxVUHXgYXF}X#FU;ps9<@L^sPc8@e`)5ApR}qck9C5v-M^57R^_F2+WoovpP2WD zCjXDiiAR{}MV*&_o4Th`VLnW!(((Pinixd|f8FA(Un=49JUZ;0-r{-)>Ll z3ninofl>Eey4N`2LH)stdOfzjL!Nohj&B({)ifXE zt;W3_$ZaD`pE9CPKu)H2# z(&GHvmF8{*cRkn5x4IYAytz4=l)Joqg0i7-!U{<)&-TN6P#koU-5*^%=E+vUG5SK! z@jF&RSU%6a>Q@;wVvLlOWNz8f2aGz!T9v3i1}jKPN`8MYLQ(vibRVt2zbDk#;Nm;SVB|sJX4{7*W^w`;C zxp0^Fi-Zl8eaE$vk@RU(RQo`28wFbON+d%7jyF|pi646ly5wxRII(uVD$S~7x#mxP)w`^4wDI9#Xu z&KQE3Up>d~*-LKumD_z*_5u~DEaVjtJgS<^pR8bHw)WJ&+4WJ+1RF-cH%e*>y}V|D zxkYfdHe$uFLUYB1Ec=(sL5-p#lTSb|)Lv-ji6WI(AVBFDF7(-wmnt;tfvjJVSI%4D zrYwDQf*XAR?;)lXO|S!KHC|*~uD?p6CLgDH9vTFg&9BD~RTn+k}14 z()DRTKS5nuZ$jqp22`glV|i3XB|H^C0PSwACKPbMH4Yu&7t^!Zq7hM{53rbc0tTs!O$35EukyC%-MkrLsDW{l?~o96O8`9Ll5X_=7E={;-;oCgv0QRdg4nxO z;oy3fTa?MK3s6vf+H%9ZVx}1Xfn-N{7<7$iKC`YOKd`vXQXZlEEi3ZGecm6wI|I2R zO_g2t{fp-+AiG~@^g|{lZl8)2^VbY~jnCC(R|byw?L3^`q^R?X^Pg#GhBS2^Q*J*I z7B2d5i}hQ0)Ex{@`5p8*bl>VR&`iSYGtJ&3`@~!?3$#o|gD@;gU zo>*dRdOSzF#%r@hX+ru$8;g|pu{3i!vZp_TpjMyI9c2I6l(ke)5o46PpxIf5+}s8BcpSBydMa=$O28Z z>-;F1nh60bUxpMlJOYsA~D-E39o#@s)Sb;$Xe) zeB)6O|3u(`ltE|`_&cXB6DT+o($#Z9^}D=h?^I>7F`sT`4vxqN*_LxYOvaGZ3)aTI zU2yMH#9_|m{cGR_Kic$g%ovUc@yF)zH zN_yn6zY(Z!%NRwizaeTT#)BqZ>v+V(q>G8OJrH($mwbP7d#FR6F2z$~c zFlWkGRdbsE!1~7qO!&1kD}kfIjWiM8QUp46U>Y7GL9u1trbS}RdY2}h#F{E0!yBk zv5H(3h9ff-n_Z0$Ean&2zbi)z6TQ!3D0lZ zAb!a7On;T+*4V#r4wzQk=2n-oK5KfA5$jy3ijzVRZa3Pgsi$?bu+!FBT*YN+>^W0 zAIASZSE16`dB%x<$Ke8IvZtMD_*JSP!0dcv0TCFc&`RC&DY`@hSr2sS*z|>%aC{{&WZ!;cmglnU1CWz=0LKU z2^=ke%`#YUnue-BWlw%7F0sP)K;E&7%vuo4#c3xN1ko6HujVY4tQwr?t6xly!0r{S zoA3Pe-LThdaXaVS8;9)HT-G|TCv?;cso(2iC8V0Xlc{oYzc;mFi0qIgoBnCc=UXF- z0*JhYj(1)HIs;=LDVkXmn~v9QH05_Em|qQ5-8T?6E)Y!+=ei(o`%)k8gOb{bGrTtq z$~v#;JLTJ}GIRn#YxS5A?dMl(@0BPGy4mdJY>_Ur@hL|=9yVd96!B~Zc~a`|xK{Yk z$Z+-XqapDMIWI$c&6y&@z51T2Q?BvUeIAf(>df5z3e>IwuD`@)bJpRjNz*(9 zuPnSch5k(g|9<)UBn|BsR(=h)cz%`bdt^Ll@bZ*i-X<@nhv*7r(UGwV0XE#4Tn{xW z(8Px{6p8=HH>i#Pz8xd)0^gqXQoQYzQXa4!bvh+}N}gI&6^Xt;*3zq7gUrTgL^|{t zl#AzFJ!&>Zl#VeA3hg**UKV4hf&|UctSk)5KBaKODG1$emo=?kGk<{k_;G}NvQ7Jk zqH%gYP%*~hkANKtY?O|vb7~=@+c$|p zH7Ll%rJ9`qh*U57;RtTh#!zHUMb?YDsA8CkRF?Jk@y}IUDmw3I>Kj)RwX^9=oa1Xu zJGgS#dK$2>{7rrX1nSJQojVQfvm2LjURn4)62eK0-iYEDz}^*T()38Q`FwvbQ`X*8 z+fw~?oBx2Tp{a6t$b`nZS{Dah+XiUQ=3}Exl#QtcBo||E&+f#N=TX{}O{i!{*9nRW zxG`(F=R4kg!W&RuP!>V&S{2>K;4YFKXG<-#Thbn=eTEs0y9uy*h3^!7Dm(bxn*UM} zF0lxhV&8t93xAY%ME*&F{^it)g&!9O7N0`xX`f$+t2iFEAEH1WFC^F~%iX}#8+fA6 zD`voEK9(^|se!yzMZ6O9nbWF!4Cl}DxC$rEDn{=PS6jqO+YdMu;lfHLx`*Qva{*UM zCl5cW;8ILGKImC2X3)%fHh@<9ZcAzQ%c<$P%vEY|r`cfH`n*+f+tzk{23!03S9Xwz z;afpV^Hp@Z@stUj>1>9V<65scVA2jH?(7k3M*5l}v=Do7LO!_WxZu>1{v3E4!l^5{ z@dE**?4NK5SS<`GcN%QEU?Xhc%+!6OG-%#$F+R?wZeTh&{>6-r!OhU|=Zi!_a^fmw zs7T(tn$|<8TxL9Hwv>u?-HnHf9f&Q>>v4BjR3TpWoe+=0mO&5%iy<K1EAjA|g~LGpTkZTpiv-*t^(&MN4v2%AJ%pNMqwG z?{_KFqw|s%S08q%9Vo*M=EA%=v6fW2 zW43=}6zoyvbTW#rY@=o`p(EHZ(W-idakiAs$iq;0J{Iwo-bj_z!|3To`xkMsQe zK8sV5ryEL7YaE{3{PBr_cz5nR-A9fnz|RYmzNi-hFET>p=k?~urVrpJ1|c|+8o}1{ z0!NL`W`ZDQvA8dr$qRf5l-0QYd|TTfIXdWMDl04ziY% z8DwpCdaaz55zFL=Lir*P z(Z;93LmSj)wPV4e1or$&ENY+6r2G_WFmFDSnLP>xj@2sm$5>gVjE=elD#|LF@Ha<< z5~rcN``t?KZGDE-&-O2}S1hfl$4qlSfC#Yqw%!w)myLcyDiij(F0>zcr>(yOZ8VQR(>`D}H+V#6%CVi&S|*M20r+ThS%WRBmWt4$#qWBcI=Vo{!+IFuPbn;3{k(TXg?p7@$t4vnD8W>`|<|6B5IDLk4d;9fD!ZlY`cTdX7 zm5c0}W(-yxLAC+_?NszoWa>F8^2oz}?QlL_T8o9pd|c3*WD78(16#hAzk4S)fVdcU zYoO`?yk{3UMGRVaT_7I0H>tt~b#(k5EmE5z&4v7NYxmJwfva29fRukzTLF4mMgH~q ztmz)Sk=pGU0X1dcSgFkYo-KFJ{`dxC9~7YDFoM3rz!%RzevEfWk|cU77)q$4)$bQBUksU@Q_=B7dv5ZhMr4byOKX6oZ9&D z3x31XkyleWb3lJ6F{w#eEdm}OxcSZo_O(_wc2#E9k^qZply^Z476NqarkKv265m5+ zpMoxY8!=NMAP`7h2{?|hUf+4f+@-jTO_V=1d^+%vOFlZ$aDmcf%(oo)!iv{Za(=y& zQ6V^R^2J9|q)Z~Pc@N(sPQYTeSL~Vf@iNe=;<<;IXzC*OQHtQ&SoM9h-Ir#csj(@! zEB@(9^t^?wfspZKk0F)b+SWw|nZZx$IhSb%mu2Qgiq;|+CvS@S6Nsn+9+gaExd)-G zrVQe}Jg*nZr(Bnwp_T^FP-ZxD5UmGct1YDh%tW`HZI~*Kk_pKuhN9#fxA~~gWC_VMrb>iI+g!YT8 zP?z>(qcW`~^fTV4hf; z2vIWWZN-Fs9!D6bg*bbTnuGRNZ46gbvaO_MUXH8ha_75!T29yJpnt2^?^84d3SEs= zIBnUl3wMq3Zp_1vIwhR5?@bUQ^VzR#!=-BuXo*C=>%Yvd=b zCEi5n7twTG6}zras_~UgB$8Aln8qEuv97%*YFYdDAf&ZpO7Gk~e+Ik}@j1zO_l4p) z5f+Abwdby%FHLNO;9-U!r1XvI9~{>oo;p`&Wc~8&Nsg23T5p=rpefIYrg4vW!B4vW z6kOnAe`neka5mF3F@dJR{g_smIlmHSH;Ya z*ZHdE@mZKTNm2HSPAzL@h`Y#_y2aBXnO?8Wyp&n;t)+s|fz8%dPkbM5w zbbhFtFhi*9F~(xPu#o)QmXF&MB2p$gFhUz9kqHOP#|pAwmbS^v9=PO7FE4~5uEWxU zGW7EOQWk%F_C|8Q-5zem7ERW8nETUhQ9~;@%tuNV4S;!uvP_ZO%dwwYNDpo9*tBF? zZ9din_%6L0NlHUqbNkVz7qMyioq44rA^=u;U2K!Bo`XT$<^mv6v0p{t@%3K=n3l%7 zf%)1cwX3;dHkzm$CW_=$B)#P=VRdndo(D@x`_S#X@e3nsd|=1?5$7TyV3Om3(u^Qd zonYq0R%yL+x|GcXw0N*-xMw`fYVx9ID6LCpqMPDw-66d8z(`wJIFA^Dz@_JZ8BCG1 zil%qbX?dI4=5<@fi8($j$fz>%;wXO)Yp3bU{oT<*JeVUf5nPPcF zgf{1COPdMe^p`9lR3`CCLqPl`({#A1C;IbcU1k5vy3zh_~XylJEm98D^vD`WTeP7#F40dra+iXi-xnxHfI7k9$%rsBq>(P#%&WQ0E)9@?j z%FzZkg^!U`f9Xa2R08b8i6FcgU9mhyRo=CD@_8b`S(-gKwj%plR1(jJ*wY(tlD#fe z)j5Dtu&k7rc)|@+kwxj2SSsIm)@0dmqm#=}@|T$PN{^Yx@UuI6VvaVB5F=la8aThG zzPHd)>5c5<(Z1r{TFGY!sh3GhEGTnR)HYw-Ps@E~m)TnKryZNUV2dDMZGn&{AijQY z-w@xFlMNOVN@JIWmhattDUn=2PPof7Zz#6h?ymbC>H5Yut(JGMq)Z6OS{h!n-?FGA zVNuvFJO&H3;?2%T8`Ru*|Ao?GnLK3`edYhK_uf%WwoCiyD~b&PD@a!nk*-wfDoXFY zgVF<`_mYUHyn-}oN()NwH3SF{6zRQ&n$SWI5ke?|kQ4S^-?v}<>$lcfXPvdq+5aVz ztUFKUnYr%!nYm^LBK7JGvbEyu4t@|Eq96@h7=r18gbb47tBBqHQO!`nr%|iW<4e}$ z?u#8U1HV`r#PjVHTcFfYBjuZJ=uP;Gs7dKr3|hCnAhkVbDES4kP?@=|B`r;-;nk16 zw2XDmd3Zg19Fs4Xr&RrF0UF#R8xrV`C9Uc3qssa;+4z7d^7p(xVp5Y_o8KxpIfp($dccz#Zuhs%&SLlx zvU`{7FI-{QeUkG}t()(df@J!U^!si{2rIqAqsqHp1JyoXcR^5WJmmH~)O6D|wUYjW zlkM-wKETy%*}QEt)mT8SIjZ~Vog2g;ATh+*7j}ryXlOSezzt$-B=6H3#5_sF@jc6` zAnYs~*x@&n%N79cJm6bLzHxCZ2DHy!$Hs&-)F0jrSKZqiJx3-8^(b%Rt0wmf0O(e* zxsu96bDNQlqGdU32zC0Zi3OL1du>yd&9Mov$rfutJXv{aC9kneMalI|*~!a43a(v^ zQdG!Y6oLi=vge=M*u|P+CQG3aJE;jwNjfRYTn>p+DplMqc1yuReiJO`pDbE*{T)xl z6!a((?_d@arSf$m((jLNkQJx*KZHhm3_~uDP;Z*bRpJ3^s3lu0lDWiakIkn5qaR{$*7D2Oz^UxVP(}lZ%#!@z zZGI=FhD~X)!r+%q)!SWu*sbx`euNc~tgr_vQWO238g!NPz&5rcR-(|F5I&{> zSMs)5o~*U(UlKy;1{LgHF>DbP!^$E!#jtjv)2-nJVLvXk@5=IZiyXQ@)RJBRFs%iyzj zR)rSCD0yUeNvgyU3AHBEs_`|Kh4F)X942KU3PxGIuQfWW3b$3*4RYdGB1_iDBI7zQ zr;Z%t$xI%N-$jXdzRQb6ypbUGZPTb3?RBV0fhHNeO=}<6W0GBO zPqi%YBhDljDiNJ2#mqaVl0zE~Q8#0)tChT9!V15U9dC8>`5rV=cizgn&q-ma-lf{x zD+7)V+6mc>pqZcRmfo(9TUJQV>JqR%Pj%7!X6?T6r${gV(Em-6{+llJhMGdp5%{|| z_n#ST%B6Nu&ZkKdujo#Z0N(uf+yB+ce>hwxul}F4lP5`#R@QUHMw!3*=8V<_WV!xT z)l@r4brfxm29I!^ima_Rafq`)n0gMN>}-?>}7} zNI+h^T=j>M^K(-MUPwCEygTg_)-NbTyZ?Usl& zu};H;oTTbJ5pG7dEWhvvZ}|VuZ>`xwO(|&}UoVSW! zEun5yOsvYz4vONXfB(-mHKERG%_zC)B;RpVlJAF*e||(kf^sI1Vc}{y z4@I0Rm9}x^v~`3~NZDh4Jr5tB7VA;O;yzC%nEnAR6n+(vLMtu7ebIS+TAWJ}1J~Ru zMNZw=Hv~$(q$&Dw*00lI4T^YjWX{&%Kd5!`YW?Jqp~*(^<7u{gDy4r9w4kN4?|*wb z{%f_dlQTj{`={%tTMUVFQN()T@#&|vQcP)YFhY!G;yNiE`OnX~s8YnabllSa;V7OQ zzl|XjwmX4MMD^3D1ITy+MXbT5>3ja4Yy2N8+}tU2gyw5>KYDv%WrA#h-d9})ems&3 zK8jgK*MsfJKfm8obBP9?{LRtp?!{xK#V6;V@yw?q$6lM)rnC-_&Wn&yFXMH68@NBw zJ#9TBikpg0&BmpXPYn07&O5I}jq|Nch&j!N=?O8*?!D$DJxll)2Tk4K`!nt478a_| zgG3F?J)cgkDTV%Y)h$2I8X>@>;FGzwDQWK8rBy)8D|DxjP{0rQj>7?oB92sG?ey;u zpRU(m!t2mV95T2Xo8GO={VzAsQUubF)UMlgbgoyJi#T-&or37Hn5g5nK~ZX zGm27=)^J;1c}>QXgi!v^Q>_NQ=SHvuMy)B3*)z>&Z<6f0hm_&e@-9&zVwKs_?I}M2 z3xi=b0X2gIgPP#>HBLD}S3$0H;s-nZBu%pip`<*mJ~k#l-kc(Ft=w)fjSyh`dtZ$a zs5V3c$Px3JWH+`;jNzz3@wAUljPleS#xg)yXuPXKh;!+Q7IdyrO(v+k2X_7b)Kya12O16H(bZZs^8aT7B}m%4X6V^+_W(Mf{DdFOBohkf+Ngm^^XmuAHGaFT#TaSdMIXC${uF6={V5PmlSFv z{p+?_sk~4yNeA~{PaJI)YczXftOiB=0khgu!=+C47>c`})XZ#o4^X)Lfy zbD!Opl%JzvI7kl7&=n-KZI3$O{V_NgDp_1vsl@gKT~diL@-jiEnsHnN8agWPB zrkL3Np25at;^?IQr}8)R{ioIQb@oF;S#tX#>K_e2dtMc7vC%Zp*tOP`Vi9_ zZ<}B0`Kj**p+cXMfKFvX%U_zL2z>-k1?R&EP6@|@e+3KypZ^le6vww6Ch?lyM!iU@;3wS zFK=!7w1-bjAbA5B+B3fU(STr;0O|zrjGj?qDZH6gDil3UP|1a6v=3jeN^vpuTuFLnBOUAnK)|CS zIjO{jWJh>6T~s+G=wUnJ778)yU%YJ+=1{6$Lv{!kx9d=Ha8+?nFb7&H!-J&c^CVO7 z#SPkF08T#O^)c=B*yx6`L#@IZ%w1rUIB64_1MFwja1;f+jw!iCh)JxDbZ~LYrgk|0 ztU$1cv8mDLP$8tLN$%K1mD^{laa^LKsK=3K$lG_dOd6i^!2Wz)P+fkAi~qPg2On>w zd5_S(lk+fVP+tvihk&mhiSQa1a{S?Ux$oV&Nsy!7s#R@pTdDn^l8|U`H_!GC?M|)x zVLYh@wm$e!ZK%N)x%1=w!OQFF6Gf)?%aUEw#VczdL2E_ws5*o07WY8M<*&y8%dMGy zTGJxx9MhD62R?W+OUC-SmCY}qhvMvRrPR4rjkUElF5bE%IE172)mAkyeQ~@7F6Yvp zg}Wlpzph#`QTR1T`hIIpc*4zODOE{auxqn8DR;n>y-c&w1~URP^pOd=$5ULJIo>Ki zzCQg6={7AmHP-b_K2ff}s>vKJ`&hiHDc+{!Z5uEwMh@SZf0pRP8;IT5__8{`^d&C% zZll3sMin~|GdMO;IsbQQjc9pO|6QL3X=gkk4~=N5?p@{l7$rRHNo6seCSvAY2!1i; zr^0QQMntW#r1)Hv9Bi;ro?kNwf@eRl8}r%oRCAu<+$nz*Kd4rrt)ZF9KEX6xiPiw_ zT|txurMYOCkyrcMkDvg1{{@QPVI7@4gd*&EhWoO}S#iIWnJ0QftK?3pJUS~!Lv!Pe z4Xgh3qhH8yH^}kan(G>VVQ04|2)UX!3Kj@?%ITNBy1uk}-C^7aM)CXvn4zz3XsMsO z@hn|frao*n9K~LT9i7Vc=~nG85L%8rKJep;Uaf5p%7Y8|IJJ0@GvUZc5Cis;GsBG_B0NH@M~5mC9!ZH20o$O)O0+ zf~y4sf(`kce1l}>r*rASVC%%1rgJ%EF=WDzjh$(22cvdE-&Wbl|68AZ>7f7$D?0C5w2_wnqVEq(UTZ#ays`>*XyXhB}z4bz|{Y1vq>l+Q^ zj_LO7iSHvhsXU#X!}`{IKh7^Bc`q|0S{_>*#lLxQ_W^X6g2$z0U8tuFzuL1i5?6&djz(Ru zZ%MGCT=eG9i^@lcalNjCxfaBp|4#a~c&N2v_rm+Z;kWvFt8Jya>*+>|>8y}JVlUjm z&wpvy3?zOf-?I{bgaR+_abLb1A)B7gR%s9jd52$RLuvMG2jG+8;$6FZhkQEFoD#U$ zWuuT>mR_>2+OoKO3_2TPIeHcT3!(-rlX-o#9{3=?Ssz@H9;}H5JMNYYxtXw)$vCa0 zC4Cvvry9R;VZk@J#(n;}$=%0-EnE+HD;$R2e^O*&c)4F-!WA7&SGQI*s4GWa*19i* zM3}hqFgQft|DcS@%et;v6zmgPP;;E8bu{;&{UsqwgXiJH;*uKV5uTii+#;cIhvqap zcG}+=U5{7AF=K;$s8VIx%SmZzv4iuy@H{_$US3Za%QEqYgCPd5@dZATvf!@3mj1s;sjxoaiEc%P0?S4`e3 zr~r=1+2Z}yA^tcdwm)R6*}0`jAEPSYu)Yzc>y@7)BA%$D!SxV`fSO8P;(Wd?t(d44#@Ei!7C)hsMY0Y?|)-N2h_kBe`t z!G(ml5t}{zNZLp0si|K%Sg$kq&rT)AAoxNfnEf3hvOh*VL2FT!79Q)DZ$5c7l&Ro( zV^-hR+^EF|bQo;I?X)(vR!@|UjEG>P#iwo!TBYBANb9-*^Xh8LLmfH|i^%6!f**!v zo=XGw&gdzD*?8Q-TFg;+zcym3kXfq%oF|O#4^@HdZVzGY?!>(6yR48uNM>0JW&lpL3 znc9Doa+s$Cm(S%I9bPP_)LG}pQR&7%nnwwO3x6iM8ee@(Jo>7?9C5kcL+1s3T?g)Q zHpUd|!KZ6BR-yH!)MRxj=UV-P_|zo!o#YgKCjaI4LT)o97;dM-C;;rm=nJVnGN}70 zut{A$$nzO)qh~tSvSo^Y5b$;<*=lWlqguw|>0o_On5PCiwBhJ%qwu27_WMu5Kf;qC zLDeH;PEh`#omz`B#qE_#;W>IOK8N`j%9g2=sT|7*^(qVYo1$~dco-nFhZ&bG%@AbF z_SK-V9P6FoxGxs}gO;@0rTqPK%*cF~^Q~Z3U9m(v54r#81z-$fVN^`uNj|RO4NUhJ zG+<<{tCezC&x=cW=CoEw7Fx2cj07CAWz0P2)``$REq-OnACqYjOL=G202Gt7CH84!t%H z)ttL{NM~BL-l7zy`jTjNc94lkUTfb3;D{S@xeZ_ z@KlmFt?AfDoLu%OM+`#xHFTq_C%!UVoMxK4j6S?QVL~2VpP{rUQX&?YWQxr^e|%w4 zgtQzZUEd`|1Sh}#hRE0@e(=CDIxeTAF{THGW8>_2E`4Q`XE~Hm+Diz?;11@8r zGQLYB$-U#dV)@%mm59Y!^%;%t_21+$Z#&j9l&B@&*V`}-iI(>)Ym@PLjY+8-L=1e| zrVxX{EEG;bZd|bO35AJ6cupP%q10WZ+ZI@=ij%_q%-o9|t%On^9kYIRtrZdh4@T{8 z9ewQnlqev^!>2E}Z7`sBKPGfwsJ6aNS?|Z^;vJb8>e;5=!EcqtPVKP@rp!QIk|?ro z3Id5s^QuVF1!&RZJ~G{hK8tCP?QtBI2ZqGw?fTX`q%GOrnn3PWh!BkvhK6)!s67P2 zP3@ATrKMK|Hwmy&KmDovkaex`oV>+zEB#1tquatq;xLU~gyezC6MBhL&BPDG!oYkcUUmkF#ZT zwCPjcPI6+i`L6uEql6fcm%RhyGC$C4a%6Z)KnE~&qmLUtF=4Rf&+3!)VvHrgZSObk zfdKYK)2=ZLPWEb1`I<)?nEkc~czvI_=rPI9I!$EgoN2Vl{QE1oqYbL$o@#T8a>H0F zV|((3vt+`A#DwOsFF{io3$R!9t?O^gF;=$x046*S>7F*$A%)!-wMpB!>>26Z3+D=P z^#x@X4)zZa^8f+L&8}{F(hP}mI0*qBH9yq(aO#AKBtZzpDhe;bi>-9EJs+^4;Yx^_Mob6)lHjseMMZFuADIYCJi>Uyl>s`M@(czSe(M+@bUy-57^f@_DugAg;w z+B+|lS_AaYXUXV)Ws~>X%)ht$rGRXCI3DJelC_60Gqln zL*d$h1@NKE%q0Vx8B@S~_Lv^aj^k`?v@}=z(DxxvB-Qpo(84B@f=x7+MOjL$lv#bC z7qMrV(=j?44{zF?^M)~5P^IP5FSy#7|$0R{%xiHLY<(7oBg7py?9_}?eJ z@)E|MB@7=)3s;n?>&80*ta-&g(lkx^Bbaa2>Ju|iTi%HHp#-DtCfK@zP(jSQuw!4| zKnwjNEwbh)?lI!KXtFdSq)bs7#vkP(1>Rl~WEYygDj3GDqW7wVr?}z>4R+TAuW|^S zb)DIpZ}u_0N?5JJ!}FQ9AGeJ?PD@VI$%MDLyL&%!LYHR0FEt!NHQkYrKr6jhgrz@&dy@T=qF`D%*tKME7=UVInp7dNGyR!vI;?3yi7BQXJ5$5IeJz_Q0WPT z_(T`fxEd-p6?(v`@RxQTR%uOo=2Bw0&7+hEZ=>n93nS%dsrWRbyUq{)(VZ#Ox4%CB z43RpS#@b-`D{mO#3Ig6O8Bm5WCqu2u{XWn9FqSq@cmRFdzLU&0?%Aal#k`&)=uh7f ztTei#PsFa~#UXRJe959`^u@gTO6evv1?Cmsh1KFPLyzz;r>1|u<zy?Qo4%PXO05!g{G1`}XINUUh&vFGvgd#)Lgm`|)kTGoF!}w8vxT8wZE-m-WO) zIid^z-)qXGzB>~qE4{)zpOx02GN+_ps&GulU+5u1;-wBXKJ_aW#D+%Z!s_= zPRJ9|h68mYi!nTq9E5Pe+!^^q88p zF>#V)2MlD3e=Vq^m7osHEeH*vQ)W-UP;LAzLm(hEP;+^qSL&P_e#fKV5c;OXZe+5a z_Got{X3V)Zoo~w$fUqPTl-8A@x7J$@VQH*6DYP|(dg#My%Hy)vb9GaZI_o6Q2B+WC zY7;dwrSq`M;!l5OOyInbo zM03h6+3K#;-B7U@6?u9?-)e@meML!Ss?cj?vg5Z1r)2|SSxJ8~{UsL{U11w^K|ZGF z(y`f)69dSn;k&+9_ihxchcsWyR!!(Fri47*MMSFPMS5F9eJ>Q=zuFuH? z`&`Xy>>K}7px8pWv}W^1$)E(uVW(P(S6L=KC3clB2Bg!i8bk+#8mifpu66{$u|#5P zD~Ym&w;1|}8yHpz+2wOAfweOhqz@4+n-kTd+fO}o;%uf1M#P1AEBX7CI|nr|&?A+B zLsS-6W+Yo95W{FonqK>{#H(FE<->3>1Js7a$$LKr<=;Nx%iMdBbYLr71-Ny>1dO<2+ka)+y z(!Yb?Zz+9aHJ)5fI77kr=hpMi3NdWc9`=x(!4aYI9fgqf4!E}tN&Fs}t36)U;^r>2yLCRdGUJ>IU~&5Elo1EpKF(Ub zek09-ZFtc`l)gdOwr)phw6}Os{!*rr{J0Hqn+e|Dp+S9+2N)3vqIH&)@I+1s0$w2P zgCx?g=!dSF2(S<~Cf_Ulv`kM`dFcbDN9w+WS+E=D)M_D{))pz4gBojMWE% zLZ`ExhM}+O`s?^5j^HCUyz98Bn-*p%5)#fFM}9uU8Rn$Wy_4fW;?4XW*SW;$*pfvk z?{S!}0Z=>lAhl$J<&bg=PZqkPaoevp-CG z`ohXzX`lQ)N@i@JC>d7XLw40+^!Mr4L6@#yfn|{`QsO7{wC_M-A{5=kYY@rX z2g!t9r@J8u^5p)X$66p!K$ffY+F)*FuZ9|(O5}NIgR{jfQ6`o~JKSLp1XAnP_nV@0 z6!hJL8on$PsEitRAfQ1(o3i%(YslXQ3yXfT8_%DvBb*Y{;%uITn=vYYV(0S5ImvCEBZ zFSw4Ie1C*)>7gwrmMZ+*B1G*PQxcY{@{Tv+6EpP4rOW5loyRIbni{+;b|)+d(KD$| z@x|EKy1bpoVz5UCoNtT>x@%B)if);#=LY<&)%1{Vx!QvW#U@ zYgGwZm+w!)Rq+4eIsB*p&S%%#x(9|&=zvUdT|lov2>%; z@Wpi-OWt?g&J|lWw-LWw|6)1M{keJP`VZw(!<~#MpHk@^@(H~-88&i?W${Ij!r-XC z#dDeka<1nNMSNbr@}!&We+V2`A6ZZs9Nv7or>A~i{6fhmj$FyN{dj8WJJ$6S2FI#l z_MeM{QN&Ezo!3t-{j}Mea`%Qyl>c1hJVh*$`I+k!W9H49RZ4&|*DUVOMXpf9_D{Lg z{(04uC)8m|ibw-?@6Sb;C`_8(H>yd0XeF0I`%ZCvsrttvA{Qy*Gl~3v=t`Z^c~@*E zBH@ok?5|S9XL(Kj)YX3#{$GWkvSsW4TKNBSkfJmk|9NQg+=p|tbg&v>JmE7~&6Yk$4g5JA)P%gM7w6eIRE z;`E&6zo?c@Fd>{b;7?58r=YFytxJCZOV3@3n9gAPPy95Ypsg+MAETEqeo>%^Sqm5c z#Lr3!+IH&S|8tRWida(r-;I+01M9GLX!gGf|HocU+4cU96^=}M8W;;oM)=(-*N$On@ zFlur|-}`eJqRc@PmhozfbiPKpVv!Du@+jO*F^KzC)*vQ4^m)q8?4ohe8vzK+%K>{u z5-i?2JYKOXo%zx{d7Z`Kwpp9ZxvLL_V!wV}D1Y7gEi)vj@7(C6oi64;uW+xDsgZ6$ z$oBTK%Z&f@UU(;qG~`LrKy7*XcxO9Omaq=lG<{u)wE%sj%zZlW@KVsyLjLqvfVWwG zJnA?b+I><0WBzOmW*RyJ*Bk|Hbp}W{*e;IlmMwgx6!Xo>`Rxks_02G|rN~fd72MqI zx@sHKpI=^!G7^ehk(-M{QJ9gzm-#C+YC_*YFOL%g;O?j<-$9*Aw6e}{TPAkS{>ja$ zQhjS;E4Oos+A(==esZbEh04FfLd@*eWOmWI@E0pHRG`MLF`gb0Z&p}-vPDPuD9==XD`>I5+0?Go|K^{ zOttpZsMKojrV z-hpVOm`ve}W7E~-rK6vEcp^#8Mv1)H`15+;F5t7hs%37rib|)ix^hRph^_w=Hb!1# zHoMqscqMu(x7fKrlydd*N%Bn{C=}|R#GC*W;?iDEaq^PGeH~)=)xY7fmN1{G*&C)J zEEg_ZfGcINUTqBC`Z0c^UFcjvu}`Set5-TDm`J*@nd)QXvl0@^Kd;$Hr3oKBGlNSF zk;`s{vs^gmZy(cyuOHS(9qSzxn*4ZU%N6f{1E!^|l1P&>z*IAdm+vR1ki6I#gvqDln6&9j(XxM#Q#Aux~?vdESbk1=;ByKO-)38CwK?bWc2A zGuCJc=;tFnQE4#HY6_u8n~vpbz+)GG{o+T4!23VQ96937;>qK~)y^^HPg-#KS>X#u z=wPt^J5Zf})ElmIxf&BggRK)4zaw$D@$XR3X9krRxly-0k(gtYOJ_r)#t3eoou?af zj5=-<7PcltbhLd&P7HUR@zj((+>TX99b>0|a??X@7V4+O{@HFD23%KxaMA3FclHW+ zu1%G#n#4@HzCZL$FU5DIlD#njID#E;%I}IweSk|I4Y~N0g9K)s@M@bFmv`Ys_sDP7 z;NADnf>LYpQ~74zCJ9A3CVWmm8VzvDQnrQHrFbJV;Fp3$;gNSi{)KXBPhvmm)K&%7$~eYQI{)ji3d1~1c^ zxr+0bV9Yx*%1B2_W;eM_7r&<$^78W&oTyo~{T?8;@!Mt!O%Cpn zBW>fE&zN1GZ7^WW-|Jn0gK=MzD3{iDbBR&1#Dr;r^x>O;U&s#HgHfm&hgev?Td3l` zFmN8UEG&YT5igY-JJ|dvJLbD`J0*Dgg=hNF(Q^j_8vu7%{Pn8-Zig4HnXJ>df`J7K>|w2}XjlBR;)rE$>ZM4=m+C>;)zVFXQH>v|vwe zUSlbw8qS$?z#=(dJ3GHU6W=5?Q_{15$D#PgPClm9rGBO$8-m1SkrjT#2*p~{(T?V` zN(I*;U>+V!t`2?K=afN(OVz#~rNEcBX|Ndk-Q5!IDW}lYw`f0V@a_*Q>ni&-D?! zCULC_DvG8**?5kwbe%UL%JeNN6#;rPe-FVM5KB;B0sc(KdtV}71;fp4u9y$jjTS)Lf{B`&i z1~c28{t7oOG4ZIyR!`hW8ZB5iczF153f-{v!cZ}=)WJOj@^0MA$tPJTV&woszW~Nf zEO(7Q@2=U0?^4btWsNp{>}0;*J8EI#O?#6=*KW8%e2r3f@9MO;xdyrP04?TsLgfyv z4Z11&Sxvy+!XQ3;W?JwW{4BKu?bkDuglYDrkq4Mf1pVZ}L=b-9C4TpO3<5{=64oMXQBC|E z;$Vh2_|Z#K&HOja%3>O{3b_ziX6n1rGY|*7!4+cZ`fWWdX3xS8_bbBzLz1-tGZzCM zrBE8q5GXk0d@Sq8p(7B}250e?%Nw^mj_usRh~fcs6#IO9B`HZumCXY~4K+@BB0 z?Cs-bYJf5mnxmgL<7u}1tSp9}y&c+MNOH3I8NMBc87!`=cF{k``SKQ2^RDEdHoytR%bUpS=jBb2Yh_s*cZ9A7# z8{9tnsl3tr-fqT)z+XEnEJ@z&8hXt1%wtQ|FMAjAK#02Jykxbd>71C}p z5W7HVL4~KGRR1jN(MDrpND8dj3$WA>?!7!cDW*iS3M9r%<=C}iDIje%C|QP}m2^WK z0%op?U9|nRSl|bYx7!ZE|85*^r|jsJeO4NEUg1e{La=7LF$g^wRUQY<`1D++x}T9g zKeN8#vU=U|KUOD>!47a@ZAAw_fMl4$l3=f_`bFb{D@x-o;8HGkt-`D*_J_?dWBO zmcP{h&2Lh(@>E2i1fHjs#E{U{AkMZ1NtP45wDncflsWg}cuF(W9o6;51=56Adq4sY zgQq7oqwU)JXoV%PAg2!$s@b!LjPX$^=dug$424X!J(O4R+SfKGHA`iDG}Y$CX9RA2 zum}sUo{UdRu-iGj%f&Ob6|4>@2jm8+zST8Rq8hX$rLt+M^=?_fm)tXZ;t{@V3Yvgt z1r3OWCUzYz-yG=DQH>dL(Y^ENY!oZ2^R1b^r&<=n3Mwre6iZN6>-FO25r7(L1o%J} zx@w#Y&}Ma(v8iGuQ)ALuQQUVmB2z_a`2D={`~3)|WZaobBGVw+FiSG{QcBmgzTSi&*$Iy0a|8V;xU!2MiYE zA#2bQxbge_RiLEaxk5hoRX?XfIM>;k{8y$2CRp zHM33J;zq2S)jH&dT7;^abLZnG_q&{#3qG`hmgZeDs|tn378~t?6eH3%dh=J^7aXd} z<0}p3N6S>2-c+Tu2ft2J&?ma3duY3F-$2WLuF^aL;&iwfpL&mYd!IhXGo{DAlygfR z_1m>kL2Vn6n~+EqLJ7buiP)I9PR$c}d8cRFn4w_eXa$?t_+9IPsBS8ckB?86(8GtG zHGIRdCaT(7RwIKnp@M>%0e~x??vwO+zsSK}uYNo4$*KNUn`AfXtaKrK9x!?YV0!d& z_GEaA++}3;n`xctCP`lRaSiNzwNmx8Xrax~>|LM{Jr;i;>ukj4$`xAB*l3}WRsNr_{E8xSccP zSPvj>OMzOm?`E=rxScWiqrm=#G3@g$S*_mAiHbWSd}s}DknrpBwf?zVtn+$H7Zl`a z%dVCCoar-@hDSNa9B3R+h8*|Juqc9dv9%bi^gDYMG?X4~84&4vG^$bf+~=CflJpBR z!@-fFnyO8ELr>4>QcQS~=IGmzB&5%Jpatt+DrULz*kQzK1=?Ygx!fzL8g}{ObN1i{ zG=PL@P;Azv8mcU)i7{*Iym5&T1;lq=a3EZ9X83Y6ttP==?&P{uxL#?Y z&j`tXq+lVP|13+vtgwb+!{~8mPyuahxL#4HGI4R4aY}7?if0%%BV+B}En7ID`DKSA zj%M`&?ih+#V_|;C7>f%QwkIo*+2H0WGXhrE2cLqcCfDzXJ^cA~C0lzHoztrq#&%F7 zm*Xm6IwEFj^DW0F;*9`}J8E(Qh`M@fch*#Qb7JlbRcEmCqDAUMW z-~#+JJ<50t{bR7{cV7@ZZPcpI`5ZsbK$9LRo@q4zwLNV^!gkr%`nt$YRMh4h?;QdP z&{MwHbvsr3?%5!lu5;bg)U9?YV~0flY^&N>%UnDCSI<;(5|xM4jZL-kT~*?Q=Mm=Z z%2<03k4|~g$7AY8GRp*uMIRb5DmN9Cf|j2LLEQ zweEjQ)S3ND7D$vi7=M5cVeFk^^xmHhh?x-iX%-Q)X7<^>XLT-*xG5;e>*2o?H_^yN zs_EqpX*zHLx>?EZ-4yHisbaJKh(6T$*&F;=U#Z6pu!UNb7TRLQpvkR?=%RtQ0!>d^ zMT0$`=Wc$Ow73Ds#j}{uPj9V1RpC6F8BFeN15HRCl$zovGp!*B@80pt*J&qP8>Fnz z-X0Ie4YpKh+}Bza5#sdz;3hv>Zx+*b;qCKaZ!x)BA$_*L`j&dbG}EP%8HOr-26%*o z7Br4|O(6#-I!w0WsL&eyZP$3T@%CC(9xh)9(a+IXRY@?5Pr9;&-%|(ecY@mOf=&<( z|IK-?ydx`I=v@fu0Ns1v8ieb$19I-Rt(0D<4lxQ*(o$055{q3Tdb-Nt$J5pqUJtKL zBqr6xWOE@kSUwyqtK66_NsWdP@i8-m#b5-v2BLJ6;ih!aq}Ghz+xwz2%iXr$Q8K@c zA$rF?GV#Y>pha-=8!F9wNF@`dgA6~^u!Y1tY)+~{X;zg+Kag=r)$P;K)qE8y5k_@$ z*;RS4@5C)oVe2F!+B?3ouJF|~=FEf}=!q(lQSH2`N<(a&`sk8g3`nro^5o53I|B<=K)|Dy z&4$#a1iT@;p3f6u*TY=_Zqp(iiK#A)a+YuyiZja>^0#WNoX_JSfxDaLZCz;41WGB# zX>L}#C_f-FQx5|6Yd??mdK_rpZWGSgFJaj4-Qe|;vyuF{lm-Wq3dF4o@mC*)wDo~R z@_>Gy8>D?)-H#%1Zpf&Cf)cYq?}75M_88V^XK{Z=mYJ8}m#Y*2tD|02>>QEY>rdU8 z{&{Q_Qg83?;Zcya=4U$e-EN@M2*uo_vCikziJsb%=V(+AE-#p z^}h94ZZ4%ggnn1%I!o#jeqoVTLiH<)=yqg*5jwADn5vpmLsa@QBgA8%aALRx9{hXk z@{Esa4C>Xj!qG&t*THSApqjS600H{1s&eRKf8>x#KUs1%ipoZ(CkD|E94t6y5obj;pj^HI6Mx|Zs;5u}nr zWS35vy(=KS_+7tSVM&Qiiyt5C05q{1CWC4VTOs&ef-%SOPjAu@uUTHM0Gt8A;W7u$ ztnAmZwA3kCXrGrcg_b5;Oe_!SB49($?~3sC>nK9mBxk!H`vM-(Foiz{b7b?yR>kY7 zyhO4Pod{Ole&3m8N(ROc1Xp>bmI?S+q-W#jq?GmSs0QcSBU67jF*Nn=?wrE9X60A^ zXy#$(xsBHxMK>RD85gh7)K_L2UcTe!2!&T0Fsz`@832bzf|bMH2wXN_Uj`aHD`3TU z4JjAV*<^)vA0?H%I3Wv6RIBX=N8fu92hPKwmzaq zacZ+sQt4~?75~$7YULbz{W7xYa5oLOu)O?ryX^w!-p{vxQDLY*%#0k5OvN+MvrOah z(SSGQ_g2qN<^nq^kf_FjpY2Z)``=4m9Iv6o`GFi(yLA7K(N|smR9n}w)pXW0O_wy# zr-Dr|kx*Q^Xk74S$HAfsb6_$jt$CQH-!BG4-o3AJ-n(jO=G*wiFO=q6BmBj-6qYt6 zO5Y5<>rRRBFqTHi+6i5&l{w?2I#p#9FM8k?AXyXb6acX;F4fYws90ig`=#z zm;e3m|L3#u+!M{R8|_{`mHjAZrkq2IB=v8el+pa}(pSqhDB>xZ(v4fEQYhA9lvIhK zSN_9?r^TrhaZP~v1m8c`c-jo0gd<9pv~{#ki^VB1SKxmY{(n#5(KU5u8;K8Q?T{Eo ztk_9+)2CK%a2G;oDcu;cmnq3XEPK!{YiP=S?V<;_+L*g4PuNoM&!0EPv<?l6;Etrr@7MXwD&o^*p2_I@PC-l|MwLBf3^4K zQB5V?yRafCt?jI!AfTcmA|MJxh5)uQCY{0SPjODT!z+DpMF}KYQ=0XIC94&Uvj> zkOo+Etpfc$|K1?xznJ^~;+4k(qhguM8w*doFIe7wskoqdkJNhEo%`$&yJ)r>TVJvi zH|(GuzIkYUQ*7ILHu4(vcOA(azcnW|#U4;y@8(B7u1tsf@jq@mbU97}peuU%&X;%$ zEF07ntlnFd*)z<~8+p{pz4A%>(9 zP_MG=!df22kHBmJ;F#9+=l=hr5;p+#w6>_c`ZtV8 zCa>XG!5;d*`zQW&4fUjKPXF7t*l}v@IOA)|-Ty$Oh(<*=n_r=9-LNqmaUtcYgzUrT zPUYM@4VkQC*dr#y_Ecx;VgtRg^<#4K$GbguXTaqyN_ofgUcc6)H!6mS{9Kp&7!rXu z)raxE8y)gjnTbfO8b?8L++cO3k7Tuh8;a_jo>^?&|r^kCiE#WfY+pm>{0 z20z~0ad*%9a9CE^iTFQ@>^S&W*@C@0l5JFuD*Wqt&F4Ux-jy4BFa1^Bf6Df5mb55L zcp3Yz=Vgq6BOs3#Z9e*+rvEG(?ja$L>Am#D^k2_MA3k`>Ymd$2UH@qs=)TbdqiWy< zJaWbq|Mk4dPT<6#1gJI)1(3JOU!-4^r)Wg{l(9IYa^Xbm8-`(@e(V!nJ*LgJ&#=U zz$gM6N#L(uA>h2oZmvKolS^Mq8;3cFb8cb}H~9rpJyRbiFi4XtI4WXgCqaZ*b=Za^ zzg98e0Y@Xm;i7mP&#r>;wqnGLwl`OROC`N=soxviZY~JmCw$=J1&<=4W*Z?%uEDsZ zOe2?H?qqVR<;>fB8wT8rVrw_aYu&Uw4=lYW_rsSTse2{p=!X#eoQ~;(iv7+9GfEkT zd91XYQdO@EB@s1(o0&R5QdjT2m6;Wo)`)evJFblra=Hv6rPQ2|+y01Y->|(uFc2>n zs+#}RmdRE@`_Tf^^{SmhxmuYtPiYQy%p$$4uf z(f6hE{U%aK{?CQ#`(zN@ZpKTD$mn)>5zU@TLsN`|G#2x!{FgluC4by3L8(JV^N+*=K`<$H=s! zv_`?${VTmA=z2v~d>j-?*zg z)%X|kf_432+_rPAtPsLuDERvdk5x<$;C0Wp7#ggGCl))LjA~vC^=xw&OsM{W3Ybkr{5a-*&Nk3&dV^H5c6w9ZMTpHwXxI1c(8h5ud>vEK zwlBL`X79@;h}AjR`A=JQ;LVB}gL;$6#7(i@Qvx2Njytp#vaJ_^ujq`P_ zoFE?SWE!}x7Rj~5zS17klXf29Z?bj155rN@6KyA;MD_=({mVTIuBFwwtMQaVgL977 zc740={u6H7XZi1thoK)?rZlFG2taoy#MGd3K5W9*XyGZ>N z6&xYv%s|~m7k7@lVaTAfwezc57QryoOXLlmpM_p$8{d%O-0dn@d2Y;3#HOFV6`1)& zoiI3RC<WS~_k+9%@pD)2A6aUT zXv_-W_Yp^AdGZ{Ff2VtlOsHjLR!bigk0GVwW==5`X()2#UY6l}yZTU>ZPY$In{L{I z8AhaAo1efIuMjs*BWMM@^pym*Foe3jB$(!!ULP3b<)mk6?R%I~Q4&T~DpQtdLp6MH z30a;x`BOEs-#afnZ? zX;BgLlseA$$qE-`dbZ42W^K{@rqJ0g~5*(~&X|T}q&PpzHVi?9@yOp9B%ROT(*VDhSz;m%65vObW9Y$p<4avb!peXqC zQm*saJ5wnou^kH~^m#c2UH@z17!_&N8(3F?KErxa^S$0GRU`Cknl3u^8kM-cv5F>5 zShg0qbPh4f>*5GJJ-b$hm2j#@$xv&dH=P)8kR*iP6@Arq65aoTm^}+9odcvFPI4y7 zH_+*Vq?3-+c@hG($U?7lrRzn9+*^I1NX7EY{3$jQ{@wLl^w?8tZkls#yJXlVs}NWS zo@j7??$M@3SKI)-(XO=9GnlCmF{|m(uTrn-v}j*Hi`2CYA-Kn)G%-ij+pv)Je)n)4 z!I|I*s;qGF8#Q0VJ)0*g^DvF5^wo!Fh@~>-G0NN}m;yLxO5HF(@a7COo#c(2ex()#ZQ>p_xnC}p4S(?GF&3dBk zUu$zhO8`*-d9=ltC!O@BxiBn8)mI1Sw}UkOZaax+6;@s6anUo_0%znP!UN>VI?pfV z2xVa+mr=*bY5+K9sky|D+rt=RpjALcA+f!EhsHas;cd{43JklVI$c^vz0f4^!-Av* z=xga0FN#;8WgKp%7dB!}urQb=L7V6wGo3~67=72j7>12vDYNy$eD+}|8_OhHywY+N z!eN8VEml@F_yt++o?#?24c~x%mu4*J)=Dq7ueM+AetNOKVR2^cLk2QzD1dGlEI{VS z-n-xwV@A4`wqh6&9o<}oN_10?O|b{{auTF-qtBil$p^XS-Ts6Z&J92K+!xj^FV}M2 z4VtN&%XGI$ChB0m&(?&kRBWSjR&^rzC!NcR$Wi(1zL3k7!KA7K0X*mPrMyqzP`u_s zua}~g(>Ft}g&}PX!R&B9DIPE#O^oMzRR%R986U6i2b%2zHG<%aJwEfkzNy&a#2gaB zStkr8j`6OU@LEP@#m0I$FnvBR;V@p-mwAs7!j<<^h0Jb_zQ*m!+bxBDfg(ItH2OgD zxhPEnOW$s`IT6kIB#V94knh}adwO1l-u2r}r!@g|b5cuP5I8s1^-vn_t}L8QESmIP zCNCxX^p>(hQGHb_db#`6VHX0tS_`UDZCfnB$Kef{iWyWAq8@JUZkdjwEKBFgpA~-E z|AEKsM{>3%z?a#I^*N(ACRNF_wCklQ_;ZXwv`u0wMt!(uK1AUYjb4Wr5tRs(?{CN^ z0bX5i?Y?Gvl%L)xz0o2B))GEH-o14+BeTLYL=Ln)rQCnM0#0AqZWzX)(i#_#_`Fqg z!lj0Zw-J`+=vHg$cstY+bvX$qu{hoToEyhYY^KK4sr@+L$MZK0H-+r9mm#@ib} zkVg1G-FVvB?bFD1nmqV;x{{mgbpsU7OFDCB(yp1f&RgB(H(PpY>rvxH=3F@T_PA8S zN;lhs@yEi1GH9Gosp;>G#j+1ix(54`)JvQF1w$!|Hqd3}egt~@W8@}Fc|AYTav*TB zEd02?AXA%^u18IP%Fn1Pgxrj;~A{ zy}UHqv5?bF{uM9E*~qGr1syBoj}$0#mbapV?~$%$S~`(IK?^qk8yWyJR7743o*e(c z%a||!V2if9-cf#n=@LN+*@~Wc;p1%%m1#*zv~uOkv1i84&4+zbX2~x2+b2zWUv7gk zh1SmI#J&BFv9eBe)pj;Ip30nWZ&%ED2mIeRs~9d&;xbTPE1n%9o}hly$D8l!GsEUS zSu1`{3l=8D@{M&t=9L>!fI3;F&QA}WL-W6<^ZPQR%kF(yh*1!|Q#Q0bLr7GGQfC;G z0_N}j@`x3J5V=T=K+o~2NfSVS=d$1TJf+*JI#>LMz>c)P3*j;5X4j$PCh0G;asX3q) z<~_GNo$|gyJ8voD?{ePyVntZ6f>LyPaI-=ais62>Zi#!|a90-AwDpTiD@JqPT~1j(?wzk<=9k2{0JGKBthaT8v) z`h9w#qItAolI3EG-2EA~0L4DoG^DQGCtgR0Msqt&yE_uQ-49dBYrI;uOEKP#5j4?z zS<9+eT`vMUNBz`Qsut6boM|eSAm(aF&6Z6PEbq2O=f8<>n#!;0PbOG5r=dJl%+bPG zx%#l#D#HxkGCIRhEBeL(^n~+vxEWG6z|)p1F<`Ek+weW;Px<2ZY?n_HBkXm_NJ(xo zD|G0lz17?-Ypv5dqj8770&}fKKXO)oV^`_H%^c_UYf5O7Mq2=f_CspSeo9Ed0gj=e z{y5!6)j`|bkQ)!z?ZYA&b)LPOn0N|upw^CO*Kih8D7)wB{$CoWxij;u!O6iH-@I#m zAffN9oJPIZQg)L2Y+U*#8@`A+4K?_N?rJ#dfS}d2SK3`pSxTDyrDAlpkyVOkedop+ z94XctRon#4l%UcvcWEoFp~6=kV(r*`>^5a|hHvEpTfc)!;(PV90WTSmhP zcjb^@n()Pk7DE(w>J9zaK0I#*A0zs%C0&xCeSP4y9dVLt{_ZMZk&<$~-&b%4v7VKh z8KqD2WhunE@7o)$AsV|aLpjJ}?QviX3JUm_>f>EP*S&nR4ju%ur8P)G#4Ff%tyN-S8sEv$iFcfGZXJX6){ zw>9`{@@X6*!7{Jy5%1IG2Ph0LGSm7DwxzLv-lly%; zyji7N#!fgSSV~pYkF^ABV3mfchc?~$UZF-0c4U16ftRKzweJ*CV&mQnXawNYoX(SVa1LAp;FMh=MSLHc8@aXS)EvzW&-mrqH2*!4M-ly19~@rrkU5{wmEVVS@C z5E;A^={1=6;?l6RrRkwMRI%fvPWaZH#{u8kfnd2CzZy{~5C42@7G-eLS_0#f^hHAu zC={*tYb{|)->dwPcqUdaH1lF<=C9hLl5*$s1Wnb8Oz5C2cFmb zfwXso1|i2o2iW^`iurCuUgX381lOtR{>4Ychoisomx>*51+oErN|N_}eea2fLOMpz z$2y%|QBl!)bW5TaC;S6?<$I0GXuJo!Gu{h_ZM{zGjEw>4wbYP-vSMO9RX@PlVW2vM zRj!v&D0^kLx73{Sd4iW%FDL;&X$>fCrOn5-hJwRd{Wbt_nBK^mD{4^1_8;bWR)%l7 zhhSJf!olxDLw_B(m5w&5SkT{SEK5?0ltxW@x5PJS8rL zeIU@r23mD8bv=4MAi%h@vm;HRLsPDIvYoKgMA#h}Fl2meMK<0YzaVAW?33lg_xLh0 z?nRW>4S>}jA&78ixrOziqN-Tk}9%z*5pXLv^wQ*!i(HaMm<5F4EE>exmXJ+OH7a&A&|q)xW9z5!Za_w zb1-2Vz=onI-PPF%p!Df39HXjcw{Im0_#Pugu?q7~U`Cwwg%l%I3GLibh$yIF4M(aQ}InsDJo_(SBD4YT1-EPbkTqXs4oDvW=_eQToxJ#8ld(A0+#7t>=FlsW& z>1r6*!oZBp>etYU^hGr6bT7v|ja zxdl)Ekvr6e91ETW>_}hB7siCCY-@1b?0B4^&iImlA;##$=MsmCPWzng-&YUf<{h!txfBy2cA3buTm2uw1~V-lSq#YN_L z#AGMe*>GfWIaLEB_C!{@3dNVJWzYFPYP`jbGEf$5)#0Bpjmke+Ify@(Kn`*?Sl=4G zl|`&Ckuk`wh+pIybT~7<5ZSRyF62u{JfB^5?2c^Ai3u9K3u*tfxPD}a|13CxTnk~p$8&V_{U@%t`o|TDQ9CuTcmkXVW zHCQ6_ZIZ_`A_u%5U<6uKcR1z&sd}EbVpsg6mYkaWjawJ})POj!5usTHp$7QuF8Ka| zwVxf+5C5brEq{%>>5z&d#8X~BTjcdYVV|G&K<&f)>*Yo z%RbPGcSrW+)U!~F{WSksoH;>Ss?%xc)=Zu)V>UkY+b{J(J(W`6YtuXH^q5_fLQOqJ zszEB|#hLW6AL9)}Cj6OV7Es7v>hGyWD3uTrQgVdoLo(VpF$y zJ=Wnq4MJ#8eOMi5ty4_KWnd|AFiSLj)SYH$2X`^Bvi{m)VqYDbEH&h7IV6~`&9Wl1 zsckf}Im`QQdMwy)u8Le5H1fi>wWD82fVmN2=_M>LX|8&UD*dEMekKT<=3F>1+?v6C zoMlRC8~?gpe!*f0$&D|e=rtvab@9egLXf+@FqbuCzzt8$00)n`sAtAgtw^izUR?WU zf@monBzcJu8SG>pep=4kgWkQTJ!HH#KO!e2XJ@x+sQ_b-~ z?~G%NmOh9O3&u$(QAuU@*6&v@@eLP?H;7jHoz#1_9=Q|D?m4vP25be}EJm;^o;*nT zRyP63Q+u4(#S+wv5j|2f1flz+aYjt0JIi zMbEC6)=gL4ouB%pv1umgx>e!l)~pHz@9BVqr0bGnD;C$TIF7pd=zDw%bU6^a5N4u1 z=8Y0;gcq^nd3>i#65U$}EIp8O+EGAwQ=Mqnw7e?}UI!2Ja>a0+Wi-kuX?9!eud~N( zYy!0=(}UZbY~?^4z7|+rWnljEQ#wZIul+`l`=Ah*ZzOM@sSM)RELKSMLV^7wDO!c( znX+D8Z}X-@eDWWB0lw4P=mkj}Pz5Z=DsgY6ms$x55o&k0ZqZtJw3)kQQsJ9CX}np%^RdWS1U zguI96UL58bg1ZrmbH6xPWu69hLqA$G_&Ql0Sd3rTe3m-4H!gGC`qr(P>&0Ykjc(TY zG%|~S8>TWcbk91mWk^pusr)iIR(?=BaJH0W&$Z@x3?^-}Vws)fS@=CEO3@358L&40 zyRM60VcTP9aJ!c}800#2kwryZ5{@doW@I4jeYjw?H0C^U1UFn}ici>US{=ZzFlm>tZ^ab%^^N*yX z*Fym3=x3!r$MnBe>ZeHke`?gXilGjou9)n}`#$ma(b;(Kn-^)(%v@96%Em+&KS0lB z%utLn+OFqEH7a^tsjZ;0AJ6m3&A^IVi@4O8Ai<^VSDe1k ziw~M7RPNu`1gEnb%2syWUEu*<1Ie^QTU^_5c<#D!_G{8_fG?phrgULq&wcGZ$+LSI zwB5=QFZmaAk6*=Rdr4hLNh*HY>OT_Xk=<9=m-7JUnZ5r-VzE6)OWrzI&y;sJ+y8y7 z{#CXa_;AiR)(jn4b-J-^$H6kYEsi^i(V8!t{VRq0#=IMvHSw=hC3}85D1o7iTi&$a z0&xX6m47tvEkB)euU0=}Xg^(H;Q95~%)+2XsJ`g8Yy}e;>HIh2dgZ>|1t8tl(Pu9# zV>NZIo}d9825`q004BeuL}qLG9&L97#Z(& zJDZ)cXl!H8yKt#BMs&e`hqA-AXG+T6x|5g8bqSX$jp~d;PIu>-ZB2LogKb!DF1WW-o_r%`ND1ko0)yeU^jwZ z4`ECTc$3XX{;=FeTpZSxD5xyhb+Bw+oT^aIyP7R`IES6%NxMaTBgzzlBv%2D_ zoVmd+W#m9+qGsG^>x*uk8@z`i_6yXGFIP{mSHv7;T<(DF2`9bnu`<21iLi*C(0f7M zP4|1zz5cXBG0ueNkX@C%0k-)X@f-+}Ug+rjOq%{+wbu;xQ4@>GcIH^5d3%KfW&&SPrJ+}FDREa9Pj>i{koxwJh6I#o~!}7DzhGZyqof( zyTUfxzbRqdDp(?k1Or z7dM)C$kE@K4V>1>(3houGXr*oIT>pT$osvgM&$mW%Nr!J)!Su4FIN60RXTW46lB3a zu$!K8ouR+h-Q7Tk6r4GS)75hr-AWgxW%8lf{wqYm3xl2cF4-$Dx~E{9&$=65YDYMu z@Ae%AxJAB^z^GPe@=_M;E&(K2)r+PcEhc;SReN~T@0?7J&v`UeW0uhVG)Uv@Rb5H- z;;;{Es@G$5^HTggdTYF&Z;|;KT^YZNh#5$0V^zZrSXj2^$P2gd8vydaX3QD-a-3R38#XpK@id^4 z?cX8?%gQAxXnb?UjmkMMBKJISQ5F__K>2ve3$X=3A;?T)muO5Wp<5hcv0YIyr>ol^N#6i`2g(5$ zD%)QT>yWLvV=l*xc{pdMgZVRnwS08i0s_+v*Lyp*=MPN%JLHLO>lbQ~@rnLMLg(y7 z)tey=XS>(GxJvckkgcW4ZIz`r3o6a%DZi`*d279TZ6*d2XG_1h+Pu}?Z3|xcASC?m;4z2p;65wGoc64y{q*)1&d(Pw zWw$X$a~=a&C$Y0;>TP8AIq&m{+sb`-Pv8*q6#J_yOj^o7nQ2FvzyYM%*kz0t~tT`JA_C}!euX{a{E*-^{1Y ze!RI0z-9BFCI9h^!+(y_PYL-88rCLl{x@mIKjQcIMYFDWO6e%lo3y)Tb)j8!#XBMC zzoDDtj{YgJ$&Aq10a;{jbk&E%=xgx&NbvB34JF3|HfY8CHw`8HnCe`=OKdtZTP3;D zw?w1kmt%T=H}Pkwp0ykg2dkVPgUAO)mOwg*<*9*x=a^uD&~Py1MD%}a2Ws*KGGF{2 ze)-$X{FP@?4P?&r^;yGy?D4@rtc`A_?6wH}du;#gM&4RB3O3`?zjIvDfR@s3R_y+7 z)(YSNdI5Xbp9-VF!w>Trc(0E4-W$_ zfCKQNUf_fuVRF5g4$zX$yF34$z8eHy)RU2~`D5!lJ}VzQ^>avn4(UJQ_ftxLD*jI_ z{Q;tXV(I@;^YrbsJL*p}{<>LAy=nP&{Z2&_e+C)HdMM!1(3a;RuTI_iEmbKa=q-P6 zL9@!KxUVBkr*a(lkydG)YiS;G{XU))3wPVhJ5=hdLABhrRFrBJ-IkVnEhi06KwTW(5NO9#3fQ0MQx*TR}r}Ses&dRUUm2NAB<^I3=TlhnNySj& z=w4gLa<8h8BbL_7);9$VF2>vt%_!dULh$pH#^v%}O1hYP9 zAv@Fi-ldM(i4;#B=5^H@-SnW5XCD+orrrc=jOgUQ;i`}X3rYAPRk67^MKgzxk2_6Q z-AfynQZ!xL;}sHX1ze< zSa{`S1YqZm?s>Y-t@)EQRDa=-!s>7`=39e~-^9J0M6lJ&w>KZYN^Ft3XNR|Bg^=o7 za<8G00#be&*&8qTETwASAeB{`bbVuHezAy;7wPF?xbjlx$XDj6)f}AqAfp&N=rLhx z$m^0mF)jFPh2{~@;f8$MFJ>-(RI-dbxH=dkr>Ffazj1HC;$NBC4d;w*@-}W$2SlSR zSn}f@LV28$6?L|bQKBczj}z*aVF*Do7SM^J06WfCG^RMl$qA}k!)I#?l= zuG_UwFeJ>+%@{<@4%McIa%aJucx%i3cKeU?(I&_=;nF+hgMx1n28*$hn9dTB&>PJs zJGmUWpUQ3GHd+2hK&zz%$Snyp3va~<*f&$!*&|Bk(iL`u-Uz0VEsJTZ9Lw;Sx(py8mKbFQiH3a!E=8zn;a1#Bb80NvuNpc<(0h&iv zE~>lmS_j;Qyf@q&zU4%FCwsLrQ!rC`g~TLk6_K1nnb=#}CBFQC>T$nJ{?M&_YB_{$ z94QsBy4-4rvf$2ACQ%FrT8O@iQVE&4$8~#@=gZK>r9n?s7x57Lp3oZ>iq6U7`C%5s zhrl-K3yrtO>P*7|Cq5l#ZQ(Ey7ABQJynI{n;n2m_YWgFJmPk}JFUW1(Qi zrf*K^5H9*ZIOpmfS24jOO|XI%LT@>_e69JMn4~%x$@PWDnr7}rj*d4UVE5`bI7La z>RO3bhG2cMiTa9)4CK;)+|^V2!o3NSVYp}OU~b}p=^s2Mx1*OoY`}{IEU2B~@M=3$ z=zAl?uxKKiaVu*^4meiMYWs7JbgA+m9ZLWMlxV5Pe3rR7rt~Nyc;c1UVOmW*ZV-FH zfp6?InB(>SZ9vUE{Qd9mVe|m|w{X4HQ3X+ugT*i2sU;FI2eHViTe-2w85jPAIUecI z`6pjd;7Nw41%=}Q01_qyQk}3**ZDeEm5bN}L%i)isw~t@KXEMu%)*$)Fchs2=F6FF zc^|4IgK+!x0%w|&OBxYj8KMlHjtXv&08gYTt{M1yVe1X0E9X0yF91}4{5G6QTb=l} z=VnVDHACZcjbQLZz-TmRsfjmTX!We?lP%Hd&M2?L(D>$kpQu^L)8@qoizqBI>PEUu zxLGEyVO$lLyKW9D;*n^FSx0vUb<{JlWXquC?-BKG!9ro55oKXpyQzo zwmxQ|F9A;pBzJVw3mSsi*yqE``TOP@mNBVtUhts7!!e5W<+^sYdi}jjVL+6)2;3*o zmUyXr3J*Yd9f?L*7;kqF%*UcvAvLSYCOPQ+pjRQ1+bGB)U^sO5km zJMN0)@}TK`tr`?nztrUdZk9K&uWLw`TmpO&DD(yIEY{)GL&lzcyo|eu)c)3;1Hy_{&0S426d#;;@;&Ee|EyIPjs0YsTu6}2A;`)? ze5%;YeZyn$k?OM?qw3ykQ<)ljE_2IU4pazdbKbH$0dtsIBb^Fq| zGhIV08V)<6h4OIoU$yv5ggMz?rPgejb%K37DVBEL8OrD3HEv_k7N2J16vGhk&yu%n zCRSJ2jM?|H>#4GscnrOcW4-xF1+&{loEnGX6hbM;=JlJt#xz&X)_qM*(N!HpnpaIW zJrCI8GFAy61DS-_ZW_0wAEGQbg|4dwWZ0c{2`@g8|b19KYpT=p_WIy2p~BEOqH89K7%*>{b$ zhOogZnD@d{^;0daNxNf@L|(HTR5Q>!KMIS~Yy=gzTf?KO0xdFgG_R&W603k+iLX3s~BW#^7q} z`E5FPY?gGL^iseCd0Roz*N@4^2DPifm^XpX^9zgLb_6I^(t{I0p}*$V!I}pcnn)04 zomHf#S?EW9TBn^+5|swn8d@1)8J4&ohO|icN|guQc{W^Z+~dmOd;kWO$G3Xtr!A+4 z>4xupha#0t?JyGJHm+N@_r%2u=dLN{br2UPHSHbIsghH)#mWn znL1%rOOJe{IjBHhill#Nl@I8-k~JbTaWRzD$Zas=+RWmCksa60SewiFx76-hZUHsT z8?CBMb^1h)8)!f{wY&s##ry#$U-jCtmzC4_Oy^wLvFz3wVI{okBz%cDtT`xoXVSzj z;M~2s9?*} ziU7|L3rGReg^7aYV7N5xprNfttx6H0-v2GBcxa-0piU&_oG-sE9 z&1AxlDgJ>m0;cq8ak;P02prqLC}plbVd%T;(TElnN9`N@z5L1LggZs@mUsrh zr_~tbVy;wH8DKiG(K{RJcD}En`r`J1DcTaJ*Km{wNuZW})Otm^{X45cvIt}A=ZCpB zDrtEvhvDW@=e}8A$(^CXIxfqkGz~UuqI})V>SDAh$;u{^@@)?(3c|UF(3YpPUpi7j z&{s?suULA@*F}_tyHg!DtU5#;bDb1z(Rz1rnuaVkcIf`>6ZYo5oA_H58sHZ>$%PNM z!%lb?AclsfvtaSq6zvP&`j3rA3QJ|XIvn6BC*(lpb%#vK97KRyG@}4LFtZQY#9#BM z!sl!2jtQzRXAt080f}q=rnrn1K-CMvUOEOq-7WDE-B#O?NzDuk#HHw)o@TC}hymd~ z4-NIApJ&{E|4UpYLtKS@hv1^?Mlri7{zUnBh_XYbyvqgbd5cnJnP7<=d#TjgNIL7O zI%YD#TwFUqoydo6zAIi4@DA>pQ4Nkwow2xNeL?XQ8I1 zsH45ACAnZ_h))0#p)YI-|#2YlN3dmqHEb6SSf(}&ELGdvWBw4A0sM-8eX z=XY4A(){5&0|rYLWqTnp;^fIj zLl}UY>E`;kirxI^Ppl!U0FsoFW>mLgA)bi1a4N_|(DsQ?qrV5FKB#30-_T3!6&pg0$1HIzN^ti-8aEh1s-oV)V%H{emvN=({aFqoS68Wbfp}beyVB z@m$S~jTcrTOv?qCR?-O0+dU`0-Ul(9 zsL>d5FHBzVqd%2GG*Il9d&R8(!B>9ZSZPz-JVFb zx+(8@>KUI$SxzGe6@OubdqP5Bokn~)1%l(<0f!5opyU_DJ8AKFDUW0XWY zImnG{)H|>EKu+r2y-6TMmped8ouvU8TCjWytp2zNV#wHq{~ls0?m@<2Tb&}dZ;u?; zs9xkrj@i(j-u2>tWjo6}iw>0A_l|0yakW42+v{^y_(?Ep#r+1J{^V*fdDpvKGnXNUbrN{SY6~Y%T=Eu5-<2!s>v(J?AtUR|s_6MdIgM;xWZ8;@;_sm0J@?Hy8yl^YJE^ zk2ue$sHS|ptrIBCaq{}wMmAHA+%$MYS|(+arC&~YrREM5eO*3%+b-&|`V9vW0DmR< zTl)a7;dQ>`$MTi5npd;|NREN5eJqF1Xm}G^4PJB3_ShVxth@X9k3-if%}SVuY8UgR zqB}~qM8Ck+W$w?%e!WKX*pOSD@XEwi1&#Li3a;dK`}ege7Z30tf@GX39dTZ^z%MXj z`q8Q{NU=`y-&O5DjY8WC$5BZ=^I?$B=AiCzZ7ie+dX>XazpG#Gj&jMkZb&ZaPw!$wGsV`A@OsReoDwc!thf&eqzW!!tfIrej>v^ z!tj3@8D6`7_ZSjCvHB;`N4((8<~7&jzXbjt*nVq1)6buN4#H27`2S4{`j^E-+jHhY W_Wo~wrL6=0E*e{2DEaN?!~X?DVGE%E diff --git a/src/main/asciidoc/images/neo4j-cluster.png b/src/main/asciidoc/images/neo4j-cluster.png deleted file mode 100644 index 96d6fcb9cca7a495dcc55a84b9ec1185bd81e4bd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 42763 zcmZ^~WmsI%vMq|chTslCf;+(-g1bxO?lf+}Ew}}DcXtWe!QI{6T_4Hb=iK|=_r3np zt7p$OrDmwDac76Bj6!`fq@}Qeiu~&1B1{70|O_3gZXHAwFUPD14F{J5D`(3 z6cHg&aI`bEur>h$`yQ5<4673V2WxPj_G@4u7Mz&WfozOkfvb=p_X3>c4+UX3C`_K( z;*BLSDB4zt+zl--O%>4-28g>>4Fye2Y(x%~wfrCa>&w?;X-<33J}pk?8SgTtove^Q zav`NjK*EV&puK&>Jb$kg_%KPCDdHbs34Yup;FJ*=R2N}Cks#kS)>gqnAG~L!(vP!V z->ek(?5`KVNMd7@zqy}SgCxMZ8x|l8_`w2g%{kNK8PTq_L8ZdfXkcWTBNj??SWe*y zHedLe6@6k}!AX=g=?w6|5Vl@MAYAZ9@<@JI_wHXj#JCFI85h-ki+LuI9~m3-EB_v3 zophy}S?@cX!jc)^FNJS*sPQG}WPBLIxMuG)Yx=TF+9k=n92HWdg3+ zU^uR&#L~mpP4pO5lB|7)FK>pO@eBx2iI1qY*Do9C;4om+8`Uo&q`fVoxVa-5#JI~f zfpHoK(ZSbOB8JB4WFuj5yAp`a?%0`+7@w+;|#}SCPPfOan(LnYEIT8rdMq35k zlVcEiI^T?;L96a5lQ}H!utA4Dn@0S?iU}HZ=sQg%J>AqLsD-f^oE!`zsiSe`6F*Ke zvWPI~BKtozyTcn8Eq&8@2P=X3*}FS9#Aamg{3!m%P#Q`zmc`eahm)3CihF$Fcf0>V z&BB^jb9esr556IN*|3D8!8Q0Ra-;kudxAi4feqAOf>2fnAaL9t^Xv<}aK4h-5a5V# zLU-x>aBu#7(C*s~opEXm)IaVRx77}(5%Q(95Wk?OY<%6Z)>N8?M`$w9SU!(aqMg6DD9`W>~#1-e|{WnYJ6RUpF}v~;5 zr2AQc)2@I=^}*iz8#x8eonwX%sCuOh6F*}dKl}V-Y4Z>A&yx`wYWC@Js3NX=@aB{t zctClb#L)I592hewsz%hnpF{e!AXyIG_LC6%`a#N#OcUOyLrk*Xq=&binK;cO4Loi9 zeUeAIP>}kuONigqw$n}IVHa)>-reHxQHJ!3c!TLB%h6i6;0<3S{^>BY1S>$R} z90$8=(Qz5vo<3-x-i{-Q6l^dPLeTeq)bs(*wyFV);M_DK5LyYJ!3PZtnz|<=2Oj80 z$`oK!3n|x4=oSFR1TFdlCkD>+x28PoqQWgfH5eT^=;5!JZiEFX)ouQ)v8T z!dN83F)YS>N?|9$M=^j{Bhc3!h^c@TaUwEEkkt-Gc#et+=B$wHgk&+|Q9y7m^MMQ- z@~9Z%q#=-9%TF!ud6M$xvj==f)LjnagaMNN6%OR|U^x@^2x>%kT(yc!D1DDqjbk~U zRkzlruQ%p#FHBAJH}s-ynH7Y}aeZDav+b4#GA~TMu=y=nH!2@Y-%!*|06d#N$M3ie zaX8X1Xj5=ba1?=#J$gNgJ-E$zPw?lVqGSQ)QovwO*4SS{>GC>aE8^B)8ZkUWqr-Z? ze3Fbemb@Yni_ysUQi8WYv=BJ_Qj$C)|0I}1bsT#N^4s~slBFZcKy^-@MRFgP6)Ulm zu=8_wWru9%o8$G)9OyLGDzS}ho{>{nvGA7?FEw)l(vXrAbb+5^uw(RaKv2YB83Iz!6euXltsLh)vO2VQ0>yIVGE&)+hR`##A*49$8Pp z=WIdsYBe~;4Qe{IVkL8>168*Y>LT;CjH3~I4m(^RC{X!I66c`i&6iHKL1vCXl zQk;pwiHAdtL+C?`LuCo~UjYg}mBLEQitq}X#h=Sg)VM0Henm|pANl|}ym7rzUy(Wh ziN%(sc)6)LT7@2h4bslvWyMB?=;drGwGx*c8u(!bm<$4$YH_S^LU1^7vSyrTyk}aD zXlLSmA-`i)^_OmhdcBI(+#BCSTYQUPIa4m>hF zcsn9JsBYhkOPRfYX^tS6QaODGXbWfn^1GzFq<#CkXGrFi#XFWNw%6hv=vTad1(BnZpCzwHI`}8natPlwl7Uhg_gJsqRgW# zWDe<=>6q-;^f)>GCnbff7U$tgeicU)hbD)o_1RMCf?N%KtxbcsjhVqShx8szd3v;~>f)quiLBa1l%qxEcAr@qWb^r>=@FnXXz(x+_KV zQ!9gujnnJF-cHiF3+U9&mG)ld-urBvDot)rZjJS^Cd3bR*eF>di)xy6(W%HRE4dSU zxNPY-wkd~m(6j2EmDni@DeIM=(c8u=s8hmw{ki3l{>JKl@Fn0y`n3&01;P-L29gL0 z52_G)4i*KP3uYA65|t7v1f~kH6E_#52c-lNH+75GWHVt*!O|RPZgP;v6v1SmajXJ7 zN+`iETtnnU*$?5A_z@Ztij00wE=%r2?wcl_j>T1Bxin3^Tnw$apL;l2mv=AL6>%A< ziQ&XKN2m6A8NCRHlf07Q%)8z9<>{d_P!b*ygMq@5;_8!j+;>R_NzeG;B3PMqwhrIm z?VoYDoTjN`={(mxbQPMKby4GL>7%LM-%?@-vf3FRS!w-MNAcv~B^Og!`tFSEOuIJR zoH!g|nu%6!SIkO?N{*GYirn*UzTeO9xUE3}=vNg$t^yfdOUsJ)V-)5C!diG` z;vH>M`HR-j*A5L+Wi`D!cTCUO{wy2c$_IC#^U+ZyyPQ>H6-DK4RY%R3mF}s>?rqR9 zvE8rM91C(Mqr-uwG*i1)g)@atBUY0-b0>h9hS)Gx9=%nQSEWoT63HJ{WPD0=h*AkmGr7!MTd!J*UW|0 zlVzSI&vE+k(VfM)wsQ1b#1ZV>_`0#nGuoO@N&*{y2V{v-lYb=BJ+@bT-e>unqTbF?Y z;Mh6?T)e!RTqpDuSlXSL1@=EmNjF)!T8-~yVsz+r6jeR}_&n)%mI{tH=RIxv)|#E2 z21Yxz)3wL#%vODzi#EnUs}%Qe_fqGytBk(cuh~zi*8+IY=}%DtH@^Pc0rR|EsSS$X z6E9{Dj#cg0)@RzC-IkdNxL!7N@7iMT3y9eSW_*B;ZfD9bMP}qq{PFziUd-=PPwY3x z9g`=Mir~_qI09%Ujma4mFui#&LFqshI@(IREeGKR-dd_f7Gn=6?fM*hUsS z`2^OpfosB3J`huKLC^0q=mt5n=F>hTrB~XK!G?{wW(Y?tF0p<9CTI!05n&Gm8ZRFl zB=aep*nllL72NYXkoK^?$yqTw-*-U?B>94Cb6azEe=+O+h!$ooR5XAZvNGI8b~X$K z#&(7#3~n~|9{~gy7_S@m$EA%4(166v#@g12+l`OxUk~n&>%Yy6WF-H(0Im4QG-MS> zMC=?*NZ1+J7?{ZT5lBc#cpZ&Rxs^o4|9kt#FFrDJAkdzhk-qm` z`#|DEmszsG;a z;${51@&8K@|B>>))(o;Y;KAR z27G(0X?`}G*chBKQYsi~yWW8b?Kaaq+>68?TERTJv`OZa;R%Q{okVRqI(eVh}un=AvguQ$y)QH>QwKAHOHQvPzUL!j^ZD*?0il`jChy~|u|bs(A(Tk^LZ2OHbVah1<)S&L0czHG+V zr3&r*>O;u818vuZFjy=kLiS?W$E7JS>3BXUew}t2xBdR;qhqUMS5WrDU?WQSNdriV zCUP>#&_2*cdfiuUdauf%2BY(xq_;0tO1{YTZpe$cT066d{& z*p{hF3|Vcz*){n+^*FqtY&SGAl`vb33nl*IQ_kh5t=lw} zElj)Aey$os#|XMT9=9Pbj4e|LGR%yZu03L}lO1M1-aq3Dv8nI!#`1rK5-j*e((S1Z zH-GPrioZFO-A$iM6R+?sLKLmc~Z74_bD986xNG4-~3aA^7xr_?a%xjldW6ng64iAR>r%Gxv4FkYS`uQ`CLxMBd8; zkv`iW`0!m*F78va#k)_Np^(8?3)~Drh0nx_cGy_hp{p~&R&DRoOBi^6Ezg8A+(l;p zRQqDvNh?3ddGw;hdjQ!C`4&}Wd6&>Me8{P^y2i&SdNDbT5W$Le-e$G2kzZ{CVM|+J zITqNnlG8&sZHrFLz);F~f?wt+hWz`Y#xvpWY!=ZK>J;UfxJ6#(XKMx{q@jlu%<7VE zwaGv0(v5Zj$A++SjrxnNwU@RDyB zmGD-?IC3s~vcMCVkF}|4yUSzsY-Ye5WAL$BTVxl*&P@T?+8dM=SjNqecQ9*}j1xtTt~!$YcjqScSwUw*gO zbo1|6a3CtkCmwv9^H7M^JbJLs=4RMtY~1b4PIoRbgL;FJBW{moX|Y0^Ob{2vvKt#4 zi%UyOH)qAJo2n|RXmA?sEZR6Tf0u2jTk*e~z)me`292;rEL~T3+~d#X5b3<$-)aXB zO3Y_@X!U2G@OLI=`U?t4N=lZzK(_Xx3as$)?&ruiMr*0J?PrR>7Uo;sD#7-BST_OL zPh*zsHLGm@Ir;-Qh-tKTLe1fZ&FN8XEB+|x^>1ccZEL557Wumt;XgnNK9Dd-2TkMr z&nK550s=Khc@$-qcl5;U+{azMSZmdd5^~wb$x^sL zwIl64UI}=aBrGd_#zr=3!&KQqA7~Oa1*bg#UA+Z7pPax!0@Pb<2lYIEhWF_|^b)^q zbiUnIwN1k|si;RIQ^hJpeC)GguA@|t*4QYOm# z?@l5f9#_+tC7Rs6RN@z3L<@0q;-qQJ#4c(RY`eEA|1zf;tKVLy5Gj z-F}dK21Z~V7d?plgpdJVGq)Q7sFc$R#11=o3@P`{fVZn;?@XQdSYK=P4kNRWhNvJh zXlLh!Tay;srdhLp#?Mt8Y)Vx}DR6rm<@Bg(ZSC^jqtL$N>8Pxu{AG``D~0Z=vhD0@ zsj_-Rgouohop3*}`eg^N0L~G|z14D-Cd8T&HT=_7Ojl~~4d`e)if3%txZZ~5xFva5 zL0uc4kvh!PT-@T945NC*qN5;zGJ1&0iv+En6uC6kW1MAX6Hr{Io`KcQac)>byg_j+a!<*8AD=BsYok$O)3?12$r0Guy27INHatzw-skU<)zMh`-3F^eFLD3D?lwZO;PHIe&rD9E!l zr!{FhvZ4o3ac-Z+GBLE0!u}yqMg6-IWw&9{D1XX>fvX zC01?5kE^u_bX|FJ`aWaSL`$!6DZYrx4$qs_xZwZw5@?uEh78oZ-mR_Y+7j13yL`jX z9P9ox>?&&(&n-HAX>td{|6fgXLB#?>ACN_zb`votW|owhn;0lhBQz45VDfT z9*3AMMO%m%XTwy+2FUZ>CWy21kP*jbNG<4j98&m>ji5g!PQ;?`LSGSZ$p{wi=Xu>m z+U?4(#WRE^G1Q6}iNQ{%09pFJmO~q9#oTJiK=0Jn|Wtyebk&1CEPR@whSVQAp|!1tG<^HP2PF84;?)O)kD=+tm!73aqHnb&r_sJIc~r77EITY(bmd4S0`U1lg=7KF zq1C59S;T)G z^Z^vaQ{k>|+cDqpPspydeu^^^QUL6!Q!zfRD4ivEwe|@@P@JS;d<<)-!ASqYNb2ZZ6663rpH(Vy5oHxMS91;RclDeF&gQYm5-*9 zlcBfvzs=FJ>7Ke@oTa-Mood~81K#%dbzb#oqrbjiTt%-f`BtyQLuc27t0B~A{||g1 zAt5T6UbA`1kxnhNGvZHhex3IrM{y)S8YrM2B)i4{C)a&kw6oA&ZOZN{(`o8SL|z}q z>_gPqeM+=7L*{tw5xSc>NKSeO*gc^V%USIIcia?lK~p@uM-63&q~aoV2fL>6Od}l| zn@Ha*;)(YI8P4vZV_~SDKxfj2l*-m`dRvsyJZpSSI~IVO>ZwiJz5_+u>$_3edcdYH zkPx@h-0V2S@VVP#MizEHR+s5w1b zq#pL{rd#l=Kil@U2fs_zwlzy3i?O7tM~)WOpn(H0G7Dr-QWw>%mf($8X>;1(V#SQY zb4}lt4y$gojMRSl4bkMWD&=}{(7SRe;k95eD?~HvL(@q-%*-h<6wPxrq?t5-n|f_Hi6Ku#IG56S#o&w$c+J`$9nq`OQLJ} zS=N=~ptlAeootTK#`%EN(1Yx@~In3`ar;o&TtbM?CFeKZlokb*Igb@HA9 zdqM$h+PAfReET6Y_VX96(E*jVAu&hjb_a%hB1(& zW^F07(Ic*iE3<$^st{r;WKtcpEm>qrX%1@=G%AZGk)Z`Upk5-q94ZMf+#LBUUt!y> zK9((?YC`--&FojZSuvkNz`^wR?p!$O{-oBIWRP-vs}#Fjch4QEf9}Izp%iW1P^hK z#VUiykU?S;1~k&K$)zuXra>ka8hb$|l)FM#APFuIKl`hoyH3dNHwTc=h_pE&=)HPG zbPYo*ZgM4$--pK6xe$pbO-tagl}1!}x&RgRP#+EL0F1zB>MI^tEJ|T-mfIG*-9dsU zkdDEtny|-v3Y{8pxCuyL5*z$G-^Bh4>Sd{o@M!p^N`=U5CD5@M<;*F%wnPNBq)~DE zj|5y3I{ufP%|)F2r)zlD8(5p9;JzMrP1)=+&RrOQ>Nvg6((7e`gs$@`imTvep#DQ6 zw(ONgvceb349KX*&J1OTZar)y$>BrnYkOkHi4I(_6|QuW3D;nE2s^y11@?gm%I^%8s!)wNdB{b%O;`_I&FRMK!= zSuNtj{m(r3;F<+}P$@y}2(%o{(di;Yq-hf<7TsFBYdUb|xg-+#e$AxQaLR=;m%*}J zsKZLe%#ZNY?9?Hxa51dLT#k7D1y}LkrY`dMq?Tf~HTu+Xy+NcQZe{lgVp{C}QR!3} zjk3}C$3tjbQw5OzQKF+IeF#4e%?oc2a42XI^th*bvJEG)gUI-d!@%-T_KWHcNv4>= z4A$^)=t}#izAb%1(ZV`BFeY%ZghMrt%&Sy#Sj6CLi6_)c|YqrrG zb9OM(Z5LPD7_2;=H;dj+*X|(0x2a|M=P?f8;XY&D(jyvP;<5)VKObHk|wER8<)SK)Rgp0oY451!bTf zxl}3Ysj{5-utdf%hgMY;J*!IB?0y?3iuY{w7u|jY_UKS<(Q>VZqGARL%}k-3pB2P^ z&R2|l3zQXiBb&pCm8DPShh)Lh9QuiJg)HU=Q@EqDhd$rs>)Vld_nnI_c~XvPqt#aH{QT?}P2MI%=@$!nyJnk;g5kRke|QW^9a^8jl^Dg-dy0B*rv}>6 zuMV&$uKKJFYiq&NE#~1UycdG%y1E(Z$pr*k(cDMWoEB4G?vKiGs^gx98UC*#R3rLr56g2~U3CA>o1d?e1O2&p=45;R zkz{q0P<1-A;MTbJihOnu7SBU(^i|GeuG*ltyiRlH@d%o9ImRVpCw?BZ<5Az23YyU4Vu)?pxwpcAXz{`SDEuKqIP`sp@+3a6FWK zc)U8~{e)75kB7Iwu=LI23X*@JsaVda6$dr)m-+9jQ|8nkvfKE0M`2b2-NScFK#zM=p>1ZAvjZRa|liM!F8ERkN^8{%E z;=#ine~IL|Hf}Q(4#IC-QDtRSh<5_EcAUVO4VU}Dzld0RpE1JO@;){Le-Gy zNqp&}J=+p)7ykml`P1j}kGuV_j${y$f9LyjsmE78@9<#~M*CnH&kcIux4VibT~5H^ zfKtb zfYkdMS5-%D+#+Pbd(n3+I_*|KW-DgzQh_7ZGvI{xr_wU_lT7RkkXdyAHJiD# zaGuZ`WW8f_+3~mNPP!Y{g=TZA@xF|>-NtNm4ngSMd5c8v3PO|jF&urGEt2rRu~8~H z*rs8y;8}tLcF!yto63dWE;suH5&!N%3}OEalxDkHO8ANJ*pV|Dr!Zn#qtGk z8{)?>k+G0rQhrO)xYWuyLE+c164>&EDdrzhu#P@|nK{_Zm*$t>2n;frH%JT+kKd?1 zzP~~2t8ppC18-PaRT9_m0iKsht^ZRmGTU`=gOWPnK*t?F3uH0WiK82XavRjsJ} z@d#Y}Qz+D4N$^;=(~$9BO7NR0#DskiJT@!LV=EmbZWvM@J|Yy%@ns+Bc}z(<#+b40c1Nj{`-L_sB!+=J(NG$!LR;1is)v|&l+ZMGZp=Lt2t3OoUcx>hxEd|r0 zVn-P|(`C|RFMLYG)@fI>kwOp0KU}5{k>Kb6-@J_%XG=i2GFNaq zCcgF?e5__^HwgpDfhU+3_b9P+C&n7unrBqCe3q zeV`+0#*V&%7SWKO*}UTm;S}mhPKIZbR{ILuxK#8~K@Dh-i$8Nq}T)*AZEa zEp}FS8>)ZWb|VOtU>`)}?cz$J!;4z03YiaU7*B)WLQE-|N;Cz@Y>12esPYzvbtTS~ z^}Mpr)}o#nBN0F&eZ%ebA*N}^%2b9a3tf;U9N@EvUK|7TC;CsNQZ6Vxz}}1;3#DkJ z!l5ClkOrNZWb?cOwot4nwn_hnfhcDKfMtsZ@+CsZ1uyU$f7aOkx{7-RBA$yyQ=l86 zcR#4#I&!RNzq;{XI1>X871ilDLodgslT&MY?U#CvS2=P0pqzk0O+F!75FaV!*z*`l zPLIcMB~%NSF47m%QCdPq{O)er;wF(z0h8Nj3P!o6I)el;i({n`yIgYmOR=*Ou*-vG|`N@!) zC4MHwjtxmDVoAIK$+GFM$R~Eu?V(~YeWnH3`Q)4Jg}*$0CX;RLAuP;7;gw z0s@=Kdk?>hXhPw9!(+LcNNJ@+!a~WD*e>`;3ak`4NuoM+9ajc!n{U~*opJzz=Yo2z zXG*kCEO3lBpT1%=W=7*N$+zSAV?Zt5I9JzueelVDBwITSzp zdwdhzW=2CHhy=9{Ifmz@-g}q4{MBI14jVd4Rc*BG1LV-UBrn@VNA>sT2VO_)?!1?k z{$~G$KD!ETcK>13Nf^<;H?W)&3$wl3Fy}dK24Rn_8W|rZeBGBhm}qnVL;Oah;}X^a z9^TW9&MAn@1FO;>{F7kjtW#w@LOdyVBHn!trcv1FMxNhHZ35URmA0JCdn{^I`9WOP z!~2b)RdT56hk1O45O4KRaWy+LAk~{~&>rrcJ0{ihk&xdjt%>^&C})9Eg2$Go{ixTy zw3)Ow$(=mrz-p0iLIsH`s)>uDF->8{Mu7%RtCgu{ZP0i;e!A@%*=eQy-M~+K3Vv`Gb?e4RDjkd)4>NmwbiYHOdh(yeTBjWZykXaOY=Utw;iK zgcyBwx88C;nGY7Ei*xhwBwxSZk({g7qv?E8KI!qOpW7x!v8%&7uF~RTr!c9Wp_1VS zEvNb$%Q12_!oOvMm>@=1pNzBYZI;npeNzEPd-P}LbLyCnR8N-uFzU4(40-Z{JvY_A zm9VDk;4=G<6;bRVu~sEIGTM5X98($S2I|Tb2<_K=-(S}{VWFrjgE4Eyc)d5>QJ&{XGgvD4c_PT;m6WXY7>5NCT{N7;niCSy8X>P4h&J2?-PQg> z=MQrag!vZ!}LBF#EGK%JPp=uiqa6wW~aZo=Py73wZRmq9QjXM5w*Gw}k5Y(g@h zJj&DZCc$&z4vweMG#g$24M$GQs2^RMEYO}XKZgzm@)By+-ogVWtr4C_&oWYdS#)_; zv53VDpaAnOSlt7zdb=8ZdRVxwwAWSqP&=d+^R@r5WbT*>zmm8Bt1@d6<39F1L^=y(8v~;J4c#8(GIlB#|W2CK5K# zHwYGa6G}(S$M0~%N>`+)@H-+trS0P4KUWuqrDp6&0s_rsr z59soESEBTyO4C6m?j{{SqVYb%ph#}&=)!rOS^=(uCud$!_2Y?>~9BDf7!nJgDr{l*3~(k$1C1ESPLiZ`pEr>6fT^m{|tg02OSMmN6M@J)L<=UY8{1yfe64XlR!hUG6}LGS-r8t$#xMX+EA)jICX{ z6I)xBo`Hz?_B6K&@ByKytb=MFT~E^V_0UJqJJ6Hvz=`7PQ#=y6k1EX ziqAX1_5u|qMIcNFmoPiPA=ZA6{N*?*gIbHW7~~=u=`WHR<3KYQD$z*F8e2hgPc6-^ zakPMki7@W>0WxVz@@pz+L#+kgBeeaMh zpHCYoo1V}D|NHz3LA7gVsq|1tQ*djG9nSO@6qqr-ykVquy59iQ2=S#UbYkdzr0Q>e zA<`!gX%uc$BSo(u467yjfhwz4$nGq3748{3S7MR z-?zlN+p5pE8?b}G%Vd)MmW*)Sral=Q?d16sN;Sx8 zsaHl75h(9I-N^llym()UeBVhw7Vv4NS49?)GIHQ7yE%b&>b=b1Qa`?J3r*InI!DS( z`kPwhjt0ZK&#NMM{3UZNE1g7X>-~~CV=THaSL(y*Be{VZU`^syW;*g9#1|f0f9auABw4 zB`KeRR~+(H+y>*SvCO!GD=tfM9A-0DXc#fhWfvRb3 zkXn*Bgi=10>mL;%t0oa6-ncIognCBy(Yg^bmdh3keC|0RxIlIXQv*nym8G4zGdiZW;lj>SrboSNiL%LIC6)wKG3 zbX(i7o5EIegb+)WlvZuRsF;*G{g+yU*qV)S*t3+YFwke0#;hYY3ZD>oKB{Q^PDo?y zkEhQURhsx0zvw)%5!>NUiT3WoV~^10?@Fz{GqgP-}hl4a+7+8*HQU@y9cwLX2 zfJ?@Gcc(o54Oa7}>+3R>!`dzU2iXBDCyR9%^<{}FvUc8=5dh#zPY&N>?_=u$Z*j#f z&58fall*JCb(MF^jCW(ngjEZPc3|~D*|$#C1LCTs*yi|-F8FwKRb?swmu1q7V`tSL zj4DN{53qT%X-k0*!H4TtX@3m4cB1cPdR-&|^3Z&5-JLB8%<#?k`%d?8E7S3ZsP2NZ8l|T{3G%~ZpG)*!trZ7`DwRU z7ewW)s+cv^1^qxP$zG$FL(VS?AY{hbo<@5M+3#|<((PKPTb5&FW#|$&9G7Id0YmJmhq&X;hjAjZ%+ED z_I|qQG8>*TkeAw~o>0?Z(oSH1z`aw_zxgOZ33UBBIXZjRUGnKV0*-6rr6I4@#;==k zw`IF4$-DT!G54#)(soUD?+BsSRPpb%rX3x+)EyjN(yM$%jp_7(4sMr;`vt_7JhRvX znQhG&PMWXoMU_@cg#372m#D`^bZZ1FWkY3Eufyzp$EO5o{}=g z+;M+g#ea&OxkJHhy+ynElAL;+@3tJ(Rk}3b)&0sUo(Gx7VWgVf(xp3}O78J`+^w`2 z&a@Bo;BXF)^j;T_rez44MtxOd;d=T7_ziCKc#MjMrE}!VEotZ5^Nnjt%-gYKx4D;p zm(QEw8_=$!9caSkKPe{cVn^?b_CjyQMXMX(Tq9;qH~&I3-3xassMA|-YkoKU zP=F2ti4Uh_jtC(E;5tg$i3<`9UaVSax3p|brUTXfgxZvnGijXTqh%}{pKLMGkbCsSPeA^?NO3ksS z2&PNN%Y{0h4DqC+dc(irl>mD8(8~_3I6o~+bsiGF?=Jb??kc=pjIJSzlto8We!n{5A?3`1zLRuy)a*to@O`83m3qUc8| z#*ZlaN9%3ussN@WljDvS(y1@a=9ZCa;pa$u3Z7m$CG=3bLyz4=b%Lbb+rQZn*R_vA z9qH>5)XAyaz0tH))^XnHsZ+|!^{2U}m5Qddr7vR)eMT?mlp_duE4cpslouDv*-qcv z_tteZNoU6jZHWWj9)oH2i=EjS_53%VVCvCSC6TrFIQJZ6a_#ElQC^?4OfbJQmLJH0JjbxWbT;=75# zKN@x9y=tgs(Pz#yP}&soD%Sq1+`NuceXHs^ zqbSkvi$l{d-CT3V>EbtRh#l9^rUdUT5)M=MdQl}bB3APUwFHoF^(s@Zy0ek*n9uiz z1L)`IeOD73nH^6wMKPWpw2pJ7?0l1^-+ znV-!K+W6b=4pl^Z-6YZ;&~@o^2v%KRhL$4^YZ~v)lqh%fY}F1kTu0}#pge-S6N^A1 z5E4T|l#K~!wm+^bpmPnR-JA^ZIwnx(LFLxZ7FHpe4!+=s@V8+D|5*tC%`$WZ)^jNZ%aseA;FR)PfSZa zYbohfY9+8+s5Rk&iAf=%bS`2nXWOp*QrvX_*X+U1>HYQo`34C5MsFNiPn7|Ts|sd$ z|9C&*(P`^|H)^KlgY0SJIcx4+4|rvTMY*Q5_xgA(<%R3eSt_19qsk=i{5tEsotR{k z5iyHd{;m4E3f7c5l-RA)Zp3+LABTmV=xo*d(4A4Wo(R@-8wpkx>21USJ>@jgYbJfx znH*cBdgEl%6|!HYNOnr%%G!6;kw@&N!d=uDOuUcbOig1 zyE3o&Wruq>b^}Zi$z8Jb^LL!b4<$a6MAf2E6%Za$5^1fEDY4i3o(glSGn7B=tiWWR zU>%zjb++EsMa-M;=VxWcs)5^%1cqE6;L+d}IbLKG=Y}~qjyARXj)5Vrf*qMe7(H+D ztof1O=x_T%6e04$dnu*yf!)L#yWHwtt<^d|!csPg|A(rt;EFP8+m#eVq`O5*x}`fL z1e9hNy1To(K{|)-?(XhxP&$T&q2rA2`+e)2^8=o>c0K!!D|Yr6QnF^MOU>+{s*^|W zfP<)MtOfiq&eAZWA=yw;@7Zi{5nEi)Fkp9At?O~YxHjWR)C$fXhpngQSL4Yjtvb-<}SHXIZqN(-0*>0DJGoNj=YlCOM1X8U@Tos+?G+Q*?s0^B4{O znr8RS7_z!5+VrmXef>3`vqg5KX_1#i1flGw*Bi4~n(S3)XikzSY%%5A4R<1DTR6hI zlg%{l5X9@&A_*3b#`yLa9{0y)fAOGj^vcqrF}($XydHj5xiwoEWLUC~B#(U+Q^L31 zccm}~wsSFyOJ)pGeju)VFM&wNXn3TeroER)G;EYWj$T(CX{7qKT-dCnvod^&Paf}= z^Sh5bL3^T(y8WxE#kg|_v!W^F(u@TKaGWg7&D4wmjO9I_qbetIy=QaW_oM_7X)k3~ zb@vGI6E^6C+hwLSs{x%%-h&Qd`^c1~YzyBm{Vj!P`eiwQIG5^{NyV=($|n35)&c+b zoSjg{ni~Pl$D_1Bb-2o*JI6zqV>IerRA6;5v|6^d2|ytjbj%$67Txs6yDhop=38xj zL3LYw>z4dAWm{ZwTm0TQuE^+gD2BRP;oR@9J}Q;xKZuH)Tozcb^6B|G-#5SW>Ov|gzlD3h9l&TV+Ao=h&a#V8clj4mWIw)I;KOtGKG zM?~ec-8m77HF7=E4qCXyNdY8cxK_TP(h!=kV2c@hPV5wNAj+t=)mGRF7dBE0riTDd zNBGl(%C^ei?Fb{@ZGXTr_~^%r>6AW_IIdGUSQ4|1KuD`>hsRV*+hOCRI-8 zb5Uwscx_>sZf_v+(kB9*VN?Q6X+xu@-rI=%n5lbP)Kcms*-9bkFbkItsMq(Ne)1>w76IPw}E zpwGAOB9TCvwpE+9l{trFe))4;;G*V|Ki;^n!QR#CewcqRhJY|o^yofE^<16cls$Mt+wbgA6&5s_$r_> zw>&AbT9=T`2@u1}IEnp54#{X6Upu)VIz?j5a9fqvsm0l!x0gTh8Zknzu2o^8gA_DA zH+f`kE0OEJ2qGi*h$Y}O%N)(<+M1h}$IQ+s(Neh#H|mn&zm9Fa8#eNu_sdX&EoRH~ z=(j`Ti5f?pVxl7Z0!LG(TJ>@Jg-G8EF`>RqXi-g-=V3s9_Cgn`J?dFD7_4uLbt>aR zLQRFL!nHt(DUad>#(GD9<>#Q`WYF=~Tsj(XxEsWq-y?H!Oo^WLkfsn375B`Hhyye~`Y7nvo4Tr*py z6$Ff*U@)x%{K3B=!yG{vRbL39puG4ezY#Sw=Dtl*=Q~s4z_B(6#x)DTgq_0yj0L~6 zSEmKC)HgD6A%!w$Gl!;Sqyv1*{nRJ7=U6T=JB|&?Q>Ekica+!)Tp4vnM*M?ZM;5OK zJmqQr%js+-hAAI^50QxYg{;=-LLL!!@RI_df8)5c%4%Z-(!H+M?3~U#rp-@~plizO zpSEYl4Lec3L=#y&Y3U+DGTbf8Z`nb*JutQzs`kFSo*`Hm5xu)21_=~FHz&S{PW3;%-WwTkO(buU_L zw#yseR6mq~@0U|kR8y0}3LF#X&hAa-)SeygwrB}_R))XYgRZXHBKRMOWJmNx^sjv# zkZgn1fDtT+B-d%bJGG1BWOW#3++}}VYL){o&)~Yw3r%!WV__siQu7ka99b@p48O%| zbuf`v9H#N05iOEl@}=!;tU!bp4-?&KG^ zO%wYJPfa~eG)fHEotFJrrjOy4n*-6bj}A&%jl@75IgN1_L$jMC{&Z6$;!8-^%#BI zOm6URBirBBUW5y1553S(U}1b%Z-(?l1Czvl+j1`M zxG1_93@vB`&xKE+Lyr_2d_K+`D}1{u{X%GInN9|~7LdClje2Yg3O&6~a~-RCd;BZzN$VM`7BNhX#W``)CnGq(II;*?t|Lp$<*ZP6 z$-INqq#dC3uhF@Pq1Yt&yEHQ4nHgI7C>*Vz;EsJgFq@Z^zE{fVHYPv`7B>6`W2RPC z2h+kLZ{xH9s@&qXQ@HRXl^+Nd8h|nE!2jt&kPE=dG&`pnBLQOuEZTZ26#Q*dwLmu{ zMm5^u!iL|MiprK+-dp>8WBk_dAQZoKG?ZoW(^%H2zDZk)+va-ea;t5OeP!KRM|GhO z%lM+86zyxj#n;zady)2W_l{g^DY0xTBweFUa@=IP0c~&W8aAP~LC&!?RneiJ4|gIC zO@ccUG5Tv4;*$mO^22@HK(8XJpn6suh+<{%;<4!wsnv&M3?_Q*_RW}C*42D)W5~t^ z_qcWN5*#Mz`>cf2ru{^w{HSHgCxzDhS4Rr%EEB`niPV>TkLS*!S)-a}RrJ3DVU(KR zf2W-FiCBFK!<%%m>y^dApl(L({cb}q->4NV90RQ}pyvfN0-bp8qtX6i5fZtg)Bkz_ z?1+6zg@BS@bVBUOiDR{FjAI>@1pnXRiD(S(dIZv}d+c~kWQl>pXIX3WQDPr&&v!;- z3JF}A;qX7cz3lL9RCj~~=WWEF3+{drG6%#rM+5k;@A>bd&a?KiQm+BPkD<~023*&F zLvgi$KZlsMshBm-7b(+mWLK82L|r+kfM=}ChP8ku92=xvxPQTHm7mWfP}cIX#901# zqu=B6T5#fZj>78N;G(h3s+Owk(fN0=P;a|GT`e}A=jBPY^*pb8Cb-Rg;;LwC9-$r& zRVZs2Rb`lxX^y9SjpLc#ncvxI3DjH#D5Tq{*` zo~GwrCT^AEWe4$Jvl3a3=4us9j8a!VU%KKazxAB*IXkikZzi!ZL^+s?t5i#)GZ(Vh zn~E=BG24x%pPCD; zl5FM;=9PijHMAH-Ej)`2!^?2gVCRwPd_!l%y_1gD{FINx^9|BIm&OsRQ7$KkEa?6A z>nw#?&YnhIpvR6Bf^Ig8;QA4Xm2!Ifkx4npLbb|Cr~?vm)>}3e|04rjbUi#)ziDvA z_o7ww_+(i?(Sdkovr#`GFVJEAN$#9i?J4Matx6236+9e_hv)QOV_dkF;pmlBw+cm#402XO2B5t zRH@mDca|}9au*pGmE+l)Y4&h#qa4|zN`{4_N{ebD^@;!%t$qv%xG^)N^28t9@$*Tl zRV9EWxj{_4PxCQJC|TV$wZkj(oH|=KO5e^C`oI8zcNS#{VSgSEqejeCu$(4m-hM}- zfVzF3WTZ^9e|<{lm@MN>HF(X4t!W^uy6&>lYHBl*RlE0#=Upg%=#$#d`_*Um-iMK3 zUW~8u#%-}=0VR`KoRQ(KR??3+?PlrJCz764)MHoUZ+eLLZtQGC+gQLc9e8^cGwdeod*z? z0m_KJB1`Q3M9cYz;bz-jTD08hp`pKX#Ii}!wr=KDx|oiAx@$N zULx8qg)YG}`_!WkA#eAaK5kZOtwv&7j@nM74@VLRlBurCH?R?Na1Xo4%!2{Q3QxU8 zf<%^@4RYe$u>|l>qa0r{NnhiV9**VEnU1rW>K#5Rzpx@LQxP~piu6e#dEB|jfS+vx z5j@F@V4@5@N@=FEm_#V?r#J@RLPrX{n-b1I3mMO#Q_vJ2#4Z%B*Gu(w4!t~PBdo^q z<|4^P%3}~Ybo6*eYe|irzSWX4w6l{HAS^Ky>2c9A7|;>%q$BrAteMWS(#Xq=swLLZ z^7fuC9E6Ut+DPO1!h98%gcCo>B?FyXIaYhX;!viQfi`c&K=4jSA?FNte0UJS@^5RJ z)Y3SCv7E*wFo`9TE=8Ml;9E-aw2C7-N#!6{M)eF7%F?RMdh;KpkVl}zOL8jY@%Aon zFO(WK(ukie5LxYP{gJ`4bPLm9%NZ-Dx@9rnmf$&n=_@7Rm9Lh~^tIh$$E)jS7%N z5BDh(NNS4m^2oR^si{aLzsvN-WRamQd+EI>Tm4ba1rGa%5`J>TF+C z*89H%ZwY64yzIhH@ZF!8a1Ix{<&y5{veoGyl2R%ytIHTNHyS+=%7MkZYqQxi4a)k%*#pv^}i zZTE?yA!VM4+{YwQ*}b5#zwHInnp#?;@n!ezX~1y=+LPw);q=v|QHe}dDPweK*0<17 zn?a;xwaqmQ%^3?#DiQ#n|DwJP_BB@9A1)TPkV!zZCp}dr(4XT`CRo$9l<&Qg#;$o9 z&K6NWjwD-uKKi$q;yyafd#lOVIj0)H6Gjz>PxWI{ma5lG+6$xjLflh>-Iz2IHL4Uu z^=M|Ky0MrzLqr{n7!Kwu&|X!rde$E~U}rWyjo*?Rn7lw1>t$_Q*RBf%W8x~Ij<&q# z7_m-(G1fGEYM^?J@rGI>*{5yJxBbx%B___bOc?tAg|hzfhB3r-uM#PJ3XK&B)49`Y zG9YvVb$H3#&<@CWj6QrwC?_2pl6bUZj=LNu1mt%Rsf@Al@{s$kQAhYZY>BDjmzri( zGEV(m2h};PuYnZ{{7-c0$cg2KoI_}3z~itruiU#=G5%)#{994$grg6MJRr7VgOS!p zm%>|FY*!kO59?P{i4#13hA!ATB6@d9m2@%EX#1gdq4P|cslV*lCH`wQuwrV#w8Og) zXmTA2dF+PbSLI^mOO)#@9I26YSYp``7^eG+LkLTpt?i@cW6#k$%_xkE$y6}=Qmkbu z7F)yF)r?G0Hd7c6;rtOYzNRnNBX7svUf{knq0VF$3LFW20-o8#l20GC(x#MCGwDJm zLy+|2Hbt#5E+m!H(W}-8l)Ux|7uYk@&wdEjpff`YAt+AOiVic})m-g9K9VBG)%T=S z-p=KgSrBhb4TQaG#;9cQ%Pi2Zk*un`uT_?43-8#YacOa27MLS4GU~u*;|>oVrnF!a zo$>yA8`2>*(KVS$Gw#`Phf;v}69&?=Ms|7GXZS?R_i5#8DemzC5}jSOedVS34^95U zI!2sp^!}ZCEc(WE6Df)1L&Cd;>)yL!kaNfL5`sQ3cic-$WjwS1@Hh zbVBj&@;6>biX&2cl5F9VEv54Q@rTLbMn+~QBJBQc_WVsh{4_aqW(T5#4$`LIT4Ll! zizZ9GP8uA4Y(;*QkAoWi;ywsvRGx}qS*h;hM6Hv>B@YijY^%Q42=;70Jl5_+xr7zt zhXLOV>+F^=#Zw4L{){Wgm-rDfXa9pxj%AA;qc*sm|E|r1dO|d(;O9d`qQ`Ds8qobA z72zy(=-`1(f!9kWqBEk4A`r!fov@fvCSP$4$4ws3+KZenM4ne&dII@usp*C3d+F=1 z@@X;8Nt`>_CsK}8t^A^$g-%?%<*V$ui=n_hz^r~ZYFR7%?63El#Rh?{N<%(x_mjKx zU+xsu*pTiwUanV09;=erfIbi_oqcGUf6qq8tgXxa#TrAij`24WXu#+bOk);z4Uo(M z=SO4lL9e?&FT;Yn*ZKBq#Du%o{^OF2Inh6f$1aH24_f>dsQf@$TG5BHJ=l8}8Y@S? zf5rabYN@0VUf^O#?|0N!M3xRVBEC9jZK3|e6TIiGvNMO+C5if_T-3#PwI zcqc1KB=HWwpshWY(wNJ)F%@)u6=M`=R;$LUy1t~| z6-6c4>YXhUw4BZmd6CX;OJu^tO|Azvj?hGJgMzbxz+i{G<$Afs5h5i4iynKoMV_D5 zc^E1R?bEJ|Q-<0lM$ohbiu!pbLmq3JBZTPfc$$FBsKo zu6~|?R;}A6Kf)peU7{VEgVla%?!2vDrKP0}nM|aqB&HHN>wNgqMULwu_cJMO6{|8k z=kuECehErfv1tkq4ZO(76|`qQE)8({(-q|w52q5(Y)AKKnf#2lSLWgrXRGA zocf_hG^<2zj(~DFAxQ+dTRduBc^Qx2`PNMmgMMnnY7fwUFS0#9#I{=X<^V>EuT8y? zqYNISU?NUQ74@DwqYZ8+*Y+x?<203WnD{GN2l@lyAK`g1dc2O2TI?=a|c6c_Iuqs zzM(Ur5q>xbtXPUbxM1IZQ`=jQ=2y_V_Iz6VBd87Et^6QA#~&c|vHVnLwWxZ^7c&Zz z$C5%8=|rcl&iSphL2JFSlmxWaQcae2GLU@vZDD~NMu1oHI{SfRB{fejHnF2H1&~cEh$u zVml``LKhklMdrqKT$4=Ki7vYd`_%0cq&8H{g`qnA6gGMbbMayj^V`82-EZq%UxCNP zC_&3}-Qm!m+_vgIaRHUZl=m80KPVO3y&RmXy%!|!E<-HPw4t7K?18=$=%~Bp{{H^p zf2hM=W+jEPFJ@)67ATlJCCLg^jj%}&xp$$je4M*eM@-;1S&?atdctHmrbQ=o=~h2= z^>1~172;`}2g!*$*UA;;!Tcx9R~E#LC@%<*cyA3AV@Ej$e&#vnHw)~S~p7L{Jo)UcjQ`fF6Q zj5;Tr+Pp0`19Q2pX~bYwEtf5WKGDZ%%%a{^0VAJ=$sGkA%{$QOZAt+GYPaGi4qS{3 zcz<$}v!g{hqcrR{PUKDkS^whco`w7UL% z1*WX4^w2ogU6b_+C;R*?RvwALhxmbKT6T35N#g#fhUNZ{z4M^jIyUW#B$)gPvamrE z!EVHNS5j0+Q&*n!)W;|G8ap*9Rey8x5RcxBlN+#5aV;u!8{zBa90S?3j23wzQYJYY zxdAh-X8cEo{K}CD1xL%D#uC2V(ZzdiJr-lB(B1VKi4;$lvi{}Bs_%~n**6!R?gCq5 zA3cv|cX`hmgu1YlnO<%-+Rj>^VgXAe1&{rK{R}gRUxb8r%RGb2-&T#*IU=I0MB9sL zZ0r7`>$+9tv0AO41$KmkVy*6na(FOAHuv7TypQ!*8{3dEkmZ@1-y;Q#-r5f>%9_?fUvP>=ar*Q^%{P)8?_;_J&L)8HJM3)ja z86&zK>AjL@y4_>0xRvqGN7!HP5>k|KHETB(M0i69Yxx^K9jiU0yDO~aNLh(}C7XWI zb^a| z<^j+KMPvH2soN<}craLVrtXCywJ5V6rI$)){u=6;xkC-|7U%y!rZi$w6Yor^_)D9p z{bFtDnA>Jqm4pL6dF1V&yb;&GO2MrqR)DoP7}=Za zf9|zc8}46e94F0bdiK&*)LA08 za6vJ4R3XY$w&`{EVkp_b?4goW!J8ZpW2{R5S|#5A^tr*I#4}JcbHNWnUP^GF#@|{c z(RH&0(GBfP^3)0ohCYp2_RASltvqy#+7b;0L)fQT{YIXr5B|RcqH9f zar^x6Xy-ucuKKI7ewB~nH|DGUa7)8QKKpJlGfz;xzIJmYI()L6=*aqBm#;VsL&Xwh zZ#vXG#Wk$jsvh`<_YxCzNe-&(W76tc@REd5FbR+r_ea!ITt=vp6B=$EOT4i!Us9o6 zgQ!hXQ=L#-m4?O5Ec+=1v@wsxE*ptlV=4Sg3Fg|wvmlQY~7f`)V!uyfbeR$XOi0kjc<;oWB%YHOd+Rj zx)A&=nfHp^p<+7=Z8mmcCxK61twSP2;i}4r$Mw5jcHkW^A8N{4hu?!S+m@-nnWq{( zDo*(2ab;20-}a#Xjoc9p>N6N(*>P$Us{aO6ujD)e(CTn9*@D)>E54!XMMh;jHqWOW zi1h#{QKV|$xGdU}iCd)o!`EE`XN)RncUymqp7CL1x2`r*Xu(P`5AsOuublL4!Q(GQP)Lm&>oS6{9=xcY+92{yIlk)Zg(KLn}U)vuE>HCm{E$XdYi#P3u<2n53JaYuK?$cLl7u!wr* z^TtKbj%HmTj_5~4#$fxL!euN~%5h@CJCP#Oyt_|bpU-ohx7=S5gHgGGN;spOHRO?e zcYZdz`tmIKjuZj(yU0}k5l)Id7rbhE6JYMVl_3JGjQG z*IG)g8Lh8PZG#@$D$wln4ZZ3*(mSV`2DrkV8$L*HDW2Fm;IgSd4x{_5+?hc?NYbVw z;#JOd+vSsax~X;9sP#G$ve7{AzV2|k+_Leqw?MOgu5({O1I(RqWSdZ@>3z~HO!xSw zAZr!!^|Q?(nFyMhGxo;r&;o_cxdYxeT>H8Gx!T-&u^5eV_D_}?*;2Tmy-&DT%fzsD zuRB6=9_~lko{AxCGtptEzz8n&$heLXJomxloGRNpuqxR#SaV5X4-uMH*KYa-fI5lT^rPtS6h6mWc^=`Cq+Ow> zgsL~(%vsd}AMce1B-v*rfE2*FU9j1{;7;&+$@ZVq<2$nJitRVczgMBA#O+NE2a|Lw zj+N;{EDfuU3hf`jCZU5zp7OM?HmwZAuLVF8Fw*6*_ByDl&~PLEmM2H=bW-IK2jo4U zzk2K4MDMX1TGXb}$k97FUM~q2t*6ScBb=A_58fj&8NyYG|=F7|2I> z3sU4NZz!F%-*~);s%(|?Y~(}?RU6oPo4!a^dqcMfU3$24nJgby&<3Q5{%Zlr4SG-6 zgY&#*QVn`T?W){f5ECQ$_9L&pG3D_7%G!(i1iMMS#AlK6y%p*bTRxxEusox;?R1Fz z{u{1+p>ZSlSwxr<0D+)_`VB63oM0}XR zwr}39+-CBr4mNph1;)!Fe#BS&-L6NYAtekP>;b(#&tJ(yKoBy!{=XEAD)@``L37g1 zK6GS*vrj!>IU$pc(dYRABT*=+Fpr4Gy*=^47UZ~_p;4gDe=9B`;>kSc>IC0ox~C^| zS#cm}ORq%%sBa!%URwfsSdGLIwHSD%2mLj#srxv#DWeaQ3k(!@afn-i*T(DM6Wt2C`w@3kKUgQpeT)!=t2YrQP-3w1KMugS{V1L7R~rhqv=|TO zT(@lREb*}YenQcQB_b$g#wvNj46kU;)~rrbyH7-N|4Wng`sHN%AEr_to7by;nxy?k zgM18KUb|N;8~Cc1y$y9Qt3Eicf|QlB-~Y6FlFG7E!0K;ni{R8W+7dEy%dbJUIS)t@ z6BYoJgvWVKu(?4=vXQtvpcMR+_`npd8NHA^3W;Af~2B`FDjmHdpysv zRXr~~?Jre5*uI#XO%mu+8mCokjd~6RMixKzzTC(rRV=A}0(e4bsAOFPJ`yqo*1~g8 zR4VPLG&tq`xoo7@+b%EeOeW%WG)<1L6nfr5JDV0mb9#BYbIFs8vWI$piq%409^Fg- zvA*J$tOQC*OYIZVnRDtLL(8hn9(g6kAmOo<^M5%3m?iyXt+o+bi#9zfp=lN9}PYdTc#_%V~y?d0v`GoWqT zIkRBS*-E{uL_tqa@3K<4Md%4q<#X!&dJSq5dcBOX9!p|8o8bQAsK9?27z38Gpgp)< zvpJW;;F-`m48J{`D?9&dTaXgE+~AtEWFhS}a`>Uc&f{! zt9k=NN0%LwP%x@xnPCHTD zt;{|TV9Tnw8AEzHHUa^; zUGF1+Kd3hA<-LFE?Cw5&d)i=%BI_v2k8slda>XjotF_&KI|tQc|Ckbgnrnu*0XP72 zk+w##8;yxQnEtuBxh0>ceaO8$@LL{H&wf#M<%)=PB*r%47?$uxbvMedZ8T0SoYjq% z_CK-hf3*WfO&v#DN`r4?m(IJ<;i9e#_pT(D6*iHEoF3^ae7Pvd^IgiuDVTrv7jq=z z&zNIbYRG>9w-_d?y%0YPUES96U)uK&sGupNrH6&b{9|VQUiIcaV_0=pyuJ$brii1u z_c@X5iA?nyn`~W8ypi!lm+*6BEeH)RE6C1|crxwJazCa6B{;ysf7rg+j$n2d9eA+u zz9#aiJW4eW3>=A=8SyuwA&baL5m_za~L9qtPQE=r{eQogwZI8WDcrbcN*iDDu78jCLtOZ@N-oV$P1 zZa$!rbwSAR!(iFjTB{IU3$CQPA>FEFY584XCxTe^5GDDl@1AJ;SO45VjDzi=K8sQ!J2bO4aZUG$P!8Xcuein`4cgi(O0hX| z2n$IaFSl!*!xy|P9EPUV>L`#!Et?j)Uxls}1o;scJ7jOoV;q1^7&@P6`_s<=tP^<4Uo=JUF=5PRmA8~Ba2pMAC?fW1Z967<+j_lhc33|YxU?*qHrC@psn0`~G1}ms3x;}0o6Ztf_C*|}ugkUg$_YH|#%HMm-S!f_MZC@3VJ3y(xD2!`wamr5(Qr4rlr^fP zCp5H0K#_X?zpbSq6BScuwslXz!X6lh^@U{}IGXNa*)-(S&94QYEyX!S+HteU3#plg zzaZ|tm$QEse6Va-GG)|$P?dg4ET%JGWh%U_?0hsAqAFI;Zt(xofUBP8biWni(TfWN zJ1wZFxiKzY4xQI#3%5f3t$M0Z^W^GvcVqOW7wm)9T>lD&G~3TuMv-`#e&eM)*lho< z^ddJ?Ain@B(d6uhUa9e4z05H2Kb}`eL82iNhuAwSKXm39^)G+P7!c*FE*XA-;a{#_@vES82l=ncDJQ9Lau5=ss*t?Kn_ zP(P7=o^-+N{G#y%Emic_py=a7I``9VMtrhsD6Uc6U_@qQMtq3GeffF#zX3zOo}H$M zW_S)?R@UppPec(|ctfdCWCM{f<_H9^R>IxVYDB`dUxI~A(4p>0ClU@bj!Hi$FTXl9 zAmAAqNa3UGt2{xy5zt(l(2wzoK3B2(ZFg^Zpk?hg=CR)gjiMDu7i zKLRB=ee4>6tOH%F%xS)Pr@fJF&57n@XkkaHro5&yPzxkAerQHX>dXRP8|=%NKSfxt zT1_#H4PztT(3434^{6d%n)-10)gq1UTFtcUpDn1@TZRRjPIKZi9sCcT=W$;%y~2<> z5-6cCgWjTi?3vb>$Pp^UL!!{lr-u*DB!pdo>b#(mrweTw$Unu?N)7POY~2mxMWdEh ztJNisWVV{p_aEkRn3b_wpzOu<$6a{OvVL?^@owp4R0J{dAtc=#(rqg6pqgR>LoM^b zkhcCR%}`X$u{%8MCLk=5RcLWH%qZp%Tw93VBsk^)|L!(6SonXeK&p*z7~tD2$n8i^ zf|RZ4YzuPZ3ueJjG8rp01LE*cQlh=#}FdB@^$-%cFvY z;r}u5{C-qZ-^jr~!@AputJHsrg4s$@=tl|2)62`x2&sa!w60;a={}$**qUicwDGnn z^%(`qiqzy$#EL;Za`(_J%SNFud%WAG;%Xc1V6kjJ3QNB4mX#+Ou&}h$qm+d^&?`HS zWh)=wA&LVP4k*Jr*WCb@F$Jhet1Bej$N7ub$fE&RF?!0;gtW;PS0!Oc$G*ftVDe~= z=Wk2dX1$OZ!4prj%vDJ$z}90!1}zEE#-l4cRec0&@WXG*v!tlmYb~vhezc#V+Y#QO zZ*^>kME)@yo!O2zaypV1T|LPM8c^dWcKPL6t3e1Fy-c{c2NZnpmJTAuEZ*)1nJ(_I zh<2YDqf1z`WU^r35M9S0yFAdBS2l{3@;vzizmMQN*xJkU%!_!}Tg~@ykQmRgr_fje#Iv~hT`Hr-=2Us^(OWN+s=O9OSG1tDJf699flr11V>XDQM_`h=iB9hn#q+vso@s${-8Zj2?qs$Dx^ut?WrR7v7 zMV#;kA&L0a3lArpI5tfj3v}XWKr0CrYhe#l~T1Hu8 zB!{~~gRW_(v((vekzYN3fO&PwttGw299!#SbA;_cq^*;aiTX>hFg;X^YmPwNW`yL3 z17)N(xQ3;~rO;bRqyM)l1r|RzJ1I3TsKA?rQ~EiJ`6F;K)JbVwEWMr&6?2tETQ*2C zl3&J`+>rse^jJ?CN^*JpoW?Il$(Fg2)QwFGZcWJzWSNzO%q;)(UKP)5x!7v9l3Ir_ znwgf+{XkMnr7!KPh{0s4WBc=2)431*P!nDp%c=(|!p;qUhxjYebw+ZFO9ceJyAcbC zS+Tu@HZ3_G-n3u8Gv5_Gz->^Olv_dUHeHYN{%)gm?tDN&N#C{M{FRoDj-5F;cO-;_ zLC6>y|C?pOlP<@<`U0g0`QRYKBR}V3#d}74aQC#mNaQDh8$~q@jUz3|Oqtqx`I6IV zPxR7xj}oV!rp@wzkZTL~iijr?WKr}0Cj|QS>X`tolL)C-u4PmL<%1viT`k{nWOabJ z?a#f&cQ^a&+$E??-*p4akY$|pki=2^aNlO~7UV3VD5f1Sq~%DU3QC_vN@0q#<5C4u z&aV4*ln@&3-tsl|-O3h+gf$?Ei%^Sh0};2eRD`clxMPF5NRqX#ZKA{#Itgx9p0=25 z;*_3CJ__T~jn=4V7x0TAuUz~7tC?5dcye^)LW}+zDc(2LX7wIr8&__SNKGRV>;^tG z;A}KIoX$YC#wGm`G*}eGq3F>RDQ^yoNKHREv;zaioSWaSr^;U3T7{|vUcGJik4)Yp zARxFw-llH0@?r!>IrJ@ehvRzwN!%P`lGW@Ya2Y>1e_F-2_&yhu1fFRLh@Z;u2Sc5S zdM55pkIav;R!4P{wLqnY`v0*f7^a9-W8N6fF+pX6w-5EDf$C!G48I;ZR@`R93!?0I zZ7>%G%I;{*IU^sH(ud;>ZC^IOywU4wJC;|Jpxz4BDoZbsey=FtqAK5;Z5HexTBif8 zVe>yWiHvlz_ZA#3&-~MnjQFe{axZB9dkKrY`dsKm?{YAB%X_9C2{10hfl^`CcID(= zvm)jk5V}~1_p1T$*vuAn$d~C&_VfOGwe`?&kFgPO270ffTfwJ!X-l-VEdJ9BeKY%e zPA24d@x)+eF4`PB03;u~+}NW!YZ-w1Sk5o;j&TXJpG>VqcBVDsC?mz!^fv9(6ZQfM zCD@YbHKYj^-o;>v$A~-s4E6AzCiY7U{v6pr6F{SDPZGEdHHTA-4_X@O*Z5{Of=0pQ z;)rK}TWX~iw?z_xZ$+gWCK$f;S`_>^a9z*1(v;)y=)JM%U6Z!GP0RIX)et&O#(zp{ z1YL$z^w6)cvW+AvuObsEhS$^nv@ih<4;DO?RbQb`XIw-#85Vv76_bfN9Q(kbGma$p45BTlmFtE*g`&X@5+=2&^L`zqas^32Ns5 zIShJ}OFKt!LZe-bZ!=Qbt%!UqK)MRH`MbH1HfAclRq|?CZy_#M`AwR0j!G{Vu5dNCc>kip2vT@ly9(G5bC^1fZfUvT2tk<94 z!mxqxwXyH~9Phd|vC4RmGb@rET^=hAczCoH)SSF&#?sH9T4i*|3=~o9c6dLW8oWM%x(_x-&RO`KKO((>PShOb?QomjEyI`jES_z~tlHWqhjL{$lGk zO+P}KJLsAv!l%p)oWo;Ypu@%)G)DilU@N646Y9O+DGzr(O~!IQK;;-{QL;6Y5<$&9rw)z+tMuR z_7_(6feX2A3i|N^$p-^QwDhpNa&*@ZQI=+^Fl|=lX}n5C#)8g#t6GuzoUEwbg?2oN z>tf#_H*>?dx2`|E*gAgErBJ*v`r}B~E-7`7o1c)9_j>^~lmWZrVwUOIo&|%pvF^o_+VtV!HEWCdNTlr}7o5>6L^CjhgpKQ1!CNzPJ!odSgz`W@Dh;jNBky>mh^EZ8|kPuP3-UqhUWI`=h{q*!=3+ z^S9-vo>(9eMXc_7FkdNbPN6tSr3lLcHg4cyua^q>a6)k(XK2IVS5CK<>`aJ1ii6XO zO!%Rh*kaoI;1?-HsH%lXU+9aj5KK7J6TvJjG6%0;b@xx!{Y8iE^C_dSRJ1J2%w2|? z$6P#}=1(?wg%q|+_z?KLHZC0Cfk zMir6?PP>YQm+qEFW@$exWDf58?DvRyxK<#i8&G5z1h{yl;Ss`X*Lw87X5O=ByElNI zJCT4r&&3L@BGjGJra!neKQfA)q=%bC1#v_p&=tPshw?Kau`O#=>-teADdNGR@@NZq z+|KtC^hP1sBO5BfA!`QdU+UT9d@jOE`=XnU#Q z;!C^kA)eRn-k!#zu+Z{gBmw0o65jk3x09M7h6li-9ewa)bwR7~6lqoiir~ODs0<7B z(Iu$*GDYv8zy3)fBHbe)e3)g2a|3%98@YvG_c6+$vSkDXI#KKI*`v%>O~e%MC1AfO z26gX_#G5pQM!1??zKYX4&E!frd6Uf>McjS&g(nPo*B24hm)a5QD~lw~ z-IW`JjiK6KEBwbQ6kS_CK${KM**vow%|nwY7GEgWr>6T!p8^Kcv=yGVHSMfzFFsBf z2R0>@bZx)tA*AC2J|2kQ`$^BCED-lbwdG!*+5^+{BdkiD6;YnltqAOwzdvC`yw!?Q zZI6VPd61zOi7Ns0B56Mfy0-h?Jp<2z5SYe?(ioQ!?bdKXC+b3f??}0SC+aU~3>v~O zqj_mtOW`5KB=;*6^UWDS%2-~J^82?w zYdJM-(7oTcpAkBFu$2|+HKJt^?&uciLh2?M6tZ%T9~5x-<$rZL?0$qyi=WXR`G7C>^p2xvY1~| zN>vW%{xf7b=#Y&aEu~?OFZ9kW;x-1;e7K97 zGh)H74|EHq0tDdqeO^X4N4Gf?W6mvSbdOTt%q3k_CHo}?ii1FZB z=-n}Vi@r0PmvYZWe08n)>*qfVy}t1k-AboFU8n2J&-=TV32&xg8PVH8AO3pS z%D_CamwBLNPfh*pMbQP8P`lF#iC7tiZ`yu$rdaqlAnFQREMk*T%L%>}?y+G}B>=%a z9?7|${2gAXtm<4iK7Fm_vARbh!lu8bnhW^KNgB!VY5ryUoIuoF6~sh{(x&U)%vT?8 z@5RB%nBte3+m&s&L1Xz6;NN4H7YBX17v`t!A`Ptw?}!l;QMI{%JyQ-xLUxkkmwEZBPlpq&&Sfl5<5e zt}F_Gt4{|a_UR%{%AAz{b3zhDB^C*yo#geyn+6!<-v=<%_(rT_h#B2~P7qi-KV8cr z`^G0b$g>*Xd|+QBj0x_P*E0tFwzWZmV^(Mw7ex&4ukSzeitQ(@xY+ z#|Wu=3#ugG3;h=eOrYcT#@J|YP_h+FPX6?y;{}q*k1dH^;aTL(aCdfk|pIv&+P4JlA=!^;O~DDz==syKZvpi-~V z`3F-ak7CWsAv~ic{SqwGAKd72Zo5+ogzxa)59R^e74oaZOYyHhlvK2_C6i*?)6AG) zHCoM;xD})R01}_QBy?~h~iUHTiZ_zoHr{>DyllcJ;RR1gxOtJ^ezBySMAtCKEmhZgXH~`}@#S@vcVRM}h zK~oALG?h7e8-$QfI|c|uI#lL$Q5?!@2$(ONmEpRJ;<*@}10)NC?4KW&TwDAyi8n6K#1YJmv9T3)+S$y<^v1pTN@^3Hp3O$NUsEzoD z{{*LLpkPa5t-+Z&R$aTaCZXr|$7xS)Pp;@MVu;Pydkc(-O^4L+ERHZ32eZ>1Pxx4N zny5O+`kgD_qqfB*<+ef_q~R?00>RG!^8e?yGXzVZf~0&kn@w@wRJka~W!+xNsiP!B zeBLC8rTbdY=lG0()P{2iA%m9TB)4(I6q6Bcs?N+Iz(<+h2gJnI!S&7!YzT?&g6)CEz zk&+2HH`Bl?X;CqdLtzbl(od82lHj;*7HI)^3jACF5C|JuS9YJVO{{BdB)z!bn z>_sqVkCm^YUM2Totxc}ffP;f@RI@}GqdQV%<;|UfRv=QU3Go@LTRDE&Yu{GKUH}g` z34{L{ZE0ZbyT_A@qAO>EJ=~%i!c(8W9_uT}S+ReVFmF3LG{!PEHU?e?;sq}|AO!#u z@as?pX`~hgC;4A49J_vg>bbO!I>gq6tU`Jak$% zboMDE{ri9i0PY1sPb&D&-%ptMf3fO+vCWAFNJh{)^I89ke*{Gl04A!KL$m&OB!5(p zJP*c<#i?z#^^1D3| zBH?!g$5cR+Ts|wm$!GY6zYTS1xmo{hmZ?68-A4U)BNt`-gx7(G04D&rMBb;V_S^!X zjSjNkAa=oVi;LE>M&d+~#udKz-cUz+cqW&l*P6G{e=j%{;0(?fZf<~O{)6-OsANXx zFrkqxfJPiEqBws)FB(eambJ@jGu&{A+b0_y%xi~wY^1XV+)0qQ%;$Rr=o?lC+^`K~imzymF(h~vfcn!J-l6|%2 zp)(f{17hSUjNKeK**)E_I$FTpQTuBe9-d0ap_El2fjIP+B=a1?RfY@Oi0+eaM#^k`Tuf9<1QBO? zn3#aJ5V-Vf+@h=)KBwnrd<+7^&Yq~$=A1z>cR9Di-+@74E+ar{b|blY!uQB7ZfdKc zp|SJqtn!E(XVwFi1KE4aRcZ*hvsi}zm-7uOWG|Ms@SLc1a`b&R-0Ehd*KgcM`?N24 zDKJ~2X@kJ9^UZk(+7>HHovDUNEN5geVPZvA?6fyw3j_=KKE}?~dF1rKnhtk;OpPK~ zAGdWiK3Z0Nm-~>}uy?r}Di(GXaq!t^AzbS%ekcMVnd+@}eRpR8E7M0pB5P2PmC__P z@1GcJGc1X3YZa~Co#1WLXohjh-CkcW^O;Dt`yM1ED#09AvNvpe_j6DUQ~>EgyB+yb z4Mim!DHyZ+eH=w|cv^$?P*T>wa6L%u4~^Qq*K3O^>zo&IN=qAa4|e$EB+e?3XsoOA zXD}h}c1UtoJIxyvGTjZ4^9%B`>#1>+wT-_~xhm$t4UPKM=MFu>(-{^=HFb9QyL{gu z&U5~4152l;QBC_|Xv3Vs$ZAi#Cc-hsj0stYX^f-x zYZ|jSg!Lo$w1^@)s8x7Uh~c8}ld(uv!9#HdwT zAAaDiJ`4JDgW*Sz6sk76TQX>U1y_lS_?Txrw(DJuz;abu@H@RE&Heg|HIQe5)S%DO z@ppqwN$ryMqJ&Mj&Xwd-b#n`V@Io$7>7hC8YMe)_O3+QsGK8?W#{Hu)fj8bL=NnN;H+7 z>lE2-Z{>h^*Fhmc*)ML4o9p*WCZ1;lEvCyurSP?a!?1n6)6`?#iws6-{cvGtCU)iu zo%A~URfZznU1WSA6dd|oXuvPp%hi^ewjOz}9;6(J?&JHbgTApw;^BIYUMv2X0E3?u zz*v=C*Hcq@xH!6GZD}%HpI+LhuHCX%TO}p^V4bf@(@pk2wxzh{9KI3?8hEB@(n(x) zS>a7}LJ_Y^py$z1q3n|4bWx4iD>+UzX5O7QdH$wKzrt9}r*MeZ@c& z7*HN$XfvK@DU~Idsr9|IDjcKY3!8j+*epiGwS4C+DFd9EeSn1R7rNt@`H{?Dv*mF) zx3)fnC4H4*zIt_@>9b|;pdDQyV|0qH+O*&LvS;oKKB~Y&ZP%FIA7+fNPyBRB)*O?7hF&uZ&em1$Y+*4Te$3%e$5NSprMt z-DH}>FFBY~UU4+JG%d#;rO`n?Qqo@XP`(3#miNtq?;{ze*psfDBz%9ih1mD44DrzI z7nXaLL$K4$E+C^3anGqs_U0%pP(&7EB z?~Hi%6Mn@CUK6e6khYuurkPI^WwhBEgo%4af1C=&pH1_ZTx5~SJq{LW0P(7b`JXGL1|TEBQVCD@8Bz{rsz$6VH7 z{`pJK&p=nW87m6vro46$4vyeJC0qll*P;$ON2jMl?Cfm4%a=QaIV76R!x{v~Iw)LU zTLJy!6M_Np9F<8e8{7;r=vE4%-tNjVUb=&t&4{I2H#0dZY4;i8)XZ9CP?7V(LFDt% zfh8%ar*XiGMt=1+d-9>=wgKJxR1p7FNSvo3hy!3+0w`=%60##J8;2X+my3~JXcx}m zh{5X}D_+mVBiW;XwVq0`93q!ZE&>Q-YY9b4>rx?LIQw+FVZn1{qMd@tI8V3^jbWh) z8}Qb84`L8HFlHI5gzp~KxDnI#UZGdzbPC_X#{O%=Pa5xX!|j(Q9PoMlRtb1*7F}|! zu3|qdFIx5RY4k=~teA(Jx{Gg+be3FwJE7aVW^MiyOCetQI8^h4A}Itl9SM2!vp_&< zzZ?y+BeOrMmpeD)W=mz9u79jXDR3zeiz@#scMI)|_gyxbXi?n8co@z;y(cz^d9(ej zI8EHPdc)HmZII$i+Sr?t=W4%4#KXGrJ}MDUv9d{UdtS(ErT*M^-xp<}qwfr^4#__>{y(5s*XNFW zveM0SY=Kyz^z>b_p+p}P|B`jyY2jPeSX|@N4n%JpVYvS7n$M}@m4dJ8eNrg)4^K}$ zE%gu2I6u#+#pVA-AhCEn-kHjO64F$Z>hq^I-o+kc&cpog(w{u{2Np~4qtNhXH0cAA zC0Jamx!kbwWC&Y4v9tbQ(AycPUOX}r?w#53cUdwZoKaqIH~l4cLSjJNpz?hBcyUu_ z=fP&BJY+H?tVsbT%pP9e5_9EWnc}2X6=wV7+gC0_S7rFaN-^gB!5754t-6Dn*c_se zzFBLET`6G|kb5CdsvU7$bhG}i%!^Pm=OOG5eNBw>Zbw-%wYGznp{2O^&+*a5Q*H-l z)5B~Za&jhr{!;T8ap?GQOD>V`^{6_4!8a{(#ej$a7#R4Z?9;C&VWToTw>1~*%(WF< zHX-u|Cob&7107P zdz@WS$H~PLC0^Bx>qVWJVs6y$>M5Jlq8&Gq@JM~`8a}NNfNauw<-g$r8vR^&<%1&F=lo>$y)w-#mMKI#Im6R^yV1;XM*g=D;hy0M3edX|6?CZt zKTH^VN`I4Rj+Ynt@##}1f491}&mG^B*dLa@Zn?;Wg$sb+MCChmB#N=%@$(t`C}u#3 z_{Pn&JZt;*&#dnTI=Mq&T6yJMOq!4^D(92kqxRdkC8-Rgy`hwK>Vn{Rcq+$jro%nV zMrkHHeglEr7JmA*ZIum|4aH`qT;F08^s3Ag*wPxNQ;xTK{$l029C6{qutg`DN+{zZ zpJ<3T`bk2fmV>p6U&$#&@O?3llbCF;8{R8~&Q~ABPtD_zPX0mu zosv65;%~R+jDm9yL7Wz@A_1({Kov3fFxXRkky_^X*?x???i*~ky+@?ip;SE&D8!Tn_0GkA;D4#2Jz`99@F$n@ zwwWXsO+(hiGrX2@#o9v?&m^s;q_U{{bO6GzuqJ^CHYry6=~=exNwV%F)y-NJ3aYU3 zRYqj5POqmZP>ILHZ#Fw1P>R*MO>B=8cx_L7O+>$WA?@rfqqr+p1CjPF zmEZTRx1`rlr9>Xp_8Fw!NCrM)w#%JcAz{C(QRvg0Ms~xhxaXoh)rYhf?~nCVxRSo! zPe-+5R8Q6>x3OL5wGLCytP6A{rG+o2)u|JzqjSf4c}6pG6wOQGeNjjV5+IAC?4Oyj z;z-&Pm?^ZT?P*Z#DBP9t@AxP5)qNZ3l*JI$RkD1IK{6Vi-tmNKPU7V|;?dMLBbC0? z!9mCZ`c^pCc|>D_O-39RRaL3@OsoF%0&Qlv8s{z+!M?^yR$05b$jtm`b*2s4?WJo> zna$8`jzF9>$-G3>MND zw2{dMPhyHRoCca2-@kmH%CmAt_>f=mZtau&b)6D&M@9$_Gv@721)|*;Y3o*+u0(Xh zPK^Rwf!)1nHv``)>0ronkIkW<2OS1bZUzSVYqA$_xj-n*Ovo94$*lQA1sRZM@%*=? zM{k%hhs$3E9JGFTYh%Z9%(2Afl27CClayh!uh#wtut(^df*SMdhJY*EZGpNKuhVWQFt4f%OVqPV4eL(U}=$ z^BxUfJt|#1zJ90qo|`NcQ!aM@ugRAM`H>2DUaXo9_@n*aaETGIily)*tm z-4``B?pLiv!}?rKV{$n3>yNLv+fMbZ<_ZDFV?uto+E8w)RY6gubGkX*&`eA5o64H{ zXIL~)QqtOgHJV5&mQA-$?PJtCwRC6KLkk- zZE4KLc_r2csBb=z;|lVNBc*=+nbP8O#+f5xR?h1Ps+WGL@{de;kpn_2H_D-)qo2<9 zn^=z4goPiRHSL78pY`o}-W^`)>|-~dDU@Lznv!?{E!A~3Tt68PtK(LXx7b?8-5tY3 znn6RNhG{7&u&&?tV-gs`L4a(}S2V$d!H*K)zTzXK7E^U%~KI(edwHe$^BPFUr&Cz=fy={pYeS+^J)L)u#Xl; zQq78(7_KrVmzk08K)tj7`LT^-gfSrVLsAP{d1F&iKckvE%)ZDQ|7^N2c;8e4{>+TR zxt2lUX0<7N?#|gABhj69J0SF-chal`EJ$!r^#afGiySK#>+~f$^_w@rk#=9HpLd|* z3$E>aqI0=wue+OWr};!(GsG@-rjcC(g{zaUk-5&Q+m|fQjBhnxT3T#wkos;|H`mIc z#6aNR+tJBw$M(aX1S9{H1q%{FRcclq(2{T9GMCWb-s4pKUih|U!GTu|8%PA~6Mj;% z@fsc4e*VmeCm2-4WoG_Yo!7C0V91^W7j<;%)yv#{ai} zzY7M3UM-8^$il_uVRYAMKZwqyxx6Y(oR%Bw zduRBuI%jQ|n$XX{N}7@S$MXor{je7H_XHcYgkm$C5+N^LWCOI}-euKEiynco4T zs8wW^S;ERVVG&+aH8{_S#usO~)%siKzKWW_={ZpF&XoEhr~rrwEsqa(Y4z;(eY-)# z%B7Cx*BATcy50>sjc%!3Erx8}!aF-6vkYTq@^}WV=G$r;y0m>t#Gp8;N8@ya^ju|A z>Wd4_HnJ8ymv_tBDs?TDM*sBbj!>*2#uAcx51OlAUvKBdv1xNUMyvit!w?PtbPQF0 z#UusH zm6KfHP~@bm$$q}b)2-QPsC~Yw`Bj)LK(ljw;=K4xVP;pfC%=-b(uJ@-uuE@x({e=Q zd#;Dj=7*nkyV=*~-$olJ9@u&qge@hm%=TKa!@REsZT)U)x}qoWFdD*IV#?1bX7^ZBs1JroZ0fg5u6JB~N;hjUIsMnU;jQX_fxb-ODRB(692mJE0aj z%t}st<>#v5!6XspPKdy5b#M2R@F8TZ1cZ9Z``gPq&4++?uB)-Hsya{+8Wu@e*|2xs zjn`RsgKB)Ya?c`MORmTrw-e`Bmbpk@SF0>NS`Ekkq82*H$xeKA^l0}A{)Pb&ih7MT zhi!}*CJU&Z$Jc9dxL=GaQbTlKoL`*r_PW|_5PBKbTK^VI{4OUK=zdARB2 zbLuWKR``5wLPfh8#9UceeEEWIJ5A9dgtWqdjUCrtpoWLEueX*ZOLXUQPU~%g5qHaa z>FuVU@5365T4>+vwhQ<5;y&4*T4|I+U_Hi=&+;=lX_S~ZNGQL|UtJ_pUMBi&RmR!X zjM+rYkZS=c_UVo!G4`(exHmuC>|67B zXTr|W9B$=s3qXJRgV-h^P;P@F1$^c66RR>F&3|m#yOhZ4>I`fh+^e%Z$S$Q8I=b_| z+;9I|kJiG5lYnZ+1g{Jn-kt*%Gyx?GIg_Z)zY3@zX_MaQVq9iel*ehTsW=*g zG3o4jixIP04&Qz43B1klu3F-5mh|yq57-lBkP;>KjXZq#X-UQ=cX$`D_TyOM>GkQ~ z#CT+v9!65S0|{n@W`Y0wlbf5@DQ@IF(84+CUQ%yWZdAWDbdhm2YEXIHY5^4I_&irA zHVM7hpH|3R44*Xu6&-LO{Qhc%da25+S%H(j6Ig)Lt7@1e)-4!?j(b9eto7EEpAwwN z4m$+H_}H2K-d~>ZIb%S|zi;EOc!To006!1`v0^_h9q?bnh$iEu<6&aje01H*JcfE_ zq#QK6#~#hM8Ae-|ZUmFx%Jx;OWn5AYvM$yfb$9&joakXz+vI%QuNhV4pTgNolGLCB zmI5R%Gv$N;B|&!dehf#kzV6_am;2OEId20^gH+X%*}nRZ4&f0Fhp%vTJ}G=S|RBbMxdxZXjdt!uab~ XqlTo{15O4b0Y3^5RoQZBlfeH0x`$ic diff --git a/src/main/asciidoc/index.adoc b/src/main/asciidoc/index.adoc index f0dc3af87..f6f9abaa8 100644 --- a/src/main/asciidoc/index.adoc +++ b/src/main/asciidoc/index.adoc @@ -1,74 +1,61 @@ -= Spring Data Neo4j - Reference Documentation -Michael Hunger; Oliver Gierke; Vince Bickers; Adam George; Luanne Misquitta; Michal Bachman; Mark Angrish; Nicolas Mervaillie; Gerrit Meier; Michael Simons -:revnumber: {version} -:revdate: {localdate} -:spring-data-commons-docs: ../../../../../spring-data-commons/src/main/asciidoc += Spring Data Neo4j⚡️RX +Gerrit Meier ; Michael Simons +:toc: +:doctype: book +:lang: en +:listing-caption: Listing +:source-highlighter: coderay +:icons: font +:sectlink: true +:sectanchors: true +:numbered: true +:xrefstyle: short -(C) 2010-2019 Graph Aware Ltd - Neo Technology, Inc. - Pivotal Software, Inc. +ifndef::manualIncludeDir[] +:manualIncludeDir: ../ +endif::[] -image::springdatagraph.png[Spring + Neo4j,align="left"] +include::{manualIncludeDir}/README.adoc[tags=properties] -NOTE: _Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically._ - -toc::[] - -include::preface.adoc[] - -:leveloffset: +1 -include::new-features.adoc[] -include::{spring-data-commons-docs}/dependencies.adoc[] -include::{spring-data-commons-docs}/repositories.adoc[] -include::{spring-data-commons-docs}/auditing.adoc[] -:leveloffset: -1 +:copyright: 2020 Neo4j, Inc., +:gh-base: https://github.com/neo4j/sdn-rx +:java-driver-starter-href: https://github.com/neo4j/neo4j-java-driver-spring-boot-starter +:springVersion: 5.2.0.RELEASE +:spring-framework-docs: https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference +:spring-framework-javadoc: https://docs.spring.io/spring/docs/{springVersion}/javadoc-api -[[reference]] -= Spring Data Neo4j Reference Documentation +(C) {copyright} -:leveloffset: +1 -include::reference/introduction.adoc[] -include::reference/getting-started.adoc[] -include::reference/ogm-support.adoc[] -include::reference/neo4j-repositories.adoc[] -include::reference/auditing.adoc[] - -:leveloffset: -1 - -[[ogm-reference-documentation]] -= Neo4j-OGM Reference Documentation +License: link:license.html[Creative Commons 4.0] [abstract] -- -This chapter is taken from the https://neo4j.com/docs/ogm-manual/current[Official Neo4j-OGM Reference Documentation]. +This is the SDN/RX manual version {spring-data-neo4j-rx-version}. + +It contains excerpts of the shared https://docs.spring.io/spring-data/commons/docs/current/reference/html[Spring Data Commons documentation], +adapted to contain only supported features and annotation. -- -:leveloffset: +1 -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/introduction.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/getting-started.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/configuration.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/annotations.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/indexing.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/connecting.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/session.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/conversion.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/filters.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/events.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/testing.adoc[] -include::https://raw.githubusercontent.com/neo4j/neo4j-ogm/v3.1.2/neo4j-ogm-docs/src/main/asciidoc/reference/ha.adoc[] -:leveloffset: -1 +_Who should read this?_ +This manual is written for: +* the enterprise architect investigating Spring integration for Neo4j. +* the engineer developing Spring Data based applications with Neo4j. -[[appendix]] -= Appendix +include::introduction-and-preface/index.adoc[] -:numbered!: -:leveloffset: +1 -include::{spring-data-commons-docs}/repository-namespace-reference.adoc[] -include::{spring-data-commons-docs}/repository-populator-namespace-reference.adoc[] -include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[] -include::{spring-data-commons-docs}/repository-query-return-types-reference.adoc[] -include::migration.adoc[] -include::faq.adoc[] +include::getting-started/index.adoc[] -:leveloffset: -1 +include::object-mapping/index.adoc[] + +include::repositories/index.adoc[] + +include::testing/index.adoc[] + +include::auditing/index.adoc[] + +include::faq/index.adoc[] + +include::appendix/index.adoc[] diff --git a/src/main/asciidoc/introduction-and-preface/building-blocks.adoc b/src/main/asciidoc/introduction-and-preface/building-blocks.adoc new file mode 100644 index 000000000..5d54eff0c --- /dev/null +++ b/src/main/asciidoc/introduction-and-preface/building-blocks.adoc @@ -0,0 +1,75 @@ +[[building-blocks]] += Building blocks + +SDN/RX consists of compossible building blocks. +It builds on top of the https://github.com/neo4j/neo4j-java-driver[Neo4j Java Driver]. +The instance of the Java driver is provided by our link:{java-driver-starter-href}[starter]. +All configuration options of the driver can be configured through the starter in the namespace `org.neo4j.driver`. +The driver bean provides imperative, asynchronous and reactive methods to interact with Neo4j. + +You can use all transaction methods the driver provides on that bean +such as https://neo4j.com/docs/driver-manual/4.0/terminology/#term-auto-commit[auto-commit transactions], +https://neo4j.com/docs/driver-manual/4.0/terminology/#term-auto-commit[transaction functions] and unmanaged transactions. +Be aware that those transactions are not tight to an ongoing Spring transaction. + +Integration with Spring Data and Spring's platform or reactive transaction manager starts at the <>. +The client is part of SDN/RX and SDN/RX is configured through a separate starter, `{artifactIdStarter}`. +The configuration namespace of that starter is `org.neo4j.data`. + +The client is mapping agnostic. +It doesn't know about your domain classes and you are responsible for mapping a result to an object suiting your needs. + +The next higher level of abstraction is the Neo4j Template. +It is aware of your domain and you can use it to query arbitrary domain objects. +The template comes in handy in scenarios with a large number of domain classes or custom queries for which you don't want +to create an additional repository abstraction each. + +The highest level of abstraction is a Spring Data repository. + +All abstractions of SDN/RX come in both imperative and reactive fashions. +It is not recommend to mix both programming styles in the same application. +The reactive infrastructure requires a Neo4j 4.0+ database. + +[[sdn-rx-building-blocks]] +[ditaa, sdn-rx-buildingblocks, png] +.SDN/RX building blocks +---- ++---------------------------------------------------------+ +| | +| SDN/RX +----------------------------+ | +| | | | +| | Spring Data Repositories | | +| | | | +| +-------------+--------------+ | +| | | +| | | +| v | +| +-------------+--------------+ | +---------------------------------------+ +| | | | Provides | | +| | Neo4j Template | | <------------------+ sdn-rx-spring-boot-starter | +| | | | | | +| +-------------+--------------+ | +---------------------------------------+ +| | | +| | | +| v | +| +-------------+--------------+ | +| Integration with | | | +| Spring Transactions | Neo4j Client | | +| from here on | | | +| +-------------+--------------+ | +| | | +| | | ++--------------------------------------|------------------+ + | + v + +-------------+--------------+ +---------------------------------------+ + | | Provides | | + | Neo4j Java Driver | <-----------------+ neo4j-java-driver-spring-boot-starter | + | | | | + +----------------------------+ +---------------------------------------+ +---- + +The template mechanism is similar to the templates of others stores. +Find some more information about it in <>. +The Neo4j Client as such is unique to SDN/RX. +You will find it's documentation in the <>. diff --git a/src/main/asciidoc/introduction-and-preface/index.adoc b/src/main/asciidoc/introduction-and-preface/index.adoc new file mode 100644 index 000000000..fe4ea36f3 --- /dev/null +++ b/src/main/asciidoc/introduction-and-preface/index.adoc @@ -0,0 +1,5 @@ +include::introduction.adoc[leveloffset=+1] + +include::preface.adoc[leveloffset=+1] + +include::building-blocks.adoc[leveloffset=+1] diff --git a/src/main/asciidoc/introduction-and-preface/introduction.adoc b/src/main/asciidoc/introduction-and-preface/introduction.adoc new file mode 100644 index 000000000..723bb0133 --- /dev/null +++ b/src/main/asciidoc/introduction-and-preface/introduction.adoc @@ -0,0 +1,21 @@ +[[introduction]] += Introduction + +== Your way through this document + +If you already familiar with the core concepts of Spring Data, head straight to <>. +This chapter will walk you through different options of configuring an application to connect to a Neo4j instance and how to model your domain. + +In most cases, you will need a domain. +Go to <> to learn about how to map nodes and relationships to your domain model. + +After that, you will need some means to query the domain. +Choices are <>, <> or on a lower level, <>. +All of them are available in a <> as well. +Apart from the paging mechanism, all the features of standard repositories are available in the reactive variant. + +You will find the building blocks in the next <>. + +To learn more about the general concepts of repositories, head over to <>. + +You can of course read on, continuing with the preface and a gentle getting started guide. diff --git a/src/main/asciidoc/introduction-and-preface/preface.adoc b/src/main/asciidoc/introduction-and-preface/preface.adoc new file mode 100644 index 000000000..f12731dce --- /dev/null +++ b/src/main/asciidoc/introduction-and-preface/preface.adoc @@ -0,0 +1,137 @@ +[[preface]] += Preface + +[[preface.nosql]] +== NoSQL and Graph databases + +A graph database is a storage engine that is specialized in storing and retrieving vast networks of information. +It efficiently stores data as nodes with relationships to other or even the same nodes, +thus allowing high-performance retrieval and querying of those structures. +Properties can be added to both nodes and relationships. +Nodes can be labelled by zero or more labels, relationships are always directed and named. + +Graph databases are well suited for storing most kinds of domain models. +In almost all domains, there are certain things connected to other things. +In most other modeling approaches, the relationships between things are reduced to a single link without identity and attributes. +Graph databases allow to keep the rich relationships that originate from the domain equally well-represented in the database without resorting to also modeling the relationships as "things". +There is very little "impedance mismatch" when putting real-life domains into a graph database. + + +[[preface.nosql.neo4j]] +=== Introducing Neo4j + +https://neo4j.com/[Neo4j] is an open source NoSQL graph database. +It is a fully transactional database (ACID) that stores data structured as graphs consisting of nodes, connected by relationships. +Inspired by the structure of the real world, it allows for high query performance on complex data, while remaining intuitive and simple for the developer. + +The starting point for learning about Neo4j is https://neo4j.com/[neo4j.com]. +Here is a list of useful resources: + +* The https://neo4j.com/docs/[Neo4j documentation] introduces Neo4j and contains links to getting started guides, reference documentation and tutorials. +* The https://neo4j.com/sandbox/[online sandbox] provides a convenient way to interact with a Neo4j instance in combination with the online https://neo4j.com/developer/get-started/[tutorial]. +* Neo4j https://neo4j.com/developer/java/[Java Bolt Driver] +* https://neo4j.com/docs/ogm-manual/current/[Neo4j Object Graph Mapper (OGM) Library] +* Several https://neo4j.com/books/[books] available for purchase and https://www.youtube.com/neo4j[videos] to watch. + + +[[preface.spring-data]] +== Spring and Spring Data + +Spring Data uses Spring Framework's https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html[core] functionality, +such as the https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#beans[IoC] container, +https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#core-convert[type conversion system], +https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#expressions[expression language], +https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/integration.html#jmx[JMX integration], +and portable https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#dao-exceptions[DAO exception hierarchy]. +While it is not necessary to know all the Spring APIs, understanding the concepts behind them is. +At a minimum, the idea behind IoC should be familiar. + +The Spring Data Neo4j project applies Spring Data concepts to the development of solutions using the Neo4j graph data store. +We provide _repositories_ as a high-level abstraction for storing and querying documents as well as templates and clients for generic domain access or generic query execution. +All of them are integrated with Spring's application transactions. + +The core functionality of the Neo4j support can be used directly, through either the `Neo4jClient` or the `Neo4jTemplate` or the reactive variants thereof. +All of them provide integration with Spring's application level transactions. +On a lower level, you can grab the Bolt driver instance, but than you have to manage your own transactions. + +To learn more about Spring, you can refer to the comprehensive documentation that explains in detail the Spring Framework. +There are a lot of articles, blog entries and books on the matter - take a look at the Spring Framework https://spring.io/docs[home page ] for more information. + +[[what-is-sdn-rx]] +== What is Spring Data Neo4j⚡️RX + +Spring Data Neo4j⚡RX is the successor to Spring Data Neo4j + Neo4j-OGM. +The separate layer of Neo4j-OGM (Neo4j Object Graph Mapper) has been replaced by Spring infrastructure, but the basic concepts of an Object Graph Mapper (OGM) still apply: + +An OGM maps nodes and relationships in the graph to objects and references in a domain model. +Object instances are mapped to nodes while object references are mapped using relationships, or serialized to properties (e.g. references to a Date). +JVM primitives are mapped to node or relationship properties. +An OGM abstracts the database and provides a convenient way to persist your domain model in the graph and query it without having to use low level drivers directly. +It also provides the flexibility to the developer to supply custom queries where the queries generated by SDN/RX are insufficient. + +=== What's in the box? + +Spring Data Neo4j⚡RX or in short SDN/RX is a next-generation https://spring.io/projects/spring-data[Spring Data] module, +created and maintained by https://neo4j.com[Neo4j, Inc.] in close collaboration with https://pivotal.io[Pivotal's] Spring Data Team. + +SDN/RX relies completely on the https://github.com/neo4j/neo4j-java-driver[Neo4j Java Driver], +without introducing another "driver" or "transport" layer between the mapping framework and the driver. +The Neo4j Java Driver - sometimes dubbed Bolt or the Bolt driver - is used as a protocol much like JDBC is with relational databases. + +Noteworthy features that differentiate SDN/RX from Spring Data Neo4j + OGM are + +* Full support for immutable entities and thus full support for Kotlin's data classes +* Full support for the reactive programming model in the Spring Framework itself and Spring Data +* Brand new Neo4j client and reactive client feature, resurrecting the idea of a template over the plain driver, easing database access + +SDN/RX is currently developed with https://github.com/spring-projects/spring-data-neo4j[Spring Data Neo4j] in parallel and will replace it eventually when they are on feature parity in regards of repository support and mapping. + + +=== Why should I use SDN/RX in favor of SDN+OGM + +SDN/RX has several features not present in SDN+OGM, notably + +* Full support for Springs reactive story, including reactive transaction +* Full support for https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#query-by-example[Query By Example] +* Full support for fully immutable entities +* Support for all modifiers and variations of derived finder methods, including spatial queries + +=== Do I need both SDN/RX and Spring Data Neo4j? + +No. + +They are mutually exclusive and you cannot mix them in one project. + +=== How does SDN/RX relate to Neo4j-OGM? + +https://neo4j.com/docs/ogm-manual/current/[Neo4j-OGM] is an Object Graph Mapping library, which is mainly used by Spring Data Neo4j as its backend for the heavy lifting of mapping nodes and relationships into domain object. +SDN/RX *does not need* and *does not support* Neo4j-OGM. +SDN/RX uses Spring Data's mapping context exclusively for scanning classes and building the meta model. + +While this pins SDN/RX to the Spring eco systems, it has several advantages, among them the smaller footprint in regards of CPU and memory usage and especially, all the features of Springs mapping context. + +=== Does SDN/RX support connections over HTTP to Neo4j? + +No. + +=== Does SDN/RX support embedded Neo4j? + +Embedded Neo4j has multiple facets to it: + +==== Does SDN/RX provide an embedded instance for your application? + +No. + +==== Does SDN/RX interact directly with an embedded instance? + +No. +An embedded database is usually represented by an instance of `org.neo4j.graphdb.GraphDatabaseService` and has no Bolt connector out of the box. + +SDN/RX can however work very much with Neo4j's test harness, the test harness is specially meant to be a drop-in replacement for the real database. +Support for both Neo4j 3.5 and 4.0 test harness is implemented via link:{java-driver-starter-href}[the Spring Boot starter for the driver]. +Have a look at the corresponding module `org.neo4j.driver:neo4j-java-driver-test-harness-spring-boot-autoconfigure`. + +==== Can I use SDN/RX without Spring Boot? + +Yes, see our `README`. +We provide `org.neo4j.springframework.data.config.AbstractNeo4jConfig` and `org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig` for that purpose. diff --git a/src/main/asciidoc/migration.adoc b/src/main/asciidoc/migration.adoc deleted file mode 100644 index 354729717..000000000 --- a/src/main/asciidoc/migration.adoc +++ /dev/null @@ -1,227 +0,0 @@ -[[migration]] -[appendix] -= Migration Guide - -[[migration.5-0]] -== Migrating from 4.2 -> 5.0/5.1 - -* Base class for repositories `GraphRepository` has been renamed `Neo4jRepository` and parameter types change from `` to ``. -* All Repository methods can return `Streams`. -* The repository method naming scheme has changed for SD commons 2.0 as part of https://jira.spring.io/browse/DATACMNS-944[DATACMNS-944]. -** for example, `findOne` repository methods are renamed `findById` and now return `Optional`. -** please check the JavaDoc of `org.springframework.data.repository.CrudRepository` -* Paged custom queries no longer accept queries without `countQuery` attribute. -* The keywords `Between` and `IsBetween` in query methods now include the given limits in the query. - Use a combination of `GreaterThan`/`isGreaterThan` and `LessThan`/`isLessThan` (e.g. `isGreaterThanLowerLimitAndIsLessThanUpperLimit`) to keep the exclusive behavior. -* Id handling : `Long` native ids are not mandatory anymore. See <>. -* Primary indexes are now deprecated and replaced by `@Id` See <>. -* Annotations on accessors are no longer valid. See <>. -* Loading with depth `-1` calls have to be reviewed (please see the Neo4j-OGM migration guide under _Migration from 2.1 to 3.0 / Performance and unlimited load depth_). -* The `ogm.properties` file and environment variable have been removed. -You have to explicitly provide the configuration file now or configure the driver programmatically. -See <>. -* The driver class name in the configuration is now inferred from connection URL. -* Java 8 dates are now better supported ; the use of `java.util.Date` or converters is not required anymore. You may want to switch to more fine grained date types like `Instant`. See <>. -* The query filters are now immutable. See <>. - -[[migration.4-2]] -== Migrating from 4.0/4.1 -> 4.2 - -Spring Data Neo4j 4.2 significantly reduces complexity of configuration for application developers. -There is no longer a need to extend from `Neo4jConfiguration` or define a `Session` bean. Configuration for various types -of applications are described <> - -1. Remove any subclassing of `Neo4jConfiguration` -2. Define the `sessionFactory` bean with an instance of `SessionFactory` and the `transactionManager` bean with an instance of `Neo4jTransactionManager`. Be sure to pass the `SessionFactory` into the constructor for the transaction manager. - -[[migration.4-0]] -== Migrating from pre 4.0 -> 4.2 - -[[migration.4-0.packages]] -=== Package Changes - -Because the Neo4j Object Graph Mapper can be used independently of Spring Data Neo4j, the core annotations have been -moved out of the spring framework packages: - -`org.springframework.data.neo4j.annotation` -> `org.neo4j.ogm.annotation` - -[NOTE] -==== -The `@Query` and `@QueryResult` annotations are only supported in the Spring modules, and are not used by the core -mapping framework. These annotations have not changed. -==== - -[[migration.4-0.annotations]] -=== Annotation Changes - -There have been some changes to the annotations that were used in previous versions of Spring Data Neo4j. -Wherever possible we have tried to maintain the previous annotations verbatim, but in a few cases this has not been -possible, usually for technical reasons but sometimes for aesthetic ones. Our goal has been to minimise the number -of annotations you need to use as well as trying to make them more self-explanatory. The following annotations -have been changed. - -|=== -h| Old h| New -m| @RelatedTo m| @Relationship -m| @RelatedToVia m| @Relationship -m| @GraphProperty m| @Property -m| @MapResult m| @QueryResult -m| @ResultColumn m| @Property -m| Relationship Direction.BOTH m| Relationship.UNDIRECTED -|=== - -[[migration.4-0.custom_converters]] -=== Custom Type Conversion -SDN provides automatic type conversion for the obvious candidates: byte[] and Byte[] arrays, Dates, BigDecimal and -BigInteger types. In order to define bespoke type conversions for particular entity attribute, you can annotate a -field or method with `@Convert` to specify your own implementation of `org.neo4j.ogm.typeconversion.AttributeConverter`. - -You can find out more about type conversions here: <> - -[[migration.4-0.date-format]] -=== Date Format Changes -The default Date converter is <>. - -SDN 3.x and earlier represented Dates as a String value consisting of the number of milliseconds since January 1, 1970, 00:00:00 GMT. - -If you are upgrading to SDN 4.x from these versions and your application used the default, then you need to annotate your `Date` -properties with `@DateLong`. -Moreover, the property values in the graph need to be converted to numbers. - -.Upgrade Date properties to numbers -[source,cypher] ----- -MATCH (n:Foo) //All nodes which contain date properties to be migrated -WHERE NOT HAS(n.migrated)// Take the first 10k nodes that haven't been migrated yet -WITH n LIMIT 10000 -SET n.dateProperty = toInt(n.dateProperty),n.migrated=1 //where dateProperty is the date with a String value to be migrated -RETURN count(n); //Run until the statement returns zero records -//Similar process to remove the migrated flag ----- - -However, if your application already represented Dates as `@GraphProperty(propertyType = Long.class)` then simply changing this to -`@DateLong` is sufficient. - -[[migration.4-0.indexing]] -=== Indexing - -The best way to retrieve start nodes for traversals and queries is by using Neo4j's integrated index facilities. -SDN supports Index and Constraint management but differs in how it does this to previous versions. - -[[migration.4-0.obsolete-annotations]] -=== Obsolete Annotations - -The following annotations are no longer used, either because they are no longer needed, or cannot be supported via Cypher. - -* @GraphTraversal -* @RelatedToVia -* @RelatedTo -* @TypeAlias -* @Fetch - -[[migration.4-0.no-support]] -=== Features No Longer Supported - -Some features of the previous annotations have been dropped. - -Overriding @Property Types:: -Support for overriding property types via arguments to @Property has been dropped. If your attribute requires -a non-default conversion to and from a database property, you can use a <> instead. - -@Relationship enforceTargetType:: -In previous versions of Spring Data Neo4j, you would have to add an `enforceTargetType` attribute into every clashing -`@Relationship` annotation. Thanks to changes in the underlying object-graph mapping mechanism, this is no longer -necessary. - -.Clashing Relationship Types -[source,java] ----- -@NodeEntity -class Person { - @Relationship(type="OWNS") - private Car car; - - @Relationship(type="OWNS") - private Pet pet; -... -} ----- - -Cross-store Persistence:: -Neo4j is dropping XA support and therefore SDN does not provide any capability for cross-store persistence - -TypeRepresentationStrategy:: -SDN 4 replaces the existing `TypeRepresentionStrategy` configuration with a straightforward convention based on simple class-names -or entities using `@NodeEntity(label=...)` - - -AspectJ Support:: -Support for AspectJ-based persistence has been removed from SDN 4 as the write-and-read-through approach only works with an integrated, embedded database, not Neo4j server. The performance improvements in SDN 4 should make their use as a performance optimisation unnecessary anyway. - - -=== Deprecation of Neo4jTemplate - -Users that rely on a direct interaction with the database should be using the Neo4j-OGM `Session` directly. -`Neo4jTemplate` has been kept to give upgrading users a better experience. - -The `Neo4jTemplate` has been slimmed-down significantly for SDN 4. It contains the exact same methods as `Session`. In fact `Neo4jTemplate` is just a very thin wrapper with an ability to support SDN Exception Translation. -Many of the operations are no longer needed or can be expressed with a straightforward Cypher query. - -If you do use `Neo4jTemplate`, then you should code against its `Neo4jOperations` interface instead of the template class. - -The following table shows the `Neo4jTemplate` functions that have been retained for version 4 of Spring Data Neo4j. In some cases the method names have changed but the same functionality is offered under the new version. - -[cols="1,1,2"] -.Neo4j Template Method Migration -|=== -|Old Method Name|New Method Name|Notes - -|`findOne` -|`load` -|Overloaded to take optional depth parameter - -|`findAll` -|`loadAll` -|Overloaded to take optional depth parameter, also now returns a `Collection` rather than a `Result` - -|`query` -|`query` -|Return type changed from `Result` to be `Iterable` - -|`save` -|`save` -| - -|`delete` -|`delete` -| - -|`count` -|`count` -|No longer defines generic type parameters - -|`findByIndexedValue` -|`loadByProperty` -|Indexes are not supported natively, but you can index node properties in your database setup and use this method to find by them - -|=== - -To achieve the old `template.fetch(entity)` equivalent behaviour, you should call one of the load methods specifying the fetch depth as a parameter. - -It's also worth noting that `exec(GraphCallback)` and the `create...()` methods have been made obsolete by Cypher. -Instead, you should now issue a Cypher query to the new `execute` method to create the nodes or relationships that you need. - -Dynamic labels, properties and relationship types are not supported as of this version, server extensions should be considered instead. - -==== Built-In Query DSL Support -Previous versions of SDN allowed you to use a DSL to generate Cypher queries. There are many different DSL -libraries available and you're free to use which of these - or none - that you want. With Cypher changing on a regular -basis, avoiding a DSL implementation in SDN means less ongoing maintenance and less likelihood of your code -being incompatible with future versions of Neo4j. - -==== Graph Traversal and Node/Relationship Manipulation -These features cannot be supported by Cypher and have therefore been dropped from `Neo4jTemplate`. - - -Please provide feedback on the new APIs of SDN 5 and the migration needs to spring-data-neo4j@neotechnology.com or via a https://jira.spring.io/browse/DATAGRAPH[JIRA issue] - diff --git a/src/main/asciidoc/new-features.adoc b/src/main/asciidoc/new-features.adoc deleted file mode 100644 index 827a3b691..000000000 --- a/src/main/asciidoc/new-features.adoc +++ /dev/null @@ -1,33 +0,0 @@ -[[new-features]] -= New & Noteworthy - -[[new-features.5-1-0]] -== What's new in Spring Data Neo4j 5.1.0 -* Support for SpEL expressions inside @Query annotation. -* Support for optimistic locking using an @Version field. -* Support for persistence constructors: No need for default constructors any more. -* Methods annotated with @PostLoad now longer need to be public, they can be any of package protected, private and protected, thus allowing for a better design of your Domain that encapsulates your model. -* Support the IgnoreCase flag: Derived queries can be case insensitive without resorting to regular expressions or custom queries. -* Derived queries can traverse relationships and thus support nested properties several levels deep. -* Full support for using multiple Neo4j-Server instances in one SDN-module allows you to use as many repository packages as you like using different connections and target domain packages. -* Prevent eager initialization of beans needed for repository infrastructure. -* @UseBookmark can now be used in custom, composed annotations. -* Composable repositories are now supported in a CDI context. - -[[new-features.5-0-0]] -== What's new in Spring Data Neo4j 5.0.0 -* SDN 5.x is designed to work with Java 8, Neo4j 3.1+, Spring 5 and Spring Boot 2.x. -* Bolt is now the default database protocol. -* For simplicity, annotations are now only supported on entity attributes, no more on accessors. -* New id management ; database ids are not mandatory anymore. -* Smarter deep querying based on domain model structure. -* Dynamic properties allow mapping in `Map` structures. -* Projections support. -* Improved causal cluster support and bookmark management. -* More flexible configuration. -* Better Java 8 support : all type queries can now return stream results and `Optional`. Better date / time management. -* Internal metadata handling has been refactored for better reliability. -* Auditing support (since 5.0.1) - -When migrating from 4.x, please see the <>. - diff --git a/src/main/asciidoc/object-mapping/index.adoc b/src/main/asciidoc/object-mapping/index.adoc new file mode 100644 index 000000000..c31370482 --- /dev/null +++ b/src/main/asciidoc/object-mapping/index.adoc @@ -0,0 +1,3 @@ +include::mapping.adoc[leveloffset=+1] + +include::sdc-object-mapping.adoc[leveloffset=+2] diff --git a/src/main/asciidoc/object-mapping/mapping.adoc b/src/main/asciidoc/object-mapping/mapping.adoc new file mode 100644 index 000000000..a3d9903a4 --- /dev/null +++ b/src/main/asciidoc/object-mapping/mapping.adoc @@ -0,0 +1,396 @@ +[[mapping]] += Object Mapping + +The following sections will explain the process of mapping between your graph and your domain. +It is split into two parts. +The first part explains the actual mapping and the available tools for you to describe how to map nodes, relationships and properties to objects. +The second part will have a look at Spring Data's object mapping fundamentals. +It gives valuable tips on general mapping, why you should prefer immutable domain objects and how you can model them with Java or Kotlin. + +[[mapping.annotations]] +== Metadata-based Mapping + +To take full advantage of the object mapping functionality inside SDN/RX, you should annotate your mapped objects with the `@Node` annotation. +Although it is not necessary for the mapping framework to have this annotation (your POJOs are mapped correctly, even without any annotations), +it lets the classpath scanner find and pre-process your domain objects to extract the necessary metadata. +If you do not use this annotation, your application takes a slight performance hit the first time you store a domain object, +because the mapping framework needs to build up its internal metadata model so that it knows about the properties of your domain object and how to persist them. + +=== Mapping Annotation Overview + +==== From SDN/RX: + +* `@Node`: Applied at the class level to indicate this class is a candidate for mapping to the database. +* `@Id`: Applied at the field level to mark the field used for identity purpose. +* `@GeneratedValue`: Applied at the field level together with `@Id` to specify how unique identifiers should be generated. +* `@Property`: Applied at the field level to modify the mapping from attributes to properties. +* `@Relationship`: Applied at the field level to specify the details of a relationship. +* `@DynamicLabels`: Applied at the field level to specify the source of dynamic labels. + +==== From Spring Data commons + +* `@org.springframework.data.annotation.Id` same as `@Id` from SDN/RX, in fact, `@Id` is annotated with Spring Data Common's Id-annotation. +* `@CreatedBy`: Applied at the field level to indicate the creator of a node. +* `@CreatedDate`: Applied at the field level to indicate the creation date of a node. +* `@LastModifiedBy`: Applied at the field level to indicate the author of the last change to a node. +* `@LastModifiedDate`: Applied at the field level to indicate the last modification date of a node. +* `@PersistenceConstructor`: Applied at one constructor to mark it as a the preferred constructor when reading entities. +* `@Persistent`: Applied at the class level to indicate this class is a candidate for mapping to the database. +* `@Version`: Applied at field level is used for optimistic locking and checked for modification on save operations. + The initial value is zero which is bumped automatically on every update. + +Have a look at <> for all annotations regarding auditing support. + +=== The basic building block: `@Node` + +The `@Node` annotation is used to mark a class as a managed domain class, subject to the classpath scanning by the mapping context. + +To map an Object to nodes in the graph and vice versa, we need a label to identify the class to map to and from. + +`@Node` has an attribute `labels` that allows you to configure one or more labels to be used when reading and writing instances of the annotated class. +The `value` attribute is an alias for `labels`. +If you don't specify a label, than the simple class name will be used as the primary label. +In case you want to provide multiple labels, you could either: + +. Supply an array to the `labels` property. +The first element in the array will considered as the primary label. +. Supply a value for `primaryLabel` and put the additional labels in `labels`. + +The primary label should always be the most concrete label that reflects your domain class. + +For each instance of an annotated class that is written through a repository or through the Neo4j template, +one node in the graph with at least the primary label will be written. +Vice versa, all nodes with the primary label will be mapped to the instances of the annotated class. + +The `@Node` annotation is not inherited from super-types and interfaces. +You can however annotate your domain classes individually at every inheritance level. +This allows polymorphic queries: You can pass in base or intermediate classes and retrieve the correct, concrete instance for your nodes. +This is only supported for abstract bases annotated with `@Node`. +The labels defined on such a class will be used as additional labels together with the labels of the concrete implementations. + +==== Dynamic or "runtime" managed labels + +All labels implicitly defined through the simple class name or explicitly via the `@Node` annotation are static. +They cannot be changed during runtime. +If you need additional labels that can be manipulated during runtime, you can use `@DynamicLabels`. +`@DynamicLabels` is an annotation on field level and marks an attribute of type `java.util.Collection` (a `List` or `Set`) for example) as source of dynamic labels. + +If this annotation is present, all labels present on a node and not statically mapped via `@Node` and the class names, will be collected into that collection during load. +During writes, all labels of the node will be replaced with the statically defined labels plus the contents of the collection. + +WARNING: If you have other applications add additional labels to nodes, don't use `@DynamicLabels`. + If `@DynamicLabels` is present on a managed entity, the resulting set of labels will be "the truth" written to the database. + +=== Identifying instances: `@Id` + +While `@Node` creates a mapping between a class and nodes having a specific label, +we also need to make the connection between individual instances of that class (objects) and instances of the node. + +This is where `@Id` comes into play. +`@Id` marks an attribute of the class to be the unique identifier of the object. +That unique identifier is in an optimal world a unique business key or in other words, a natural key. +`@Id` can be used on all attributes with a supported simple type. + +Natural keys are however pretty hard to find. +Peoples names for example are seldom unique, change over time or worse, not everyone has a first and last name. + +We therefore support two different kind of _surrogate keys_. + +On an attribute of type `long` or `Long`, `@Id` can be used with `@GeneratedValue`. +This maps the Neo4j internal id, which is *not* a property on a node or relationship and usually not visible, +to the attribute and allows SDN/RX to retrieve individual instances of the class. + +`@GeneratedValue` provides the attribute `generatorClass`. +`generatorClass` can be used to specify a class implementing `IdGenerator`. +An `IdGenerator` is a functional interface and its `generateId` takes the primary label and the instance to generate an Id for. +We support `UUIDStringGenerator` as one implementation out of the box. + +You can also specify a Spring Bean from the application context on `@GeneratedValue` via `generatorRef`. +That bean also needs to implement `IdGenerator`, but can make use of everything in the context, including the Neo4j client or template to interact with the database. + +NOTE: Don't skip the important notes about ID handling in <> + +=== Mapping properties: `@Property` + +All attributes of a `@Node`-annotated class will be persisted as properties of Neo4j nodes and relationships. +Without further configuration, the name of the attribute in the Java or Kotlin class will be used as Neo4j property. + +If you are working with an existing Neo4j schema or just like to adapt the mapping to your needs, you will need to use `@Property`. +The `name` is used to specify the name of the property inside the database. + +=== Connecting nodes: `@Relationship` + +The `@Relationship` annotation can be used on all attributes that are not a simple type. +It is applicable on attributes of other types annotated with `@Node` or collections and maps thereof. + +The `type` or the `value` attribute allow configuration of the relationship's type, `direction` allows specifying the direction. +The default direction in SDN/RX is `Relationship.Direction#OUTGOING`. + +We support dynamic relationships. +Dynamic relationships are represented as a `Map`. +In such a case, the type of the relationship to the other domain class is given by the maps key and must not be configured through the `@Relationship`. + +==== Map relationship properties + +Neo4j supports defining properties not only on nodes but also on relationships. +To express those properties in the model SDN/RX provides `@RelationshipProperties` to be applied on a simple Java class. + +In the entity class the relationship can be modelled as before but its type has to be a `Map` with the related node as the key and the relation property class as value. + +A relationship property class and its usage may look like this: + +.Relationship properties `Roles` +[source,java] +---- +include::../../examples/reactive-web/src/main/java/org/neo4j/springframework/data/examples/spring_boot/domain/Roles.java[tags=mapping.relationship.properties] +---- + +.Defining relationship properties for an entity +[source,java,indent=0] +---- +include::../../examples/reactive-web/src/main/java/org/neo4j/springframework/data/examples/spring_boot/domain/MovieEntity.java[tags=mapping.relationship.properties] +---- + +==== Relationship query limit + +In general there is no limitation of relationships / hops for creating the queries. +SDN/RX parses the whole reachable graph from your modelled nodes. +It is possible to have self-referencing entities and self-referencing concrete instances. + +If these entities or instances for a cycle we have a strict limit of *2* repetitions of walking the same path through the graph. +E.g. You model a social network of `(:Person)-[:HAS_FRIEND]->(:Person)-[:HAS_FRIEND]...` you will only get the friends of the second degree. +If you need a more specific mapping for your domain we advise you to use custom queries. + +=== A complete example + +Putting all those together, we can create a simple domain. +We use movies and people with different roles: + +.The `MovieEntity` +==== +[source,java] +---- +include::../../examples/reactive-web/src/main/java/org/neo4j/springframework/data/examples/spring_boot/domain/MovieEntity.java[tags=mapping.annotations] +---- +<.> `@Node` is used to mark this class as a managed entity. + It also is used to configure the Neo4j label. + The label defaults to the name of the class, if you're just using plain `@Node`. +<.> Each entity has to have an id. + We use the movie's name as unique identifier. +<.> This shows `@Property` as a way to use a different name for the field than for the graph property. +<.> This configures an incoming relationship to a person. +<.> This is the constructor to be used by your application code as well as by SDN/RX. +==== + +People are mapped in two roles here, `actors` and `directors`. +The domain class is the same: + +[[mapping.complete-example.person]] +.The `PersonEntity` +==== +[source,java] +---- +include::../../examples/reactive-web/src/main/java/org/neo4j/springframework/data/examples/spring_boot/domain/PersonEntity.java[tags=mapping.annotations] +---- +==== + +NOTE: We haven't modelled the relationship between movies and people in both direction. + Why is that? + We see the `MovieEntity` as the aggregate root, owning the relationships. + On the other hand, we want to be able to pull all people from the database without selecting all the movies associated with them. + Please consider your applications use case before you try to map every relationship in your database in every direction. + While you can do this, you may end up rebuilding a graph database inside your object graph and this is not the intention of a mapping framework. + + +[[mapping.id-handling]] +== Handling and provisioning of unique IDs + +=== Using the internal Neo4j id + +The easiest way to give your domain classes an unique identifier is the combination of `@Id` and `@GeneratedValue` +on a field of type `Long` (preferable the object, not the scalar `long`, as literal `null` is the better indicator whether an instance is new or not): + +.Mutable MovieEntity with internal Neo4j id +==== +[source,java] +---- +@Node("Movie") +public class MovieEntity { + + @Id @GeneratedValue + private Long id; + + private String name; + + public MovieEntity(String name) { + this.name = name; + } +} +---- +==== + +You don't need to provide a setter for the field, SDN/RX will use reflection to assign the field, but use a setter if there is one. +If you want to create an immutable entity with an internally generated id, you have to provide a _wither_. + +.Immutable MovieEntity with internal Neo4j id +==== +[source,java] +---- +@Node("Movie") +public class MovieEntity { + + @Id @GeneratedValue + private final Long id; // <.> + + private String name; + + public MovieEntity(String name) { // <.> + this(null, name); + } + + private MovieEntity(Long id, String name) { // <.> + this.id = id; + this.name = name; + } + + public MovieEntity withId(Long id) { // <.> + if (this.id.equals(id)) { + return this; + } else { + return new MovieEntity(id, this.title); + } + } +} +---- +<.> Immutable final id field indicating a generated value +<.> Public constructor, used by the application and Spring Data +<.> Internally used constructor +<.> This is a so-called _wither_ for the `id`-attribute. + It creates a new entity and set's the field accordingly, without modifying the original entity, thus making it immutable. +==== + +You either have to provide a setter for the id attribute or something like a _wither_, if you want to have + +* Advantages: It is pretty clear that the id attribute is the surrogate business key, it takes no further effort or configuration to use it. +* Disadvantage: It is tied to Neo4js internal database id, which is not unique to our application entity only over a database lifetime. +* Disadvantage: It takes more effort to create an immutable entity + +=== Use externally provided surrogate keys + +The `@GeneratedValue` annotation can take a class implementing `org.neo4j.springframework.data.core.schema.IdGenerator` as parameter. +SDN/RX provides `InternalIdGenerator` (the default) and `UUIDStringGenerator` out of the box. +The later generates new UUIDs for each entity and returns them as `java.lang.String`. +An application entity using that would look like this: + +.Mutable MovieEntity with externally generated surrogate key +==== +[source,java] +---- +@Node("Movie") +public class MovieEntity { + + @Id @GeneratedValue(UUIDStringGenerator.class) + private String id; + + private String name; +} +---- +==== + +We have to discuss two separate things regarding advantages and disadvantages. +The assignment itself and the UUID-Strategy. +A https://en.wikipedia.org/wiki/Universally_unique_identifier[universally unique identifier] is meant to be unique for practical purposes. +To quote Wikipedia: +“Thus, anyone can create a UUID and use it to identify something with near certainty that the identifier does not duplicate one that has already been, +or will be, created to identify something else.” +Our strategy uses Java internal UUID mechanism, employing a cryptographically strong pseudo random number generator. +In most cases that should work fine, but your mileage might vary. + +That leaves the assignment itself: + +* Advantage: The application is in full control and can generate a unique key that is just unique enough for the purpose of the application. + The generated value will be stable and there won’t be a need to change it later on. +* Disadvantage: The generated strategy is applied on the application side of things. + In those days most applications will be deployed in more than one instance to scale nicely. + If your strategy is prone to generate duplicates than inserts will fail as uniques of the primary key will be violated. + So while you don’t have to think about a unique business key in this scenario, you have to think more what to generate. + +You have several options to role your own ID generator. +One is a POJO implementing a generator: + +.Naive sequence generator +==== +[source,java] +---- +import java.util.concurrent.atomic.AtomicInteger; + +import org.neo4j.springframework.data.core.schema.IdGenerator; +import org.springframework.util.StringUtils; + +public class TestSequenceGenerator implements IdGenerator { + + private final AtomicInteger sequence = new AtomicInteger(0); + + @Override + public String generateId(String primaryLabel, Object entity) { + return StringUtils.uncapitalize(primaryLabel) + + "-" + sequence.incrementAndGet(); + } +} +---- +==== + +Another option is to provide an additional Spring Bean like this: + +.Neo4jClient based ID generator +==== +[source,java] +---- +@Component +class MyIdGenerator implements IdGenerator { + + private final Neo4jClient neo4jClient; + + public MyIdGenerator(Neo4jClient neo4jClient) { + this.neo4jClient = neo4jClient; + } + + @Override + public String generateId(String primaryLabel, Object entity) { + return neo4jClient.query("YOUR CYPHER QUERY FOR THE NEXT ID") // <.> + .fetchAs(String.class).one().get(); + } +} +---- +<.> Use exactly the query or logic your need. +==== + +The generator above would be configured as a bean reference like this: + +.Mutable MovieEntity using a Spring Bean as Id generator +==== +[source,java] +---- +@Node("Movie") +public class MovieEntity { + + @Id @GeneratedValue(generatorRef = "myIdGenerator") + private String id; + + private String name; +} +---- +==== + +=== Using a business key + +We have been using a business key in the complete example's `MovieEntity` and <>. +The name of the person is assigned at construction time, both by your application and while being loaded through Spring Data. + +This is only possible, if you find a stable, unique business key, but makes great immutable domain objects. + +* Advantages: Using a business or natural key as primary key is natural. + The entity in question is clearly identified and it feels most of the time just right in the further modelling of your domain. +* Disadvantages: Business keys as primary keys will be hard to update once you realise that the key you found is not as stable as you thought. + Often it turns out that it can change, even when promised otherwise. + Apart from that, finding identifier that are truly unique for a thing is hard. diff --git a/src/main/asciidoc/object-mapping/sdc-object-mapping.adoc b/src/main/asciidoc/object-mapping/sdc-object-mapping.adoc new file mode 100644 index 000000000..9ae0136fa --- /dev/null +++ b/src/main/asciidoc/object-mapping/sdc-object-mapping.adoc @@ -0,0 +1,290 @@ +[[mapping.fundamentals]] += Spring Data Object Mapping Fundamentals + +This section covers the fundamentals of Spring Data object mapping, object creation, field and property access, mutability and immutability. + +Core responsibility of the Spring Data object mapping is to create instances of domain objects and map the store-native data structures onto those. +This means we need two fundamental steps: + +1. Instance creation by using one of the constructors exposed. +2. Instance population to materialize all exposed properties. + +[[mapping.fundamentals.object-creation]] +== Object creation + +Spring Data automatically tries to detect a persistent entity's constructor to be used to materialize objects of that type. +The resolution algorithm works as follows: + +1. If there is a no-argument constructor, it will be used. +Other constructors will be ignored. +2. If there is a single constructor taking arguments, it will be used. +3. If there are multiple constructors taking arguments, the one to be used by Spring Data will have to be annotated with `@PersistenceConstructor`. + +The value resolution assumes constructor argument names to match the property names of the entity, +i.e. the resolution will be performed as if the property was to be populated, including all customizations in mapping (different datastore column or field name etc.). +This also requires either parameter names information available in the class file or an `@ConstructorProperties` annotation being present on the constructor. + +[[mapping.fundamentals.object-creation.details]] +.Object creation internals +**** + +To avoid the overhead of reflection, Spring Data object creation uses a factory class generated at runtime by default, +which will call the domain classes constructor directly. +I.e. for this example type: + +[source, java] +---- +class Person { + Person(String firstname, String lastname) { … } +} +---- + +we will create a factory class semantically equivalent to this one at runtime: + +[source, java] +---- +class PersonObjectInstantiator implements ObjectInstantiator { + + Object newInstance(Object... args) { + return new Person((String) args[0], (String) args[1]); + } +} +---- + +This gives us a roundabout 10% performance boost over reflection. +For the domain class to be eligible for such optimization, it needs to adhere to a set of constraints: + +- it must not be a private class +- it must not be a non-static inner class +- it must not be a CGLib proxy class +- the constructor to be used by Spring Data must not be private + +If any of these criteria match, Spring Data will fall back to entity instantiation via reflection. +**** + +[[mapping.fundamentals.property-population]] +== Property population + +Once an instance of the entity has been created, Spring Data populates all remaining persistent properties of that class. +Unless already populated by the entity's constructor (i.e. consumed through its constructor argument list), +the identifier property will be populated first to allow the resolution of cyclic object references. +After that, all non-transient properties that have not already been populated by the constructor are set on the entity instance. +For that we use the following algorithm: + +1. If the property is immutable but exposes a _wither_ method (see below), we use the _wither_ to create a new entity instance with the new property value. +2. If property access (i.e. access through getters and setters) is defined, we are invoking the setter method. +3. By default, we set the field value directly. + +[[mapping.fundamentals.property-population.details]] +.Property population internals +**** +Similarly to our <> we also use +Spring Data runtime generated accessor classes to interact with the entity instance. + +[source, java] +---- +class Person { + + private final Long id; + private String firstname; + private @AccessType(Type.PROPERTY) String lastname; + + Person() { + this.id = null; + } + + Person(Long id, String firstname, String lastname) { + // Field assignments + } + + Person withId(Long id) { + return new Person(id, this.firstname, this.lastame); + } + + void setLastname(String lastname) { + this.lastname = lastname; + } +} +---- + +.A generated Property Accessor +==== +[source, java] +---- +class PersonPropertyAccessor implements PersistentPropertyAccessor { + + private static final MethodHandle firstname; <2> + + private Person person; <1> + + public void setProperty(PersistentProperty property, Object value) { + + String name = property.getName(); + + if ("firstname".equals(name)) { + firstname.invoke(person, (String) value); <2> + } else if ("id".equals(name)) { + this.person = person.withId((Long) value); <3> + } else if ("lastname".equals(name)) { + this.person.setLastname((String) value); <4> + } + } +} +---- +<.> PropertyAccessor's hold a mutable instance of the underlying object. + This is, to enable mutations of otherwise immutable properties. +<.> By default, Spring Data uses field-access to read and write property values. + As per visibility rules of `private` fields, `MethodHandles` are used to interact with fields. +<.> The class exposes a `withId(…)` method that's used to set the identifier, + e.g. when an instance is inserted into the datastore and an identifier has been generated. Calling `withId(…)` creates a new `Person` object. All subsequent mutations will take place in the new instance leaving the previous untouched. +<.> Using property-access allows direct method invocations without using `MethodHandles`. +==== + +This gives us a roundabout 25% performance boost over reflection. +For the domain class to be eligible for such optimization, it needs to adhere to a set of constraints: + +- Types must not reside in the default or under the `java` package. +- Types and their constructors must be `public` +- Types that are inner classes must be `static`. +- The used Java Runtime must allow for declaring classes in the originating `ClassLoader`. + Java 9 and newer impose certain limitations. + +By default, Spring Data attempts to use generated property accessors and falls back to reflection-based ones if a limitation is detected. +**** + +Let's have a look at the following entity: + +.A sample entity +==== +[source, java] +---- +class Person { + + private final @Id Long id; <1> + private final String firstname, lastname; <2> + private final LocalDate birthday; + private final int age; <3> + + private String comment; <4> + private @AccessType(Type.PROPERTY) String remarks; <5> + + static Person of(String firstname, String lastname, LocalDate birthday) { <6> + + return new Person(null, firstname, lastname, birthday, + Period.between(birthday, LocalDate.now()).getYears()); + } + + Person(Long id, String firstname, String lastname, LocalDate birthday, int age) { <6> + + this.id = id; + this.firstname = firstname; + this.lastname = lastname; + this.birthday = birthday; + this.age = age; + } + + Person withId(Long id) { <1> + return new Person(id, this.firstname, this.lastname, this.birthday); + } + + void setRemarks(String remarks) { <5> + this.remarks = remarks; + } +} +---- +==== +<.> The identifier property is final but set to `null` in the constructor. + The class exposes a `withId(…)` method that's used to set the identifier, e.g. when an instance is inserted into the datastore and an identifier has been generated. + The original `Person` instance stays unchanged as a new one is created. + The same pattern is usually applied for other properties that are store managed but might have to be changed for persistence operations. +<.> The `firstname` and `lastname` properties are ordinary immutable properties potentially exposed through getters. +<.> The `age` property is an immutable but derived one from the `birthday` property. + With the design shown, the database value will trump the defaulting as Spring Data uses the only declared constructor. + Even if the intent is that the calculation should be preferred, it's important that this constructor also takes `age` as parameter (to potentially ignore it) + as otherwise the property population step will attempt to set the age field and fail due to it being immutable and no wither being present. +<.> The `comment` property is mutable is populated by setting its field directly. +<.> The `remarks` properties are mutable and populated by setting the `comment` field directly or by invoking the setter method for +<.> The class exposes a factory method and a constructor for object creation. + The core idea here is to use factory methods instead of additional constructors to avoid the need for constructor disambiguation through `@PersistenceConstructor`. + Instead, defaulting of properties is handled within the factory method. + +== General recommendations + +* _Try to stick to immutable objects_ -- + Immutable objects are straightforward to create as materializing an object is then a matter of calling its constructor only. + Also, this avoids your domain objects to be littered with setter methods that allow client code to manipulate the objects state. + If you need those, prefer to make them package protected so that they can only be invoked by a limited amount of co-located types. + Constructor-only materialization is up to 30% faster than properties population. +* _Provide an all-args constructor_ -- + Even if you cannot or don't want to model your entities as immutable values, + there's still value in providing a constructor that takes all properties of the entity as arguments, including the mutable ones, + as this allows the object mapping to skip the property population for optimal performance. +* _Use factory methods instead of overloaded constructors to avoid ``@PersistenceConstructor``_ -- + With an all-argument constructor needed for optimal performance, we usually want to expose more application use case specific constructors + that omit things like auto-generated identifiers etc. + It's an established pattern to rather use static factory methods to expose these variants of the all-args constructor. +* _Make sure you adhere to the constraints that allow the generated instantiator and property accessor classes to be used_ +* _For identifiers to be generated, still use a final field in combination with a wither method_ +* _Use Lombok to avoid boilerplate code_ -- + As persistence operations usually require a constructor taking all arguments, their declaration becomes a tedious repetition of boilerplate parameter to field assignments that can best be avoided by using Lombok's `@AllArgsConstructor`. + +[[mapping.fundamentals.kotlin]] +== Kotlin support + +Spring Data adapts specifics of Kotlin to allow object creation and mutation. + +=== Kotlin object creation + +Kotlin classes are supported to be instantiated , all classes are immutable by default and require explicit property declarations to define mutable properties. +Consider the following `data` class `Person`: + +==== +[source,java] +---- +data class Person(val id: String, val name: String) +---- +==== + +The class above compiles to a typical class with an explicit constructor. +We can customize this class by adding another constructor and annotate it with `@PersistenceConstructor` to indicate a constructor preference: + +==== +[source,java] +---- +data class Person(var id: String, val name: String) { + + @PersistenceConstructor + constructor(id: String) : this(id, "unknown") +} +---- +==== + +Kotlin supports parameter optionality by allowing default values to be used if a parameter is not provided. +When Spring Data detects a constructor with parameter defaulting, then it leaves these parameters absent +if the data store does not provide a value (or simply returns `null`) so Kotlin can apply parameter defaulting. +Consider the following class that applies parameter defaulting for `name` + +==== +[source,java] +---- +data class Person(var id: String, val name: String = "unknown") +---- +==== + +Every time the `name` parameter is either not part of the result or its value is `null`, then the `name` defaults to `unknown`. + +=== Property population of Kotlin data classes + +In Kotlin, all classes are immutable by default and require explicit property declarations to define mutable properties. +Consider the following `data` class `Person`: + +==== +[source,java] +---- +data class Person(val id: String, val name: String) +---- +==== + +This class is effectively immutable. +It allows to create new instances as Kotlin generates a `copy(…)` method that creates new object instances +copying all property values from the existing object and applying property values provided as arguments to the method. diff --git a/src/main/asciidoc/preface.adoc b/src/main/asciidoc/preface.adoc deleted file mode 100644 index 90515b1af..000000000 --- a/src/main/asciidoc/preface.adoc +++ /dev/null @@ -1,106 +0,0 @@ -[[preface]] -= Preface - -The Spring Data Neo4j project applies Spring Data concepts to the development of solutions using the Neo4j graph data store. -We provide _"repositories"_ as a high-level abstraction for storing and querying documents. - -The next section provides some basic introduction to Spring and Graph databases. - -The Spring Data Commons section then describes the common foundation of all Spring Data projects: the repositories. -_This part is taken from from SD commons project and may include examples from other persistence type such as JPA_. - -The rest of the document describes the Spring Data Neo4j features and specifics. -It includes the <>, and the <>, on which SDN is based on. -It assumes the user is familiar with the Neo4j graph database as well as Spring concepts. - -[[preface.spring-data]] -== Spring and Spring Data - -Spring Data uses Spring framework's https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html[core] functionality, -such as the https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#beans[IoC] container, -https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#core-convert[type conversion system], -https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#expressions[expression language], -https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/integration.html#jmx[JMX integration], -and portable https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#dao-exceptions[DAO exception hierarchy]. -While it is not important to know the Spring APIs, understanding the concepts behind them is. -At a minimum, the idea behind IoC should be familiar for whatever IoC container you choose to use. - -The core functionality of the Neo4j support can be used directly, through the Neo4j-Session. -This class corresponds to the Hibernate Session or JPA EntityManager. - -To learn more about Spring, you can refer to the comprehensive documentation that explains in detail the Spring Framework. -There are a lot of articles, blog entries and books on the matter - take a look at the Spring framework https://spring.io/docs[home page ] for more information. - - -[[preface.nosql]] -== NoSQL and Graph databases - -A graph database is a storage engine that is specialised in storing and retrieving vast networks of information. -It efficiently stores data as nodes with relationships to other or even the same nodes, -thus allowing high-performance retrieval and querying of those structures. -Properties can be added to both nodes and relationships. -Nodes can be labelled by zero or more labels, relationships are always directed and named. - -Graph databases are well suited for storing most kinds of domain models. -In almost all domains, there are certain things connected to other things. -In most other modelling approaches, the relationships between things are reduced to a single link without identity and attributes. -Graph databases allow to keep the rich relationships that originate from the domain equally well-represented in the database without resorting to also modelling the relationships as "things". -There is very little "impedance mismatch" when putting real-life domains into a graph database. - - -[[preface.nosql.neo4j]] -=== Introducing Neo4j - -https://neo4j.com/[Neo4j] is an open source NoSQL graph database. -It is a fully transactional database (ACID) that stores data structured as graphs consisting of nodes, connected by relationships. -Inspired by the structure of the real world, it allows for high query performance on complex data, while remaining intuitive and simple for the developer. - -The starting point for learning about Neo4j is https://neo4j.com/[neo4j.com]. -Here is a list of useful resources: - -* The https://neo4j.com/docs/[Neo4j documentation] introduces Neo4j and contains links to getting started guides, reference documentation and tutorials. -* The https://neo4j.com/sandbox/[online sandbox] provides a convenient way to interact with a Neo4j instance in combination with the online https://neo4j.com/developer/get-started/[tutorial]. -* Neo4j https://neo4j.com/developer/java/[Java Bolt Driver] -* Neo4j https://neo4j.com/docs/ogm-manual/current/[Neo4j Object Graph Mapper (OGM) Library] -* Several https://neo4j.com/books/[books] available for purchase and https://www.youtube.com/neo4j[videos] to watch. - - -[[preface.requirements]] -== Requirements - -Spring Data Neo4j 5.1.x at minimum, requires: - -* JDK Version 8 and above. -* Neo4j Graph Database 3.1 and above. -* Spring Framework {springVersion} and above. - -If you plan on altering the version of the Neo4j-OGM make sure it is a 3.0.0+ release. - -[[preface.additional-resources]] -== Additional Resources - -[[preface.additional-resources.metadata]] -=== Project metadata - -* Version control - https://github.com/spring-projects/spring-data-neo4j -* Bugtracker - https://jira.spring.io/browse/DATAGRAPH -* Release repository - https://repo.spring.io/libs-release -* Milestone repository - https://repo.spring.io/libs-milestone -* Snapshot repository - https://repo.spring.io/libs-snapshot - -[[preface.additional-resources.getting-help]] -=== Getting Help & give feedback - -If you encounter issues, you can use the templates for reporting issues: https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template. -If you are looking for advice, here are some more resources: - -* The https://github.com/neo4j-examples/sdn-university[sample project: SDN University]. -More example projects for Spring Data Neo4j are available in the https://github.com/neo4j-examples?query=sdn[Neo4j-Examples] repository. - -* The https://projects.spring.io/spring-data-neo4j[Spring Data Neo4j project site] contains links to basic project information such as source code, JavaDocs, issue tracking, etc. -* Talk and share with the community on the https://neo4j-users.slack.com[SDN/Neo4j-OGM Slack channel] -* For more detailed questions, use https://stackoverflow.com/questions/tagged/spring-data-neo4j[Spring Data Neo4j on StackOverflow] -* For professional support feel free to contact https://www.neo4j.com[Neo4j] or https://www.graphaware.com[GraphAware]. - -If you are new to Spring as well as to Spring Data, look for information about https://spring.io/projects[Spring projects]. - diff --git a/src/main/asciidoc/reference/auditing.adoc b/src/main/asciidoc/reference/auditing.adoc deleted file mode 100644 index aa719173b..000000000 --- a/src/main/asciidoc/reference/auditing.adoc +++ /dev/null @@ -1,26 +0,0 @@ -[[reference_programming-auditing]] -=== Auditing - -Spring Data Neo4j integrates into the Spring Data auditing infrastructure -to keep track of who created or changed an entity and the point in time this happened. - -While Spring Data Neo4j uses the same annotations for auditing as all Spring Data modules do, auditing support itself has to be explicitly enabled. -To enable Spring Data Neo4j's auditing, use `@EnableNeo4jAuditing` on a `@Configuration`-class as shown in <>. - -[source,java] -[[EnabledAuditing]] -.Neo4jConfiguration.java ----- -import org.springframework.data.neo4j.annotation.EnableNeo4jAuditing; - -@Configuration -@EnableNeo4jAuditing -public class Neo4jConfiguration {} ----- - -[NOTE] -If you are working with custom ids by setting them directly or using your own `IdStrategy`, the auditing support is limited. -It it is not possible for Spring Data Neo4j to figure out if an entity is new or already exists in the database. -As a consequence the fields annotated with `@CreatedBy` and `@CreatedDate` will never get filled. - -Please refer to the <> section of the shared Spring Data reference for further details. diff --git a/src/main/asciidoc/reference/getting-started.adoc b/src/main/asciidoc/reference/getting-started.adoc deleted file mode 100644 index e33d9ea8a..000000000 --- a/src/main/asciidoc/reference/getting-started.adoc +++ /dev/null @@ -1,348 +0,0 @@ -[[reference.getting_started]] -= Getting started - -Depending on what type of project you are doing there are several options when it comes to creating a new SDN project: - -* Use https://start.spring.io (for Spring Boot projects) -* Use the https://spring.io/tools/sts[Spring Tool Suite] (based on eclipse) -* Adding the required libraries using your dependency management tool - -If you plan on using Neo4j in server mode, you will also need a running instance. -Refer to the Getting Started section of the https://neo4j.com/docs/developer-manual/current/get-started[Neo4j Developer manual] on how to get that up and running. - -== Using Spring Boot - -To create a Spring Boot project simply go to https://start.spring.io and specify a group and artifact like: `org.spring.neo4j.example` and `demo`. -In the _Dependencies_ box type: "Neo4j". -You can also add any other Spring support like "Web" etc. -Once you are satisfied with your dependencies hit the generate button, download the zip and unzip into your workspace. - - -== Using Spring Tool Suite - -To create a Spring project in STS go to File → New → Spring Template Project → Simple Spring Utility Project → press _Yes_ when prompted. -Then enter a project and a package name such as `org.spring.neo4j.example`. - -Then add the following to `pom.xml` dependencies section. - -[source,xml,subs="+attributes"] ----- - - - - - - org.springframework.data - spring-data-neo4j - {version} - - - ----- - -Also change the version of Spring in the `pom.xml` to be - -[source,xml,subs="+attributes"] ----- -{springVersion} ----- - - -[[reference.getting_started.dependencies]] -== Using Dependency Management - -Spring Data Neo4j projects can be built using Maven, Gradle or any other tool that supports Maven's repository system. - -NOTE: Adding the depedency-management-block is not necessary in a Spring Boot based project. Spring Boot manages Spring Data dependencies and releasetrains automatically. - -[[reference.getting_started.dependencies.maven]] -=== Maven - -By default, SDN will use the Bolt driver to connect to Neo4j and you don't need to declare it as a separate dependency in your `pom.xml`. -If you want to use the embedded or HTTP drivers in your production application, you must add the following dependencies as well. - -[source,xml,subs="+attributes"] ----- - - - - org.springframework.data - spring-data-releasetrain - ${spring-data-releasetrain.version} - import - pom - - - - - - - org.springframework.data - spring-data-neo4j - - - - - org.neo4j - neo4j-ogm-embedded-driver - - - - - org.neo4j - neo4j-ogm-http-driver - - ----- - - -[[reference.getting_started.dependencies.testing]] -==== Testing - -.Maven dependencies for testing -[source,xml,subs="+attributes"] ----- - - org.neo4j.test - neo4j-harness - 3.2.5 - test - - - org.springframework - spring-test - ${spring.version} - test - ----- - -NOTE: Spring Boot brings `spring-test` through `spring-boot-starter-test`, which simplifies testing a lot. You don't need to declare `spring-test` explicitly. - -//todo check versions and conflicts in current Spring Boot configurations -[NOTE] -==== -Using neo4j-harness brings in a dependency on Jetty container. -If you use Spring Boot dependency management the version may be set to an incompatible version. -This may be avoided by overriding `jetty.version` property to a version required by neo4j server. -[source,xml] ----- - - - 9.2.22.v20170606 - ----- - -Also having the jetty dependency on the classpath might cause your application to use jetty as a servlet container in your tests -instead of defaulting to Tomcat. You can avoid that e.g. by forcing the EmbeddedTomcat auto-configuration. - -[source,java] ----- -@SpringBootApplication -// Import tomcat autoconfig to avoid starting Jetty, which is on classpath because of neo4j dependencies -@Import(EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat.class) ----- -==== - - -[[reference.getting_started.dependencies.gradle]] -=== Gradle - -Gradle dependencies are basically the same as Maven: - -[source,groovy] ----- -dependencies { - compile 'org.springframework.data:spring-data-neo4j:{version}' - - // add this dependency if you want to use the embedded driver - compile 'org.neo4j:neo4j-ogm-embedded-driver:{ogm-version}' - - // add this dependency if you want to use the Http driver - compile 'org.neo4j:neo4j-ogm-http-driver:{ogm-version}' - -} ----- - -== Examples -There is a https://github.com/spring-projects/spring-data-examples[github repository with several examples] that you can download and play around with to get a feel for how the library works. - - -[[reference.getting_started.spring-configuration]] -== Configuration - -[NOTE] -For those not familiar with how to configure the Spring container using Java based bean metadata instead of XML based metadata see the high-level introduction in the reference docs https://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/new-in-3.0.html#new-java-configuration[here] as well as the detailed documentation https://docs.spring.io/spring/docs/4.2.9.RELEASE/spring-framework-reference/html/beans.html#beans-java-instantiating-container[here]. - -For most applications the following configuration is all that's needed to get up and running. - -.Spring Data Neo4j repositories using JavaConfig -[source,java] ----- -@Configuration -@EnableNeo4jRepositories(basePackages = "org.neo4j.example.repository") -@EnableTransactionManagement -public class MyConfiguration { - - @Bean - public SessionFactory sessionFactory() { - // with domain entity base package(s) - return new SessionFactory(configuration(), "org.neo4j.example.domain"); - } - - @Bean - public org.neo4j.ogm.config.Configuration configuration() { - ConfigurationSource properties = new ClasspathConfigurationSource("ogm.properties"); - org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration.Builder(properties).build(); - return configuration; - } - - @Bean - public Neo4jTransactionManager transactionManager() { - return new Neo4jTransactionManager(sessionFactory()); - } - -} ----- - -Here we wire up a `SessionFactory` configured from defaults. -We can change these defaults by providing an `ogm.properties` file at the root of the classpath or by passing in a `org.neo4j.ogm.config.Configuration` object. -The last infrastructure component declared here is the `Neo4jTransactionManager`. -We finally activate Spring Data Neo4j repositories using the `@EnableNeo4jRepositories` annotation. -If no base package is configured it will use the one the configuration class resides in. - -Note that you will have to activate `@EnableTransactionManagement` explicitly to get annotation based -configuration at facades working as well as define an instance of this `Neo4jTransactionManager` with the bean name `transactionManager`. -The example above assumes you are using component scanning. - -To allow your query methods to be transactional simply use `@Transactional` at the repository interface you define. - - -[[reference.getting_started.driver]] -=== Driver Configuration - -SDN provides support for connecting to Neo4j using different drivers. - -The following drivers are available. - -- Http driver -- Embedded driver -- Bolt driver - -To configure the driver programmatically, create a Neo4j-OGM `Configuration` bean and pass it as the first argument to the `SessionFactory` constructor in your Spring configuration: - -[source,java] -.Java Configuration ----- -@Bean -public org.neo4j.ogm.config.Configuration configuration() { - org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration.Builder() - .uri("bolt://localhost") - .credentials("user", "secret") - .build(); - return configuration; -} - - -@Bean -public SessionFactory sessionFactory() { - return new SessionFactory(configuration(), ); <1> -} ----- -<1> `packages` is a list of Java packages containing the annotated domain model. - -Configuration can also be initialized from an external file like this. - -[source,java] ----- -@Bean -public org.neo4j.ogm.config.Configuration configuration() { - ConfigurationSource properties = new ClasspathConfigurationSource("db.properties"); - return new org.neo4j.ogm.config.Configuration.Builder(properties).build(); -} ----- -where `db.properties` looks like -[source,properties] ----- -URI=bolt://localhost -username=user -password=secret -connection.pool.size=... #see Java driver doc -encryption.level=... #see Java driver doc -trust.strategy=... #see Java driver doc -trust.certificate.file=... #see Java driver doc -connection.liveness.check.timeout=... #see Java driver doc -verify.connection=... #see Java driver doc ----- - -[NOTE] -The driver is automatically inferred from the URI scheme. - -[NOTE] -To set up authentication, TLS or other advanced options please see the Configuration section of the Neo4j-OGM Reference. - -[NOTE] -As of 4.2.0 the Neo4j-OGM embedded driver no longer ships with the Neo4j kernel. Users are expected to provide this dependency through their dependency management system. - - - -[[reference.getting_started.spring-configuration.boot]] -=== Spring Boot Applications - -Spring Boot 2.0 works straight out of the box with Spring Data Neo4j 5. - -Update your Spring Boot Maven POM with the following. -You may need to add `` depending on versioning (when using milestone or snapshot versions). - -[source,xml] ----- - ... - - - org.springframework.boot - spring-boot-starter-data-neo4j - - - ... ----- - -Then add to your Spring Boot configuration class these annotations: - -[source,xml] ----- -@EnableNeo4jRepositories("com.company.project.repository") -@EntityScan(basePackages = "com.company.project.domain") ----- - -==== Configuring Events with Boot - -When defining a Spring `EventListener`. Simply defining a `@Bean` will automatically register it with the `SessionFactory`. - -== Connecting to Neo4j - -The `SessionFactory` is needed by SDN to create instances of `org.neo4j.ogm.session.Session` as required. -When constructed, it sets up the object-graph mapping metadata, which is then used across all `Session` objects that it creates. -As seen in the above example, the packages to scan for domain object metadata should be provided to the `SessionFactory` constructor. - -Your application typically connects only to one instance of Neo4j. -Therefore there is usually only one `SessionFactory` per application. -This `SessionFactory` should be configured in such a way that it scans all necessary packages. -`@EnableNeo4jRepositories` detects one single bean of type `SessionFactory` out of the box and you don't need to configure anything more. - -In cases however where your setup requires the application to connect to multiple different instances of Neo4j, SDN allows you to specify that instance in `@EnableNeo4jRepositories` as follows: - -[source,java] ----- -@Configuration -@EnableNeo4jRepositories( - basePackages = "org.neo4j.example.repository", - sessionFactoryRef = "mySpecialSessionFactory" // <1> -) -@EnableTransactionManagement -public class MyConfiguration { -} ----- -<1> Use the name of the session factory you want to be bound to the repositories for that package - -In cases like this SDN also supports multiple declarations of `@EnableNeo4jRepositories` that target different packages. -Our recommendation however is connecting one application to one instance. -If your domains are so different that they are stored in different databases, a microservices approach might be a better fit to your application. diff --git a/src/main/asciidoc/reference/introduction.adoc b/src/main/asciidoc/reference/introduction.adoc deleted file mode 100644 index d1c505fd1..000000000 --- a/src/main/asciidoc/reference/introduction.adoc +++ /dev/null @@ -1,39 +0,0 @@ -[[reference.introduction]] -= Introduction - -It is important to understand how a Spring Data Neo4j (SDN) application is structured because this could have implications in how you design your application. - -[[reference.architecture]] -== SDN Architecture - -A high level look of the architecture looks like: - -image::SDN-Architecture.png[Spring Data Neo4j Architecture,align="center",width="653",height="896"] - -* *Drivers* are used to connect to the database. -At the moment these come in three variants: -_Embedded_, _HTTP_ and the binary protocol _Bolt_. -The latter uses the official Neo4j Java driver. - -* *Neo4j Object Graph Mapper* (Neo4j-OGM) - -* *Spring Data Neo4j* provides code on top of Neo4-OGM to help quickly build Spring based Neo4j apps. - -Those coming from other Spring Data projects or are familiar with ORM products like JPA or Hibernate may quickly recognise this architecture. - -[NOTE] -Please read the <> for a smooth upgrade from Spring Data Neo4j 3. - - -[[reference.how-to-use-this-reference]] -== How to use this reference - - -Spring Data Neo4j is largely broken up into two main components: - -- <>: Provides close integration between Spring Data and Neo4j-OGM, the main underlying technology used in SDN. -- <>: Provides Spring Repository support. - -It is recommended SDN developers also familiarise themselves with Neo4j-OGM. The Neo4j-OGM reference documentation has been reproduced after this -section for convenience. - diff --git a/src/main/asciidoc/reference/neo4j-repositories.adoc b/src/main/asciidoc/reference/neo4j-repositories.adoc deleted file mode 100644 index 54a472d59..000000000 --- a/src/main/asciidoc/reference/neo4j-repositories.adoc +++ /dev/null @@ -1,693 +0,0 @@ -[[neo4j.repositories]] -= Neo4j Repositories - -[[neo4j-repo-intro]] -== Introduction - -This chapter will point out the features for repository support for Neo4j and the Neo4j-OGM. -This builds on the core repository support explained in <>. -So make sure you have got a sound understanding of the basic concepts explained there. - -The following table outlines the repositories functionality currently either supported, partially supported or not supported in SDN: -// NME -[frame="topbot",options="header"] -|====================== -| Feature | Supported in SDN | Notes -| `CrudRepository` support | icon:check[] | -| `PagingAndSortingRepository` support | icon:check[] | -| Derived Count Queries | icon:check[] | -| JavaConfig annotation based configuration | icon:check[] | -| XML based configuration | icon:check[] | -| Multi Spring Data module support | icon:check[] | -| Configurable Query Lookup Strategy | icon:times[] | -| Derived Query support | icon:check[] | See supported keywords for query methods below -| Derived Query Property expressions support | icon:times[] | -| Paging and Slice support | icon:check[] | -| Derived query paging limit support | icon:check[] | -| Java 8 Streaming and Optional support | icon:check[] | -| `@Async` support | icon:check[] | -| Custom behaviour on repositories | icon:check[] | -| `QueryDslPredicateExecutor` support | icon:times[] | -| Web support (incl. Spring Data REST) | icon:minus[] | Partial: QueryDSL not supported. -| Repository populators | icon:times[] | -|====================== - -== Usage - -The `Repository` instances are created automatically through Spring and can be autowired into your Spring beans as required. -You don't have to provide an implementation for the interfaces you declared. - -.Using basic `Neo4jRepository` CRUD-methods -[source,java] ----- -@Repository -public interface PersonRepository extends Neo4jRepository {} - -public class MySpringBean { - - private final PersonRepository repo; - - @Autowired - public MySpringBean(PersonRepository repo) { - this.repo = repo; - } -} - -// then you can use the repository as you would any other object -Person michael = repo.save(new Person("Michael", 36)); - -Optional dave = repo.findById(123); - -long numberOfPeople = repo.count(); ----- - -The recommended way of providing repositories is to define a repository interface per aggregate root and not for every domain class. -The underlying Spring repository infrastructure will automatically detect these repositories, along with additional implementation classes, -and create an injectable repository implementation to be used in services or other Spring beans. - -The repositories provided by Spring Data Neo4j build on the composable repository infrastructure in https://docs.spring.io/spring-data/data-commons/docs/current/reference/html/[Spring Data Commons]. -These allow for interface-based composition of repositories consisting of provided default implementations for certain interfaces and additional custom implementations for other methods. - -Spring Data Neo4j comes with a single `org.springframework.data.repository.PagingAndSortingRepository` specialisation called `Neo4jRepository` used for all object-graph mapping repositories. -This sub-interface also adds specific finder methods that take a _depth_ argument to control the horizon with which related entities are fetched and saved. -Generally, it provides all the desired repository methods. -If other operations are required then the additional repository interfaces should be added to the individual interface declaration. - - -== Query Methods - -=== Query and Finder Methods - -Most of the data access operations you usually trigger on a repository will result in a query being executed against the Neo4j database. -Defining such a query is just a matter of declaring a method on the repository interface. - -.`PersonRepository` with query methods -==== -[source,java] ----- -public interface PersonRepository extends PagingAndSortingRepository { - - List findByLastname(String lastname); <1> - - Page findByFirstname(String firstname, Pageable pageable); <2> - - Person findByShippingAddresses(Address address); <3> - - Stream findAllBy(); <4> -} ----- -<1> The method shows a query for all people with the given last name. -The query will be derived parsing the method name for constraints which can be concatenated with `And` and `Or`. -Thus the method name will result in a query expression of `{"lastname" : lastname}`. - -<2> Applies pagination to a query. -Just equip your method signature with a `Pageable` parameter and let the method return a `Page` instance and we will automatically page the query accordingly. - -<3> Shows that you can query based on properties which are not a primitive type. - -<4> Uses a Java 8 `Stream` which reads and converts individual elements while iterating the stream. -==== - - -[cols="1,2,3", options="header"] -.Supported keywords for query methods -|=============== -|Keyword -|Sample -|Cypher snippet - -|`After` -|`findByLaunchDateAfter(Date date)` -|`n.launchDate > date` - -|`Before` -|`findByLaunchDateBefore(Date date)` -|`n.launchDate < date` - -|`Containing` (String) -|`findByNameContaining(String namePart)` -|`n.name CONTAINS namePart` - -|`Containing` (Collection) -| -`findByEmailAddressesContains(Collection addresses)` - -`findByEmailAddressesContains(String address)` -| -`ANY(collectionFields IN [addresses] WHERE collectionFields in n.emailAddresses)` - -`ANY(collectionFields IN address WHERE collectionFields in n.emailAddresses)` - -|`In` -|`findByNameIn(Iterable names)` -|`n.name IN names` - -|`Between` -|`findByScoreBetween(double min, double max)` + -`findByScoreBetween(Range range)` -|`n.score >= min AND n.score \<= max` + -Depending on the `Range` definition `n.score >= min AND n.score \<= max` or -`n.score > min AND n.score < max` - -|`StartingWith` -|`findByNameStartingWith(String nameStart)` -|`n.name STARTS WITH nameStart` - -|`EndingWith` -|`findByNameEndingWith(String nameEnd)` -|`n.name ENDS WITH nameEnd` - -|`Exists` -|`findByNameExists()` -|`EXISTS(n.name)` - -|`True` -|`findByActivatedIsTrue()` -|`n.activated = true` - -|`False` -|`findByActivatedIsFalse()` -|`NOT(n.activated = true)` - -|`Is` -|`findByNameIs(String name)` -|`n.name = name` - -|`NotNull` -|`findByNameNotNull()` -|`NOT(n.name IS NULL)` - -|`Null` -|`findByNameNull()` -|`n.name IS NULL` - -|`GreaterThan` -|`findByScoreGreaterThan(double score)` -|`n.score > score` - -|`GreaterThanEqual` -|`findByScoreGreaterThanEqual(double score)` -|`n.score >= score` - -|`LessThan` -|`findByScoreLessThan(double score)` -|`n.score < score` - -|`LessThanEqual` -|`findByScoreLessThanEqual(double score)` -|`n.score \<= score` - -|`Like` -|`findByNameLike(String name)` -|`n.name =~ name` - -|`NotLike` -|`findByNameNotLike(String name)` -|`NOT(n.name =~ name)` - -|`Near` -|`findByLocationNear(Distance distance, Point point)` -|`distance( point(n),point({latitude:lat, longitude:lon}) ) < distance` - -|`Regex` -|`findByNameRegex(String regex)` -|`n.name =~ regex` - -|`And` -|`findByNameAndDescription(String name, String description)` -|`n.name = name AND n.description = description` - -|`Or` -|`findByNameOrDescription(String name, String description)` -|`n.name = name OR n.description = description` (Cannot be used to OR nested properties) - -|=============== - - -[[reference_programming_model_annotatedQueries]] -=== Annotated queries - -Queries using the Cypher graph query language can be supplied with the `@Query` annotation. - -That means a repository method annotated with + -`@Query("MATCH (:Actor {name:$name})-[:ACTED_IN]\->(m:Movie) return m")` + -will use the supplied query to retrieve data from Neo4j. - -The named or indexed parameter `$param` will be substituted by the actual method parameter. -Node and relationship entities are handled directly and converted into their respective ids. -All other parameters types are provided directly (i.e. `String`, `Long`, etc.). - -There is special support for the `Pageable` parameter from Spring Data Commons, which is supported to add programmatic paging and slicing -(alternatively static paging and sorting can be supplied in the query string itself). - -If it is required that paged results return the correct total count, the @Query annotation can be supplied with a count query in the countQuery attribute. -This query is executed separately after the result query and its result is used to populate the number of elements on the page. - -[NOTE] -==== -Custom queries do not support a custom depth. -Additionally, `@Query` does not support mapping a path to domain entities, as such, a path should not be returned from a Cypher query. -Instead, return nodes and relationships to have them mapped to domain entities. -==== - -=== Named queries - -Sometimes it makes sense to extract e.g. a long query. -Spring Data Neo4j will look in the `META-INF/neo4j-named-queries.properties` file to find named queries. -If you provide a query property like `User.findByQuery=MATCH (e) WHERE e.name=$name RETURN e` you can refer to this method by providing a finder method in your repository. -The repository has to support the given entity type (in this example `User`) and the method has to be named as the defined one (`findByQuery`). -As you can see in the example it is possible to parameterize the query. -Named count query can be specified by adding `.countQuery` suffix to the related query property key. For example, if the next query should return paged result `User.findAllByQuery=MATCH (e) RETURN e`, the count query can be specified by the following way: `User.findAllByQuery.countQuery=MATCH (e) RETURN count(e)`. - -=== Query results - -Typical results for queries are `Iterable`, `Iterable>` or simply `Type`. -Nodes and relationships are converted to their respective entities (if they exist). -Other values are converted using the registered <> (e.g. enums). - -=== Cypher examples - -`MATCH (n) WHERE id(n)=9 RETURN n`:: -returns the node with id 9 - -`MATCH (movie:Movie {title:'Matrix'}) RETURN movie`:: -returns the nodes which are indexed with title equal to 'Matrix' - -`MATCH (movie:Movie {title:'Matrix'})<-[:ACTS_IN]-(actor) RETURN actor.name`:: -returns the names of the actors that have a ACTS_IN relationship to the movie node for 'Matrix' - -`MATCH (movie:Movie {title:'Matrix'})<-[r:RATED]-(user) WHERE r.stars > 3 RETURN user.name, r.stars, r.comment`:: -returns users names and their ratings (>3) of the movie titled 'Matrix' - -`MATCH (user:User {name='Michael'})-[:FRIEND]-(friend)-[r:RATED]\->(movie) RETURN movie.title, AVG(r.stars), COUNT(\*) ORDER BY AVG(r.stars) DESC, COUNT(*) DESC`:: -returns the movies rated by the friends of the user 'Michael', aggregated by `movie.title`, with averaged ratings and rating-counts sorted by both - -Examples of Cypher queries placed on repository methods with @Query where values are replaced with method parameters, -as described in the <>) section. - -[source,java,subs="-replacements"] ----- -public interface MovieRepository extends Neo4jRepository { - - // returns the node with id equal to idOfMovie parameter - @Query("MATCH (n) WHERE id(n)=$0 RETURN n") - Movie getMovieFromId(Integer idOfMovie); - - // returns the nodes which have a title according to the movieTitle parameter - @Query("MATCH (movie:Movie {title=$0}) RETURN movie") - Movie getMovieFromTitle(String movieTitle); - - // same with optional result - @Query("MATCH (movie:Movie {title=$0}) RETURN movie") - Optional getMovieFromTitle(String movieTitle); - - // returns a Page of Actors that have a ACTS_IN relationship to the movie node with the title equal to movieTitle parameter. - @Query(value = "MATCH (movie:Movie {title=$0})<-[:ACTS_IN]-(actor) RETURN actor", countQuery= "MATCH (movie:Movie {title=$0})<-[:ACTS_IN]-(actor) RETURN count(actor)") - Page getActorsThatActInMovieFromTitle(String movieTitle, PageRequest page); - - // returns a Page of Actors that have a ACTS_IN relationship to the movie node with the title equal to movieTitle parameter with an accurate total count - @Query(value = "MATCH (movie:Movie {title=$0})<-[:ACTS_IN]-(actor) RETURN actor", countQuery = "MATCH (movie:Movie {title=$0})<-[:ACTS_IN]-(actor) RETURN count(*)") - Page getActorsThatActInMovieFromTitle(String movieTitle, Pageable page); - - // returns a Slice of Actors that have a ACTS_IN relationship to the movie node with the title equal to movieTitle parameter. - @Query("MATCH (movie:Movie {title=$0})<-[:ACTS_IN]-(actor) RETURN actor") - Slice getActorsThatActInMovieFromTitle(String movieTitle, Pageable page); - - // returns users who rated a movie (movie parameter) higher than rating (rating parameter) - @Query("MATCH (movie:Movie)<-[r:RATED]-(user) " + - "WHERE id(movie)=$movieId AND r.stars > {rating} " + - "RETURN user") - Iterable getUsersWhoRatedMovieFromTitle(@Param("movieId") Movie movie, @Param("rating") Integer rating); - - // returns users who rated a movie based on movie title (movieTitle parameter) higher than rating (rating parameter) - @Query("MATCH (movie:Movie {title:$0})<-[r:RATED]-(user) " + - "WHERE r.stars > $1 " + - "RETURN user") - Iterable getUsersWhoRatedMovieFromTitle(String movieTitle, Integer rating); - - @Query(value = "MATCH (movie:Movie) RETURN movie;") - Stream getAllMovies(); -} ----- - -[[reference_derived-queries]] -=== Queries derived from finder-method names - -Using the metadata infrastructure in the underlying object-graph mapper, a finder method name can be split into its semantic parts and converted into a cypher query. -Navigation along relationships will be reflected in the generated `MATCH` clause and properties with operators will end up as expressions in the `WHERE` clause. -The parameters will be used in the order they appear in the method signature so they should align with the expressions stated in the method name. - -.Some examples of methods of a `PersonRepository` and the Cypher queries derived from them -[source,java] ----- -public interface PersonRepository extends Neo4jRepository { - - // MATCH (person:Person {name=$0}) RETURN person - Person findByName(String name); - - // MATCH (person:Person) - // WHERE person.age = $0 AND person.married = $1 - // RETURN person - Iterable findByAgeAndMarried(int age, boolean married); - - // MATCH (person:Person) - // WHERE person.age = $0 - // RETURN person ORDER BY person.name SKIP $skip LIMIT $limit - Page findByAge(int age, Pageable pageable); - - // MATCH (person:Person) - // WHERE person.age = $0 - // RETURN person ORDER BY person.name - List findByAge(int age, Sort sort); - - // Allow a custom depth as a parameter - Person findByName(String name, @Depth int depth); - - // Set a fix depth of 0 for the query - @Depth(value = 0) - Person findBySurname(String surname); - -} ----- - - -[[reference_programming-model_mapresult]] -=== Mapping Query Results - -For queries executed via `@Query` repository methods, it's possible to specify a conversion of complex query results to POJOs. -These result objects are then populated with the query result data. -Those POJOs are easier to handle and might be used as Data Transfer Objects (DTOs) as they are not attached to a `Session` and don't participate in any lifecycle. -To take advantage of this feature, use a class annotated with `@QueryResult` as the method return type. - -The properties of your `@QueryResult` annotated class must have the same names as the returned values. -Please keep in mind that Java and Cypher are case-sensitive. - -.Example of query result mapping -[source,java,subs="-replacements"] ----- -public interface MovieRepository extends Neo4jRepository { - - @Query("MATCH (movie:Movie)-[r:RATING]->(), (movie)<-[:ACTS_IN]-(actor:Actor) " + - "WHERE movie.id=$0 " + - "RETURN movie as movie, COLLECT(actor) AS cast, AVG(r.stars) AS averageRating") - MovieData getMovieData(String movieId); -} - - -@QueryResult -public class MovieData { - Movie movie; - Double averageRating; - Set cast; -} ----- - -[[reference_programming-model_sorting_and_paging]] -=== Sorting and Paging -Spring Data Neo4j supports sorting and paging of results when using Spring Data's `Pageable` and `Sort` interfaces. - -==== -.Repository-based paging -[source,java] ----- -Pageable pageable = PageRequest.of(0, 3); -Page page = worldRepository.findAll(pageable, 0); ----- - -.Repository-based sorting -[source,java] ----- -Sort sort = new Sort(Sort.Direction.ASC, "name"); -Iterable worlds = worldRepository.findAll(sort, 0)) { ----- - -.Repository-based sorting with paging -[source,java] ----- -Pageable pageable = PageRequest.of(0, 3, Sort.Direction.ASC, "name"); -Page page = worldRepository.findAll(pageable, 0); ----- -==== - -include::projections.adoc[] - -[[reference_programming-model_transactions]] -== Transactions - -Neo4j is a transactional database, only allowing operations to be performed within transaction boundaries. -Spring Data Neo4j integrates nicely with both the declarative transaction support with `@Transactional` as well as the manual transaction handling with `TransactionTemplate`. - -The methods on the repositories instances are transactional by default. -If you are, for example, simply just looking up an object through a repository then you do not need to define anything else: -SDN will take of everything for you. -That said, it is strongly recommended that you always annotate any service boundaries to the database with a `@Transactional` annotation. -This way all your code for that method will always run in one transaction, even if you add a write operation later on. - -More standard behaviour with transactions is using a facade or service implementation that typically covers more than one repository or database call as part of a 'Unit of Work'. -Its purpose is to define transactional boundaries for non-CRUD operations: - -[NOTE] -SDN only supports `PROPAGATION_REQUIRED` and `ISOLATION_DEFAULT` type transactions. - -.Using an `@Service` as facade to define transaction boundaries for multiple repository calls -[source,java] ----- -@Service -class UserManagementImpl implements UserManagement { - - private final UserRepository userRepository; - private final RoleRepository roleRepository; - - @Autowired - public UserManagementImpl(UserRepository userRepository, - RoleRepository roleRepository) { - this.userRepository = userRepository; - this.roleRepository = roleRepository; - } - - @Transactional - public void addRoleToAllUsers(String roleName) { - - Role role = roleRepository.findByName(roleName); - - for (User user : userRepository.findAll()) { - user.addRole(role); - userRepository.save(user); - } -} ----- -This will cause all calls to `addRoleToAllUsers(…)` to run inside a transaction (participating in an existing one or create a new one if none already running). -The transaction configuration at the repositories will be neglected as the outer transaction configuration determines the actual one used. - -It is highly recommended that users understand how Spring transactions work. -Below are some excellent resources: - -* https://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#spring-data-tier[Spring Transaction Management] -* https://graphaware.com/neo4j/2016/09/30/upgrading-to-sdn-42.html[Upgrading to Spring Data Neo4j 4.2] - -=== Read only Transactions - -You can start a read only transaction by marking a class or method with `@Transactional(readOnly=true)`. - -[CAUTION] -Be careful when nesting transactions. -Spring's `@Transactional` propagates by default outer transactions and doesn't validate whether they are compatible with inner. -The `Neo4jTransactionManager` can be configured to validate existing transaction by calling `#setValidateExistingTransaction(true)` during bean initialization. -For more details see https://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#tx-propagation[Spring's documentation]. - - -=== Transaction Bound Events - -SDN provides the ability to bind the listener of an event to a phase of the transaction. -The typical example is to handle the event when the transaction has completed successfully: -this allows events to be used with more flexibility when the outcome of the current transaction actually matters to the listener. - -The transaction module implements an `EventListenerFactory` that looks for the new `@TransactionalEventListener` annotation. -When this one is present, an extended event listener that is aware of the transaction is registered instead of the default. - -.Example: An order creation listener. -[source,java] ----- -@Component -public class MyComponent { - - @TransactionalEventListener(condition = "#creationEvent.awesome") - public void handleOrderCreatedEvent(CreationEvent creationEvent) { - ... - } - -} ----- - -`@TransactionalEventListener` is a regular `@EventListener` and also exposes a `TransactionPhase`, the default being `AFTER_COMMIT`. -You can also hook other phases of the transaction (`BEFORE_COMMIT`, `AFTER_ROLLBACK` and `AFTER_COMPLETION` that is just an alias for `AFTER_COMMIT` and `AFTER_ROLLBACK`). - -By default, if no transaction is running the event isn't sent at all as we can't obviously honor the requested phase, -but there is a fallbackExecution attribute in `@TransactionalEventListener` that tells Spring to invoke the listener immediately if there is no transaction. - -[NOTE] -Only public methods in a managed bean can be annotated with `@EventListener` to consume events. -`@TransactionalEventListener` is the annotation that provides transaction-bound event support described here. - -To find out more about Spring's Event listening capabilities see https://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#context-functionality-events-annotation[the Spring reference manual] and https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2[How to build Transaction aware Eventing with Spring 4.2]. - -[[reference_clustering]] -== Clustering support - -=== Bookmark management -Neo4j causal clusters use bookmarks to manage _read your own writes_ scenarios. -You'll find background information on the way causal clusters work in the https://neo4j.com/docs/operations-manual/current/clustering/[Neo4j operations manual]. - -In SDN, you can use the bookmark management feature to handle these scenarios easily. -You just need to: - -* Add the `@EnableBookmarkManagement` annotation once on one of your Spring configuration classes. -* Provide one bean implementing `org.springframework.data.neo4j.bookmark.BookmarkManager`. SDN supplies an implementation named `CaffeineBookmarkManager` based on the popular caching framework https://github.com/ben-manes/caffeine[Caffeine]. -* Add `@UseBookmark` to each transactional Java method involved in a _read your own writes_ scenario. - -A configuration using Caffeine may look like this: - -[source,java] ----- -@Configuration -@EnableBookmarkManagement -public class ExampleConfiguration { - - @Bean - public BookmarkManager bookmarkManager() { - return new CaffeineBookmarkManager(); - } -} ----- - -Please make sure that Caffeine is on the class path before you use this configuration. - -Every method annotated with `@UseBookmark` will then collect the bookmarks coming from the database at the end of transactions. -These bookmarks are then stored into a SDN managed context, and reused on later calls to other `@UseBookmark` annotated methods. - -WARNING: `@UseBookmark` has to be used on `@Transactional` annotated methods. - -== Miscellaneous - - -=== CDI integration - -Instances of the repository interfaces are usually created by a container and Spring is the most natural choice when working with Spring Data. -There's sophisticated support to easily set up Spring to create bean instances documented in <>. -Spring Data Neo4j ships with a custom CDI extension that allows using the repository abstraction in CDI environments. - -You can now set up the infrastructure by implementing a CDI Producer for the `SessionFactory` and `Session`: - -[source, java] ----- -class SessionFactoryProducer { - - @Produces - @ApplicationScoped - public SessionFactory createSessionFactory() { - return new SessionFactory("package"); - } - - public void close(@Disposes SessionFactory sessionFactory) { - sessionFactory.close(); - } -} ----- - -The necessary setup can vary depending on the JavaEE environment you run in. -It might also just be enough to redeclare a `Session` as CDI bean as follows: - -[source, java] ----- -class CdiConfig { - - @Produces - @RequestScoped - @PersistenceContext - public Session session; -} ----- - -In this example, the container has to be capable of creating Neo4j-OGM `Sessions` itself. -All the configuration does is re-exporting the Neo4j-OGM `Session` as CDI bean. - -The Spring Data Neo4j CDI extension will pick up all sessions available as CDI beans and create a proxy for a Spring Data repository whenever a bean of a repository type is requested by the container. -Thus obtaining an instance of a Spring Data repository is a matter of declaring an `@Injected` property: - -[source, java] ----- -class RepositoryClient { - - @Inject - PersonRepository repository; - - public void businessMethod() { - List people = repository.findAll(); - } -} ----- - - - -=== JSR-303 (Bean Validation) Support - -Spring Data Neo4j allows developers to use _JSR-303_ annotations like `@NotNull` etc. on their domain models. -While this is supported, it's not a best practice. -It is highly recommended to create _JSR-303_ annotations on actual Java Beans, similar to things like Data Transfer Objects (DTOs). - -[[reference_programming-model_conversion]] -=== Conversion Service -It is possible to have Spring Data Neo4j use converters registered with https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/html/validation.html#core-convert[Spring's ConversionService]. -There must be one unique instance of a `ConversionService`-Bean in your application context to use this. -If there is more than one instance, you have to mark the one to be used by SDN with `@Primary`, otherwise an internal conversion service will be used. - -When those requirements are met, use the `graphPropertyType` attribute on the `@Convert` annotation instead of specifying an `org.neo4j.ogm.typeconversion.AttributeConverter` through its `value`: - -.Using graphPropertyType -[source,java] ----- -@NodeEntity -public class MyEntity { - - @Convert(graphPropertyType = Integer.class) - private DecimalCurrencyAmount fundValue; - -} ----- - -Spring Data Neo4j will look for converters registered with Spring's ConversionService that can convert both to and from the type specified by `graphPropertyType` and use them if they exist. - -[NOTE] -==== -Default converters and those defined explicitly via an implementation of `org.neo4j.ogm.typeconversion.AttributeConverter` -will take precedence over converters registered with Spring's ConversionService. -==== - -`Neo4jRepository` should be the interface from which your entity repository interfaces inherit, with `T` being specified as the domain entity type to persist. -`ID` is defined by the field type annotated with `@Id`. - -Examples of methods you get for free out of `Neo4jRepository` are as follows. -For all of these examples the `ID` parameter is a `Long` that matches the graph id: - -Load an entity instance via an id:: -`Optional findById(id)` - -Check for existence of an id in the graph:: -`boolean existsById(id)` - -Iterate over all nodes of a node entity type:: -`Iterable findAll()` -`Iterable findAll(Sort ...)` -`Page findAll(Pageable ...)` - -Count the instances of the repository entity type:: -`Long count()` - -Save entities:: -`T save(T)` and `Iterable saveAll(Iterable)` - -Delete graph entities:: -`void delete(T)`, `void deleteAll(Iterable)`, and `void deleteAll()` - -[NOTE] -For users coming from versions before `4.2.x`, `Neo4jRepository` has replaced `GraphRepository` but essentially has the same features. diff --git a/src/main/asciidoc/reference/ogm-support.adoc b/src/main/asciidoc/reference/ogm-support.adoc deleted file mode 100644 index ddefdad5e..000000000 --- a/src/main/asciidoc/reference/ogm-support.adoc +++ /dev/null @@ -1,104 +0,0 @@ -[[reference.ogm-support]] -= Neo4j-OGM Support - -To get started, you need only your domain model and the annotations provided by the Neo4j-OGM library. -You use annotations to mark domain objects to be reflected by nodes and relationships of the graph database. -Annotations for individual fields allow you to declare how fields should be processed and mapped to properties of nodes in the graph. - -Refer to the Neo4j-OGM documentation for more details. - - -[[introduction-graph-database]] -== What is Neo4j-OGM? - -An OGM (Object Graph Mapper) maps nodes and relationships in the graph to objects and references in your domain model. -Object instances are mapped to nodes while object references are mapped using relationships, or serialized to properties. -JVM primitives are mapped to properties of a node or a relationship. -An OGM lets you create a view of your database based on your domain model. -It also provides the flexibility to supply custom queries in cases where the queries generated by Neo4j-OGM are insufficient. - -The OGM can be thought of as analogous to Hibernate or JPA. -Users should have an understanding of what an object mapper does when using this guide. - -While SDN's _repositories_ will cover a majority of user scenarios, sometimes they don't offer enough options. -Neo4j-OGM's `Session` offers a convenient API to interact more direct with a Neo4j graph database. -SDN now allows you to wire up the Neo4j-OGM `Session` directly into your Spring managed beans. - -[[reference.architecture.session]] -=== Understanding the Session - -A `Session` is used to drive the object-graph mapping framework. -All repository implementations are backed by the `Session`. -It keeps track of the changes that have been made to entities and their relationships. -The reason it does this is so that only entities and relationships that have changed get persisted on save, which is particularly efficient when working with large graphs. - -Sessions are usually bound to a thread by default and rely on the garbage collector to clean them up once they are out of scope of processing. -For most users this means there is nothing to configure. -Request/response type applications SDN will take care of session management for you (as defined in the configuration section above). -If you have a batch or long running desktop type application you may want to know how you can control using the session a bit more. - -.Design Consideration: Session caching -**** -Once an entity is tracked by the session, reloading this entity within the scope of the same session will result in the session cache returning the previously loaded entity. -However, the subgraph in the session will expand if the entity or its related entities retrieve additional relationships from the graph. - -If you want to fetch fresh data from the graph, then this can be achieved by using a new session or clearing the current -sessions context using `org.neo4j.ogm.session.Session.clear()`. - -The lifetime of the `Session` can be managed in code. -For example, associated with single _fetch-update-save_ cycle or unit of work. - -If your application relies on long-running sessions then you may not see changes made from other users and find yourself working with outdated objects. -On the other hand, if your sessions have too narrow a scope then your save operations can be unnecessarily expensive, as updates will be made to all objects if the session isn't aware of the those that were originally loaded. - -There's therefore a trade off between the two approaches. -In general, the scope of a `Session` should correspond to a "unit of work" in your application. -**** - -== Basic Operations - -For Spring Data Neo4j, low level operations are handled by Neo4j-OGM `Session`. -Basic operations are limited to CRUD operations on entities and executing arbitrary Cypher queries; more low-level manipulation of the graph database is not possible. - -Given that the latest version of the framework is driven by Cypher queries alone, there's no way to work directly with `Node` and `Relationship` objects, especially in remote server mode. -Similarly, the `traverse()` method has disappeared, again because the underlying query-driven model doesn't handle it in an efficient way. - -If you did rely on low-level manipulation of the graph database itself or being able to use `traverse()` in previous versions of Spring Data Neo4j, then your best options are: - -. Write a Cypher query to perform the operations on the nodes/relationships instead -. Write a Neo4j server extension and call it over REST from your application - -Of course, there are pros and cons to both of these approaches, but these are largely outside the scope of this document. -In general, for low-level, very high-performance operations like complex graph traversals you will get the best performance by writing a server-side extension. -For most purposes, though, Cypher will be performant and expressive enough to perform the operations that you need. - -== Entity Persistence - -`Session` allows you to `save`, `load`, `loadAll` and `delete` entities. -The eagerness with which objects are retrieved is controlled by specifying the 'depth' argument to any of the load methods. - -All of these basic CRUD methods just call onto the underlying methods of `Session`, albeit with transaction handling and exception translation managed for you by SDN's `TransactionManager` bean. - -== Cypher Queries - -The `Session` also allows execution of arbitrary Cypher queries via its `query`, `queryForObject` and `queryForObjects` methods. -Cypher queries that return tabular results should be passed into the `query` method. -An `org.neo4j.ogm.session.result.Result` is returned. -This consists of `org.neo4j.ogm.session.result.QueryStatistics` representing statistics of modifying cypher statements if applicable, -and an `Iterable>` containing the raw data, of which nodes and relationships are mapped to domain entities if possible. -The keys in each `Map` correspond to the names listed in the return clause of the executed Cypher query. - -[NOTE] -Modifications made to the graph via Cypher queries directly will not be reflected in your domain objects within the session. - - -== Transactions - -If you configured the `Neo4jTransactionManager` bean, any `Session` that is managed by Spring will automatically take part in thread contextual transactions. -In order to do this you will need to wrap your service code using `@Transactional` or the `TransactionTemplate`. - -[NOTE] -It is important to know that if you enable Transactions *ALL* code that uses the `Session` directly must be enclosed in a `@Transactional` annotation. -Declarative Spring Data repositories (see <>) are already marked as `@Transactional` and will create implicit transactions if no transaction boundaries are defined at the callers site. - -For more details see <> diff --git a/src/main/asciidoc/reference/projections.adoc b/src/main/asciidoc/reference/projections.adoc deleted file mode 100644 index e26d62d77..000000000 --- a/src/main/asciidoc/reference/projections.adoc +++ /dev/null @@ -1,138 +0,0 @@ -[[reference_programming-projections]] -=== Projections - -Spring Data Repositories usually return the domain model (either as `@NodeEntity` or as a `@QueryResult`) when using query methods. -However, sometimes you may need a different view of that model for various reasons. -In this section you will learn how to define projections to serve up simplified and reduced views of resources. - -Look at the following domain model: - -[source,java] ----- -@NodeEntity -public class Cinema { - - private Long id; - private String name, location; - - @Relationship(type = "VISITED", direction = Relationship.INCOMING) - private Set visited = new HashSet<>(); - - @Relationship(type = "BLOCKBUSTER", direction = Relationship.OUTGOING) - private Movie blockbusterOfTheWeek; - … -} ----- - -This `Cinema` has several attributes: - -* `id` is the graph id -* `name` and `location` are data attributes -* `visited` and `blockbusterOfTheWeek` are links to other domain objects - -Now assume we create a corresponding repository as follows: - -[source,java] ----- -public interface CinemaRepository extends Neo4jRepository { - - Cinema findByName(String name); -} ----- - -Spring Data will return the domain object including all of its attributes and all the users that visited this cinema. -That can be a big amount of data and can lead to performance issues. - -There are several ways to avoid that : - -* use a custom `depth` for loading (see <>) -* use a custom annotated query (see <>) -* use a projection - -.Simple Projection -==== -[source,java] ----- -public interface CinemaNameAndBlockbuster { <1> - - public String getName(); <2> - public Movie getBlockbusterOfTheWeek(); -} ----- -This projection has the following details: - -<1> A plain Java interface making it declarative. -<2> Only some attributes of the entity are exported. -==== - -The `CinemaNameAndBlockbuster` projection only has getters for `name` and `blockbusterOfTheWeek` meaning that it will not serve up any user information. -The query method definition returns in this case `CinemaNameAndBlockbuster` instead of `Cinema`. - -[source,java] ----- -interface CinemaRepository extends Neo4jRepository { - - CinemaNameAndBlockbuster findByName(String name); -} ----- - -Projections declare a contract between the underlying type and the method signatures related to the exposed properties. -Hence it is required to name getter methods according to the property name of the underlying type. -If the underlying property is named `name`, then the getter method must be named `getName` otherwise Spring Data is not able to look up the source property. -This type of projection is also called _closed projection_. - -NOTE: Closed projections expose a subset of properties that could be used to optimize the query in a way that reduces the selected fields from the data store. -However, it is not implemented at the moment. -For performance sensitive querying, you can still use custom queries with maps or `QueryResult` (see <>) - -The other type is, as you might imagine, an _open projection_. - -[[projections.remodelling-data]] -==== Remodelling data - -So far, you have seen how projections can be used to reduce the information that is presented to the user. -Projections can be used to adjust the exposed data model. -You can add virtual properties to your projection. -Look at the following projection interface: - -.Renaming a property -==== -[source,java] ----- -interface RenamedProperty { <1> - - @Value("#{target.name}") - String getCinemaName(); <2> - - @Value("#{target.blockbusterOfTheWeek.name}") - String getBlockbusterOfTheWeekName(); <3> -} ----- -This projection has the following details: - -<1> A plain Java interface making it declarative. -<2> Expose the `name` attribute as a virtual property called `cinemaName`. -<3> Export the `name` sub-property of the linked `Movie` entity as a virtual property. -==== - -The backing domain model does not have these properties so we need to tell Spring Data from where they are obtained. -Virtual properties are the place where `@Value` comes into play. -The `cinemaName` getter is annotated with `@Value` to use https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#expressions[SpEL expressions] pointing to the backing property `name`. -You may have noticed `name` is prefixed with `target` which is the variable name pointing to the backing object. -Using `@Value` on methods allows defining where and how the value is obtained. - -`@Value` gives full access to the target object and its nested properties. -SpEL expressions are extremely powerful as the definition is always applied to the projection method. - -We could imagine this: - -[source,java] ----- -interface RenamedProperty { - - @Value("#{target.name} #{(target.location == null) ? '' : target.location}") - String getNameAndLocation(); -} ----- - -In this example, the location is appended to the cinema name only if it is available. diff --git a/src/main/asciidoc/repositories/index.adoc b/src/main/asciidoc/repositories/index.adoc new file mode 100644 index 000000000..1cdbbea6c --- /dev/null +++ b/src/main/asciidoc/repositories/index.adoc @@ -0,0 +1,2 @@ +include::sdc-repositories.adoc[leveloffset=+1] +include::sdc-projections.adoc[leveloffset=+1] diff --git a/src/main/asciidoc/repositories/sdc-projections.adoc b/src/main/asciidoc/repositories/sdc-projections.adoc new file mode 100644 index 000000000..43c03b22c --- /dev/null +++ b/src/main/asciidoc/repositories/sdc-projections.adoc @@ -0,0 +1,182 @@ +// This is part of the documentation usually pulled in from Spring Data Commons +:springVersion: 5.2.0.RELEASE +:spring-framework-docs: https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference +:spring-framework-javadoc: https://docs.spring.io/spring/docs/{springVersion}/javadoc-api +[[projections]] += Projections + +Spring Data query methods usually return one or multiple instances of the aggregate root managed by the repository. +However, it might sometimes be desirable to create projections based on certain attributes of those types. +Spring Data allows modeling dedicated return types, to more selectively retrieve partial views of the managed aggregates. + +Imagine a repository and aggregate root type such as the following example: + +.A sample aggregate and repository +==== +[source, java, subs="+attributes"] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/Person.java[tag=projection.entity] + +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/Person.java[tags=projection.repository;projection.repository.concrete;!projection.repository.interface] +---- +==== + +Now imagine that we want to retrieve the person's name attributes only. +What means does Spring Data offer to achieve this? +The rest of this chapter answers that question. + +[[projections.interfaces]] +== Interface-based Projections + +The easiest way to limit the result of the queries to only the name attributes is by declaring an interface that exposes accessor methods for the properties to be read, as shown in the following example: + +.A projection interface to retrieve a subset of attributes +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/NamesOnly.java[tags=projection.interface;!projection.interface.default-method;!projection.interface.open-projection;!projection.interface.bean-access;!projection.interface.method-parameters] +---- +==== + +The important bit here is that the properties defined here exactly match properties in the aggregate root. +Doing so lets a query method be added as follows: + +.A repository using an interface based projection with a query method +==== +[source, java, subs="+attributes"] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/Person.java[tags=projection.repository;projection.repository.interface;!projection.repository.concrete] +---- +==== + +The query execution engine creates proxy instances of that interface at runtime for each element returned and forwards calls to the exposed methods to the target object. + +[[projections.interfaces.nested]] +Projections can be used recursively. +If you want to include some of the `Address` information as well, create a projection interface for that and return that interface from the declaration of `getAddress()`, as shown in the following example: + +.A projection interface to retrieve a subset of attributes +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/PersonSummary.java[tag=projection.interface.nested] +---- +==== + +On method invocation, the `address` property of the target instance is obtained and wrapped into a projecting proxy in turn. + +[[projections.interfaces.closed]] +=== Closed Projections + +A projection interface whose accessor methods all match properties of the target aggregate is considered to be a closed projection. +The following example (which we used earlier in this chapter, too) is a closed projection: + +.A closed projection +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/NamesOnly.java[tags=projection.interface;!projection.interface.default-method;!projection.interface.open-projection;!projection.interface.bean-access;!projection.interface.method-parameters] +---- +==== + +If you use a closed projection, Spring Data can optimize the query execution, because we know about all the attributes that are needed to back the projection proxy. +For more details on that, see the module-specific part of the reference documentation. + +[[projections.interfaces.open]] +=== Open Projections + +Accessor methods in projection interfaces can also be used to compute new values by using the `@Value` annotation, as shown in the following example: + +[[projections.interfaces.open.simple]] +.An Open Projection +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/NamesOnly.java[tags=projection.interface;!projection.interface.default-method;!projection.interface.closed-projection;!projection.interface.bean-access;!projection.interface.method-parameters] +---- +==== + +The aggregate root backing the projection is available in the `target` variable. +A projection interface using `@Value` is an open projection. +Spring Data cannot apply query execution optimizations in this case, because the SpEL expression could use any attribute of the aggregate root. + +The expressions used in `@Value` should not be too complex -- you want to avoid programming in `String` variables. +For very simple expressions, one option might be to resort to default methods (introduced in Java 8), as shown in the following example: + +[[projections.interfaces.open.default]] +.A projection interface using a default method for custom logic +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/NamesOnly.java[tags=projection.interface;!projection.interface.open-projection] +---- +==== + +This approach requires you to be able to implement logic purely based on the other accessor methods exposed on the projection interface. +A second, more flexible, option is to implement the custom logic in a Spring bean and then invoke that from the SpEL expression, as shown in the following example: + +[[projections.interfaces.open.bean-reference]] +.Sample Person object +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/NamesOnly.java[tags=projection.interface.bean-access;projection.interface;!projection.interface.open-projection;!projection.interface.closed-projection;!projection.interface.default-method;!projection.interface.method-parameters] +---- +==== + +Notice how the SpEL expression refers to `nameBean` and invokes the `getFullName(…)` method and forwards the projection target as a method parameter. +Methods backed by SpEL expression evaluation can also use method parameters, which can then be referred to from the expression. +The method parameters are available through an `Object` array named `args`. The following example shows how to get a method parameter from the `args` array: + +.Sample Person object +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/NamesOnly.java[tags=projection.interface;!projection.interface.open-projection;!projection.interface.closed-projection;!projection.interface.default-method;!projection.interface.bean-access] +---- +==== + +Again, for more complex expressions, you should use a Spring bean and let the expression invoke a method, as described <>. + +[[projections.dtos]] +== Class-based Projections (DTOs) + +Another way of defining projections is by using value type DTOs (Data Transfer Objects) that hold properties for the fields that are supposed to be retrieved. +These DTO types can be used in exactly the same way projection interfaces are used, except that no proxying happens and no nested projections can be applied. + +If the store optimizes the query execution by limiting the fields to be loaded, the fields to be loaded are determined from the parameter names of the constructor that is exposed. + +The following example shows a projecting DTO: + +.A projecting DTO +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/NamesOnlyDto.java[tags=projection.class] +---- +==== + +[[projection.dynamic]] +== Dynamic Projections + +So far, we have used the projection type as the return type or element type of a collection. +However, you might want to select the type to be used at invocation time (which makes it dynamic). +To apply dynamic projections, use a query method such as the one shown in the following example: + +.A repository using a dynamic projection parameter +==== +[source, java, subs="+attributes"] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/Person.java[tags=projection.dynamic-projection-repository] +---- +==== + +This way, the method can be used to obtain the aggregates as is or with a projection applied, as shown in the following example: + +.Using a repository with dynamic projections +==== +[source, java, subs="+attributes"] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/projection/Person.java[tags=projection.dynamic-projection-usage] +---- +==== diff --git a/src/main/asciidoc/repositories/sdc-repositories.adoc b/src/main/asciidoc/repositories/sdc-repositories.adoc new file mode 100644 index 000000000..3f1cc9c9d --- /dev/null +++ b/src/main/asciidoc/repositories/sdc-repositories.adoc @@ -0,0 +1,1395 @@ +// This is part of the documentation usually pulled in from Spring Data Commons +// but in here, we copied it and removed Jpa, QueryDSL and other things that just dont fit in here. +:springVersion: 5.2.0.RELEASE +:spring-framework-docs: https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference +:spring-framework-javadoc: https://docs.spring.io/spring/docs/{springVersion}/javadoc-api + +[[repositories]] += Working with Spring Data Repositories + +The goal of the Spring Data repository abstraction is to significantly reduce the amount of boilerplate code required +to implement data access layers for various persistence stores. + +[[repositories.core-concepts]] +== Core concepts +The central interface in the Spring Data repository abstraction is `Repository`. +It takes the domain class to manage as well as the ID type of the domain class as type arguments. +This interface acts primarily as a marker interface to capture the types to work with and to help you to discover interfaces that extend this one. +The `CrudRepository` provides sophisticated CRUD functionality for the entity class that is being managed. + +[[repositories.repository]] +.`CrudRepository` interface +==== +[source, java] +---- +public interface CrudRepository extends Repository { + + S save(S entity); <.> + + Optional findById(ID primaryKey); <.> + + Iterable findAll(); <.> + + long count(); <.> + + void delete(T entity); <.> + + boolean existsById(ID primaryKey); <.> + + // … more functionality omitted. +} +---- +<.> Saves the given entity. +<.> Returns the entity identified by the given ID. +<.> Returns all entities. +<.> Returns the number of entities. +<.> Deletes the given entity. +<.> Indicates whether an entity with the given ID exists. +==== + +NOTE: We also provide a technology-specific abstraction: + such as `Neo4jRepository` and the reactive variant, `ReactiveNeo4jRepository`. + Those interfaces extend `CrudRepository` and expose the capabilities of the underlying persistence technology + in addition to the rather generic persistence technology-agnostic interfaces such as `CrudRepository`. + Also, methods returning an `Iterable` are narrowed down to return a `java.util.List` instead. + +On top of the `CrudRepository`, there is a `PagingAndSortingRepository` abstraction that adds additional methods to ease paginated access to entities: + +.`PagingAndSortingRepository` interface +==== +[source, java] +---- +public interface PagingAndSortingRepository extends CrudRepository { + + Iterable findAll(Sort sort); + + Page findAll(Pageable pageable); +} +---- +==== + +To access the second page of `User` by a page size of 20, you could do something like the following: + +[source, java] +---- +PagingAndSortingRepository repository = // … get access to a bean +Page users = repository.findAll(PageRequest.of(1, 20)); +---- + +In addition to query methods, query derivation for both count and delete queries is available. +The following list shows the interface definition for a derived count query: + +.Derived Count Query +==== +[source, java] +---- +interface UserRepository extends CrudRepository { + + long countByLastname(String lastname); +} +---- +==== + +The following list shows the interface definition for a derived delete query: + +.Derived Delete Query +==== +[source, java] +---- +interface UserRepository extends CrudRepository { + + long deleteByLastname(String lastname); + + List removeByLastname(String lastname); +} +---- +==== + +[[repositories.query-methods]] +== Query methods + +Standard CRUD functionality repositories usually have queries on the underlying datastore. +With Spring Data, declaring those queries becomes a four-step process: + +. Declare an interface extending Repository or one of its subinterfaces and type it to the domain class and ID type that it should handle, as shown in the following example: ++ + +[source, java] +---- +interface PersonRepository extends Repository { … } +---- + +. Declare query methods on the interface. ++ + +[source, java] +---- +interface PersonRepository extends Repository { + List findByLastname(String lastname); +} +---- + +. Provide some <> to set up Spring to create proxy instances for those interfaces. + ++ + +[source, java] +---- +include::../../examples/docs/src/main/java/org/neo4j/doc/springframework/data/docs/repositories/Config.java[tag=java-config-imperative-short] +---- + ++ + +The `Driver` bean is required to provide the actual connection to the database. + ++ + +Note that the configuration does not configure a package explicitly, because the package of the annotated class is used by default. +To customize the package to scan, use one of the `basePackage…` attributes of the `@EnableNeo4jRepositories`-annotation. + +. Inject the repository instance and use it, as shown in the following example: ++ + +[source, java] +---- +class SomeClient { + + private final PersonRepository repository; + + SomeClient(PersonRepository repository) { + this.repository = repository; + } + + void doSomething() { + List persons = repository.findByLastname("Matthews"); + } +} +---- + +The following sections explain each step in detail. + +[[repositories.definition]] +== Defining Repository Interfaces + +First, define a domain class-specific repository interface. +The interface must extend `Repository` and be typed to the domain class and an ID type. +If you want to expose CRUD methods for that domain type, extend `CrudRepository` instead of `Repository`. + +[[repositories.definition-tuning]] +=== Fine-tuning Repository Definition + +Typically, your repository interface extends `Repository`, `CrudRepository`, or `PagingAndSortingRepository`. +Alternatively, if you do not want to extend Spring Data interfaces, you can also annotate your repository interface with `@RepositoryDefinition`. +Extending `CrudRepository` exposes a complete set of methods to manipulate your entities. +If you prefer to be selective about the methods being exposed, copy the methods you want to expose from `CrudRepository` into your domain repository. + +NOTE: Doing so lets you define your own abstractions on top of the provided Spring Data Repositories functionality. + +The following example shows how to selectively expose CRUD methods (`findById` and `save`, in this case): + +.Selectively exposing CRUD methods +==== +[source, java] +---- +@NoRepositoryBean +interface MyBaseRepository extends Repository { + + Optional findById(ID id); + + S save(S entity); +} + +interface UserRepository extends MyBaseRepository { + User findByEmailAddress(EmailAddress emailAddress); +} +---- +==== + +In the prior example, you defined a common base interface for all your domain repositories and exposed `findById(…)` as well as `save(…)`. +These methods are routed into the base repository implementation (for the imperative version, the implementation is `SimpleNeo4jRepository`), +because they match the method signatures in `CrudRepository`. +So the `UserRepository` can now save users, find individual users by ID, and trigger a query to find `Users` by email address. + +NOTE: The intermediate repository interface is annotated with `@NoRepositoryBean`. + Make sure you add that annotation to all repository interfaces for which Spring Data should not create instances at runtime. + +[[repositories.multiple-modules]] +=== Using Repositories with Multiple Spring Data Modules + +Using a unique Spring Data module in your application makes things simple, because all repository interfaces in the defined scope are bound to one Spring Data module. +Sometimes, applications require using more than one Spring Data module. +In such cases, a repository definition must distinguish between persistence technologies. +When it detects multiple repository factories on the class path, Spring Data enters strict repository configuration mode. +Strict configuration uses details on the repository or the domain class to decide about Spring Data module binding for a repository definition: + +1. If the repository definition <>, then it is a valid candidate for the particular Spring Data module. +2. If the domain class is <>, then it is a valid candidate for the particular Spring Data module. +Spring Data modules accept either third-party annotations (such as JPA's `@Entity`) or provide their own annotations (such as `@Node` for Spring Data Neo4j⚡RX). + +The following example shows a repository that uses module-specific interfaces (JPA in this case): + +[[repositories.multiple-modules.types]] +.Repository definitions using module-specific interfaces +==== +[source, java] +---- +interface MyRepository extends JpaRepository { } + +@NoRepositoryBean +interface MyBaseRepository extends JpaRepository { … } + +interface UserRepository extends MyBaseRepository { … } +---- +`MyRepository` and `UserRepository` extend `JpaRepository` in their type hierarchy. +They are valid candidates for the Spring Data JPA module. +==== + +The following example shows a repository that uses generic interfaces: + +.Repository definitions using generic interfaces +==== +[source, java] +---- +interface AmbiguousRepository extends Repository { … } + +@NoRepositoryBean +interface MyBaseRepository extends CrudRepository { … } + +interface AmbiguousUserRepository extends MyBaseRepository { … } +---- +`AmbiguousRepository` and `AmbiguousUserRepository` extend only `Repository` and `CrudRepository` in their type hierarchy. +While this is perfectly fine when using a unique Spring Data module, multiple modules cannot distinguish to which particular Spring Data these repositories should be bound. +==== + +The following example shows a repository that uses domain classes with annotations: + +[[repositories.multiple-modules.annotations]] +.Repository definitions using domain classes with annotations +==== +[source, java] +---- +interface PersonRepository extends Repository { … } + +@Entity +class Person { … } + +interface UserRepository extends Repository { … } + +@Node +class User { … } +---- +`PersonRepository` references `Person`, which is annotated with the JPA `@Entity` annotation, so this repository clearly belongs to Spring Data JPA. +`UserRepository` references `User`, which is annotated with SDN/RX's `@Node` annotation. +==== + +The following bad example shows a repository that uses domain classes with mixed annotations: + +.Repository definitions using domain classes with mixed annotations +==== +[source, java] +---- +interface JpaPersonRepository extends Repository { … } + +interface Neo4jPersonRepository extends Repository { … } + +@Entity +@Node +class Person { … } +---- +This example shows a domain class using both JPA and Spring Data Neo4j⚡RX annotations. +It defines two repositories, `JpaPersonRepository` and `Neo4jPersonRepository`. +One is intended for JPA and the other for Neo4j usage. +Spring Data is no longer able to tell the repositories apart, which leads to undefined behavior. +==== + +<> and <> are used for strict repository configuration +to identify repository candidates for a particular Spring Data module. +Using multiple persistence technology-specific annotations on the same domain type is possible and enables reuse of domain types across multiple persistence technologies. +However, Spring Data can then no longer determine a unique module with which to bind the repository. + +The last way to distinguish repositories is by scoping repository base packages. +Base packages define the starting points for scanning for repository interface definitions, which implies having repository definitions located in the appropriate packages. + +The following example shows annotation-driven configuration of base packages: + +.Annotation-driven configuration of base packages +==== +[source, java] +---- +@Configuration +@EnableJpaRepositories(basePackages = "com.acme.repositories.jpa") +@EnableNeo4jRepositories(basePackages = "com.acme.repositories.neo4j") +class Config { +} +---- +==== + +[[repositories.query-methods.details]] +== Defining Query Methods + +The repository proxy has two ways to derive a store-specific query from the method name: + +* By deriving the query from the method name directly. +* By using a manually defined query. + +The next section describes the available options. + +[[repositories.query-methods.query-lookup-strategies]] +=== Query Lookup Strategies + +The following strategies are available for the repository infrastructure to resolve the query. +In your Java configuration, you can use the `queryLookupStrategy` attribute of the `EnableNeo4jRepositories` annotation. + +- `CREATE` attempts to construct a store-specific query from the query method name. + The general approach is to remove a given set of well known prefixes from the method name and parse the rest of the method. + You can read more about query construction in "`<>`". + +- `USE_DECLARED_QUERY` tries to find a declared query and throws an exception if cannot find one. + The query can be defined by an annotation somewhere or declared by other means. + Consult the documentation of the specific store to find available options for that store. + If the repository infrastructure does not find a declared query for the method at bootstrap time, it fails. + +- `CREATE_IF_NOT_FOUND` (default) combines `CREATE` and `USE_DECLARED_QUERY`. + It looks up a declared query first, and, if no declared query is found, it creates a custom method name-based query. + This is the default lookup strategy and, thus, is used if you do not configure anything explicitly. + It allows quick query definition by method names but also custom-tuning of these queries by introducing declared queries as needed. + +[[repositories.query-methods.query-creation]] +=== Query Creation + +The query builder mechanism built into Spring Data repository infrastructure is useful for building constraining queries over entities of the repository. +The mechanism strips the prefixes `find…By`, `read…By`, `query…By`, `count…By`, and `get…By` from the method and starts parsing the rest of it. +The introducing clause can contain further expressions, such as a `Distinct` to set a distinct flag on the query to be created. +However, the first `By` acts as delimiter to indicate the start of the actual criteria. +At a very basic level, you can define conditions on entity properties and concatenate them with `And` and `Or`. +The following example shows how to create a number of queries: + +.Query creation from method names +==== +[source, java] +---- +interface PersonRepository extends Repository { + + List findByEmailAddressAndLastname(EmailAddress emailAddress, String lastname); + + // Enables the distinct flag for the query + List findDistinctPeopleByLastnameOrFirstname(String lastname, String firstname); + List findPeopleDistinctByLastnameOrFirstname(String lastname, String firstname); + + // Enabling ignoring case for an individual property + List findByLastnameIgnoreCase(String lastname); + // Enabling ignoring case for all suitable properties + List findByLastnameAndFirstnameAllIgnoreCase(String lastname, String firstname); + + // Enabling static ORDER BY for a query + List findByLastnameOrderByFirstnameAsc(String lastname); + List findByLastnameOrderByFirstnameDesc(String lastname); +} +---- +==== + +There are some general things to notice: + +- The expressions are usually property traversals combined with operators that can be concatenated. + You can combine property expressions with `AND` and `OR`. + You also get support for operators such as `Between`, `LessThan`, `GreaterThan`, and `Like` for the property expressions. + +- The method parser supports setting an `IgnoreCase` flag for individual properties (for example, `findByLastnameIgnoreCase(…)`) + or for all properties of a type that supports ignoring case (usually `String` instances -- for example, `findByLastnameAndFirstnameAllIgnoreCase(…)`). + +- You can apply static ordering by appending an `OrderBy` clause to the query method that references a property and by providing a sorting direction (`Asc` or `Desc`). + To create a query method that supports dynamic sorting, see "`<>`". + +[[repositories.query-methods.query-property-expressions]] +=== Property Expressions + +Property expressions can refer only to a direct property of the managed entity, as shown in the preceding example. +At query creation time, you already make sure that the parsed property is a property of the managed domain class. +However, you can also define constraints by traversing nested properties. Consider the following method signature: + +[source, java] +---- +List findByAddressZipCode(ZipCode zipCode); +---- + +Assume a `Person` has an `Address` with a `ZipCode`. +In that case, the method creates the property traversal `x.address.zipCode`. +The resolution algorithm starts by interpreting the entire part (`AddressZipCode`) as the property and checks the domain class for a property with that name (uncapitalized). +If the algorithm succeeds, it uses that property. +If not, the algorithm splits up the source at the camel case parts from the right side into a head and a tail and tries to find the corresponding property -- in our example, `AddressZip` and `Code`. +If the algorithm finds a property with that head, it takes the tail and continues building the tree down from there, splitting the tail up in the way just described. +If the first split does not match, the algorithm moves the split point to the left (`Address`, `ZipCode`) and continues. + +Although this should work for most cases, it is possible for the algorithm to select the wrong property. +Suppose the `Person` class has an `addressZip` property as well. +The algorithm would match in the first split round already, choose the wrong property, and fail (as the type of `addressZip` probably has no `code` property). + +To resolve this ambiguity you can use `_` inside your method name to manually define traversal points. +So our method name would be as follows: + +[source, java] +---- +List findByAddress_ZipCode(ZipCode zipCode); +---- + +Because we treat the underscore character as a reserved character, we strongly advise following standard Java naming conventions +(that is, not using underscores in property names but using camel case instead). + +[[repositories.special-parameters]] +=== Special parameter handling +To handle parameters in your query, define method parameters as already seen in the preceding examples. +Besides that, the infrastructure recognizes certain specific types like `Pageable` and `Sort`, to apply pagination and sorting to your queries dynamically. +The following example demonstrates these features: + +.Using `Pageable`, `Slice`, and `Sort` in query methods +==== +[source, java] +---- +Page findByLastname(String lastname, Pageable pageable); + +Slice findByLastname(String lastname, Pageable pageable); + +List findByLastname(String lastname, Sort sort); + +List findByLastname(String lastname, Pageable pageable); +---- +==== + +IMPORTANT: APIs taking `Sort` and `Pageable` expect non-`null` values to be handed into methods. +If you don't want to apply any sorting or pagination use `Sort.unsorted()` and `Pageable.unpaged()`. + +The first method lets you pass an `org.springframework.data.domain.Pageable` instance to the query method to dynamically add paging to your statically defined query. +A `Page` knows about the total number of elements and pages available. +It does so by the infrastructure triggering a count query to calculate the overall number. +As this might be expensive (depending on the store used), you can instead return a `Slice`. +A `Slice` only knows about whether a next `Slice` is available, which might be sufficient when walking through a larger result set. + +Sorting options are handled through the `Pageable` instance, too. +If you only need sorting, add an `org.springframework.data.domain.Sort` parameter to your method. +As you can see, returning a `List` is also possible. +In this case, the additional metadata required to build the actual `Page` instance is not created +(which, in turn, means that the additional count query that would have been necessary is not issued). +Rather, it restricts the query to look up only the given range of entities. + +NOTE: To find out how many pages you get for an entire query, you have to trigger an additional count query. + By default, this query is derived from the query you actually trigger. + +[[repositories.paging-and-sorting]] +==== Paging and Sorting + +Simple sorting expressions can be defined by using property names. +Expressions can be concatenated to collect multiple criterias into one expression. + +.Defining sort expressions +==== +[source, java] +---- +Sort sort = Sort.by("firstname").ascending() + .and(Sort.by("lastname").descending()); +---- +==== + +For a more type-safe way of defining sort expressions, start with the type to define the sort expression for and use method references to define the properties to sort on. + +.Defining sort expressions using the type-safe API +==== +[source, java] +---- +TypedSort person = Sort.sort(Person.class); + +TypedSort sort = person.by(Person::getFirstname).ascending() + .and(person.by(Person::getLastname).descending()); +---- +==== + +[[repositories.limit-query-result]] +=== Limiting Query Results + +The results of query methods can be limited by using the `first` or `top` keywords, which can be used interchangeably. +An optional numeric value can be appended to `top` or `first` to specify the maximum result size to be returned. +If the number is left out, a result size of 1 is assumed. +The following example shows how to limit the query size: + +.Limiting the result size of a query with `Top` and `First` +==== +[source, java] +---- +User findFirstByOrderByLastnameAsc(); + +User findTopByOrderByAgeDesc(); + +Page queryFirst10ByLastname(String lastname, Pageable pageable); + +Slice findTop3ByLastname(String lastname, Pageable pageable); + +List findFirst10ByLastname(String lastname, Sort sort); + +List findTop10ByLastname(String lastname, Pageable pageable); +---- +==== + +The limiting expressions also support the `Distinct` keyword. +Also, for the queries limiting the result set to one instance, wrapping the result into with the `Optional` keyword is supported. + +If pagination or slicing is applied to a limiting query pagination (and the calculation of the number of pages available), it is applied within the limited result. + +NOTE: Limiting the results in combination with dynamic sorting by using a `Sort` parameter lets you express query methods for the 'K' smallest as well as for the 'K' biggest elements. + +[[repositories.collections-and-iterables]] +=== Repository Methods Returning Collections or Iterables +Query methods that return multiple results can use standard Java `Iterable`, `List`, `Set`. +Beyond that we support returning Spring Data's `Streamable`, a custom extension of `Iterable`, as well as collection types provided by https://www.vavr.io/[Vavr]. + +[[repositories.collections-and-iterables.streamable]] +==== Using Streamable as Query Method Return Type +`Streamable` can be used as alternative to `Iterable` or any collection type. +It provides convenience methods to access a non-parallel `Stream` (missing from `Iterable`), the ability to directly `….filter(…)` and `….map(…)` over the elements and concatenate the `Streamable` to others: + +.Using Streamable to combine query method results +==== +[source, java] +---- +interface PersonRepository extends Repository { + Streamable findByFirstnameContaining(String firstname); + Streamable findByLastnameContaining(String lastname); +} + +Streamable result = repository.findByFirstnameContaining("av") + .and(repository.findByLastnameContaining("ea")); +---- +==== + +[[repositories.collections-and-iterables.streamable-wrapper]] +==== Returning Custom Streamable Wrapper Types + +Providing dedicated wrapper types for collections is a commonly used pattern to provide API on a query execution result that returns multiple elements. +Usually these types are used by invoking a repository method returning a collection-like type and creating an instance of the wrapper type manually. +That additional step can be avoided as Spring Data allows to use these wrapper types as query method return types if they meet the following criterias: + +. The type implements `Streamable`. +. The type exposes either a constructor or a static factory method named `of(…)` or `valueOf(…)` taking `Streamable` as argument. + +A sample use case looks as follows: + +==== +[source, java] +---- +class Product { <.> + MonetaryAmount getPrice() { … } +} + +@RequiredArgConstructor(staticName = "of") +class Products implements Streamable { <.> + + private Streamable streamable; + + public MonetaryAmount getTotal() { <.> + return streamable.stream() // + .map(Priced::getPrice) + .reduce(Money.of(0), MonetaryAmount::add); + } +} + +interface ProductRepository implements Repository { + Products findAllByDescriptionContaining(String text); <.> +} +---- +<.> A `Product` entity that exposes API to access the product's price. +<.> A wrapper type for a `Streamable` that can be constructed via `Products.of(…)` (factory method created via the Lombok annotation). +<.> The wrapper type exposes additional API calculating new values on the `Streamable`. +<.> That wrapper type can be used as query method return type directly. No need to return `Stremable` and manually wrap it in the repository client. +==== + +[[repositories.collections-and-iterables.vavr]] +==== Support for Vavr Collections + +https://www.vavr.io/[Vavr] is a library to embrace functional programming concepts in Java. +It ships with a custom set of collection types that can be used as query method return types. + +[options=header] +|==== +|Vavr collection type|Used Vavr implementation type|Valid Java source types +|`io.vavr.collection.Seq`|`io.vavr.collection.List`|`java.util.Iterable` +|`io.vavr.collection.Set`|`io.vavr.collection.LinkedHashSet`|`java.util.Iterable` +|`io.vavr.collection.Map`|`io.vavr.collection.LinkedHashMap`|`java.util.Map` +|==== + +The types in the first column (or subtypes thereof) can be used as quer method return types and will get the types in the second column +used as implementation type depending on the Java type of the actual query result (third column). +Alternatively, `Traversable` (Vavr the `Iterable` equivalent) can be declared and we derive the implementation class +from the actual return value, i.e. a `java.util.List` will be turned into a Vavr `List`/`Seq`, a `java.util.Set` becomes a Vavr `LinkedHashSet`/`Set` etc. + +[[repositories.nullability]] +=== Null Handling of Repository Methods + +As of Spring Data 2.0, repository CRUD methods that return an individual aggregate instance use Java 8's `Optional` to indicate the potential absence of a value. +Besides that, Spring Data supports returning the following wrapper types on query methods: + +* `com.google.common.base.Optional` +* `scala.Option` +* `io.vavr.control.Option` + +Alternatively, query methods can choose not to use a wrapper type at all. +The absence of a query result is then indicated by returning `null`. +Repository methods returning collections, collection alternatives, wrappers, and streams are guaranteed never to return `null` but rather the corresponding empty representation. +See "`<>`" for details. + +[[repositories.nullability.annotations]] +==== Nullability Annotations + +You can express nullability constraints for repository methods by using link:{spring-framework-docs}/core.html#null-safety[Spring Framework's nullability annotations]. +They provide a tooling-friendly approach and opt-in `null` checks during runtime, as follows: + +* {spring-framework-javadoc}/org/springframework/lang/NonNullApi.html[`@NonNullApi`]: + Used on the package level to declare that the default behavior for parameters and return values is to not accept or produce `null` values. +* {spring-framework-javadoc}/org/springframework/lang/NonNull.html[`@NonNull`]: + Used on a parameter or return value that must not be `null` + (not needed on a parameter and return value where `@NonNullApi` applies). +* {spring-framework-javadoc}/org/springframework/lang/Nullable.html[`@Nullable`]: + Used on a parameter or return value that can be `null`. + +Spring annotations are meta-annotated with https://jcp.org/en/jsr/detail?id=305[JSR 305] annotations (a dormant but widely spread JSR). +JSR 305 meta-annotations let tooling vendors such as https://www.jetbrains.com/help/idea/nullable-and-notnull-annotations.html[IDEA], https://help.eclipse.org/oxygen/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/task-using_external_null_annotations.htm[Eclipse], and link:https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types[Kotlin] provide null-safety support in a generic way, without having to hard-code support for Spring annotations. +To enable runtime checking of nullability constraints for query methods, you need to activate non-nullability on the package level by using Spring’s `@NonNullApi` in `package-info.java`, as shown in the following example: + +.Declaring Non-nullability in `package-info.java` +==== +[source, java] +---- +@org.springframework.lang.NonNullApi +package com.acme; +---- +==== + +Once non-null defaulting is in place, repository query method invocations get validated at runtime for nullability constraints. +If a query execution result violates the defined constraint, an exception is thrown. +This happens when the method would return `null` but is declared as non-nullable (the default with the annotation defined on the package the repository resides in). +If you want to opt-in to nullable results again, selectively use `@Nullable` on individual methods. +Using the result wrapper types mentioned at the start of this section continues to work as expected: An empty result is translated into the value that represents absence. + +The following example shows a number of the techniques just described: + +.Using different nullability constraints +==== +[source, java] +---- +package com.acme; <.> + +import org.springframework.lang.Nullable; + +interface UserRepository extends Repository { + + User getByEmailAddress(EmailAddress emailAddress); <.> + + @Nullable + User findByEmailAddress(@Nullable EmailAddress emailAdress); <.> + + Optional findOptionalByEmailAddress(EmailAddress emailAddress); <.> +} +---- +<.> The repository resides in a package (or sub-package) for which we have defined non-null behavior. +<.> Throws an `EmptyResultDataAccessException` when the query executed does not produce a result. + Throws an `IllegalArgumentException` when the `emailAddress` handed to the method is `null`. +<.> Returns `null` when the query executed does not produce a result. + Also accepts `null` as the value for `emailAddress`. +<.> Returns `Optional.empty()` when the query executed does not produce a result. + Throws an `IllegalArgumentException` when the `emailAddress` handed to the method is `null`. +==== + +[[repositories.nullability.kotlin]] +==== Nullability in Kotlin-based Repositories + +Kotlin has the definition of https://kotlinlang.org/docs/reference/null-safety.html[nullability constraints] baked into the language. +Kotlin code compiles to bytecode, which does not express nullability constraints through method signatures but rather through compiled-in metadata. +Make sure to include the `kotlin-reflect` JAR in your project to enable introspection of Kotlin's nullability constraints. +Spring Data repositories use the language mechanism to define those constraints to apply the same runtime checks, as follows: + +.Using nullability constraints on Kotlin repositories +==== +[source, kotlin] +---- +interface UserRepository : Repository { + + fun findByUsername(username: String): User <.> + + fun findByFirstname(firstname: String?): User? <.> +} +---- +<.> The method defines both the parameter and the result as non-nullable (the Kotlin default). + The Kotlin compiler rejects method invocations that pass `null` to the method. + If the query execution yields an empty result, an `EmptyResultDataAccessException` is thrown. +<.> This method accepts `null` for the `firstname` parameter and returns `null` if the query execution does not produce a result. +==== + +[[repositories.query-streaming]] +=== Streaming query results + +The results of query methods can be processed incrementally by using a Java 8 `Stream` as return type. +Instead of wrapping the query results in a `Stream` data store-specific methods are used to perform the streaming, as shown in the following example: + +.Stream the result of a query with Java 8 `Stream` +==== +[source, java] +---- +@Query("MATCH (u:User) RETURN u") +Stream findAllByCustomQueryAndStream(); + +Stream readAllByFirstnameNotNull(); + +@Query("MATCH (u:User) RETURN u") +Stream streamAllPaged(Pageable pageable); +---- +==== +NOTE: A `Stream` potentially wraps underlying data store-specific resources and must, therefore, be closed after usage. + You can either manually close the `Stream` by using the `close()` method or by using a Java 7 `try-with-resources` block, as shown in the following example: + +.Working with a `Stream` result in a try-with-resources block +==== +[source, java] +---- +try (Stream stream = repository.findAllByCustomQueryAndStream()) { + stream.forEach(…); +} +---- +==== +NOTE: Not all Spring Data modules currently support `Stream` as a return type. + +[[repositories.query-async]] +=== Async query results + +Repository queries can be run asynchronously by using link:{spring-framework-docs}/integration.html#scheduling[Spring's asynchronous method execution capability]. +This means the method returns immediately upon invocation while the actual query execution occurs in a task that has been submitted to a Spring `TaskExecutor`. +Asynchronous query execution is different from reactive query execution and should not be mixed. +Refer to store-specific documentation for more details on reactive support. +The following example shows a number of asynchronous queries: + +==== +[source, java] +---- +@Async +Future findByFirstname(String firstname); <.> + +@Async +CompletableFuture findOneByFirstname(String firstname); <.> + +@Async +ListenableFuture findOneByLastname(String lastname); <.> +---- +<.> Use `java.util.concurrent.Future` as the return type. +<.> Use a Java 8 `java.util.concurrent.CompletableFuture` as the return type. +<.> Use a `org.springframework.util.concurrent.ListenableFuture` as the return type. +==== + +[[repositories.create-instances]] +== Creating Repository Instances +In this section, you create instances and bean definitions for the defined repository interfaces. + +NOTE: This section is only relevant if you don't work in a Spring Boot scenario. + SDN/RX provides dedicated support for Spring Boot, including automatic configuration of + the Neo4j driver, Repositories and entity scanning. + + + Please be aware that SDN/RX does not support XML based Spring configuration. + + +[[repositories.create-instances.java-config]] +=== JavaConfig +The repository infrastructure is triggered by using either `@EnableNeo4jRepositories` or `EnableReactiveNeo4jRepositories` annotation on a JavaConfig class. +For an introduction into Java-based configuration of the Spring container, see link:{spring-framework-docs}/core.html#beans-java[JavaConfig in the Spring reference documentation]. + +WARNING: While the Neo4j driver contains support for blocking and reactive programming in one single jar, + blocking and reactive programming style should not be mixed in one application. + +A sample configuration to enable Spring Data Neo4j repositories resembles the following: + +.Sample annotation based repository configuration +==== +[source, java] +---- +include::../../examples/docs/src/main/java/org/neo4j/doc/springframework/data/docs/repositories/Config.java[tag=java-config-imperative] +---- +==== +<.> Mark this as a Spring Configuration class +<.> Enable imperative Neo4j repositories +<.> Enable transactions +<.> `AbstractNeo4jConfig` provides all the beans needed for SDN/RX to work +<.> Provide a connection to the database +<.> This is optional: Preconfigure the list of packages where SDN/RX should look for `@Node`-annotated classes + +The configuration of reactive repositories looks very similar: + +.Sample annotation based reactive repository configuration +==== +[source,java] +---- +include::../../examples/docs/src/main/java/org/neo4j/doc/springframework/data/docs/repositories/ReactiveConfig.java[tag=java-config-reactive] +---- +==== + +The driver has the same type. +Please note that you need at least Neo4j 4.0 to use the reactive sessions provided by the driver. + + +[[repositories.custom-implementations]] +== Custom Implementations for Spring Data Repositories +This section covers repository customization and how fragments form a composite repository. + +When a query method requires a different behavior or cannot be implemented by query derivation, then it is necessary to provide a custom implementation. +Spring Data repositories let you provide custom repository code and integrate it with generic CRUD abstraction and query method functionality. + +[[repositories.single-repository-behavior]] +=== Customizing Individual Repositories +To enrich a repository with custom functionality, you must first define a fragment interface and an implementation for the custom functionality, as shown in the following example: + +.Interface for custom repository functionality +==== +[source, java] +---- +interface CustomizedUserRepository { + void someCustomMethod(User user); +} +---- +==== + +Then you can let your repository interface additionally extend from the fragment interface, as shown in the following example: + +.Implementation of custom repository functionality +==== +[source, java] +---- +class CustomizedUserRepositoryImpl implements CustomizedUserRepository { + + public void someCustomMethod(User user) { + // Your custom implementation + } +} +---- +==== + +NOTE: The most important part of the class name that corresponds to the fragment interface is the `Impl` postfix. + +The implementation itself does not depend on Spring Data and can be a regular Spring bean. +Consequently, you can use standard dependency injection behavior to inject references to other beans +(such as a `Neo4jClient` or the `Neo4jTemplate`), take part in aspects, and so on. + +You can let your repository interface extend the fragment interface, as shown in the following example: + +.Changes to your repository interface +==== +[source, java] +---- +interface UserRepository extends CrudRepository, CustomizedUserRepository { + + // Declare query methods here +} +---- +==== + +Extending the fragment interface with your repository interface combines the CRUD and custom functionality and makes it available to clients. + +Spring Data repositories are implemented by using fragments that form a repository composition. +Fragments are the base repository, functional aspects and custom interfaces along with their implementation. +Each time you add an interface to your repository interface, you enhance the composition by adding a fragment. +The base repository and repository aspect implementations are provided by each Spring Data module. + +The following example shows custom interfaces and their implementations: + +.Fragments with their implementations +==== +[source, java] +---- +interface HumanRepository { + void someHumanMethod(User user); +} + +class HumanRepositoryImpl implements HumanRepository { + + public void someHumanMethod(User user) { + // Your custom implementation + } +} + +interface ContactRepository { + + void someContactMethod(User user); + + User anotherContactMethod(User user); +} + +class ContactRepositoryImpl implements ContactRepository { + + public void someContactMethod(User user) { + // Your custom implementation + } + + public User anotherContactMethod(User user) { + // Your custom implementation + } +} +---- +==== + +The following example shows the interface for a custom repository that extends `CrudRepository`: + +.Changes to your repository interface +==== +[source, java] +---- +interface UserRepository extends CrudRepository, HumanRepository, ContactRepository { + + // Declare query methods here +} +---- +==== + +Repositories may be composed of multiple custom implementations that are imported in the order of their declaration. +Custom implementations have a higher priority than the base implementation and repository aspects. +This ordering lets you override base repository and aspect methods and resolves ambiguity if two fragments contribute the same method signature. +Repository fragments are not limited to use in a single repository interface. +Multiple repositories may use a fragment interface, letting you reuse customizations across different repositories. + +The following example shows a repository fragment and its implementation: + +.Fragments overriding `save(…)` +==== +[source, java] +---- +interface CustomizedSave { + S save(S entity); +} + +class CustomizedSaveImpl implements CustomizedSave { + + public S save(S entity) { + // Your custom implementation + } +} +---- +==== + +The following example shows a repository that uses the preceding repository fragment: + +.Customized repository interfaces +==== +[source, java] +---- +interface UserRepository extends CrudRepository, CustomizedSave { +} + +interface PersonRepository extends CrudRepository, CustomizedSave { +} +---- +==== + +==== Configuration +The repository infrastructure tries to autodetect custom implementation fragments by scanning for classes below the package in which it found a repository. +These classes need to follow the naming convention of appending the store's `repositoryImplementationPostfix` attribute to the fragment interface name. +This postfix defaults to `Impl`. +The following example shows a configuration changing the default postfix to `MyPostfix`: + +.Configuration example +==== +[source, java] +---- +include::../../examples/docs/src/main/java/org/neo4j/doc/springframework/data/docs/repositories/CustomFragmentPostfix.java[tag=all] +---- +==== + +With this configuration, SDN/RX tries to look up a class called `com.acme.repository.CustomizedUserRepositoryMyPostfix` to act as a custom repository implementation. + +[[repositories.single-repository-behaviour.ambiguity]] +===== Resolution of Ambiguity + +If multiple implementations with matching class names are found in different packages, Spring Data uses the bean names to identify which one to use. + +Given the following two custom implementations for the `CustomizedUserRepository` shown earlier, the first implementation is used. +Its bean name is `customizedUserRepositoryImpl`, which matches that of the fragment interface (`CustomizedUserRepository`) plus the postfix `Impl`. + +.Resolution of ambiguous implementations +==== +[source, java] +---- +package com.acme.impl.one; + +class CustomizedUserRepositoryImpl implements CustomizedUserRepository { + + // Your custom implementation +} +---- +[source, java] +---- +package com.acme.impl.two; + +@Component("specialCustomImpl") +class CustomizedUserRepositoryImpl implements CustomizedUserRepository { + + // Your custom implementation +} +---- +==== + +If you annotate the `UserRepository` interface with `@Component("specialCustom")`, the bean name plus `Impl` then matches the one +defined for the repository implementation in `com.acme.impl.two`, and it is used instead of the first one. + +[[repositories.manual-wiring]] +===== Manual Wiring + +If your custom implementation uses annotation-based configuration and autowiring only, the preceding approach shown works well, +because it is treated as any other Spring bean. +If your implementation fragment bean needs special wiring, you can declare the bean and name it according to the conventions +described in the <>. +The infrastructure then refers to the manually defined bean definition by name instead of creating one itself. + +[[repositories.customize-base-repository]] +=== Customize the Base Repository + +The approach described in the <> requires customization of each repository interfaces +when you want to customize the base repository behavior so that all repositories are affected. +To change behavior for all repositories instead, you can create an implementation that extends the repository base class. +This class then acts as a custom base class for the repository proxies, as shown in the following example: + +.Custom repository base class +==== +[source, java] +---- +public class MyRepositoryImpl extends SimpleNeo4jRepository { + + MyRepositoryImpl( + Neo4jOperations neo4jOperations, + Neo4jEntityInformation entityInformation + ) { + super(neo4jOperations, entityInformation); + } + + @Override + public List findAll() { + throw new UnsupportedOperationException( + "This implementation does not support `findAll`."); + } +} +---- +==== + +CAUTION: The class needs to have a constructor matching `SimpleNeo4jRepository` or `SimpleReactiveNeo4jRepository`. + +The final step is to make the Spring Data infrastructure aware of the customized repository base class. +In Java configuration, you can do so by using the `repositoryBaseClass` attribute of the `@Enable$Neo4jRepositories` annotation, as shown in the following example: + +.Configuring a custom repository base class using JavaConfig +==== +[source, java] +---- +@Configuration +@EnableNeo4jRepositories(repositoryBaseClass = MyRepositoryImpl.class) +@EnableTransactionManagement +public class Config extends AbstractNeo4jConfig { + + @Bean + public Driver driver() { + return GraphDatabase + .driver("neo4j://localhost:7687", AuthTokens.basic("neo4j", "secret")); + } +} +---- +==== + +[[core.domain-events]] +== Publishing Events from Aggregate Roots + +Entities managed by repositories are aggregate roots. +In a Domain-Driven Design application, these aggregate roots usually publish domain events. +Spring Data provides an annotation called `@DomainEvents` that you can use on a method of your aggregate root to make that publication as easy as possible, as shown in the following example. + +First, define a custom event: + +.Defining a custom domain event: +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/domain_events/SomeEvent.java[tag=domain-events] +---- +<1> You have to inherit from Spring's `ApplicationEvent` +==== + +The next step is to expose these events from a `@Node` entity: + +.Exposing domain events from an aggregate root +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/domain_events/AnAggregateRoot.java[tag=domain-events] +---- +<.> Store your events in a collection and mark that collection as `@Transient` so that those events are not treated as a relationship to be stored +<.> Whenever you need to log an event, add it to the events collection +<.> Mark one method with `@DomainEvents`. The method must not take any arguments and can return either a single event instance or a collection of events. +<.> After all events have been published, we have a method annotated with `@AfterDomainEventPublication`. It can be used to potentially clean the list of events to be published (among other uses). +==== + +The methods are called every time one of a Spring Data repository's `save(…)` methods is called as shown in the following snippets: + + +.Store the aggregate root via standard repository calls +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/domain_events/DomainEventsTest.java[tag=domain-events] +---- +==== + +To react on this events, register a standard Spring `ApplicationListener`, typed to your event: + +.Create a custom event listener +==== +[source, java,indent=0] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/domain_events/DomainEventsApplication.java[tag=domain-events] +---- +==== + +[[core.extensions]] +== Spring Data Extensions + +This section documents a set of Spring Data extensions that enable Spring Data usage in a variety of contexts. +Currently, most of the integration is targeted towards Spring MVC. + +[[core.web]] +=== Web support + +Spring Data modules that support the repository programming model ship with a variety of web support. +The web related components require Spring MVC JARs to be on the classpath. +Some of them even provide integration with https://github.com/SpringSource/spring-hateoas[Spring HATEOAS]. +In general, the integration support is enabled by using the `@EnableSpringDataWebSupport` annotation in your JavaConfig configuration class, as shown in the following example: + +.Enabling Spring Data web support +==== +[source, java] +---- +@Configuration +@EnableWebMvc +@EnableSpringDataWebSupport +class WebConfiguration {} +---- +==== + +The `@EnableSpringDataWebSupport` annotation registers a few components we will discuss in a bit. +It will also detect Spring HATEOAS on the classpath and register integration components for it as well if present. + +[[core.web.basic]] +==== Basic Web Support +The configuration shown in the <> registers a few basic components: + +- A <> to let Spring MVC resolve instances of repository-managed domain classes from request parameters or path variables. +- <> implementations to let Spring MVC resolve `Pageable` and `Sort` instances from request parameters. + +[[core.web.basic.domain-class-converter]] +===== `DomainClassConverter` +The `DomainClassConverter` lets you use domain types in your Spring MVC controller method signatures directly, +so that you need not manually lookup the instances through the repository, as shown in the following example: + +.A Spring MVC controller using domain types in method signatures +==== +[source, java] +---- +@Controller +@RequestMapping("/users") +class UserController { + + @RequestMapping("/{id}") + String showUserForm(@PathVariable("id") User user, Model model) { + + model.addAttribute("user", user); + return "userForm"; + } +} +---- +==== + +As you can see, the method receives a `User` instance directly, and no further lookup is necessary. +The instance can be resolved by letting Spring MVC convert the path variable into the `id` type of the domain class first +and eventually access the instance through calling `findById(…)` on the repository instance registered for the domain type. + +NOTE: Currently, the repository has to implement `CrudRepository` to be eligible to be discovered for conversion. + +[[core.web.basic.paging-and-sorting]] +===== HandlerMethodArgumentResolvers for Pageable and Sort +The configuration snippet shown in the <> also registers a `PageableHandlerMethodArgumentResolver` +as well as an instance of `SortHandlerMethodArgumentResolver`. +The registration enables `Pageable` and `Sort` as valid controller method arguments, as shown in the following example: + +.Using Pageable as controller method argument +==== +[source, java] +---- +@Controller +@RequestMapping("/users") +class UserController { + + private final UserRepository repository; + + UserController(UserRepository repository) { + this.repository = repository; + } + + @RequestMapping + String showUsers(Model model, Pageable pageable) { + + model.addAttribute("users", repository.findAll(pageable)); + return "users"; + } +} +---- +==== + +The preceding method signature causes Spring MVC try to derive a `Pageable` instance from the request parameters by using the following default configuration: + +.Request parameters evaluated for `Pageable` instances +[options = "autowidth"] +|=============== +|`page`|Page you want to retrieve. 0-indexed and defaults to 0. +|`size`|Size of the page you want to retrieve. Defaults to 20. +|`sort`|Properties that should be sorted by in the format `property,property(,ASC\|DESC)`. + Default sort direction is ascending. Use multiple `sort` parameters if you want to switch directions -- for example, `?sort=firstname&sort=lastname,asc`. +|=============== + +To customize this behavior, register a bean implementing the `PageableHandlerMethodArgumentResolverCustomizer` interface or the `SortHandlerMethodArgumentResolverCustomizer` interface, +respectively. Its `customize()` method gets called, letting you change settings, as shown in the following example: + +[source, java] +---- +@Bean SortHandlerMethodArgumentResolverCustomizer sortCustomizer() { + return s -> s.setPropertyDelimiter("<-->"); +} +---- + +If setting the properties of an existing `MethodArgumentResolver` is not sufficient for your purpose, extend either `SpringDataWebConfiguration` or +the HATEOAS-enabled equivalent, override the `pageableResolver()` or `sortResolver()` methods, and import your customized configuration file instead of using the `@Enable` annotation. + +If you need multiple `Pageable` or `Sort` instances to be resolved from the request (for multiple tables, for example), +you can use Spring's `@Qualifier` annotation to distinguish one from another. +The request parameters then have to be prefixed with `${qualifier}_`. +The following example shows the resulting method signature: + +[source, java] +---- +String showUsers(Model model, + @Qualifier("thing1") Pageable first, + @Qualifier("thing2") Pageable second) { … } +---- + +you have to populate `thing1_page` and `thing2_page` and so on. + +The default `Pageable` passed into the method is equivalent to a `PageRequest.of(0, 20)` but can be customized by using the `@PageableDefault` annotation on the `Pageable` parameter. + +[[core.web.pageables]] +==== Hypermedia Support for Pageables +Spring HATEOAS ships with a representation model class (`PagedResources`) that allows enriching the content of a `Page` instance +with the necessary `Page` metadata as well as links to let the clients easily navigate the pages. +The conversion of a Page to a `PagedResources` is done by an implementation of the Spring HATEOAS `ResourceAssembler` interface, called the `PagedResourcesAssembler`. +The following example shows how to use a `PagedResourcesAssembler` as a controller method argument: + +.Using a PagedResourcesAssembler as controller method argument +==== +[source, java] +---- +@Controller +class PersonController { + + @Autowired PersonRepository repository; + + @RequestMapping(value = "/persons", method = RequestMethod.GET) + HttpEntity> persons(Pageable pageable, + PagedResourcesAssembler assembler) { + + Page persons = repository.findAll(pageable); + return new ResponseEntity<>(assembler.toResources(persons), HttpStatus.OK); + } +} +---- +==== + +Enabling the configuration as shown in the preceding example lets the `PagedResourcesAssembler` be used as a controller method argument. +Calling `toResources(…)` on it has the following effects: + +- The content of the `Page` becomes the content of the `PagedResources` instance. +- The `PagedResources` object gets a `PageMetadata` instance attached, and it is populated with information from the `Page` and the underlying `PageRequest`. +- The `PagedResources` may get `prev` and `next` links attached, depending on the page's state. +The links point to the URI to which the method maps. +The pagination parameters added to the method match the setup of the `PageableHandlerMethodArgumentResolver` to make sure the links can be resolved later. + +Assume we have 30 Person instances in the database. You can now trigger a request (`GET http://localhost:8080/persons`) and see output similar to the following: + +[source, javascript] +---- +{ "links" : [ { "rel" : "next", + "href" : "http://localhost:8080/persons?page=1&size=20 } + ], + "content" : [ + … // 20 Person instances rendered here + ], + "pageMetadata" : { + "size" : 20, + "totalElements" : 30, + "totalPages" : 2, + "number" : 0 + } +} +---- + +You see that the assembler produced the correct URI and also picked up the default configuration to resolve the parameters into a `Pageable` for an upcoming request. +This means that, if you change that configuration, the links automatically adhere to the change. +By default, the assembler points to the controller method it was invoked in, but that can be customized by handing in a custom `Link` +to be used as base to build the pagination links, which overloads the `PagedResourcesAssembler.toResource(…)` method. + +[[core.repository-populators]] +=== Repository Populators +If you work with the Spring JDBC module, you are probably familiar with the support to populate a `DataSource` with SQL scripts. +A similar abstraction is available on the repositories level, although it does not use SQL as the data definition language because it must be store-independent. +Thus, the populators support XML (through Spring's OXM abstraction) and JSON (through Jackson) to define data with which to populate the repositories. + +Assume you have a file `data.json` with the following content: + +.Data defined as JSON +==== +[source, json] +---- +include::../../examples/docs/src/test/resources/data.json[] +---- +==== + +The `_class` keys point to your domain class, in this case a `MovieEntity` + +.Corresponding entity +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/populators/MovieEntity.java[tag=populators] +---- +==== + +If you don't provide a custom constructor, you need to help the Jackson JSON library a bit by providing a so called mixin, teaching Jackson how to instantiate the object: + +.Optional Jackson module helping Jackson with your domain +==== +[source, java] +---- +include::../../examples/docs/src/test/java/org/neo4j/doc/springframework/data/docs/repositories/populators/MovieModule.java[tag=populators] +---- +==== + +And finally, you declare a `FactoryBean It is important that you inject the `ObjectMapper` from the context as this takes care of all registered Jackson Modules +<2> Here you point to `data.json` resource +==== + +The preceding declaration causes the `data.json` file to be read and deserialized by the Jackson `ObjectMapper`. + +The type to which the JSON object is unmarshalled is determined by inspecting the `_class` attribute of the JSON document. +The infrastructure eventually selects the appropriate repository to handle the object that was deserialized. + +To instead use XML to define the data the repositories should be populated with, you need to use a `UnmarshallerRepositoryPopulatorFactoryBean` and a JAXB2 marshaller. diff --git a/src/main/asciidoc/testing/index.adoc b/src/main/asciidoc/testing/index.adoc new file mode 100644 index 000000000..afae676fd --- /dev/null +++ b/src/main/asciidoc/testing/index.adoc @@ -0,0 +1 @@ +include::testing.adoc[leveloffset=+1] diff --git a/src/main/asciidoc/testing/testing.adoc b/src/main/asciidoc/testing/testing.adoc new file mode 100644 index 000000000..22bf938f8 --- /dev/null +++ b/src/main/asciidoc/testing/testing.adoc @@ -0,0 +1,228 @@ +[[testing]] += Testing + +We offer `org.neo4j.springframework.boot.test.autoconfigure.data.DataNeo4jTest` and `org.neo4j.springframework.boot.test.autoconfigure.data.ReactiveDataNeo4jTest` +inside an additional module under the following coordinates: +`org.neo4j.springframework.data:spring-data-neo4j-rx-spring-boot-test-autoconfigure`. +Include the following dependency in your project setup + +[source,xml,subs="verbatim,attributes"] +.spring-data-neo4j-rx-spring-boot-test-autoconfigure for Maven +---- + + org.neo4j.springframework.data + spring-data-neo4j-rx-spring-boot-test-autoconfigure + {spring-data-neo4j-rx-version} + test + +---- + +Or with Gradle + +[source,groovy,subs="verbatim,attributes"] +.spring-data-neo4j-rx-spring-boot-test-autoconfigure for Gradle +---- +dependencies { + testImplementation 'org.neo4j.springframework.data:spring-data-neo4j-rx-spring-boot-test-autoconfigure:{spring-data-neo4j-rx-version}' +} +---- + +Both `@DataNeo4jTest` and `@ReactiveDataNeo4jTest` are Spring Boot https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-testing[test slices]. +By default, they provide the Neo4j test harness through the transitive dependency of https://github.com/neo4j/neo4j-java-driver-spring-boot-starter/tree/master/neo4j-java-driver-test-harness-spring-boot-autoconfigure[neo4j-java-driver-test-harness-spring-boot-autoconfigure]. +Both slices provide all the necessary infrastructure for tests using Neo4j: A driver bean, a transaction manager, a client, a template and declared repositories, +in their imperative or reactive variants. +`@DataNeo4jTest` provides both variants if reactive repositories are enabled while `@ReactiveDataNeo4jTest` provides only reactive infrastructure. + +The dependencies include the Neo4j test harness in version 3.5.x by default. Thus, reactive database access and multiple databases cannot be tested out of the box. +The reason for doing this is simple: Spring Data's JDK baseline is JDK 8. The Neo4j test harness in version 4 requires JDK 11+, so we cannot make it the default. + +Here are the available options. +Both test slices include `@ExtendWith(SpringExtension.class)` so that they run automatically with JUnit 5 (JUnit Jupiter). + +[[dataneo4jtest]] +== `@DataNeo4jTest` + +`@DataNeo4jTest` provides both imperative and reactive infrastructure by default. +If you annotate a test with it the test becomes `@Transactional`. + +`@Transactional` in Spring tests always means imperative transactional, as declarative transactions needs the return type of a method to decide whether the imperative `PlatformTransactionManager` or the reactive `ReactiveTransactionManager` kicks in. +This is the reason you cannot use `@DataNeo4jTest` with setting `spring.data.neo4j.repositories.type` to `reactive` as this disables imperative infrastructure. + +=== With Neo4j test harness + +This is the default. +See the <>. +This class uses the included Neo4j test harness 3.5 by default. + +[source,java] +[[dataneo4jtest-template-example]] +.TemplateExampleTest.java +---- +include::../../examples/imperative-web/src/test/java/org/neo4j/springframework/data/examples/spring_boot/TemplateExampleTest.java[tags=testing.dataneo4jtest] +---- + +=== With Neo4j 4.0 test harness + +Include the following dependency in your project setup + +[source,xml,subs="verbatim,attributes"] +.Neo4j 4.0 test harness for Maven +---- + + org.neo4j.test + neo4j-harness + {neo4j-version} + test + +---- + +Or if you like Gradle better: + +[source,groovy,subs="verbatim,attributes"] +.Neo4j 4.0 test harness for Gradle +---- +dependencies { + testImplementation 'org.neo4j.test:neo4j-harness:{neo4j-version}' +} +---- + +IMPORTANT: The test setup doesn't change. `@DataNeo4jTest` is enough. + +This setup works with both imperative and reactive infrastructure. + +=== With Testcontainers + +Bring in the required dependencies: + +[source,xml] +[[testcontainers-dependencies]] +.Dependencies for Testcontainers +---- + + org.neo4j.springframework.data + spring-data-neo4j-rx-spring-boot-test-autoconfigure + {spring-data-neo4j-rx-version} + test + + + org.neo4j.test + neo4j-harness + + + + + org.testcontainers + junit-jupiter + 1.13.0 + test + + + org.testcontainers + neo4j + 1.13.0 + test + + +---- +<.> Be aware of this exclusion. If you don't exclude that dependency, it will have + precedence over any manual configuration of the Neo4j URL. + +As of Spring Framework 5.2.5, the TestContext framework provides support for dynamic property sources via the `@DynamicPropertySource` annotation. +This annotation can be used in integration tests that need to add properties with dynamic values. +For more information, have a look at the https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/testing.html#testcontext-ctx-management-dynamic-property-sources[Spring Framework reference]. + +A `@DataNeo4jTest` using `@DynamicPropertySource` together with Testcontainers looks like this: + +[source,java] +[[configure-your-container-source]] +.Configure your Neo4j URLs dynamically in a Spring Boot Test +---- +import org.neo4j.springframework.boot.test.autoconfigure.data.DataNeo4jTest; + +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; + +import org.testcontainers.containers.Neo4jContainer; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers +@DataNeo4jTest +class ExampleTest { + + @Container + private static Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.0"); + + @DynamicPropertySource + static void neo4jProperties(DynamicPropertyRegistry registry) { + registry.add("org.neo4j.driver.uri", neo4jContainer::getBoltUrl); + registry.add("org.neo4j.driver.authentication.username", () -> "neo4j"); + registry.add("org.neo4j.driver.authentication.password", neo4jContainer::getAdminPassword); + } +} +---- + +An alternative to this approach in older versions of Spring Boot and the Spring Framework is an initializer that looks like this: + +[source,java] +.Alternative injection of dynamic properties prior to Spring Boot 2.2.6 +---- +@Testcontainers +@ContextConfiguration(initializers = PriorToBoot226Test.Initializer.class) +@DataNeo4jTest +class PriorToBoot226Test { + + @Container + private static Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.0"); + + static class Initializer implements ApplicationContextInitializer { + public void initialize(ConfigurableApplicationContext configurableApplicationContext) { + TestPropertyValues.of( + "org.neo4j.driver.uri=" + neo4jContainer.getBoltUrl(), + "org.neo4j.driver.authentication.username=neo4j", + "org.neo4j.driver.authentication.password=" + neo4jContainer.getAdminPassword() + ).applyTo(configurableApplicationContext.getEnvironment()); + } + } +} +---- + +[IMPORTANT] +==== +If you dont want to exclude `org.neo4j.test:neo4j-harness` as advised in <>, you can manually exclude +the `Neo4jTestHarnessAutoConfiguration.class` from the test slice like this: + +[source,java] +---- +import org.neo4j.driver.springframework.boot.test.autoconfigure.Neo4jTestHarnessAutoConfiguration; +import org.neo4j.springframework.boot.test.autoconfigure.data.DataNeo4jTest; + +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers +@DataNeo4jTest(excludeAutoConfiguration = Neo4jTestHarnessAutoConfiguration.class) +public class TemplateExampleTest { + // Configuration of Neo4j connection as above. +} +---- +==== + +[[reactivedataneo4jtest]] +== `@ReactiveDataNeo4jTest` + +Everything said about `@DataNeo4jTest` applies to `@ReactiveDataNeo4jTest` as well. +However, `@ReactiveDataNeo4jTest` enables reactive infrastructure only and is not meta-annotated with `@Transactional`, +thus it doesn't depend on a `PlatformTransactionManager`. + +`@ReactiveDataNeo4jTest` also checks whether the Neo4j instance configured is capable of handling reactive connections. + +Our recommendation is to use it together with Testcontainers and exclude the Neo4j test harness dependency. + +A typical example would look like this: + +[source,java] +[[reactivedataneo4jtest-repository-example]] +.RepositoryIT.java +---- +include::../../examples/reactive-web/src/test/java/org/neo4j/springframework/data/examples/spring_boot/RepositoryIT.java[tags=testing.reactivedataneo4jtest] +---- diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/AbstractNeo4jConfig.java b/src/main/java/org/springframework/data/neo4j/config/AbstractNeo4jConfig.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/AbstractNeo4jConfig.java rename to src/main/java/org/springframework/data/neo4j/config/AbstractNeo4jConfig.java index e309f9145..bd4bd1825 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/AbstractNeo4jConfig.java +++ b/src/main/java/org/springframework/data/neo4j/config/AbstractNeo4jConfig.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import org.apiguardian.api.API; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.core.Neo4jClient; -import org.neo4j.springframework.data.core.Neo4jTemplate; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.transaction.Neo4jTransactionManager; -import org.neo4j.springframework.data.core.DatabaseSelectionProvider; -import org.neo4j.springframework.data.repository.config.Neo4jRepositoryConfigurationExtension; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.data.neo4j.core.DatabaseSelectionProvider; +import org.springframework.data.neo4j.core.Neo4jClient; +import org.springframework.data.neo4j.core.Neo4jTemplate; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager; +import org.springframework.data.neo4j.repository.config.Neo4jRepositoryConfigurationExtension; import org.springframework.transaction.PlatformTransactionManager; /** diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/AbstractReactiveNeo4jConfig.java b/src/main/java/org/springframework/data/neo4j/config/AbstractReactiveNeo4jConfig.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/AbstractReactiveNeo4jConfig.java rename to src/main/java/org/springframework/data/neo4j/config/AbstractReactiveNeo4jConfig.java index c02856ff7..8095e67f8 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/AbstractReactiveNeo4jConfig.java +++ b/src/main/java/org/springframework/data/neo4j/config/AbstractReactiveNeo4jConfig.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import org.apiguardian.api.API; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.core.ReactiveNeo4jClient; -import org.neo4j.springframework.data.core.ReactiveDatabaseSelectionProvider; -import org.neo4j.springframework.data.core.ReactiveNeo4jTemplate; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.transaction.ReactiveNeo4jTransactionManager; -import org.neo4j.springframework.data.repository.config.ReactiveNeo4jRepositoryConfigurationExtension; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider; +import org.springframework.data.neo4j.core.ReactiveNeo4jClient; +import org.springframework.data.neo4j.core.ReactiveNeo4jTemplate; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager; +import org.springframework.data.neo4j.repository.config.ReactiveNeo4jRepositoryConfigurationExtension; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.ReactiveTransactionManager; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/EnableNeo4jAuditing.java b/src/main/java/org/springframework/data/neo4j/config/EnableNeo4jAuditing.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/EnableNeo4jAuditing.java rename to src/main/java/org/springframework/data/neo4j/config/EnableNeo4jAuditing.java index 32645cd09..df6b6b59c 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/EnableNeo4jAuditing.java +++ b/src/main/java/org/springframework/data/neo4j/config/EnableNeo4jAuditing.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jAuditingRegistrar.java b/src/main/java/org/springframework/data/neo4j/config/Neo4jAuditingRegistrar.java similarity index 94% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jAuditingRegistrar.java rename to src/main/java/org/springframework/data/neo4j/config/Neo4jAuditingRegistrar.java index 3ef2710d2..8fc20d3a9 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jAuditingRegistrar.java +++ b/src/main/java/org/springframework/data/neo4j/config/Neo4jAuditingRegistrar.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import java.lang.annotation.Annotation; -import org.neo4j.springframework.data.repository.event.AuditingBeforeBindCallback; -import org.neo4j.springframework.data.repository.event.ReactiveAuditingBeforeBindCallback; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -31,6 +26,8 @@ import org.springframework.data.auditing.config.AuditingBeanDefinitionRegistrarS import org.springframework.data.auditing.config.AuditingConfiguration; import org.springframework.data.config.ParsingUtils; import org.springframework.data.mapping.context.PersistentEntities; +import org.springframework.data.neo4j.repository.event.AuditingBeforeBindCallback; +import org.springframework.data.neo4j.repository.event.ReactiveAuditingBeforeBindCallback; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jConfigurationSupport.java b/src/main/java/org/springframework/data/neo4j/config/Neo4jConfigurationSupport.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jConfigurationSupport.java rename to src/main/java/org/springframework/data/neo4j/config/Neo4jConfigurationSupport.java index a887bfba7..a8d9b3158 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jConfigurationSupport.java +++ b/src/main/java/org/springframework/data/neo4j/config/Neo4jConfigurationSupport.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import java.util.Collection; import java.util.Collections; @@ -24,13 +21,13 @@ import java.util.HashSet; import java.util.Set; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.schema.Node; 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.neo4j.core.convert.Neo4jConversions; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.schema.Node; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; @@ -52,7 +49,7 @@ abstract class Neo4jConfigurationSupport { } /** - * Creates a {@link org.neo4j.springframework.data.core.mapping.Neo4jMappingContext} equipped with entity classes + * Creates a {@link Neo4jMappingContext} equipped with entity classes * scanned from the mapping base package. * * @return A new {@link Neo4jMappingContext} with initial classes to scan for entities set. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jDefaultCallbacksRegistrar.java b/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultCallbacksRegistrar.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jDefaultCallbacksRegistrar.java rename to src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultCallbacksRegistrar.java index 89b7fdd5c..c711a307e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jDefaultCallbacksRegistrar.java +++ b/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultCallbacksRegistrar.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,20 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import org.apiguardian.api.API; -import org.neo4j.springframework.data.repository.event.IdGeneratingBeforeBindCallback; -import org.neo4j.springframework.data.repository.event.OptimisticLockingBeforeBindCallback; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; import org.springframework.core.type.AnnotationMetadata; +import org.springframework.data.neo4j.core.Neo4jOperations; +import org.springframework.data.neo4j.repository.event.IdGeneratingBeforeBindCallback; +import org.springframework.data.neo4j.repository.event.OptimisticLockingBeforeBindCallback; /** - * This brings in the default callbacks required for the default implementation of {@link org.neo4j.springframework.data.core.Neo4jOperations} to work. + * This brings in the default callbacks required for the default implementation of {@link Neo4jOperations} to work. * The offered support configuration class {@link AbstractNeo4jConfig} imports this and so does the Spring Boot autoconfiguration. * * @author Michael J. Simons diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jDefaultReactiveCallbacksRegistrar.java b/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultReactiveCallbacksRegistrar.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jDefaultReactiveCallbacksRegistrar.java rename to src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultReactiveCallbacksRegistrar.java index aa88d97ee..b15e58848 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/Neo4jDefaultReactiveCallbacksRegistrar.java +++ b/src/main/java/org/springframework/data/neo4j/config/Neo4jDefaultReactiveCallbacksRegistrar.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,20 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import org.apiguardian.api.API; -import org.neo4j.springframework.data.repository.event.ReactiveIdGeneratingBeforeBindCallback; -import org.neo4j.springframework.data.repository.event.ReactiveOptimisticLockingBeforeBindCallback; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; import org.springframework.core.type.AnnotationMetadata; +import org.springframework.data.neo4j.core.Neo4jOperations; +import org.springframework.data.neo4j.repository.event.ReactiveIdGeneratingBeforeBindCallback; +import org.springframework.data.neo4j.repository.event.ReactiveOptimisticLockingBeforeBindCallback; /** - * This brings in the default callbacks required for the default implementation of {@link org.neo4j.springframework.data.core.Neo4jOperations} to work. + * This brings in the default callbacks required for the default implementation of {@link Neo4jOperations} to work. * The offered support configuration class {@link AbstractNeo4jConfig} imports this and so does the Spring Boot autoconfiguration. * * @author Michael J. Simons diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/package-info.java b/src/main/java/org/springframework/data/neo4j/config/package-info.java similarity index 83% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/package-info.java rename to src/main/java/org/springframework/data/neo4j/config/package-info.java index 10837e9ec..f7d65b55e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/config/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/config/package-info.java @@ -3,6 +3,6 @@ * {@link org.springframework.context.annotation.Configuration}. */ @NonNullApi -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DatabaseSelection.java b/src/main/java/org/springframework/data/neo4j/core/DatabaseSelection.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DatabaseSelection.java rename to src/main/java/org/springframework/data/neo4j/core/DatabaseSelection.java index 23f4f7397..1a3a505ed 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DatabaseSelection.java +++ b/src/main/java/org/springframework/data/neo4j/core/DatabaseSelection.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.Objects; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DatabaseSelectionProvider.java b/src/main/java/org/springframework/data/neo4j/core/DatabaseSelectionProvider.java similarity index 93% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DatabaseSelectionProvider.java rename to src/main/java/org/springframework/data/neo4j/core/DatabaseSelectionProvider.java index efbdbeccb..0e9e24b1c 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DatabaseSelectionProvider.java +++ b/src/main/java/org/springframework/data/neo4j/core/DatabaseSelectionProvider.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import org.apiguardian.api.API; import org.springframework.util.Assert; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DefaultNeo4jClient.java b/src/main/java/org/springframework/data/neo4j/core/DefaultNeo4jClient.java similarity index 94% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DefaultNeo4jClient.java rename to src/main/java/org/springframework/data/neo4j/core/DefaultNeo4jClient.java index 9132a9738..5ee7366ad 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DefaultNeo4jClient.java +++ b/src/main/java/org/springframework/data/neo4j/core/DefaultNeo4jClient.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static java.util.stream.Collectors.*; -import static org.neo4j.springframework.data.core.Neo4jClient.*; -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionManager.*; -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionUtils.*; +import static org.springframework.data.neo4j.core.Neo4jClient.*; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -43,13 +38,15 @@ import org.neo4j.driver.Result; import org.neo4j.driver.Session; import org.neo4j.driver.summary.ResultSummary; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.repository.support.Neo4jPersistenceExceptionTranslator; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.converter.ConverterRegistry; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.dao.DataAccessException; import org.springframework.dao.support.PersistenceExceptionTranslator; +import org.springframework.data.neo4j.core.convert.Neo4jConversions; +import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager; +import org.springframework.data.neo4j.core.transaction.Neo4jTransactionUtils; +import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator; import org.springframework.lang.Nullable; import org.springframework.util.Assert; @@ -79,9 +76,9 @@ class DefaultNeo4jClient implements Neo4jClient { AutoCloseableQueryRunner getQueryRunner(@Nullable final String targetDatabase) { - QueryRunner queryRunner = retrieveTransaction(driver, targetDatabase); + QueryRunner queryRunner = Neo4jTransactionManager.retrieveTransaction(driver, targetDatabase); if (queryRunner == null) { - queryRunner = driver.session(defaultSessionConfig(targetDatabase)); + queryRunner = driver.session(Neo4jTransactionUtils.defaultSessionConfig(targetDatabase)); } return (AutoCloseableQueryRunner) Proxy.newProxyInstance(this.getClass().getClassLoader(), diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DefaultReactiveNeo4jClient.java b/src/main/java/org/springframework/data/neo4j/core/DefaultReactiveNeo4jClient.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DefaultReactiveNeo4jClient.java rename to src/main/java/org/springframework/data/neo4j/core/DefaultReactiveNeo4jClient.java index 789ff2b12..66d5180a2 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DefaultReactiveNeo4jClient.java +++ b/src/main/java/org/springframework/data/neo4j/core/DefaultReactiveNeo4jClient.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; - -import static org.neo4j.springframework.data.core.Neo4jClient.*; -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionUtils.*; -import static org.neo4j.springframework.data.core.transaction.ReactiveNeo4jTransactionManager.*; +package org.springframework.data.neo4j.core; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -38,14 +31,15 @@ import org.neo4j.driver.reactive.RxResult; import org.neo4j.driver.reactive.RxSession; import org.neo4j.driver.summary.ResultSummary; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.Neo4jClient.*; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.repository.support.Neo4jPersistenceExceptionTranslator; import org.reactivestreams.Publisher; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.converter.ConverterRegistry; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.dao.DataAccessException; +import org.springframework.data.neo4j.core.convert.Neo4jConversions; +import org.springframework.data.neo4j.core.transaction.Neo4jTransactionUtils; +import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager; +import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator; import org.springframework.lang.Nullable; import org.springframework.util.Assert; @@ -74,10 +68,10 @@ class DefaultReactiveNeo4jClient implements ReactiveNeo4jClient { Mono retrieveRxStatementRunnerHolder(String targetDatabase) { - return retrieveReactiveTransaction(driver, targetDatabase) + return ReactiveNeo4jTransactionManager.retrieveReactiveTransaction(driver, targetDatabase) .map(rxTransaction -> new RxStatementRunnerHolder(rxTransaction, Mono.empty(), Mono.empty())) // .switchIfEmpty( - Mono.using(() -> driver.rxSession(defaultSessionConfig(targetDatabase)), + Mono.using(() -> driver.rxSession(Neo4jTransactionUtils.defaultSessionConfig(targetDatabase)), session -> Mono.from(session.beginTransaction()) .map(tx -> new RxStatementRunnerHolder(tx, tx.commit(), tx.rollback())), RxSession::close) ); @@ -131,11 +125,11 @@ class DefaultReactiveNeo4jClient implements ReactiveNeo4jClient { @Override public RunnableSpecTightToDatabase in(@SuppressWarnings("HiddenField") String targetDatabase) { - this.targetDatabase = verifyDatabaseName(targetDatabase); + this.targetDatabase = Neo4jClient.verifyDatabaseName(targetDatabase); return this; } - class DefaultOngoingBindSpec implements OngoingBindSpec { + class DefaultOngoingBindSpec implements Neo4jClient.OngoingBindSpec { @Nullable private final T value; @@ -161,7 +155,7 @@ class DefaultReactiveNeo4jClient implements ReactiveNeo4jClient { } @Override - public OngoingBindSpec bind(@Nullable Object value) { + public Neo4jClient.OngoingBindSpec bind(@Nullable Object value) { return new DefaultOngoingBindSpec(value); } @@ -313,7 +307,7 @@ class DefaultReactiveNeo4jClient implements ReactiveNeo4jClient { @Override public RunnableDelegation in(@Nullable @SuppressWarnings("HiddenField") String targetDatabase) { - this.targetDatabase = verifyDatabaseName(targetDatabase); + this.targetDatabase = Neo4jClient.verifyDatabaseName(targetDatabase); return this; } diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DelegatingMappingFunctionWithNullCheck.java b/src/main/java/org/springframework/data/neo4j/core/DelegatingMappingFunctionWithNullCheck.java similarity index 89% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DelegatingMappingFunctionWithNullCheck.java rename to src/main/java/org/springframework/data/neo4j/core/DelegatingMappingFunctionWithNullCheck.java index b5e915bdb..dd88a5b80 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DelegatingMappingFunctionWithNullCheck.java +++ b/src/main/java/org/springframework/data/neo4j/core/DelegatingMappingFunctionWithNullCheck.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.function.BiFunction; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DynamicLabels.java b/src/main/java/org/springframework/data/neo4j/core/DynamicLabels.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DynamicLabels.java rename to src/main/java/org/springframework/data/neo4j/core/DynamicLabels.java index 0bea8098e..ee35e9520 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/DynamicLabels.java +++ b/src/main/java/org/springframework/data/neo4j/core/DynamicLabels.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; - -import static org.neo4j.springframework.data.core.schema.Constants.*; +package org.springframework.data.neo4j.core; import java.util.ArrayList; import java.util.Collection; @@ -29,6 +24,7 @@ import java.util.function.UnaryOperator; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Node; import org.neo4j.cypherdsl.core.StatementBuilder.OngoingMatchAndUpdate; +import org.springframework.data.neo4j.core.schema.Constants; /** * Decorator for an ongoing update statement that removes obsolete dynamic labels and adds new ones. @@ -40,7 +36,7 @@ final class DynamicLabels public static final DynamicLabels EMPTY = new DynamicLabels(Collections.emptyList(), Collections.emptyList()); - private static final Node rootNode = Cypher.anyNode(NAME_OF_ROOT_NODE); + private static final Node rootNode = Cypher.anyNode(Constants.NAME_OF_ROOT_NODE); private final List oldLabels; private final List newLabels; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NamedParameters.java b/src/main/java/org/springframework/data/neo4j/core/NamedParameters.java similarity index 93% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NamedParameters.java rename to src/main/java/org/springframework/data/neo4j/core/NamedParameters.java index 8a1be740f..4465dd58e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NamedParameters.java +++ b/src/main/java/org/springframework/data/neo4j/core/NamedParameters.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static java.util.stream.Collectors.*; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jClient.java b/src/main/java/org/springframework/data/neo4j/core/Neo4jClient.java similarity index 97% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jClient.java rename to src/main/java/org/springframework/data/neo4j/core/Neo4jClient.java index 82f163e95..5823d077b 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jClient.java +++ b/src/main/java/org/springframework/data/neo4j/core/Neo4jClient.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.Collection; import java.util.Map; @@ -28,8 +25,8 @@ import java.util.function.Supplier; import org.apache.commons.logging.LogFactory; import org.apiguardian.api.API; import org.neo4j.driver.Driver; -import org.neo4j.driver.Record; import org.neo4j.driver.QueryRunner; +import org.neo4j.driver.Record; import org.neo4j.driver.summary.ResultSummary; import org.neo4j.driver.types.TypeSystem; import org.springframework.core.log.LogAccessor; @@ -47,7 +44,7 @@ public interface Neo4jClient { // TODO Create examples how to use the callbacks etc. with Springs TransactionTemplate to deal with rollbacks etc. - LogAccessor cypherLog = new LogAccessor(LogFactory.getLog("org.neo4j.springframework.data.cypher")); + LogAccessor cypherLog = new LogAccessor(LogFactory.getLog("org.springframework.data.neo4j.cypher")); static Neo4jClient create(Driver driver) { diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jOperations.java b/src/main/java/org/springframework/data/neo4j/core/Neo4jOperations.java similarity index 97% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jOperations.java rename to src/main/java/org/springframework/data/neo4j/core/Neo4jOperations.java index 2f89ce413..330f80f07 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jOperations.java +++ b/src/main/java/org/springframework/data/neo4j/core/Neo4jOperations.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.List; import java.util.Map; @@ -24,8 +21,8 @@ import java.util.Optional; import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Statement; -import org.neo4j.springframework.data.repository.NoResultException; import org.springframework.dao.IncorrectResultSizeDataAccessException; +import org.springframework.data.neo4j.repository.NoResultException; /** * Specifies operations one can perform on a database, based on an Domain Type. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jTemplate.java b/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java similarity index 92% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jTemplate.java rename to src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java index 0649f442f..27f8cf03d 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/Neo4jTemplate.java +++ b/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static java.util.Collections.*; import static java.util.stream.Collectors.*; import static org.neo4j.cypherdsl.core.Cypher.*; -import static org.neo4j.springframework.data.core.schema.Constants.*; import java.util.ArrayList; import java.util.Collection; @@ -33,24 +29,13 @@ import java.util.function.Function; import org.apache.commons.logging.LogFactory; import org.apiguardian.api.API; -import org.neo4j.driver.exceptions.NoSuchRecordException; -import org.neo4j.driver.summary.ResultSummary; -import org.neo4j.driver.summary.SummaryCounters; import org.neo4j.cypherdsl.core.Condition; import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Statement; import org.neo4j.cypherdsl.core.renderer.Renderer; -import org.neo4j.springframework.data.core.Neo4jClient.RunnableSpecTightToDatabase; -import org.neo4j.springframework.data.core.NestedRelationshipProcessingStateMachine.ProcessState; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; -import org.neo4j.springframework.data.core.schema.CypherGenerator; -import org.neo4j.springframework.data.core.schema.NodeDescription; -import org.neo4j.springframework.data.core.schema.RelationshipDescription; -import org.neo4j.springframework.data.core.support.Relationships; -import org.neo4j.springframework.data.repository.NoResultException; -import org.neo4j.springframework.data.repository.event.BeforeBindCallback; +import org.neo4j.driver.exceptions.NoSuchRecordException; +import org.neo4j.driver.summary.ResultSummary; +import org.neo4j.driver.summary.SummaryCounters; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -60,6 +45,17 @@ import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.data.mapping.AssociationHandler; import org.springframework.data.mapping.PersistentPropertyAccessor; import org.springframework.data.mapping.callback.EntityCallbacks; +import org.springframework.data.neo4j.core.NestedRelationshipProcessingStateMachine.ProcessState; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; +import org.springframework.data.neo4j.core.schema.Constants; +import org.springframework.data.neo4j.core.schema.CypherGenerator; +import org.springframework.data.neo4j.core.schema.NodeDescription; +import org.springframework.data.neo4j.core.schema.RelationshipDescription; +import org.springframework.data.neo4j.core.support.Relationships; +import org.springframework.data.neo4j.repository.NoResultException; +import org.springframework.data.neo4j.repository.event.BeforeBindCallback; import org.springframework.data.util.ClassTypeInformation; import org.springframework.lang.Nullable; import org.springframework.util.Assert; @@ -186,21 +182,21 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware { public Optional findById(Object id, Class domainType) { Neo4jPersistentEntity entityMetaData = neo4jMappingContext.getPersistentEntity(domainType); Statement statement = cypherGenerator - .prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().isEqualTo(parameter(NAME_OF_ID))) + .prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().isEqualTo(parameter(Constants.NAME_OF_ID))) .returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)) .build(); - return createExecutableQuery(domainType, statement, singletonMap(NAME_OF_ID, convertIdValues(id))).getSingleResult(); + return createExecutableQuery(domainType, statement, singletonMap(Constants.NAME_OF_ID, convertIdValues(id))).getSingleResult(); } @Override public List findAllById(Iterable ids, Class domainType) { Neo4jPersistentEntity entityMetaData = neo4jMappingContext.getPersistentEntity(domainType); Statement statement = cypherGenerator - .prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().in((parameter(NAME_OF_IDS)))) + .prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().in((parameter(Constants.NAME_OF_IDS)))) .returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)) .build(); - return createExecutableQuery(domainType, statement, singletonMap(NAME_OF_IDS, convertIdValues(ids))).getResults(); + return createExecutableQuery(domainType, statement, singletonMap(Constants.NAME_OF_IDS, convertIdValues(ids))).getResults(); } private Object convertIdValues(Object idValues) { @@ -251,21 +247,21 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware { return entityMetaData.getDynamicLabelsProperty().map(p -> { PersistentPropertyAccessor propertyAccessor = entityMetaData.getPropertyAccessor(entityToBeSaved); - RunnableSpecTightToDatabase runnableQuery = neo4jClient + Neo4jClient.RunnableSpecTightToDatabase runnableQuery = neo4jClient .query(() -> renderer.render(cypherGenerator.createStatementReturningDynamicLabels(entityMetaData))) .in(inDatabase) - .bind(propertyAccessor.getProperty(entityMetaData.getRequiredIdProperty())).to(NAME_OF_ID) - .bind(entityMetaData.getStaticLabels()).to(NAME_OF_STATIC_LABELS_PARAM); + .bind(propertyAccessor.getProperty(entityMetaData.getRequiredIdProperty())).to(Constants.NAME_OF_ID) + .bind(entityMetaData.getStaticLabels()).to(Constants.NAME_OF_STATIC_LABELS_PARAM); if (entityMetaData.hasVersionProperty()) { runnableQuery = runnableQuery .bind((Long) propertyAccessor.getProperty(entityMetaData.getRequiredVersionProperty()) - 1) - .to(NAME_OF_VERSION_PARAM); + .to(Constants.NAME_OF_VERSION_PARAM); } Optional> optionalResult = runnableQuery.fetch().one(); return new DynamicLabels( - optionalResult.map(r -> (Collection) r.get(NAME_OF_LABELS)).orElseGet(Collections::emptyList), + optionalResult.map(r -> (Collection) r.get(Constants.NAME_OF_LABELS)).orElseGet(Collections::emptyList), (Collection) propertyAccessor.getProperty(p) ); }).orElse(DynamicLabels.EMPTY); @@ -309,7 +305,7 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware { ResultSummary resultSummary = neo4jClient .query(() -> renderer.render(cypherGenerator.prepareSaveOfMultipleInstancesOf(entityMetaData))) .in(databaseName) - .bind(entityList).to(NAME_OF_ENTITY_LIST_PARAM) + .bind(entityList).to(Constants.NAME_OF_ENTITY_LIST_PARAM) .run(); // Save related @@ -442,7 +438,7 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware { neo4jClient.query(renderer.render(relationshipRemoveQuery)) .in(inDatabase) - .bind(convertIdValues(fromId)).to(FROM_ID_PARAMETER_NAME).run(); + .bind(convertIdValues(fromId)).to(Constants.FROM_ID_PARAMETER_NAME).run(); } // nothing to do because there is nothing to map @@ -472,7 +468,7 @@ public final class Neo4jTemplate implements Neo4jOperations, BeanFactoryAware { neo4jClient.query(renderer.render(statementHolder.getRelationshipCreationQuery())) .in(inDatabase) - .bind(convertIdValues(fromId)).to(FROM_ID_PARAMETER_NAME) + .bind(convertIdValues(fromId)).to(Constants.FROM_ID_PARAMETER_NAME) .bindAll(statementHolder.getProperties()) .run(); diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NestedRelationshipContext.java b/src/main/java/org/springframework/data/neo4j/core/NestedRelationshipContext.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NestedRelationshipContext.java rename to src/main/java/org/springframework/data/neo4j/core/NestedRelationshipContext.java index f10e332c3..2ea10cf40 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NestedRelationshipContext.java +++ b/src/main/java/org/springframework/data/neo4j/core/NestedRelationshipContext.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.Map; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; -import org.neo4j.springframework.data.core.schema.RelationshipDescription; import org.springframework.data.mapping.Association; import org.springframework.data.mapping.PersistentPropertyAccessor; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; +import org.springframework.data.neo4j.core.schema.RelationshipDescription; import org.springframework.lang.Nullable; /** diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NestedRelationshipProcessingStateMachine.java b/src/main/java/org/springframework/data/neo4j/core/NestedRelationshipProcessingStateMachine.java similarity index 93% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NestedRelationshipProcessingStateMachine.java rename to src/main/java/org/springframework/data/neo4j/core/NestedRelationshipProcessingStateMachine.java index bf42356b1..e916c1a4a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/NestedRelationshipProcessingStateMachine.java +++ b/src/main/java/org/springframework/data/neo4j/core/NestedRelationshipProcessingStateMachine.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.Collection; import java.util.HashSet; @@ -24,7 +21,7 @@ import java.util.Set; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import org.neo4j.springframework.data.core.schema.RelationshipDescription; +import org.springframework.data.neo4j.core.schema.RelationshipDescription; import org.springframework.lang.Nullable; /** diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/PreparedQuery.java b/src/main/java/org/springframework/data/neo4j/core/PreparedQuery.java similarity index 95% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/PreparedQuery.java rename to src/main/java/org/springframework/data/neo4j/core/PreparedQuery.java index 4eb17f03a..589cde320 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/PreparedQuery.java +++ b/src/main/java/org/springframework/data/neo4j/core/PreparedQuery.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.Collections; import java.util.HashMap; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveDatabaseSelectionProvider.java b/src/main/java/org/springframework/data/neo4j/core/ReactiveDatabaseSelectionProvider.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveDatabaseSelectionProvider.java rename to src/main/java/org/springframework/data/neo4j/core/ReactiveDatabaseSelectionProvider.java index da671c9ed..3a6bdfab2 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveDatabaseSelectionProvider.java +++ b/src/main/java/org/springframework/data/neo4j/core/ReactiveDatabaseSelectionProvider.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import reactor.core.publisher.Mono; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jClient.java b/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jClient.java similarity index 95% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jClient.java rename to src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jClient.java index 3c6ca49c8..ac6bd2c45 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jClient.java +++ b/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jClient.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -33,8 +30,8 @@ import org.neo4j.driver.Record; import org.neo4j.driver.reactive.RxQueryRunner; import org.neo4j.driver.summary.ResultSummary; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.Neo4jClient.BindSpec; import org.springframework.core.log.LogAccessor; +import org.springframework.data.neo4j.core.Neo4jClient.BindSpec; /** * Reactive Neo4j client. The main difference to the {@link Neo4jClient imperative Neo4j client} is the fact that all @@ -47,7 +44,7 @@ import org.springframework.core.log.LogAccessor; @API(status = API.Status.STABLE, since = "1.0") public interface ReactiveNeo4jClient { - LogAccessor cypherLog = new LogAccessor(LogFactory.getLog("org.neo4j.springframework.data.cypher")); + LogAccessor cypherLog = new LogAccessor(LogFactory.getLog("org.springframework.data.neo4j.cypher")); static ReactiveNeo4jClient create(Driver driver) { diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jOperations.java b/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jOperations.java similarity index 97% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jOperations.java rename to src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jOperations.java index a38399c00..5b512e74e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jOperations.java +++ b/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jOperations.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jTemplate.java b/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java similarity index 93% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jTemplate.java rename to src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java index d2062e8f1..fa99873e8 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/ReactiveNeo4jTemplate.java +++ b/src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static java.util.Collections.*; import static java.util.stream.Collectors.*; import static org.neo4j.cypherdsl.core.Cypher.*; -import static org.neo4j.springframework.data.core.DatabaseSelection.*; -import static org.neo4j.springframework.data.core.schema.Constants.*; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -38,22 +33,13 @@ import java.util.function.Function; import org.apache.commons.logging.LogFactory; import org.apiguardian.api.API; -import org.neo4j.driver.exceptions.NoSuchRecordException; -import org.neo4j.driver.summary.ResultSummary; -import org.neo4j.driver.summary.SummaryCounters; import org.neo4j.cypherdsl.core.Condition; import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Statement; import org.neo4j.cypherdsl.core.renderer.Renderer; -import org.neo4j.springframework.data.core.NestedRelationshipProcessingStateMachine.ProcessState; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; -import org.neo4j.springframework.data.core.schema.CypherGenerator; -import org.neo4j.springframework.data.core.schema.NodeDescription; -import org.neo4j.springframework.data.core.schema.RelationshipDescription; -import org.neo4j.springframework.data.core.support.Relationships; -import org.neo4j.springframework.data.repository.event.ReactiveBeforeBindCallback; +import org.neo4j.driver.exceptions.NoSuchRecordException; +import org.neo4j.driver.summary.ResultSummary; +import org.neo4j.driver.summary.SummaryCounters; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -63,6 +49,16 @@ import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.data.mapping.AssociationHandler; import org.springframework.data.mapping.PersistentPropertyAccessor; import org.springframework.data.mapping.callback.ReactiveEntityCallbacks; +import org.springframework.data.neo4j.core.NestedRelationshipProcessingStateMachine.ProcessState; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; +import org.springframework.data.neo4j.core.schema.Constants; +import org.springframework.data.neo4j.core.schema.CypherGenerator; +import org.springframework.data.neo4j.core.schema.NodeDescription; +import org.springframework.data.neo4j.core.schema.RelationshipDescription; +import org.springframework.data.neo4j.core.support.Relationships; +import org.springframework.data.neo4j.repository.event.ReactiveBeforeBindCallback; import org.springframework.data.util.ClassTypeInformation; import org.springframework.lang.Nullable; import org.springframework.util.Assert; @@ -187,11 +183,11 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea Neo4jPersistentEntity entityMetaData = neo4jMappingContext.getPersistentEntity(domainType); Statement statement = cypherGenerator - .prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().isEqualTo(parameter(NAME_OF_ID))) + .prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().isEqualTo(parameter(Constants.NAME_OF_ID))) .returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)) .build(); - return createExecutableQuery(domainType, statement, singletonMap(NAME_OF_ID, convertIdValues(id))) + return createExecutableQuery(domainType, statement, singletonMap(Constants.NAME_OF_ID, convertIdValues(id))) .flatMap(ExecutableQuery::getSingleResult); } @@ -200,11 +196,11 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea Neo4jPersistentEntity entityMetaData = neo4jMappingContext.getPersistentEntity(domainType); Statement statement = cypherGenerator - .prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().in((parameter(NAME_OF_IDS)))) + .prepareMatchOf(entityMetaData, entityMetaData.getIdExpression().in((parameter(Constants.NAME_OF_IDS)))) .returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)) .build(); - return createExecutableQuery(domainType, statement, singletonMap(NAME_OF_IDS, convertIdValues(ids))) + return createExecutableQuery(domainType, statement, singletonMap(Constants.NAME_OF_IDS, convertIdValues(ids))) .flatMapMany(ExecutableQuery::getResults); } @@ -270,17 +266,17 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea ReactiveNeo4jClient.RunnableSpecTightToDatabase runnableQuery = neo4jClient .query(() -> renderer.render(cypherGenerator.createStatementReturningDynamicLabels(entityMetaData))) .in(inDatabase) - .bind(propertyAccessor.getProperty(entityMetaData.getRequiredIdProperty())).to(NAME_OF_ID) - .bind(entityMetaData.getStaticLabels()).to(NAME_OF_STATIC_LABELS_PARAM); + .bind(propertyAccessor.getProperty(entityMetaData.getRequiredIdProperty())).to(Constants.NAME_OF_ID) + .bind(entityMetaData.getStaticLabels()).to(Constants.NAME_OF_STATIC_LABELS_PARAM); if (entityMetaData.hasVersionProperty()) { runnableQuery = runnableQuery .bind((Long) propertyAccessor.getProperty(entityMetaData.getRequiredVersionProperty()) - 1) - .to(NAME_OF_VERSION_PARAM); + .to(Constants.NAME_OF_VERSION_PARAM); } return runnableQuery.fetch().one() - .map(m -> (Collection) m.get(NAME_OF_LABELS)) + .map(m -> (Collection) m.get(Constants.NAME_OF_LABELS)) .switchIfEmpty(Mono.just(Collections.emptyList())) .zipWith(Mono.just((Collection) propertyAccessor.getProperty(p))) .map(t -> Tuples.of(entityToBeSaved, new DynamicLabels(t.getT1(), t.getT2()))); @@ -328,7 +324,7 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea .query(() -> renderer .render(cypherGenerator.prepareSaveOfMultipleInstancesOf(entityMetaData))) .in(databaseName.getValue()) - .bind(boundedEntityList).to(NAME_OF_ENTITY_LIST_PARAM).run(); + .bind(boundedEntityList).to(Constants.NAME_OF_ENTITY_LIST_PARAM).run(); }) .doOnNext(resultSummary -> { SummaryCounters counters = resultSummary.counters(); @@ -451,7 +447,7 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea relationshipCreationMonos.add( neo4jClient.query(renderer.render(relationshipRemoveQuery)) .in(inDatabase) - .bind(convertIdValues(fromId)).to(FROM_ID_PARAMETER_NAME) + .bind(convertIdValues(fromId)).to(Constants.FROM_ID_PARAMETER_NAME) .run().checkpoint("delete relationships").then()); } @@ -494,7 +490,7 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea Mono relationshipCreationMonoNested = neo4jClient .query(renderer.render(statementHolder.getRelationshipCreationQuery())) .in(inDatabase) - .bind(convertIdValues(fromId)).to(FROM_ID_PARAMETER_NAME) + .bind(convertIdValues(fromId)).to(Constants.FROM_ID_PARAMETER_NAME) .bindAll(statementHolder.getProperties()) .run(); @@ -540,7 +536,7 @@ public final class ReactiveNeo4jTemplate implements ReactiveNeo4jOperations, Bea private Mono getDatabaseName() { - return this.databaseSelectionProvider.getDatabaseSelection().switchIfEmpty(Mono.just(undecided())); + return this.databaseSelectionProvider.getDatabaseSelection().switchIfEmpty(Mono.just(DatabaseSelection.undecided())); } @Override diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/RelationshipStatementHolder.java b/src/main/java/org/springframework/data/neo4j/core/RelationshipStatementHolder.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/RelationshipStatementHolder.java rename to src/main/java/org/springframework/data/neo4j/core/RelationshipStatementHolder.java index 0749f527c..3f77d1f44 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/RelationshipStatementHolder.java +++ b/src/main/java/org/springframework/data/neo4j/core/RelationshipStatementHolder.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.neo4j.cypherdsl.core.Statement; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.schema.CypherGenerator; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.schema.CypherGenerator; import org.springframework.data.util.TypeInformation; import org.springframework.lang.NonNull; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/SingleValueMappingFunction.java b/src/main/java/org/springframework/data/neo4j/core/SingleValueMappingFunction.java similarity index 89% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/SingleValueMappingFunction.java rename to src/main/java/org/springframework/data/neo4j/core/SingleValueMappingFunction.java index 89f277d5c..c754e3cdf 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/SingleValueMappingFunction.java +++ b/src/main/java/org/springframework/data/neo4j/core/SingleValueMappingFunction.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import java.util.function.BiFunction; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/AdditionalTypes.java b/src/main/java/org/springframework/data/neo4j/core/convert/AdditionalTypes.java similarity index 98% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/AdditionalTypes.java rename to src/main/java/org/springframework/data/neo4j/core/convert/AdditionalTypes.java index 502497ed2..896fc9155 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/AdditionalTypes.java +++ b/src/main/java/org/springframework/data/neo4j/core/convert/AdditionalTypes.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import static org.springframework.data.convert.ConverterBuilder.*; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/CypherTypes.java b/src/main/java/org/springframework/data/neo4j/core/convert/CypherTypes.java similarity index 93% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/CypherTypes.java rename to src/main/java/org/springframework/data/neo4j/core/convert/CypherTypes.java index 2d966af2f..5dceabd77 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/CypherTypes.java +++ b/src/main/java/org/springframework/data/neo4j/core/convert/CypherTypes.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import static org.springframework.data.convert.ConverterBuilder.*; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jConversions.java b/src/main/java/org/springframework/data/neo4j/core/convert/Neo4jConversions.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jConversions.java rename to src/main/java/org/springframework/data/neo4j/core/convert/Neo4jConversions.java index 942dc6444..5497b28cf 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jConversions.java +++ b/src/main/java/org/springframework/data/neo4j/core/convert/Neo4jConversions.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import java.util.ArrayList; import java.util.Collection; @@ -24,7 +21,6 @@ import java.util.Collections; import java.util.List; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.convert.AdditionalTypes.EnumArrayConverter; import org.springframework.core.convert.converter.ConverterRegistry; import org.springframework.data.convert.CustomConversions; @@ -70,6 +66,6 @@ public final class Neo4jConversions extends CustomConversions { @Override public void registerConvertersIn(ConverterRegistry conversionService) { super.registerConvertersIn(conversionService); - conversionService.addConverter(new EnumArrayConverter()); + conversionService.addConverter(new AdditionalTypes.EnumArrayConverter()); } } diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jConverter.java b/src/main/java/org/springframework/data/neo4j/core/convert/Neo4jConverter.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jConverter.java rename to src/main/java/org/springframework/data/neo4j/core/convert/Neo4jConverter.java index 5bb516a72..3d8cb7df0 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jConverter.java +++ b/src/main/java/org/springframework/data/neo4j/core/convert/Neo4jConverter.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import java.util.Map; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jSimpleTypes.java b/src/main/java/org/springframework/data/neo4j/core/convert/Neo4jSimpleTypes.java similarity index 86% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jSimpleTypes.java rename to src/main/java/org/springframework/data/neo4j/core/convert/Neo4jSimpleTypes.java index 2858b2560..d91a09292 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/Neo4jSimpleTypes.java +++ b/src/main/java/org/springframework/data/neo4j/core/convert/Neo4jSimpleTypes.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import java.math.BigDecimal; import java.math.BigInteger; @@ -36,11 +33,11 @@ import org.apiguardian.api.API; import org.neo4j.driver.Value; import org.neo4j.driver.types.IsoDuration; import org.neo4j.driver.types.Point; -import org.neo4j.springframework.data.types.CartesianPoint2d; -import org.neo4j.springframework.data.types.CartesianPoint3d; -import org.neo4j.springframework.data.types.GeographicPoint2d; -import org.neo4j.springframework.data.types.GeographicPoint3d; import org.springframework.data.mapping.model.SimpleTypeHolder; +import org.springframework.data.neo4j.types.CartesianPoint2d; +import org.springframework.data.neo4j.types.CartesianPoint3d; +import org.springframework.data.neo4j.types.GeographicPoint2d; +import org.springframework.data.neo4j.types.GeographicPoint3d; /** * A list of Neo4j simple types: All attributes that can be mapped to a property. Some special logic has to be applied diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/SpatialTypes.java b/src/main/java/org/springframework/data/neo4j/core/convert/SpatialTypes.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/SpatialTypes.java rename to src/main/java/org/springframework/data/neo4j/core/convert/SpatialTypes.java index 4ba2a3a23..da3e8cd38 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/SpatialTypes.java +++ b/src/main/java/org/springframework/data/neo4j/core/convert/SpatialTypes.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import static org.springframework.data.convert.ConverterBuilder.*; @@ -26,15 +23,15 @@ import java.util.List; import org.neo4j.driver.Value; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.types.CartesianPoint2d; -import org.neo4j.springframework.data.types.CartesianPoint3d; -import org.neo4j.springframework.data.types.Coordinate; -import org.neo4j.springframework.data.types.GeographicPoint2d; -import org.neo4j.springframework.data.types.GeographicPoint3d; -import org.neo4j.springframework.data.types.Neo4jPoint; -import org.neo4j.springframework.data.types.PointBuilder; import org.springframework.data.convert.ConverterBuilder; import org.springframework.data.geo.Point; +import org.springframework.data.neo4j.types.CartesianPoint2d; +import org.springframework.data.neo4j.types.CartesianPoint3d; +import org.springframework.data.neo4j.types.Coordinate; +import org.springframework.data.neo4j.types.GeographicPoint2d; +import org.springframework.data.neo4j.types.GeographicPoint3d; +import org.springframework.data.neo4j.types.Neo4jPoint; +import org.springframework.data.neo4j.types.PointBuilder; import org.springframework.util.Assert; /** diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/TemporalAmountAdapter.java b/src/main/java/org/springframework/data/neo4j/core/convert/TemporalAmountAdapter.java similarity index 94% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/TemporalAmountAdapter.java rename to src/main/java/org/springframework/data/neo4j/core/convert/TemporalAmountAdapter.java index d9a97337d..f1fbfa511 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/TemporalAmountAdapter.java +++ b/src/main/java/org/springframework/data/neo4j/core/convert/TemporalAmountAdapter.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import java.time.Duration; import java.time.Period; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/package-info.java b/src/main/java/org/springframework/data/neo4j/core/convert/package-info.java similarity index 66% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/package-info.java rename to src/main/java/org/springframework/data/neo4j/core/convert/package-info.java index dfc7bd9e8..cdab3bc0a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/convert/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/core/convert/package-info.java @@ -2,6 +2,6 @@ * Neo4j-specific conversion classes. */ @NonNullApi -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jConverter.java b/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jConverter.java similarity index 94% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jConverter.java rename to src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jConverter.java index 3b79d95b5..723e14fa2 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jConverter.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jConverter.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import static java.util.stream.Collectors.*; -import static org.neo4j.springframework.data.core.schema.Constants.*; -import static org.neo4j.springframework.data.core.schema.RelationshipDescription.*; import static org.springframework.core.CollectionFactory.*; import java.util.ArrayList; @@ -47,9 +42,6 @@ import org.neo4j.driver.types.MapAccessor; import org.neo4j.driver.types.Node; import org.neo4j.driver.types.Relationship; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.core.convert.Neo4jConverter; -import org.neo4j.springframework.data.core.schema.RelationshipDescription; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.support.ConfigurableConversionService; import org.springframework.core.convert.support.DefaultConversionService; @@ -62,6 +54,10 @@ import org.springframework.data.mapping.PersistentPropertyAccessor; import org.springframework.data.mapping.PreferredConstructor; import org.springframework.data.mapping.PropertyHandler; import org.springframework.data.mapping.model.ParameterValueProvider; +import org.springframework.data.neo4j.core.convert.Neo4jConversions; +import org.springframework.data.neo4j.core.convert.Neo4jConverter; +import org.springframework.data.neo4j.core.schema.Constants; +import org.springframework.data.neo4j.core.schema.RelationshipDescription; import org.springframework.data.util.TypeInformation; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; @@ -191,12 +187,12 @@ final class DefaultNeo4jConverter implements Neo4jConverter { properties.put(p.getPropertyName(), value); }); - parameters.put(NAME_OF_PROPERTIES_PARAM, properties); + parameters.put(Constants.NAME_OF_PROPERTIES_PARAM, properties); // in case of relationship properties ignore internal id property if (nodeDescription.hasIdProperty()) { Neo4jPersistentProperty idProperty = nodeDescription.getRequiredIdProperty(); - parameters.put(NAME_OF_ID, + parameters.put(Constants.NAME_OF_ID, writeValueFromProperty(propertyAccessor.getProperty(idProperty), idProperty.getTypeInformation())); } // in case of relationship properties ignore internal id property @@ -204,7 +200,7 @@ final class DefaultNeo4jConverter implements Neo4jConverter { Long versionProperty = (Long) propertyAccessor.getProperty(nodeDescription.getRequiredVersionProperty()); // we incremented this upfront the persist operation so the matching version would be one "before" - parameters.put(NAME_OF_VERSION_PARAM, versionProperty - 1); + parameters.put(Constants.NAME_OF_VERSION_PARAM, versionProperty - 1); } } @@ -244,7 +240,7 @@ final class DefaultNeo4jConverter implements Neo4jConverter { private static MapAccessor mergeRootNodeWithRecord(Node node, Record record) { Map mergedAttributes = new HashMap<>(node.size() + record.size() + 1); - mergedAttributes.put(NAME_OF_INTERNAL_ID, node.id()); + mergedAttributes.put(Constants.NAME_OF_INTERNAL_ID, node.id()); mergedAttributes.putAll(node.asMap(Function.identity())); mergedAttributes.putAll(record.asMap(Function.identity())); @@ -295,11 +291,11 @@ final class DefaultNeo4jConverter implements Neo4jConverter { * Returns the list of labels for the entity to be created from the "main" node returned. * * @param queryResult The complete query result - * @return The list of labels defined by the query variable {@link org.neo4j.springframework.data.core.schema.Constants#NAME_OF_LABELS}. + * @return The list of labels defined by the query variable {@link Constants#NAME_OF_LABELS}. */ @NonNull private List getLabels(MapAccessor queryResult) { - Value labelsValue = queryResult.get(NAME_OF_LABELS); + Value labelsValue = queryResult.get(Constants.NAME_OF_LABELS); List labels = new ArrayList<>(); if (!labelsValue.isNull()) { labels = labelsValue.asList(Value::asString); @@ -486,7 +482,7 @@ final class DefaultNeo4jConverter implements Neo4jConverter { // internal (generated) id or external set String relatedEntityIdKey = idProperty.isInternalIdProperty() - ? NAME_OF_INTERNAL_ID + ? Constants.NAME_OF_INTERNAL_ID : concreteTargetNodeDescription.getIdDescription() .getOptionalGraphPropertyName() .orElse(idProperty.getName()); @@ -496,7 +492,8 @@ final class DefaultNeo4jConverter implements Neo4jConverter { () -> map(relatedEntity, concreteTargetNodeDescription, knownObjects)); if (relationshipDescription.hasRelationshipProperties()) { - Relationship relatedEntityRelationship = relatedEntity.get(NAME_OF_RELATIONSHIP).asRelationship(); + Relationship relatedEntityRelationship = relatedEntity.get( + RelationshipDescription.NAME_OF_RELATIONSHIP).asRelationship(); Class propertiesClass = relationshipDescription.getRelationshipPropertiesClass(); Object relationshipProperties = map(relatedEntityRelationship, @@ -504,7 +501,7 @@ final class DefaultNeo4jConverter implements Neo4jConverter { knownObjects); relationshipsAndProperties.put(valueEntry, relationshipProperties); } else { - mappedObjectHandler.accept(relatedEntity.get(NAME_OF_RELATIONSHIP_TYPE).asString(), valueEntry); + mappedObjectHandler.accept(relatedEntity.get(RelationshipDescription.NAME_OF_RELATIONSHIP_TYPE).asString(), valueEntry); } } } @@ -531,7 +528,7 @@ final class DefaultNeo4jConverter implements Neo4jConverter { if (property.isInternalIdProperty()) { return propertyContainer instanceof Node ? Values.value(((Node) propertyContainer).id()) : - propertyContainer.get(NAME_OF_INTERNAL_ID); + propertyContainer.get(Constants.NAME_OF_INTERNAL_ID); } else { String graphPropertyName = property.getPropertyName(); return propertyContainer.get(graphPropertyName); diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jIsNewStrategy.java b/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jIsNewStrategy.java similarity index 94% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jIsNewStrategy.java rename to src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jIsNewStrategy.java index 925cc438b..02c107d3a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jIsNewStrategy.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jIsNewStrategy.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import java.util.function.Function; import org.apache.commons.logging.LogFactory; -import org.neo4j.springframework.data.core.schema.IdDescription; import org.springframework.core.log.LogAccessor; +import org.springframework.data.neo4j.core.schema.IdDescription; import org.springframework.data.support.IsNewStrategy; import org.springframework.lang.Nullable; import org.springframework.util.Assert; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentEntity.java b/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentEntity.java similarity index 95% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentEntity.java rename to src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentEntity.java index 13ac407b6..033354ed7 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentEntity.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentEntity.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import static java.util.Collections.*; import static org.springframework.util.StringUtils.*; @@ -25,12 +22,10 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.neo4j.springframework.data.core.schema.*; -import org.neo4j.springframework.data.core.schema.GeneratedValue.InternalIdGenerator; -import org.neo4j.springframework.data.core.schema.GeneratedValue.UUIDGenerator; import org.springframework.data.mapping.Association; import org.springframework.data.mapping.PropertyHandler; import org.springframework.data.mapping.model.BasicPersistentEntity; +import org.springframework.data.neo4j.core.schema.*; import org.springframework.data.support.IsNewStrategy; import org.springframework.data.util.Lazy; import org.springframework.data.util.TypeInformation; @@ -320,13 +315,13 @@ class DefaultNeo4jPersistentEntity extends BasicPersistentEntity> idGeneratorClass = generatedValueAnnotation.generatorClass(); String idGeneratorRef = generatedValueAnnotation.generatorRef(); - if (idProperty.getActualType() == UUID.class && idGeneratorClass == InternalIdGenerator.class + if (idProperty.getActualType() == UUID.class && idGeneratorClass == GeneratedValue.InternalIdGenerator.class && !StringUtils.hasText(idGeneratorRef)) { - idGeneratorClass = UUIDGenerator.class; + idGeneratorClass = GeneratedValue.UUIDGenerator.class; } // Internally generated ids. - if (idGeneratorClass == InternalIdGenerator.class && idGeneratorRef.isEmpty()) { + if (idGeneratorClass == GeneratedValue.InternalIdGenerator.class && idGeneratorRef.isEmpty()) { if (idProperty.findAnnotation(Property.class) != null) { throw new IllegalArgumentException( "Cannot use internal id strategy with custom property " + propertyName diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentProperty.java b/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentProperty.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentProperty.java rename to src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentProperty.java index c1ebd4116..9e7507b27 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentProperty.java +++ b/src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentProperty.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,20 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import java.util.Optional; -import org.neo4j.springframework.data.core.schema.NodeDescription; -import org.neo4j.springframework.data.core.schema.Relationship; -import org.neo4j.springframework.data.core.schema.RelationshipDescription; -import org.neo4j.springframework.data.core.schema.RelationshipProperties; import org.springframework.data.mapping.Association; import org.springframework.data.mapping.MappingException; import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty; import org.springframework.data.mapping.model.Property; import org.springframework.data.mapping.model.SimpleTypeHolder; +import org.springframework.data.neo4j.core.schema.NodeDescription; +import org.springframework.data.neo4j.core.schema.Relationship; +import org.springframework.data.neo4j.core.schema.RelationshipDescription; +import org.springframework.data.neo4j.core.schema.RelationshipProperties; import org.springframework.data.util.Lazy; import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; @@ -156,8 +153,8 @@ class DefaultNeo4jPersistentProperty extends AnnotationBasedPersistentProperty additionalLabels = nodeDescription.getAdditionalLabels(); - Node rootNode = node(primaryLabel, additionalLabels).named(NAME_OF_ROOT_NODE); + Node rootNode = node(primaryLabel, additionalLabels).named(Constants.NAME_OF_ROOT_NODE); IdDescription idDescription = nodeDescription.getIdDescription(); List expressions = new ArrayList<>(); - expressions.add(NAME_OF_ROOT_NODE); + expressions.add(Constants.NAME_OF_ROOT_NODE); if (idDescription.isInternallyGeneratedId()) { - expressions.add(Functions.id(rootNode).as(NAME_OF_INTERNAL_ID)); + expressions.add(Functions.id(rootNode).as(Constants.NAME_OF_INTERNAL_ID)); } return match(rootNode).where(conditionOrNoCondition(condition)) .with(expressions.toArray(new Expression[] {})); @@ -114,23 +110,24 @@ public enum CypherGenerator { */ public Statement createStatementReturningDynamicLabels(NodeDescription nodeDescription) { - final Node rootNode = anyNode(NAME_OF_ROOT_NODE); + final Node rootNode = Cypher.anyNode(Constants.NAME_OF_ROOT_NODE); Condition versionCondition; if (((Neo4jPersistentEntity) nodeDescription).hasVersionProperty()) { PersistentProperty versionProperty = ((Neo4jPersistentEntity) nodeDescription).getRequiredVersionProperty(); - versionCondition = rootNode.property(versionProperty.getName()).isEqualTo(parameter(NAME_OF_VERSION_PARAM)); + versionCondition = rootNode.property(versionProperty.getName()).isEqualTo(parameter( + Constants.NAME_OF_VERSION_PARAM)); } else { versionCondition = Conditions.noCondition(); } return match(rootNode) - .where(nodeDescription.getIdDescription().asIdExpression().isEqualTo(parameter(NAME_OF_ID))) + .where(nodeDescription.getIdDescription().asIdExpression().isEqualTo(parameter(Constants.NAME_OF_ID))) .and(versionCondition) .unwind(rootNode.labels()).as("label") - .with(Cypher.name("label")).where(Cypher.name("label").in(parameter(NAME_OF_STATIC_LABELS_PARAM)).not()) - .returning(Functions.collect(Cypher.name("label")).as(NAME_OF_LABELS)).build(); + .with(Cypher.name("label")).where(Cypher.name("label").in(parameter(Constants.NAME_OF_STATIC_LABELS_PARAM)).not()) + .returning(Functions.collect(Cypher.name("label")).as(Constants.NAME_OF_LABELS)).build(); } public Statement prepareDeleteOf(NodeDescription nodeDescription) { @@ -140,7 +137,7 @@ public enum CypherGenerator { public Statement prepareDeleteOf(NodeDescription nodeDescription, @Nullable Condition condition) { Node rootNode = node(nodeDescription.getPrimaryLabel(), nodeDescription.getAdditionalLabels()) - .named(NAME_OF_ROOT_NODE); + .named(Constants.NAME_OF_ROOT_NODE); return match(rootNode).where(conditionOrNoCondition(condition)).detachDelete(rootNode).build(); } @@ -149,9 +146,9 @@ public enum CypherGenerator { String primaryLabel = nodeDescription.getPrimaryLabel(); List additionalLabels = nodeDescription.getAdditionalLabels(); - Node rootNode = node(primaryLabel, additionalLabels).named(NAME_OF_ROOT_NODE); + Node rootNode = node(primaryLabel, additionalLabels).named(Constants.NAME_OF_ROOT_NODE); IdDescription idDescription = nodeDescription.getIdDescription(); - Parameter idParameter = parameter(NAME_OF_ID); + Parameter idParameter = parameter(Constants.NAME_OF_ID); if (!idDescription.isInternallyGeneratedId()) { String nameOfIdProperty = idDescription.getOptionalGraphPropertyName() @@ -168,14 +165,15 @@ public enum CypherGenerator { .where(possibleExistingNode.property(nameOfIdProperty).isEqualTo(idParameter)) .with(possibleExistingNode).where(possibleExistingNode.isNull()) .create(rootNode) - .set(rootNode, parameter(NAME_OF_PROPERTIES_PARAM))) + .set(rootNode, parameter(Constants.NAME_OF_PROPERTIES_PARAM))) .returning(rootNode.internalId()) .build(); Statement updateIfExists = updateDecorator.apply(match(rootNode) .where(rootNode.property(nameOfIdProperty).isEqualTo(idParameter)) - .and(rootNode.property(versionProperty.getName()).isEqualTo(parameter(NAME_OF_VERSION_PARAM))) - .set(rootNode, parameter(NAME_OF_PROPERTIES_PARAM))) + .and(rootNode.property(versionProperty.getName()).isEqualTo(parameter( + Constants.NAME_OF_VERSION_PARAM))) + .set(rootNode, parameter(Constants.NAME_OF_PROPERTIES_PARAM))) .returning(rootNode.internalId()) .build(); return Cypher.union(createIfNew, updateIfExists); @@ -183,7 +181,7 @@ public enum CypherGenerator { } else { return updateDecorator.apply( Cypher.merge(rootNode.withProperties(nameOfIdProperty, idParameter)) - .set(rootNode, parameter(NAME_OF_PROPERTIES_PARAM)) + .set(rootNode, parameter(Constants.NAME_OF_PROPERTIES_PARAM)) ).returning(rootNode.internalId()).build(); } } else { @@ -202,13 +200,14 @@ public enum CypherGenerator { .where(possibleExistingNode.internalId().isEqualTo(idParameter)) .with(possibleExistingNode).where(possibleExistingNode.isNull()) .create(rootNode) - .set(rootNode, parameter(NAME_OF_PROPERTIES_PARAM))) + .set(rootNode, parameter(Constants.NAME_OF_PROPERTIES_PARAM))) .returning(rootNode.internalId()).build(); updateIfExists = updateDecorator.apply(match(rootNode) .where(rootNode.internalId().isEqualTo(idParameter)) - .and(rootNode.property(versionProperty.getName()).isEqualTo(parameter(NAME_OF_VERSION_PARAM))) - .set(rootNode, parameter(NAME_OF_PROPERTIES_PARAM))) + .and(rootNode.property(versionProperty.getName()).isEqualTo(parameter( + Constants.NAME_OF_VERSION_PARAM))) + .set(rootNode, parameter(Constants.NAME_OF_PROPERTIES_PARAM))) .returning(rootNode.internalId()) .build(); } else { @@ -216,13 +215,13 @@ public enum CypherGenerator { .where(possibleExistingNode.internalId().isEqualTo(idParameter)) .with(possibleExistingNode).where(possibleExistingNode.isNull()) .create(rootNode) - .set(rootNode, parameter(NAME_OF_PROPERTIES_PARAM))) + .set(rootNode, parameter(Constants.NAME_OF_PROPERTIES_PARAM))) .returning(rootNode.internalId()) .build(); updateIfExists = updateDecorator.apply(match(rootNode) .where(rootNode.internalId().isEqualTo(idParameter)) - .set(rootNode, parameter(NAME_OF_PROPERTIES_PARAM))) + .set(rootNode, parameter(Constants.NAME_OF_PROPERTIES_PARAM))) .returning(rootNode.internalId()).build(); } @@ -236,7 +235,7 @@ public enum CypherGenerator { "Only entities that use external IDs can be saved in a batch."); Node rootNode = node(nodeDescription.getPrimaryLabel(), nodeDescription.getAdditionalLabels()) - .named(NAME_OF_ROOT_NODE); + .named(Constants.NAME_OF_ROOT_NODE); IdDescription idDescription = nodeDescription.getIdDescription(); String nameOfIdProperty = idDescription.getOptionalGraphPropertyName() @@ -244,10 +243,10 @@ public enum CypherGenerator { String row = "entity"; return Cypher - .unwind(parameter(NAME_OF_ENTITY_LIST_PARAM)).as(row) - .merge(rootNode.withProperties(nameOfIdProperty, property(row, NAME_OF_ID))) - .set(rootNode, property(row, NAME_OF_PROPERTIES_PARAM)) - .returning(Functions.collect(rootNode.property(nameOfIdProperty)).as(NAME_OF_IDS)) + .unwind(parameter(Constants.NAME_OF_ENTITY_LIST_PARAM)).as(row) + .merge(rootNode.withProperties(nameOfIdProperty, Cypher.property(row, Constants.NAME_OF_ID))) + .set(rootNode, Cypher.property(row, Constants.NAME_OF_PROPERTIES_PARAM)) + .returning(Functions.collect(rootNode.property(nameOfIdProperty)).as(Constants.NAME_OF_IDS)) .build(); } @@ -262,7 +261,7 @@ public enum CypherGenerator { final Node endNode = anyNode(END_NODE_NAME); String idPropertyName = neo4jPersistentEntity.getRequiredIdProperty().getPropertyName(); - Parameter idParameter = parameter(FROM_ID_PARAMETER_NAME); + Parameter idParameter = parameter(Constants.FROM_ID_PARAMETER_NAME); String type = relationship.isDynamic() ? dynamicRelationshipType : relationship.getType(); return match(startNode) .where(neo4jPersistentEntity.isUsingInternalIds() @@ -290,8 +289,8 @@ public enum CypherGenerator { Node endNode = anyNode(END_NODE_NAME); String idPropertyName = neo4jPersistentEntity.getRequiredIdProperty().getPropertyName(); - Parameter idParameter = parameter(FROM_ID_PARAMETER_NAME); - Parameter relationshipProperties = parameter(NAME_OF_PROPERTIES_PARAM); + Parameter idParameter = parameter(Constants.FROM_ID_PARAMETER_NAME); + Parameter relationshipProperties = parameter(Constants.NAME_OF_PROPERTIES_PARAM); String type = relationship.getType(); Relationship relOutgoing = startNode.relationshipTo(endNode, type).named(RELATIONSHIP_NAME); @@ -330,7 +329,7 @@ public enum CypherGenerator { ? startNode.relationshipTo(endNode, relationshipType).named(relationshipToRemoveName) : startNode.relationshipFrom(endNode, relationshipType).named(relationshipToRemoveName); - Parameter idParameter = parameter(FROM_ID_PARAMETER_NAME); + Parameter idParameter = parameter(Constants.FROM_ID_PARAMETER_NAME); return match(relationship) .where(neo4jPersistentEntity.isUsingInternalIds() ? startNode.internalId().isEqualTo(idParameter) @@ -356,7 +355,7 @@ public enum CypherGenerator { List processedRelationships = new ArrayList<>(); - return projectPropertiesAndRelationships(nodeDescription, NAME_OF_ROOT_NODE, includeField, + return projectPropertiesAndRelationships(nodeDescription, Constants.NAME_OF_ROOT_NODE, includeField, processedRelationships); } @@ -398,21 +397,21 @@ public enum CypherGenerator { } if (property.isInternalIdProperty()) { - nodePropertiesProjection.add(NAME_OF_INTERNAL_ID); + nodePropertiesProjection.add(Constants.NAME_OF_INTERNAL_ID); nodePropertiesProjection.add(Functions.id(node)); } else if (!((Neo4jPersistentProperty) property).isDynamicLabels()) { nodePropertiesProjection.add(property.getPropertyName()); } } - nodePropertiesProjection.add(NAME_OF_LABELS); + nodePropertiesProjection.add(Constants.NAME_OF_LABELS); nodePropertiesProjection.add(Functions.labels(node)); return nodePropertiesProjection; } /** - * @see org.neo4j.springframework.data.core.schema.CypherGenerator#projectNodeProperties + * @see CypherGenerator#projectNodeProperties */ private List generateListsFor(Collection relationships, SymbolicName nodeName, Predicate includeField, @@ -429,7 +428,7 @@ public enum CypherGenerator { // if we already processed the other way before, do not try to jump in the infinite loop // unless it is a root node relationship - if (!nodeName.equals(NAME_OF_ROOT_NODE) && relationshipDescription.hasRelationshipObverse() + if (!nodeName.equals(Constants.NAME_OF_ROOT_NODE) && relationshipDescription.hasRelationshipObverse() && processedRelationships.contains(relationshipDescription.getRelationshipObverse())) { continue; } diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/DynamicLabels.java b/src/main/java/org/springframework/data/neo4j/core/schema/DynamicLabels.java similarity index 88% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/DynamicLabels.java rename to src/main/java/org/springframework/data/neo4j/core/schema/DynamicLabels.java index 34e11aa01..84066e5f5 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/DynamicLabels.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/DynamicLabels.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/GeneratedValue.java b/src/main/java/org/springframework/data/neo4j/core/schema/GeneratedValue.java similarity index 92% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/GeneratedValue.java rename to src/main/java/org/springframework/data/neo4j/core/schema/GeneratedValue.java index 5b3b5e627..991685f00 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/GeneratedValue.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/GeneratedValue.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/GraphPropertyDescription.java b/src/main/java/org/springframework/data/neo4j/core/schema/GraphPropertyDescription.java similarity index 89% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/GraphPropertyDescription.java rename to src/main/java/org/springframework/data/neo4j/core/schema/GraphPropertyDescription.java index 3f6dd94a8..9f05e8fe9 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/GraphPropertyDescription.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/GraphPropertyDescription.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import org.apiguardian.api.API; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Id.java b/src/main/java/org/springframework/data/neo4j/core/schema/Id.java similarity index 92% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Id.java rename to src/main/java/org/springframework/data/neo4j/core/schema/Id.java index a41ef9be2..41cdca55b 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Id.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/Id.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/IdDescription.java b/src/main/java/org/springframework/data/neo4j/core/schema/IdDescription.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/IdDescription.java rename to src/main/java/org/springframework/data/neo4j/core/schema/IdDescription.java index 8464bc758..5d21792ad 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/IdDescription.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/IdDescription.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; - -import static org.neo4j.cypherdsl.core.Cypher.*; -import static org.neo4j.springframework.data.core.schema.Constants.*; +package org.springframework.data.neo4j.core.schema; import java.util.Optional; import org.apiguardian.api.API; +import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.Expression; import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Node; @@ -95,12 +90,12 @@ public final class IdDescription { this.idGeneratorRef = idGeneratorRef != null && idGeneratorRef.isEmpty() ? null : idGeneratorRef; this.graphPropertyName = graphPropertyName; this.idExpression = Lazy.of(() -> { - final Node rootNode = anyNode(NAME_OF_ROOT_NODE); + final Node rootNode = Cypher.anyNode(Constants.NAME_OF_ROOT_NODE); if (this.isInternallyGeneratedId()) { return Functions.id(rootNode); } else { return this.getOptionalGraphPropertyName() - .map(propertyName -> property(NAME_OF_ROOT_NODE, propertyName)).get(); + .map(propertyName -> Cypher.property(Constants.NAME_OF_ROOT_NODE, propertyName)).get(); } }); } diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/IdGenerator.java b/src/main/java/org/springframework/data/neo4j/core/schema/IdGenerator.java similarity index 82% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/IdGenerator.java rename to src/main/java/org/springframework/data/neo4j/core/schema/IdGenerator.java index df341b25d..54f7bd2f1 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/IdGenerator.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/IdGenerator.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import org.apiguardian.api.API; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Node.java b/src/main/java/org/springframework/data/neo4j/core/schema/Node.java similarity index 88% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Node.java rename to src/main/java/org/springframework/data/neo4j/core/schema/Node.java index 5946d3246..56b8a19e0 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Node.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/Node.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/NodeDescription.java b/src/main/java/org/springframework/data/neo4j/core/schema/NodeDescription.java similarity index 94% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/NodeDescription.java rename to src/main/java/org/springframework/data/neo4j/core/schema/NodeDescription.java index de0ad243d..769a58575 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/NodeDescription.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/NodeDescription.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.util.ArrayList; import java.util.Collection; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Property.java b/src/main/java/org/springframework/data/neo4j/core/schema/Property.java similarity index 86% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Property.java rename to src/main/java/org/springframework/data/neo4j/core/schema/Property.java index cd4e4d4a3..df483838e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Property.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/Property.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Relationship.java b/src/main/java/org/springframework/data/neo4j/core/schema/Relationship.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Relationship.java rename to src/main/java/org/springframework/data/neo4j/core/schema/Relationship.java index c3d474297..cf9a320e8 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Relationship.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/Relationship.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/RelationshipDescription.java b/src/main/java/org/springframework/data/neo4j/core/schema/RelationshipDescription.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/RelationshipDescription.java rename to src/main/java/org/springframework/data/neo4j/core/schema/RelationshipDescription.java index c0eb530d7..5a1b3d5b1 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/RelationshipDescription.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/RelationshipDescription.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.schema.Relationship.Direction; import org.springframework.lang.NonNull; import org.springframework.lang.Nullable; @@ -80,7 +76,7 @@ public interface RelationshipDescription { * * @return The direction of the relationship */ - Direction getDirection(); + Relationship.Direction getDirection(); /** * If this is a relationship with properties, the properties-defining class will get returned, @@ -100,11 +96,11 @@ public interface RelationshipDescription { boolean hasRelationshipProperties(); default boolean isOutgoing() { - return Direction.OUTGOING.equals(this.getDirection()); + return Relationship.Direction.OUTGOING.equals(this.getDirection()); } default boolean isIncoming() { - return Direction.INCOMING.equals(this.getDirection()); + return Relationship.Direction.INCOMING.equals(this.getDirection()); } @NonNull diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/RelationshipProperties.java b/src/main/java/org/springframework/data/neo4j/core/schema/RelationshipProperties.java similarity index 85% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/RelationshipProperties.java rename to src/main/java/org/springframework/data/neo4j/core/schema/RelationshipProperties.java index cba2dbe6b..ccfc74ed5 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/RelationshipProperties.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/RelationshipProperties.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Schema.java b/src/main/java/org/springframework/data/neo4j/core/schema/Schema.java similarity index 94% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Schema.java rename to src/main/java/org/springframework/data/neo4j/core/schema/Schema.java index 495766d09..e594f20a6 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/Schema.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/Schema.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import java.util.HashMap; import java.util.Map; @@ -28,8 +25,8 @@ import java.util.function.Function; import org.apiguardian.api.API; import org.neo4j.driver.Record; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.convert.Neo4jConverter; import org.springframework.data.mapping.MappingException; +import org.springframework.data.neo4j.core.convert.Neo4jConverter; import org.springframework.lang.Nullable; /** diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/UnknownEntityException.java b/src/main/java/org/springframework/data/neo4j/core/schema/UnknownEntityException.java similarity index 85% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/UnknownEntityException.java rename to src/main/java/org/springframework/data/neo4j/core/schema/UnknownEntityException.java index b91df89ae..07684198b 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/UnknownEntityException.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/UnknownEntityException.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import org.apiguardian.api.API; import org.springframework.dao.InvalidDataAccessApiUsageException; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/package-info.java b/src/main/java/org/springframework/data/neo4j/core/schema/package-info.java similarity index 85% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/package-info.java rename to src/main/java/org/springframework/data/neo4j/core/schema/package-info.java index ef0cdbe34..3a10722a2 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/schema/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/core/schema/package-info.java @@ -5,6 +5,6 @@ * @author Michael J. Simons */ @NonNullApi -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/support/Relationships.java b/src/main/java/org/springframework/data/neo4j/core/support/Relationships.java similarity index 88% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/support/Relationships.java rename to src/main/java/org/springframework/data/neo4j/core/support/Relationships.java index 633869f6f..accf26f2f 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/support/Relationships.java +++ b/src/main/java/org/springframework/data/neo4j/core/support/Relationships.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.support; +package org.springframework.data.neo4j.core.support; import static java.util.stream.Collectors.*; @@ -25,7 +22,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Map; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; import org.springframework.lang.Nullable; /** diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/support/UUIDStringGenerator.java b/src/main/java/org/springframework/data/neo4j/core/support/UUIDStringGenerator.java similarity index 77% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/support/UUIDStringGenerator.java rename to src/main/java/org/springframework/data/neo4j/core/support/UUIDStringGenerator.java index 68f148919..5753da45f 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/support/UUIDStringGenerator.java +++ b/src/main/java/org/springframework/data/neo4j/core/support/UUIDStringGenerator.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.support; +package org.springframework.data.neo4j.core.support; import java.util.UUID; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.schema.IdGenerator; +import org.springframework.data.neo4j.core.schema.IdGenerator; /** * A generator providing UUIDs. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jBookmarkManager.java b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jBookmarkManager.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jBookmarkManager.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jBookmarkManager.java index 4828cdb65..f69e4bd69 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jBookmarkManager.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jBookmarkManager.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import java.util.Collection; import java.util.Collections; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jSessionSynchronization.java b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jSessionSynchronization.java similarity index 92% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jSessionSynchronization.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jSessionSynchronization.java index 99574ea36..480d44e1b 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jSessionSynchronization.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jSessionSynchronization.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import org.neo4j.driver.Driver; import org.springframework.transaction.support.ResourceHolderSynchronization; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionContext.java b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionContext.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionContext.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionContext.java index b34b9d2a7..585797b22 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionContext.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionContext.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import java.util.Collection; import java.util.Collections; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionHolder.java b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionHolder.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionHolder.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionHolder.java index 1b5043ef9..fa7566b52 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionHolder.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionHolder.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionUtils.*; +import static org.springframework.data.neo4j.core.transaction.Neo4jTransactionUtils.*; import java.util.Collection; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionManager.java b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionManager.java similarity index 95% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionManager.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionManager.java index 53846f58c..1b0583c0d 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionManager.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionManager.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionUtils.*; +import static org.springframework.data.neo4j.core.transaction.Neo4jTransactionUtils.*; import org.apiguardian.api.API; import org.neo4j.driver.Bookmark; @@ -26,7 +23,8 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; import org.neo4j.driver.TransactionConfig; -import org.neo4j.springframework.data.core.DatabaseSelectionProvider; +import org.springframework.data.neo4j.core.DatabaseSelectionProvider; +import org.springframework.data.neo4j.core.Neo4jClient; import org.springframework.lang.Nullable; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; @@ -73,7 +71,7 @@ public class Neo4jTransactionManager extends AbstractPlatformTransactionManager } /** - * This methods provides a native Neo4j transaction to be used from within a {@link org.neo4j.springframework.data.core.Neo4jClient}. + * This methods provides a native Neo4j transaction to be used from within a {@link Neo4jClient}. * In most cases this the native transaction will be controlled from the Neo4j specific * {@link org.springframework.transaction.PlatformTransactionManager}. However, SDN-RX provides support for other * transaction managers as well. This methods registers a session synchronization in such cases on the foreign transaction manager. @@ -176,7 +174,7 @@ public class Neo4jTransactionManager extends AbstractPlatformTransactionManager TransactionSynchronizationManager.bindResource(this.driver, transactionHolder); } catch (Exception ex) { - throw new TransactionSystemException(String.format("Could not open a new Neo4j session: %s", ex.getMessage())); + throw new TransactionSystemException(String.format("Could not open a new Neo4j session: %s", ex.getMessage()), ex); } } diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionUtils.java b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionUtils.java similarity index 94% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionUtils.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionUtils.java index dc33348ae..aa26ec033 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionUtils.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionUtils.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import java.time.Duration; import java.util.Collection; @@ -24,9 +21,9 @@ import java.util.Collections; import java.util.Objects; import org.neo4j.driver.AccessMode; -import org.neo4j.driver.TransactionConfig; -import org.neo4j.driver.SessionConfig; import org.neo4j.driver.Bookmark; +import org.neo4j.driver.SessionConfig; +import org.neo4j.driver.TransactionConfig; import org.springframework.lang.Nullable; import org.springframework.transaction.IllegalTransactionStateException; import org.springframework.transaction.InvalidIsolationLevelException; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jSessionSynchronization.java b/src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jSessionSynchronization.java similarity index 92% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jSessionSynchronization.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jSessionSynchronization.java index 9e5598356..72769ad18 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jSessionSynchronization.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jSessionSynchronization.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import reactor.core.publisher.Mono; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionHolder.java b/src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionHolder.java similarity index 83% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionHolder.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionHolder.java index f6e9afbe5..3b9364c8a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionHolder.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionHolder.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; - -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionUtils.*; +package org.springframework.data.neo4j.core.transaction; import reactor.core.publisher.Mono; @@ -54,7 +49,7 @@ final class ReactiveNeo4jTransactionHolder extends ResourceHolderSupport { @Nullable RxTransaction getTransaction(String inDatabase) { - return namesMapToTheSameDatabase(this.context.getDatabaseName(), inDatabase) ? transaction : null; + return Neo4jTransactionUtils.namesMapToTheSameDatabase(this.context.getDatabaseName(), inDatabase) ? transaction : null; } Mono commit() { diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionManager.java b/src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionManager.java similarity index 92% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionManager.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionManager.java index bc9f9b21e..76b976c5d 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionManager.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionManager.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; - -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionUtils.*; +package org.springframework.data.neo4j.core.transaction; import reactor.core.publisher.Mono; import reactor.util.function.Tuples; @@ -28,8 +23,8 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.TransactionConfig; import org.neo4j.driver.reactive.RxSession; import org.neo4j.driver.reactive.RxTransaction; -import org.neo4j.springframework.data.core.DatabaseSelection; -import org.neo4j.springframework.data.core.ReactiveDatabaseSelectionProvider; +import org.springframework.data.neo4j.core.DatabaseSelection; +import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider; import org.springframework.lang.Nullable; import org.springframework.transaction.NoTransactionException; import org.springframework.transaction.TransactionDefinition; @@ -89,7 +84,7 @@ public class ReactiveNeo4jTransactionManager extends AbstractReactiveTransaction // Otherwise open up a new native transaction return Mono.defer(() -> { - RxSession session = driver.rxSession(defaultSessionConfig(targetDatabase)); + RxSession session = driver.rxSession(Neo4jTransactionUtils.defaultSessionConfig(targetDatabase)); return Mono.from(session.beginTransaction(TransactionConfig.empty())).map(tx -> { ReactiveNeo4jTransactionHolder newConnectionHolder = new ReactiveNeo4jTransactionHolder( @@ -108,7 +103,7 @@ public class ReactiveNeo4jTransactionManager extends AbstractReactiveTransaction RxTransaction transaction = connectionHolder.getTransaction(targetDatabase); if (transaction == null) { throw new IllegalStateException( - formatOngoingTxInAnotherDbErrorMessage(connectionHolder.getDatabaseName(), targetDatabase)); + Neo4jTransactionUtils.formatOngoingTxInAnotherDbErrorMessage(connectionHolder.getDatabaseName(), targetDatabase)); } return transaction; } @@ -156,7 +151,7 @@ public class ReactiveNeo4jTransactionManager extends AbstractReactiveTransaction return Mono.defer(() -> { ReactiveNeo4jTransactionObject transactionObject = extractNeo4jTransaction(transaction); - TransactionConfig transactionConfig = createTransactionConfigFrom(transactionDefinition); + TransactionConfig transactionConfig = Neo4jTransactionUtils.createTransactionConfigFrom(transactionDefinition); boolean readOnly = transactionDefinition.isReadOnly(); transactionSynchronizationManager.setCurrentTransactionReadOnly(readOnly); @@ -164,7 +159,8 @@ public class ReactiveNeo4jTransactionManager extends AbstractReactiveTransaction return databaseSelectionProvider.getDatabaseSelection() .switchIfEmpty(Mono.just(DatabaseSelection.undecided())) .map(databaseName -> new Neo4jTransactionContext(databaseName.getValue(), bookmarkManager.getBookmarks())) - .map(context -> Tuples.of(context, this.driver.rxSession(sessionConfig(readOnly, context.getBookmarks(), context.getDatabaseName())))) + .map(context -> Tuples.of(context, this.driver.rxSession( + Neo4jTransactionUtils.sessionConfig(readOnly, context.getBookmarks(), context.getDatabaseName())))) .flatMap(contextAndSession -> Mono .from(contextAndSession.getT2().beginTransaction(transactionConfig)) .map(nativeTransaction -> new ReactiveNeo4jTransactionHolder(contextAndSession.getT1(), contextAndSession.getT2(), nativeTransaction)) diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/package-info.java b/src/main/java/org/springframework/data/neo4j/core/transaction/package-info.java similarity index 70% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/package-info.java rename to src/main/java/org/springframework/data/neo4j/core/transaction/package-info.java index 585bf095f..f75ba3547 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/core/transaction/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/core/transaction/package-info.java @@ -2,6 +2,6 @@ * Core infrastructure for providing Neo4j sessions to Spring Data Neo4j. */ @NonNullApi -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/Neo4jRepository.java b/src/main/java/org/springframework/data/neo4j/repository/Neo4jRepository.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/Neo4jRepository.java rename to src/main/java/org/springframework/data/neo4j/repository/Neo4jRepository.java index 91b9828e5..7abc3dab8 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/Neo4jRepository.java +++ b/src/main/java/org/springframework/data/neo4j/repository/Neo4jRepository.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository; +package org.springframework.data.neo4j.repository; import java.util.List; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/NoResultException.java b/src/main/java/org/springframework/data/neo4j/repository/NoResultException.java similarity index 83% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/NoResultException.java rename to src/main/java/org/springframework/data/neo4j/repository/NoResultException.java index 3670cbb35..d959b804a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/NoResultException.java +++ b/src/main/java/org/springframework/data/neo4j/repository/NoResultException.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository; +package org.springframework.data.neo4j.repository; import org.apiguardian.api.API; import org.springframework.dao.EmptyResultDataAccessException; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/ReactiveNeo4jRepository.java b/src/main/java/org/springframework/data/neo4j/repository/ReactiveNeo4jRepository.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/ReactiveNeo4jRepository.java rename to src/main/java/org/springframework/data/neo4j/repository/ReactiveNeo4jRepository.java index c189286f8..e7f7f4a2a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/ReactiveNeo4jRepository.java +++ b/src/main/java/org/springframework/data/neo4j/repository/ReactiveNeo4jRepository.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository; +package org.springframework.data.neo4j.repository; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/EnableNeo4jRepositories.java b/src/main/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositories.java similarity index 79% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/EnableNeo4jRepositories.java rename to src/main/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositories.java index b86e180b3..dc5852a72 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/EnableNeo4jRepositories.java +++ b/src/main/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositories.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.config; - -import static org.neo4j.springframework.data.repository.config.Neo4jRepositoryConfigurationExtension.*; +package org.springframework.data.neo4j.repository.config; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -27,11 +22,14 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.neo4j.springframework.data.repository.support.Neo4jRepositoryFactoryBean; import org.springframework.beans.factory.FactoryBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; import org.springframework.core.annotation.AliasFor; +import org.springframework.data.neo4j.core.Neo4jTemplate; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager; +import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactoryBean; import org.springframework.data.repository.config.DefaultRepositoryBaseClass; /** @@ -85,19 +83,19 @@ public @interface EnableNeo4jRepositories { Class repositoryBaseClass() default DefaultRepositoryBaseClass.class; /** - * Configures the name of the {@link org.neo4j.springframework.data.core.mapping.Neo4jMappingContext} bean to be used with the repositories detected. + * Configures the name of the {@link Neo4jMappingContext} bean to be used with the repositories detected. */ - String neo4jMappingContextRef() default DEFAULT_MAPPING_CONTEXT_BEAN_NAME; + String neo4jMappingContextRef() default Neo4jRepositoryConfigurationExtension.DEFAULT_MAPPING_CONTEXT_BEAN_NAME; /** - * Configures the name of the {@link org.neo4j.springframework.data.core.Neo4jTemplate} bean to be used with the repositories detected. + * Configures the name of the {@link Neo4jTemplate} bean to be used with the repositories detected. */ - String neo4jTemplateRef() default DEFAULT_NEO4J_TEMPLATE_BEAN_NAME; + String neo4jTemplateRef() default Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME; /** - * Configures the name of the {@link org.neo4j.springframework.data.core.transaction.Neo4jTransactionManager} bean to be used with the repositories detected. + * Configures the name of the {@link Neo4jTransactionManager} bean to be used with the repositories detected. */ - String transactionManagerRef() default DEFAULT_TRANSACTION_MANAGER_BEAN_NAME; + String transactionManagerRef() default Neo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME; /** * Specifies which types are eligible for component scanning. Further narrows the set of candidate components from diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/EnableReactiveNeo4jRepositories.java b/src/main/java/org/springframework/data/neo4j/repository/config/EnableReactiveNeo4jRepositories.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/EnableReactiveNeo4jRepositories.java rename to src/main/java/org/springframework/data/neo4j/repository/config/EnableReactiveNeo4jRepositories.java index d2c4d8977..e54591e3e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/EnableReactiveNeo4jRepositories.java +++ b/src/main/java/org/springframework/data/neo4j/repository/config/EnableReactiveNeo4jRepositories.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.config; +package org.springframework.data.neo4j.repository.config; -import static org.neo4j.springframework.data.repository.config.ReactiveNeo4jRepositoryConfigurationExtension.*; +import static org.springframework.data.neo4j.repository.config.ReactiveNeo4jRepositoryConfigurationExtension.*; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +28,10 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Import; import org.springframework.core.annotation.AliasFor; -import org.neo4j.springframework.data.repository.support.ReactiveNeo4jRepositoryFactoryBean; +import org.springframework.data.neo4j.core.ReactiveNeo4jTemplate; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager; +import org.springframework.data.neo4j.repository.support.ReactiveNeo4jRepositoryFactoryBean; import org.springframework.data.repository.config.DefaultRepositoryBaseClass; /** @@ -86,17 +86,17 @@ public @interface EnableReactiveNeo4jRepositories { Class repositoryBaseClass() default DefaultRepositoryBaseClass.class; /** - * Configures the name of the {@link org.neo4j.springframework.data.core.mapping.Neo4jMappingContext} bean to be used with the repositories detected. + * Configures the name of the {@link Neo4jMappingContext} bean to be used with the repositories detected. */ String neo4jMappingContextRef() default DEFAULT_MAPPING_CONTEXT_BEAN_NAME; /** - * Configures the name of the {@link org.neo4j.springframework.data.core.ReactiveNeo4jTemplate} bean to be used with the repositories detected. + * Configures the name of the {@link ReactiveNeo4jTemplate} bean to be used with the repositories detected. */ String neo4jTemplateRef() default DEFAULT_NEO4J_TEMPLATE_BEAN_NAME; /** - * Configures the name of the {@link org.neo4j.springframework.data.core.transaction.ReactiveNeo4jTransactionManager} bean to be used with the repositories detected. + * Configures the name of the {@link ReactiveNeo4jTransactionManager} bean to be used with the repositories detected. */ String transactionManagerRef() default DEFAULT_TRANSACTION_MANAGER_BEAN_NAME; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/Neo4jRepositoriesRegistrar.java b/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrar.java similarity index 89% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/Neo4jRepositoriesRegistrar.java rename to src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrar.java index 37251c248..e860c8313 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/Neo4jRepositoriesRegistrar.java +++ b/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoriesRegistrar.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.config; +package org.springframework.data.neo4j.repository.config; import java.lang.annotation.Annotation; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/Neo4jRepositoryConfigurationExtension.java b/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtension.java similarity index 89% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/Neo4jRepositoryConfigurationExtension.java rename to src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtension.java index fb9e47cf2..4646a577e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/Neo4jRepositoryConfigurationExtension.java +++ b/src/main/java/org/springframework/data/neo4j/repository/config/Neo4jRepositoryConfigurationExtension.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.config; +package org.springframework.data.neo4j.repository.config; import java.lang.annotation.Annotation; import java.util.Collection; import java.util.Collections; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.support.Neo4jRepositoryFactoryBean; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.data.neo4j.core.schema.Node; +import org.springframework.data.neo4j.repository.Neo4jRepository; +import org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactoryBean; import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport; import org.springframework.data.repository.config.RepositoryConfigurationSource; import org.springframework.data.repository.core.RepositoryMetadata; @@ -61,6 +58,11 @@ public final class Neo4jRepositoryConfigurationExtension extends RepositoryConfi */ static final String DEFAULT_MAPPING_CONTEXT_BEAN_NAME = "neo4jMappingContext"; + public Neo4jRepositoryConfigurationExtension() { + + new StartupLogger(StartupLogger.Mode.IMPERATIVE).logStarting(); + } + /* * (non-Javadoc) * @see org.springframework.data.repository.config14.RepositoryConfigurationExtension#getRepositoryFactoryBeanClassName() diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/ReactiveNeo4jRepositoriesRegistrar.java b/src/main/java/org/springframework/data/neo4j/repository/config/ReactiveNeo4jRepositoriesRegistrar.java similarity index 89% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/ReactiveNeo4jRepositoriesRegistrar.java rename to src/main/java/org/springframework/data/neo4j/repository/config/ReactiveNeo4jRepositoriesRegistrar.java index 83a7963c7..45229542d 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/ReactiveNeo4jRepositoriesRegistrar.java +++ b/src/main/java/org/springframework/data/neo4j/repository/config/ReactiveNeo4jRepositoriesRegistrar.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.config; +package org.springframework.data.neo4j.repository.config; import java.lang.annotation.Annotation; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/ReactiveNeo4jRepositoryConfigurationExtension.java b/src/main/java/org/springframework/data/neo4j/repository/config/ReactiveNeo4jRepositoryConfigurationExtension.java similarity index 89% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/ReactiveNeo4jRepositoryConfigurationExtension.java rename to src/main/java/org/springframework/data/neo4j/repository/config/ReactiveNeo4jRepositoryConfigurationExtension.java index 777d4c14a..a8d79417e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/ReactiveNeo4jRepositoryConfigurationExtension.java +++ b/src/main/java/org/springframework/data/neo4j/repository/config/ReactiveNeo4jRepositoryConfigurationExtension.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,18 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.config; +package org.springframework.data.neo4j.repository.config; import java.lang.annotation.Annotation; import java.util.Collection; import java.util.Collections; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.support.ReactiveNeo4jRepositoryFactoryBean; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.data.neo4j.core.schema.Node; +import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.support.ReactiveNeo4jRepositoryFactoryBean; import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport; import org.springframework.data.repository.config.RepositoryConfigurationSource; import org.springframework.data.repository.core.RepositoryMetadata; @@ -61,6 +58,11 @@ public final class ReactiveNeo4jRepositoryConfigurationExtension extends Reposit */ static final String DEFAULT_MAPPING_CONTEXT_BEAN_NAME = "neo4jMappingContext"; + public ReactiveNeo4jRepositoryConfigurationExtension() { + + new StartupLogger(StartupLogger.Mode.REACTIVE).logStarting(); + } + /* * (non-Javadoc) * @see org.springframework.data.repository.config14.RepositoryConfigurationExtension#getRepositoryFactoryBeanClassName() diff --git a/src/main/java/org/springframework/data/neo4j/repository/config/StartupLogger.java b/src/main/java/org/springframework/data/neo4j/repository/config/StartupLogger.java new file mode 100644 index 000000000..c496f86a7 --- /dev/null +++ b/src/main/java/org/springframework/data/neo4j/repository/config/StartupLogger.java @@ -0,0 +1,87 @@ +/* + * 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.repository.config; + +import java.util.Optional; + +import org.apache.commons.logging.LogFactory; +import org.neo4j.driver.Driver; +import org.springframework.core.log.LogAccessor; +import org.springframework.data.mapping.context.AbstractMappingContext; +import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport; + +/** + * Logs startup information. + * + * @author Michael J. Simons + * @soundtrack Helge & Hardcore - Jazz + */ +final class StartupLogger { + + enum Mode { + IMPERATIVE("imperative"), REACTIVE("reactive"); + + final String displayValue; + + Mode(String displayValue) { + this.displayValue = displayValue; + } + } + + private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(StartupLogger.class)); + + private final Mode mode; + + StartupLogger(Mode mode) { + this.mode = mode; + } + + void logStarting() { + + if (!logger.isDebugEnabled()) { + return; + } + logger.debug(() -> getStartingMessage()); + } + + String getStartingMessage() { + + StringBuilder sb = new StringBuilder(); + + String sdnRx = getVersionOf(EnableNeo4jRepositories.class).map(v -> "SDN/RX v" + v) + .orElse("an unknown version of SDN/RX"); + String sdC = getVersionOf(AbstractMappingContext.class).map(v -> "Spring Data Commons v" + v) + .orElse("an unknown version of Spring Data Commons"); + String driver = getVersionOf(Driver.class).map(v -> "Neo4j Driver v" + v) + .orElse("an unknown version of the Neo4j Java Driver"); + RepositoryConfigurationExtensionSupport f; + sb.append("Bootstrapping ").append(mode.displayValue).append(" Neo4j repositories based on ") + .append(sdnRx) + .append(" with ").append(sdC) + .append(" and ").append(driver).append("."); + + return sb.toString(); + } + + private Optional getVersionOf(Class clazz) { + + return Optional.ofNullable(clazz) + .map(Class::getPackage) + .map(Package::getImplementationVersion) + .map(String::trim) + .filter(v -> !v.isEmpty()); + } +} diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/package-info.java b/src/main/java/org/springframework/data/neo4j/repository/config/package-info.java similarity index 69% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/package-info.java rename to src/main/java/org/springframework/data/neo4j/repository/config/package-info.java index de61b211e..0cd9cd83a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/config/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/repository/config/package-info.java @@ -2,6 +2,6 @@ * Configuration infrastructure for Neo4j specific repositories. */ @NonNullApi -package org.neo4j.springframework.data.repository.config; +package org.springframework.data.neo4j.repository.config; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/AuditingBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallback.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/AuditingBeforeBindCallback.java rename to src/main/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallback.java index 98e0d533e..280f458fe 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/AuditingBeforeBindCallback.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallback.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import org.apiguardian.api.API; import org.springframework.beans.factory.ObjectFactory; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/BeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/BeforeBindCallback.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/BeforeBindCallback.java rename to src/main/java/org/springframework/data/neo4j/repository/event/BeforeBindCallback.java index 7c3bae4dd..99bb9d23b 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/BeforeBindCallback.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/BeforeBindCallback.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import org.apiguardian.api.API; import org.springframework.data.mapping.callback.EntityCallback; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/IdGeneratingBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/IdGeneratingBeforeBindCallback.java similarity index 82% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/IdGeneratingBeforeBindCallback.java rename to src/main/java/org/springframework/data/neo4j/repository/event/IdGeneratingBeforeBindCallback.java index 9cf31b7fd..ded153bfa 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/IdGeneratingBeforeBindCallback.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/IdGeneratingBeforeBindCallback.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; import org.springframework.core.Ordered; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; /** * Callback used to call the ID generator configured for an entity just before binding. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/IdPopulator.java b/src/main/java/org/springframework/data/neo4j/repository/event/IdPopulator.java similarity index 82% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/IdPopulator.java rename to src/main/java/org/springframework/data/neo4j/repository/event/IdPopulator.java index 101718a24..75213e7a2 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/IdPopulator.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/IdPopulator.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import java.util.Optional; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; -import org.neo4j.springframework.data.core.schema.IdDescription; -import org.neo4j.springframework.data.core.schema.IdGenerator; import org.springframework.data.mapping.PersistentPropertyAccessor; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; +import org.springframework.data.neo4j.core.schema.IdDescription; +import org.springframework.data.neo4j.core.schema.IdGenerator; import org.springframework.util.Assert; /** diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/OptimisticLockingBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/OptimisticLockingBeforeBindCallback.java similarity index 83% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/OptimisticLockingBeforeBindCallback.java rename to src/main/java/org/springframework/data/neo4j/repository/event/OptimisticLockingBeforeBindCallback.java index 651ecfd4b..3609291a1 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/OptimisticLockingBeforeBindCallback.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/OptimisticLockingBeforeBindCallback.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; import org.springframework.core.Ordered; import org.springframework.data.mapping.PersistentPropertyAccessor; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; /** * Callback to increment the value of the version property for a given entity. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveAuditingBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallback.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveAuditingBeforeBindCallback.java rename to src/main/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallback.java index 631afaa8a..e136dff87 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveAuditingBeforeBindCallback.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallback.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import reactor.core.publisher.Mono; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveBeforeBindCallback.java similarity index 88% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveBeforeBindCallback.java rename to src/main/java/org/springframework/data/neo4j/repository/event/ReactiveBeforeBindCallback.java index 20b6a754e..9129721c4 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveBeforeBindCallback.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveBeforeBindCallback.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import org.apiguardian.api.API; import org.reactivestreams.Publisher; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveIdGeneratingBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveIdGeneratingBeforeBindCallback.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveIdGeneratingBeforeBindCallback.java rename to src/main/java/org/springframework/data/neo4j/repository/event/ReactiveIdGeneratingBeforeBindCallback.java index 0b03581fe..e19b05d08 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveIdGeneratingBeforeBindCallback.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveIdGeneratingBeforeBindCallback.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import reactor.core.publisher.Mono; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; import org.reactivestreams.Publisher; import org.springframework.core.Ordered; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; /** * Callback used to call the ID generator configured for an entity just before binding. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveOptimisticLockingBeforeBindCallback.java b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveOptimisticLockingBeforeBindCallback.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveOptimisticLockingBeforeBindCallback.java rename to src/main/java/org/springframework/data/neo4j/repository/event/ReactiveOptimisticLockingBeforeBindCallback.java index 7765f01c8..5814b0e7b 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/ReactiveOptimisticLockingBeforeBindCallback.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/ReactiveOptimisticLockingBeforeBindCallback.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import reactor.core.publisher.Mono; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; import org.reactivestreams.Publisher; import org.springframework.core.Ordered; import org.springframework.data.mapping.PersistentPropertyAccessor; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; /** * Callback to increment the value of the version property for a given entity. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/package-info.java b/src/main/java/org/springframework/data/neo4j/repository/event/package-info.java similarity index 93% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/package-info.java rename to src/main/java/org/springframework/data/neo4j/repository/event/package-info.java index 5263bade3..6571840f8 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/event/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/repository/event/package-info.java @@ -12,6 +12,6 @@ * @soundtrack Bon Jovi - Slippery When Wet */ @NonNullApi -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/package-info.java b/src/main/java/org/springframework/data/neo4j/repository/package-info.java similarity index 70% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/package-info.java rename to src/main/java/org/springframework/data/neo4j/repository/package-info.java index 2b184ba74..d3fc29f62 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/repository/package-info.java @@ -2,6 +2,6 @@ * This package contains the repository infrastructure. */ @NonNullApi -package org.neo4j.springframework.data.repository; +package org.springframework.data.neo4j.repository; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/AbstractNeo4jQuery.java b/src/main/java/org/springframework/data/neo4j/repository/query/AbstractNeo4jQuery.java similarity index 84% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/AbstractNeo4jQuery.java rename to src/main/java/org/springframework/data/neo4j/repository/query/AbstractNeo4jQuery.java index e595f01d7..d66361fd7 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/AbstractNeo4jQuery.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/AbstractNeo4jQuery.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.query; +package org.springframework.data.neo4j.repository.query; import java.util.Collections; import java.util.List; @@ -24,10 +21,9 @@ import java.util.function.BiFunction; import org.neo4j.driver.Record; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.Neo4jOperations; -import org.neo4j.springframework.data.core.PreparedQuery; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.repository.query.Neo4jQueryExecution.DefaultQueryExecution; +import org.springframework.data.neo4j.core.Neo4jOperations; +import org.springframework.data.neo4j.core.PreparedQuery; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; import org.springframework.data.repository.query.QueryMethod; import org.springframework.data.repository.query.RepositoryQuery; import org.springframework.data.repository.query.ResultProcessor; @@ -69,7 +65,7 @@ abstract class AbstractNeo4jQuery extends Neo4jQuerySupport implements Repositor PreparedQuery preparedQuery = prepareQuery(resultProcessor.getReturnedType().getReturnedType(), getInputProperties(resultProcessor), parameterAccessor, null, getMappingFunction(resultProcessor)); - Object rawResult = new DefaultQueryExecution(neo4jOperations).execute( + Object rawResult = new Neo4jQueryExecution.DefaultQueryExecution(neo4jOperations).execute( preparedQuery, queryMethod.isCollectionLikeQuery() || queryMethod.isPageQuery()); Object processedResult = resultProcessor.processResult(rawResult, OptionalUnwrappingConverter.INSTANCE); diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/AbstractReactiveNeo4jQuery.java b/src/main/java/org/springframework/data/neo4j/repository/query/AbstractReactiveNeo4jQuery.java similarity index 86% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/AbstractReactiveNeo4jQuery.java rename to src/main/java/org/springframework/data/neo4j/repository/query/AbstractReactiveNeo4jQuery.java index 9bc54f2e3..4cbec1b7d 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/AbstractReactiveNeo4jQuery.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/AbstractReactiveNeo4jQuery.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.query; +package org.springframework.data.neo4j.repository.query; import java.util.List; import java.util.function.BiFunction; import org.neo4j.driver.Record; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.PreparedQuery; -import org.neo4j.springframework.data.core.ReactiveNeo4jOperations; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.PreparedQuery; +import org.springframework.data.neo4j.core.ReactiveNeo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; import org.springframework.data.repository.query.QueryMethod; import org.springframework.data.repository.query.RepositoryQuery; import org.springframework.data.repository.query.ResultProcessor; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/BoundingBox.java b/src/main/java/org/springframework/data/neo4j/repository/query/BoundingBox.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/BoundingBox.java rename to src/main/java/org/springframework/data/neo4j/repository/query/BoundingBox.java index 0aae5fe5d..d194b0d4c 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/BoundingBox.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/BoundingBox.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.query; +package org.springframework.data.neo4j.repository.query; import java.util.Arrays; import java.util.Objects; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CountQuery.java b/src/main/java/org/springframework/data/neo4j/repository/query/CountQuery.java similarity index 83% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CountQuery.java rename to src/main/java/org/springframework/data/neo4j/repository/query/CountQuery.java index 28498b6e0..31fb5e8ef 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CountQuery.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/CountQuery.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.query; +package org.springframework.data.neo4j.repository.query; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CypherAdapterUtils.java b/src/main/java/org/springframework/data/neo4j/repository/query/CypherAdapterUtils.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CypherAdapterUtils.java rename to src/main/java/org/springframework/data/neo4j/repository/query/CypherAdapterUtils.java index 6dfdad434..4e2ed3213 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CypherAdapterUtils.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/CypherAdapterUtils.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.query; +package org.springframework.data.neo4j.repository.query; import static org.neo4j.cypherdsl.core.Cypher.*; -import static org.neo4j.springframework.data.core.schema.Constants.*; +import static org.springframework.data.neo4j.core.schema.Constants.*; import java.util.function.Function; @@ -27,10 +24,10 @@ import org.apiguardian.api.API; import org.neo4j.cypherdsl.core.Cypher; import org.neo4j.cypherdsl.core.SortItem; import org.neo4j.cypherdsl.core.StatementBuilder; -import org.neo4j.springframework.data.core.schema.GraphPropertyDescription; -import org.neo4j.springframework.data.core.schema.NodeDescription; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; +import org.springframework.data.neo4j.core.schema.GraphPropertyDescription; +import org.springframework.data.neo4j.core.schema.NodeDescription; /** * Bridging between Spring Data domain Objects and Cypher constructs. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CypherQueryCreator.java b/src/main/java/org/springframework/data/neo4j/repository/query/CypherQueryCreator.java similarity index 95% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CypherQueryCreator.java rename to src/main/java/org/springframework/data/neo4j/repository/query/CypherQueryCreator.java index fe420968c..95961cfb8 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/query/CypherQueryCreator.java +++ b/src/main/java/org/springframework/data/neo4j/repository/query/CypherQueryCreator.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.query; +package org.springframework.data.neo4j.repository.query; import static java.util.stream.Collectors.*; import static org.neo4j.cypherdsl.core.Functions.*; -import static org.neo4j.springframework.data.core.schema.Constants.*; -import static org.neo4j.springframework.data.repository.query.CypherAdapterUtils.*; -import static org.neo4j.springframework.data.repository.query.PartValidator.*; +import static org.springframework.data.neo4j.core.schema.Constants.*; import java.util.ArrayList; import java.util.Iterator; @@ -36,17 +31,10 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Stream; -import org.neo4j.driver.types.Point; import org.neo4j.cypherdsl.core.*; import org.neo4j.cypherdsl.core.StatementBuilder.OngoingMatchAndReturnWithOrder; import org.neo4j.cypherdsl.core.renderer.Renderer; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; -import org.neo4j.springframework.data.core.schema.CypherGenerator; -import org.neo4j.springframework.data.core.schema.NodeDescription; -import org.neo4j.springframework.data.core.schema.RelationshipDescription; -import org.neo4j.springframework.data.core.schema.RelationshipProperties; -import org.neo4j.springframework.data.repository.query.Neo4jQueryMethod.Neo4jParameter; +import org.neo4j.driver.types.Point; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Range; import org.springframework.data.domain.Sort; @@ -57,6 +45,12 @@ import org.springframework.data.geo.Polygon; import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentProperty; import org.springframework.data.mapping.PersistentPropertyPath; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; +import org.springframework.data.neo4j.core.schema.CypherGenerator; +import org.springframework.data.neo4j.core.schema.NodeDescription; +import org.springframework.data.neo4j.core.schema.RelationshipDescription; +import org.springframework.data.neo4j.core.schema.RelationshipProperties; import org.springframework.data.repository.query.ParametersParameterAccessor; import org.springframework.data.repository.query.parser.AbstractQueryCreator; import org.springframework.data.repository.query.parser.Part; @@ -293,7 +287,7 @@ final class CypherQueryCreator extends AbstractQueryCreator entityInformation = getEntityInformation(metadata.getDomainType()); - assertIdentifierType(metadata.getIdType(), entityInformation.getIdType()); + Neo4jRepositoryFactorySupport.assertIdentifierType(metadata.getIdType(), entityInformation.getIdType()); return getTargetRepositoryViaReflection(metadata, neo4jOperations, entityInformation); } diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactoryBean.java b/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBean.java similarity index 86% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactoryBean.java rename to src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBean.java index 14975f151..3a062779d 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactoryBean.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryBean.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import java.io.Serializable; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.Neo4jOperations; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.Neo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; import org.springframework.data.repository.Repository; import org.springframework.data.repository.core.support.RepositoryFactorySupport; import org.springframework.data.repository.core.support.TransactionalRepositoryFactoryBeanSupport; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactorySupport.java b/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactorySupport.java similarity index 89% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactorySupport.java rename to src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactorySupport.java index c41982032..f3e9add4c 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactorySupport.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactorySupport.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; /** * Shared repository factory functionality between imperative and reactive world. diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Predicate.java b/src/main/java/org/springframework/data/neo4j/repository/support/Predicate.java similarity index 90% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Predicate.java rename to src/main/java/org/springframework/data/neo4j/repository/support/Predicate.java index 89c0fa7f8..1bc2a109f 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/Predicate.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/Predicate.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static org.neo4j.cypherdsl.core.Cypher.*; -import static org.neo4j.springframework.data.core.schema.Constants.*; +import static org.springframework.data.neo4j.core.schema.Constants.*; import java.util.Collection; import java.util.Collections; @@ -29,20 +26,20 @@ import java.util.Optional; import java.util.function.BiFunction; import org.apache.commons.logging.LogFactory; -import org.neo4j.springframework.data.core.convert.Neo4jConverter; import org.neo4j.cypherdsl.core.Condition; import org.neo4j.cypherdsl.core.Conditions; import org.neo4j.cypherdsl.core.Expression; import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.StatementBuilder; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; -import org.neo4j.springframework.data.core.schema.GraphPropertyDescription; -import org.neo4j.springframework.data.core.schema.NodeDescription; import org.springframework.core.log.LogAccessor; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; +import org.springframework.data.neo4j.core.convert.Neo4jConverter; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; +import org.springframework.data.neo4j.core.schema.GraphPropertyDescription; +import org.springframework.data.neo4j.core.schema.NodeDescription; import org.springframework.data.support.ExampleMatcherAccessor; import org.springframework.data.util.DirectFieldAccessFallbackBeanWrapper; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactory.java b/src/main/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactory.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactory.java rename to src/main/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactory.java index 618bbcd4b..1930a0567 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactory.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactory.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,20 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; -import static org.neo4j.springframework.data.repository.support.Neo4jRepositoryFactorySupport.*; +import static org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactorySupport.*; import java.util.Optional; -import org.neo4j.springframework.data.core.ReactiveNeo4jOperations; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.query.ReactiveNeo4jQueryLookupStrategy; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.data.neo4j.core.ReactiveNeo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.query.ReactiveNeo4jQueryLookupStrategy; import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.core.RepositoryMetadata; import org.springframework.data.repository.core.support.ReactiveRepositoryFactorySupport; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactoryBean.java b/src/main/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactoryBean.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactoryBean.java rename to src/main/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactoryBean.java index a60ac0093..b0f991b8e 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactoryBean.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactoryBean.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import java.io.Serializable; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.ReactiveNeo4jOperations; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; import org.springframework.data.mapping.callback.ReactiveEntityCallbacks; +import org.springframework.data.neo4j.core.ReactiveNeo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; import org.springframework.data.repository.Repository; import org.springframework.data.repository.core.support.RepositoryFactorySupport; import org.springframework.data.repository.core.support.TransactionalRepositoryFactoryBeanSupport; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactivePersistenceExceptionTranslationInterceptor.java b/src/main/java/org/springframework/data/neo4j/repository/support/ReactivePersistenceExceptionTranslationInterceptor.java similarity index 95% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactivePersistenceExceptionTranslationInterceptor.java rename to src/main/java/org/springframework/data/neo4j/repository/support/ReactivePersistenceExceptionTranslationInterceptor.java index b845ba126..fd4e5bcfc 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactivePersistenceExceptionTranslationInterceptor.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/ReactivePersistenceExceptionTranslationInterceptor.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactivePersistenceExceptionTranslationPostProcessor.java b/src/main/java/org/springframework/data/neo4j/repository/support/ReactivePersistenceExceptionTranslationPostProcessor.java similarity index 92% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactivePersistenceExceptionTranslationPostProcessor.java rename to src/main/java/org/springframework/data/neo4j/repository/support/ReactivePersistenceExceptionTranslationPostProcessor.java index bc0424484..17e1da23b 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/ReactivePersistenceExceptionTranslationPostProcessor.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/ReactivePersistenceExceptionTranslationPostProcessor.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -34,6 +31,8 @@ import org.springframework.aop.support.StaticMethodMatcher; import org.springframework.aop.support.annotation.AnnotationMatchingPointcut; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.ListableBeanFactory; +import org.springframework.data.neo4j.core.ReactiveNeo4jClient; +import org.springframework.data.neo4j.core.ReactiveNeo4jTemplate; import org.springframework.stereotype.Repository; import org.springframework.util.Assert; @@ -44,7 +43,7 @@ import org.springframework.util.Assert; * the exposed proxy (either an existing AOP proxy or a newly generated proxy that implements all of the target's interfaces). *

That proxy will modify the reactive types by the matched method and inject an exception translation into the reactive flow. *

This class can be declared as a standard bean if you run a lot of custom repositories in which you use either the - * {@link org.neo4j.springframework.data.core.ReactiveNeo4jTemplate} or the {@link org.neo4j.springframework.data.core.ReactiveNeo4jClient}. + * {@link ReactiveNeo4jTemplate} or the {@link ReactiveNeo4jClient}. * * @author Michael J. Simons * @soundtrack Fatoni - Andorra diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleNeo4jRepository.java b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java similarity index 88% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleNeo4jRepository.java rename to src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java index 9cc344d39..03c2b3688 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleNeo4jRepository.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleNeo4jRepository.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static java.util.stream.Collectors.*; -import static org.neo4j.springframework.data.repository.query.CypherAdapterUtils.*; import java.util.List; import java.util.Optional; @@ -27,15 +23,16 @@ import java.util.function.LongSupplier; import java.util.stream.StreamSupport; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.Neo4jOperations; import org.neo4j.cypherdsl.core.Statement; import org.neo4j.cypherdsl.core.StatementBuilder; import org.neo4j.cypherdsl.core.StatementBuilder.OngoingReadingAndReturn; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.schema.CypherGenerator; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; +import org.springframework.data.neo4j.core.Neo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.schema.CypherGenerator; +import org.springframework.data.neo4j.repository.query.CypherAdapterUtils; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.support.PageableExecutionUtils; import org.springframework.stereotype.Repository; @@ -95,7 +92,7 @@ public class SimpleNeo4jRepository implements PagingAndSortingRepository< Statement statement = cypherGenerator.prepareMatchOf(entityMetaData) .returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)) - .orderBy(toSortItems(entityMetaData, sort)) + .orderBy(CypherAdapterUtils.toSortItems(entityMetaData, sort)) .build(); return this.neo4jOperations.findAll(statement, entityInformation.getJavaType()); @@ -108,7 +105,7 @@ public class SimpleNeo4jRepository implements PagingAndSortingRepository< .returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)); StatementBuilder.BuildableStatement returningWithPaging = - addPagingParameter(entityMetaData, pageable, returning); + CypherAdapterUtils.addPagingParameter(entityMetaData, pageable, returning); Statement statement = returningWithPaging.build(); diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleQueryByExampleExecutor.java b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleQueryByExampleExecutor.java similarity index 85% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleQueryByExampleExecutor.java rename to src/main/java/org/springframework/data/neo4j/repository/support/SimpleQueryByExampleExecutor.java index c2f69dbfc..6a290a790 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleQueryByExampleExecutor.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleQueryByExampleExecutor.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,26 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static org.neo4j.cypherdsl.core.Cypher.*; -import static org.neo4j.springframework.data.repository.query.CypherAdapterUtils.*; import java.util.List; import java.util.Optional; import java.util.function.LongSupplier; -import org.neo4j.springframework.data.core.Neo4jOperations; import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Statement; import org.neo4j.cypherdsl.core.StatementBuilder; import org.neo4j.cypherdsl.core.StatementBuilder.BuildableStatement; -import org.neo4j.springframework.data.core.schema.CypherGenerator; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; import org.springframework.data.domain.Example; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; +import org.springframework.data.neo4j.core.Neo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.schema.CypherGenerator; +import org.springframework.data.neo4j.repository.query.CypherAdapterUtils; import org.springframework.data.repository.query.QueryByExampleExecutor; import org.springframework.data.repository.support.PageableExecutionUtils; @@ -90,7 +87,7 @@ class SimpleQueryByExampleExecutor implements QueryByExampleExecutor { Predicate predicate = Predicate.create(mappingContext, example); Statement statement = predicate.useWithReadingFragment(cypherGenerator::prepareMatchOf) .returning(asterisk()) - .orderBy(toSortItems(predicate.getNeo4jPersistentEntity(), sort)).build(); + .orderBy(CypherAdapterUtils.toSortItems(predicate.getNeo4jPersistentEntity(), sort)).build(); return this.neo4jOperations.findAll(statement, predicate.getParameters(), example.getProbeType()); } @@ -119,7 +116,8 @@ class SimpleQueryByExampleExecutor implements QueryByExampleExecutor { .useWithReadingFragment(cypherGenerator::prepareMatchOf) .returning(asterisk()); - BuildableStatement returningWithPaging = addPagingParameter(predicate.getNeo4jPersistentEntity(), pageable, + BuildableStatement returningWithPaging = CypherAdapterUtils + .addPagingParameter(predicate.getNeo4jPersistentEntity(), pageable, returning); Statement statement = returningWithPaging.build(); diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleReactiveNeo4jRepository.java b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveNeo4jRepository.java similarity index 91% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleReactiveNeo4jRepository.java rename to src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveNeo4jRepository.java index c3e1cfd0d..d46eab6ee 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleReactiveNeo4jRepository.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveNeo4jRepository.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static java.util.stream.Collectors.*; -import static org.neo4j.springframework.data.repository.query.CypherAdapterUtils.*; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -28,12 +24,13 @@ import java.util.List; import java.util.stream.StreamSupport; import org.apiguardian.api.API; -import org.neo4j.springframework.data.core.ReactiveNeo4jOperations; import org.neo4j.cypherdsl.core.Statement; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.schema.CypherGenerator; import org.reactivestreams.Publisher; import org.springframework.data.domain.Sort; +import org.springframework.data.neo4j.core.ReactiveNeo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.schema.CypherGenerator; +import org.springframework.data.neo4j.repository.query.CypherAdapterUtils; import org.springframework.data.repository.reactive.ReactiveSortingRepository; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; @@ -102,7 +99,7 @@ public class SimpleReactiveNeo4jRepository implements ReactiveSortingRepo public Flux findAll(Sort sort) { Statement statement = cypherGenerator.prepareMatchOf(entityMetaData) .returning(cypherGenerator.createReturnStatementForMatch(entityMetaData)) - .orderBy(toSortItems(entityMetaData, sort)) + .orderBy(CypherAdapterUtils.toSortItems(entityMetaData, sort)) .build(); return neo4jOperations.findAll(statement, this.entityInformation.getJavaType()); diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleReactiveQueryByExampleExecutor.java b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveQueryByExampleExecutor.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleReactiveQueryByExampleExecutor.java rename to src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveQueryByExampleExecutor.java index d4322ffaa..33964de69 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/SimpleReactiveQueryByExampleExecutor.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/SimpleReactiveQueryByExampleExecutor.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,21 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static org.neo4j.cypherdsl.core.Cypher.*; -import static org.neo4j.springframework.data.repository.query.CypherAdapterUtils.*; +import static org.springframework.data.neo4j.repository.query.CypherAdapterUtils.*; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import org.neo4j.cypherdsl.core.Functions; import org.neo4j.cypherdsl.core.Statement; -import org.neo4j.springframework.data.core.ReactiveNeo4jOperations; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.schema.CypherGenerator; import org.springframework.data.domain.Example; import org.springframework.data.domain.Sort; +import org.springframework.data.neo4j.core.ReactiveNeo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.schema.CypherGenerator; import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor; /** diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/package-info.java b/src/main/java/org/springframework/data/neo4j/repository/support/package-info.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/package-info.java rename to src/main/java/org/springframework/data/neo4j/repository/support/package-info.java index 75e1cc621..5ca12b0ad 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/repository/support/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/repository/support/package-info.java @@ -4,6 +4,6 @@ * and {@link org.springframework.data.repository.reactive.ReactiveSortingRepository}. */ @NonNullApi -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/AbstractPoint.java b/src/main/java/org/springframework/data/neo4j/types/AbstractPoint.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/AbstractPoint.java rename to src/main/java/org/springframework/data/neo4j/types/AbstractPoint.java index 905b63660..7f5e1713a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/AbstractPoint.java +++ b/src/main/java/org/springframework/data/neo4j/types/AbstractPoint.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import java.util.Objects; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/CartesianPoint2d.java b/src/main/java/org/springframework/data/neo4j/types/CartesianPoint2d.java similarity index 85% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/CartesianPoint2d.java rename to src/main/java/org/springframework/data/neo4j/types/CartesianPoint2d.java index 51ec0796a..5ffe7053a 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/CartesianPoint2d.java +++ b/src/main/java/org/springframework/data/neo4j/types/CartesianPoint2d.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import org.apiguardian.api.API; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/CartesianPoint3d.java b/src/main/java/org/springframework/data/neo4j/types/CartesianPoint3d.java similarity index 86% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/CartesianPoint3d.java rename to src/main/java/org/springframework/data/neo4j/types/CartesianPoint3d.java index c1a354242..e8b95eb96 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/CartesianPoint3d.java +++ b/src/main/java/org/springframework/data/neo4j/types/CartesianPoint3d.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import org.apiguardian.api.API; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/Coordinate.java b/src/main/java/org/springframework/data/neo4j/types/Coordinate.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/Coordinate.java rename to src/main/java/org/springframework/data/neo4j/types/Coordinate.java index 587698744..bff83ebea 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/Coordinate.java +++ b/src/main/java/org/springframework/data/neo4j/types/Coordinate.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import java.util.Objects; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/GeographicPoint2d.java b/src/main/java/org/springframework/data/neo4j/types/GeographicPoint2d.java similarity index 86% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/GeographicPoint2d.java rename to src/main/java/org/springframework/data/neo4j/types/GeographicPoint2d.java index 948ecb961..34a9841ff 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/GeographicPoint2d.java +++ b/src/main/java/org/springframework/data/neo4j/types/GeographicPoint2d.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import org.apiguardian.api.API; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/GeographicPoint3d.java b/src/main/java/org/springframework/data/neo4j/types/GeographicPoint3d.java similarity index 87% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/GeographicPoint3d.java rename to src/main/java/org/springframework/data/neo4j/types/GeographicPoint3d.java index 08bbbaf21..ede3963c3 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/GeographicPoint3d.java +++ b/src/main/java/org/springframework/data/neo4j/types/GeographicPoint3d.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import org.apiguardian.api.API; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/Neo4jPoint.java b/src/main/java/org/springframework/data/neo4j/types/Neo4jPoint.java similarity index 86% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/Neo4jPoint.java rename to src/main/java/org/springframework/data/neo4j/types/Neo4jPoint.java index df8865236..96b8eb863 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/Neo4jPoint.java +++ b/src/main/java/org/springframework/data/neo4j/types/Neo4jPoint.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import org.apiguardian.api.API; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/PointBuilder.java b/src/main/java/org/springframework/data/neo4j/types/PointBuilder.java similarity index 86% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/PointBuilder.java rename to src/main/java/org/springframework/data/neo4j/types/PointBuilder.java index ac5faefda..5e44c3d65 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/PointBuilder.java +++ b/src/main/java/org/springframework/data/neo4j/types/PointBuilder.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import org.apiguardian.api.API; diff --git a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/package-info.java b/src/main/java/org/springframework/data/neo4j/types/package-info.java similarity index 69% rename from spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/package-info.java rename to src/main/java/org/springframework/data/neo4j/types/package-info.java index 60101da83..ac8a285ae 100644 --- a/spring-data-neo4j/src/main/java/org/neo4j/springframework/data/types/package-info.java +++ b/src/main/java/org/springframework/data/neo4j/types/package-info.java @@ -2,6 +2,6 @@ * Additional types provided by SDN/RX. */ @NonNullApi -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import org.springframework.lang.NonNullApi; diff --git a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/Neo4jClientExtensions.kt b/src/main/kotlin/org/springframework/data/neo4j/core/Neo4jClientExtensions.kt similarity index 87% rename from spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/Neo4jClientExtensions.kt rename to src/main/kotlin/org/springframework/data/neo4j/core/Neo4jClientExtensions.kt index 2bd14c003..9f5a89e36 100644 --- a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/Neo4jClientExtensions.kt +++ b/src/main/kotlin/org/springframework/data/neo4j/core/Neo4jClientExtensions.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core +package org.springframework.data.neo4j.core -import java.util.function.BiFunction import org.neo4j.driver.Record import org.neo4j.driver.types.TypeSystem +import java.util.function.BiFunction /** * Extension for [Neo4jClient.RunnableSpec.in] providing an `inDatabase` alias since `in` is a reserved keyword in Kotlin. @@ -58,7 +55,7 @@ class KRecordFetchSpec (private val delegate: Neo4jClient.RecordFetchSp */ class KMappingSpec(private val delegate: Neo4jClient.MappingSpec) { fun mappedBy(mappingFunction: BiFunction): KRecordFetchSpec = - KRecordFetchSpec(delegate.mappedBy(mappingFunction)) + KRecordFetchSpec(delegate.mappedBy(mappingFunction)) fun one(): T? = delegate.one().orElse(null) @@ -73,7 +70,7 @@ class KMappingSpec(private val delegate: Neo4jClient.MappingSpec) { * @since 1.0 */ inline fun Neo4jClient.RunnableSpecTightToDatabase.fetchAs(): KMappingSpec = - KMappingSpec(fetchAs(T::class.java)) + KMappingSpec(fetchAs(T::class.java)) /** * Extension for [Neo4jClient.RunnableSpecTightToDatabase.mappedBy] leveraging reified type parameters and removing @@ -84,4 +81,4 @@ inline fun Neo4jClient.RunnableSpecTightToDatabase.fetchAs(): inline fun Neo4jClient.RunnableSpecTightToDatabase.mappedBy( noinline mappingFunction: (TypeSystem, Record) -> T ) = - KRecordFetchSpec(fetchAs(T::class.java).mappedBy(mappingFunction)) + KRecordFetchSpec(fetchAs(T::class.java).mappedBy(mappingFunction)) diff --git a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/PreparedQueryFactory.kt b/src/main/kotlin/org/springframework/data/neo4j/core/PreparedQueryFactory.kt similarity index 82% rename from spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/PreparedQueryFactory.kt rename to src/main/kotlin/org/springframework/data/neo4j/core/PreparedQueryFactory.kt index 9fb40381e..34abd666b 100644 --- a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/PreparedQueryFactory.kt +++ b/src/main/kotlin/org/springframework/data/neo4j/core/PreparedQueryFactory.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core +package org.springframework.data.neo4j.core import kotlin.reflect.KClass diff --git a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jClientExtensions.kt b/src/main/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jClientExtensions.kt similarity index 89% rename from spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jClientExtensions.kt rename to src/main/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jClientExtensions.kt index 6005effa6..b8e779413 100644 --- a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jClientExtensions.kt +++ b/src/main/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jClientExtensions.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core +package org.springframework.data.neo4j.core import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.asFlow @@ -33,7 +30,7 @@ import org.neo4j.driver.types.TypeSystem * @since 1.0 */ fun ReactiveNeo4jClient.RunnableSpec.inDatabase(targetDatabase: String): - ReactiveNeo4jClient.RunnableSpecTightToDatabase = `in`(targetDatabase) + ReactiveNeo4jClient.RunnableSpecTightToDatabase = `in`(targetDatabase) /** * Extension for [ReactiveNeo4jClient.OngoingDelegation.in] providing an `inDatabase` alias since `in` is a reserved keyword in Kotlin. @@ -42,7 +39,7 @@ fun ReactiveNeo4jClient.RunnableSpec.inDatabase(targetDatabase: String): * @since 1.0 */ fun ReactiveNeo4jClient.OngoingDelegation.inDatabase(targetDatabase: String): - ReactiveNeo4jClient.RunnableDelegation = `in`(targetDatabase) + ReactiveNeo4jClient.RunnableDelegation = `in`(targetDatabase) /** * Extension for [ReactiveNeo4jClient.RunnableSpecTightToDatabase.fetchAs] leveraging reified type parameters. @@ -50,7 +47,7 @@ fun ReactiveNeo4jClient.OngoingDelegation.inDatabase(targetDatabas * @since 1.0 */ inline fun ReactiveNeo4jClient.RunnableSpecTightToDatabase.fetchAs(): - ReactiveNeo4jClient.MappingSpec = fetchAs(T::class.java) + ReactiveNeo4jClient.MappingSpec = fetchAs(T::class.java) /** * Extension for [ReactiveNeo4jClient.RunnableSpecTightToDatabase.mappedBy] leveraging reified type parameters and removing diff --git a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jOperationsExtensions.kt b/src/main/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jOperationsExtensions.kt similarity index 85% rename from spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jOperationsExtensions.kt rename to src/main/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jOperationsExtensions.kt index a27618db8..2190f9c82 100644 --- a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jOperationsExtensions.kt +++ b/src/main/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jOperationsExtensions.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core +package org.springframework.data.neo4j.core import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.reactive.asFlow diff --git a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/cypher/Parameters.kt b/src/main/kotlin/org/springframework/data/neo4j/core/cypher/Parameters.kt similarity index 83% rename from spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/cypher/Parameters.kt rename to src/main/kotlin/org/springframework/data/neo4j/core/cypher/Parameters.kt index e950a9d25..7cf7d0a8c 100644 --- a/spring-data-neo4j/src/main/kotlin/org/neo4j/springframework/data/core/cypher/Parameters.kt +++ b/src/main/kotlin/org/springframework/data/neo4j/core/cypher/Parameters.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.cypher +package org.springframework.data.neo4j.core.cypher // A couple of extension methods that escapes $parameterNames inside multiline strings. // See ParameterTest.kt for an example how to use them. diff --git a/spring-data-neo4j/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories similarity index 56% rename from spring-data-neo4j/src/main/resources/META-INF/spring.factories rename to src/main/resources/META-INF/spring.factories index f094a8494..17b2666e7 100644 --- a/spring-data-neo4j/src/main/resources/META-INF/spring.factories +++ b/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.data.repository.core.support.RepositoryFactorySupport=org.neo4j.springframework.data.repository.support.Neo4jRepositoryFactory +org.springframework.data.repository.core.support.RepositoryFactorySupport=org.springframework.data.neo4j.repository.support.Neo4jRepositoryFactory diff --git a/spring-data-neo4j/src/main/resources/META-INF/spring.tooling b/src/main/resources/META-INF/spring.tooling similarity index 100% rename from spring-data-neo4j/src/main/resources/META-INF/spring.tooling rename to src/main/resources/META-INF/spring.tooling diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/config/Neo4jAuditingRegistrarTest.java b/src/test/java/org/springframework/data/neo4j/config/Neo4jAuditingRegistrarTest.java similarity index 87% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/config/Neo4jAuditingRegistrarTest.java rename to src/test/java/org/springframework/data/neo4j/config/Neo4jAuditingRegistrarTest.java index aa72ccd88..34a910c89 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/config/Neo4jAuditingRegistrarTest.java +++ b/src/test/java/org/springframework/data/neo4j/config/Neo4jAuditingRegistrarTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.config; +package org.springframework.data.neo4j.config; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/DatabaseSelectionProviderTest.java b/src/test/java/org/springframework/data/neo4j/core/DatabaseSelectionProviderTest.java similarity index 89% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/DatabaseSelectionProviderTest.java rename to src/test/java/org/springframework/data/neo4j/core/DatabaseSelectionProviderTest.java index 526645d5e..10e748e46 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/DatabaseSelectionProviderTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/DatabaseSelectionProviderTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/DelegatingMappingFunctionWithNullCheckTest.java b/src/test/java/org/springframework/data/neo4j/core/DelegatingMappingFunctionWithNullCheckTest.java similarity index 87% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/DelegatingMappingFunctionWithNullCheckTest.java rename to src/test/java/org/springframework/data/neo4j/core/DelegatingMappingFunctionWithNullCheckTest.java index 820b615e8..035a92d88 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/DelegatingMappingFunctionWithNullCheckTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/DelegatingMappingFunctionWithNullCheckTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/NamedParametersTest.java b/src/test/java/org/springframework/data/neo4j/core/NamedParametersTest.java similarity index 95% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/NamedParametersTest.java rename to src/test/java/org/springframework/data/neo4j/core/NamedParametersTest.java index f87e1178e..41349f9bb 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/NamedParametersTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/NamedParametersTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static java.util.Collections.*; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/Neo4jClientTest.java b/src/test/java/org/springframework/data/neo4j/core/Neo4jClientTest.java similarity index 98% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/Neo4jClientTest.java rename to src/test/java/org/springframework/data/neo4j/core/Neo4jClientTest.java index ab7151454..545a7a667 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/Neo4jClientTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/Neo4jClientTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -48,8 +45,8 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.Record; import org.neo4j.driver.Result; import org.neo4j.driver.Session; -import org.neo4j.driver.Values; import org.neo4j.driver.SessionConfig; +import org.neo4j.driver.Values; import org.neo4j.driver.summary.ResultSummary; import org.neo4j.driver.types.TypeSystem; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/ReactiveNeo4jClientTest.java b/src/test/java/org/springframework/data/neo4j/core/ReactiveNeo4jClientTest.java similarity index 88% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/ReactiveNeo4jClientTest.java rename to src/test/java/org/springframework/data/neo4j/core/ReactiveNeo4jClientTest.java index b4b219e3e..9324ca4b9 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/ReactiveNeo4jClientTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/ReactiveNeo4jClientTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -43,18 +40,13 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.neo4j.driver.Driver; import org.neo4j.driver.Record; -import org.neo4j.driver.Values; import org.neo4j.driver.SessionConfig; +import org.neo4j.driver.Values; import org.neo4j.driver.reactive.RxResult; import org.neo4j.driver.reactive.RxSession; import org.neo4j.driver.reactive.RxTransaction; import org.neo4j.driver.summary.ResultSummary; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.Neo4jClientTest.Bike; -import org.neo4j.springframework.data.core.Neo4jClientTest.BikeOwner; -import org.neo4j.springframework.data.core.Neo4jClientTest.BikeOwnerBinder; -import org.neo4j.springframework.data.core.Neo4jClientTest.BikeOwnerReader; -import org.neo4j.springframework.data.core.Neo4jClientTest.MapAssertionMatcher; /** * @author Michael J. Simons @@ -143,7 +135,7 @@ class ReactiveNeo4jClientTest { expectedParameters.putAll(parameters); expectedParameters.put("name", "michael"); expectedParameters.put("aDate", LocalDate.of(2019, 1, 1)); - verify(transaction).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters))); + verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters))); verify(result).records(); verify(record1).asMap(); @@ -181,7 +173,7 @@ class ReactiveNeo4jClientTest { Map expectedParameters = new HashMap<>(); expectedParameters.put("name", "Someone.*"); - verify(transaction).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters))); + verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters))); verify(result).records(); verify(record1).asMap(); verify(transaction).commit(); @@ -281,11 +273,11 @@ class ReactiveNeo4jClientTest { String cypher = "MATCH (o:User {name: $name}) - [:OWNS] -> (b:Bike)" + "RETURN o, collect(b) as bikes"; - BikeOwnerReader mappingFunction = new BikeOwnerReader(); - Flux bikeOwners = client + Neo4jClientTest.BikeOwnerReader mappingFunction = new Neo4jClientTest.BikeOwnerReader(); + Flux bikeOwners = client .query(cypher) .bind("michael").to("name") - .fetchAs(BikeOwner.class).mappedBy(mappingFunction) + .fetchAs(Neo4jClientTest.BikeOwner.class).mappedBy(mappingFunction) .all(); StepVerifier.create(bikeOwners) @@ -297,7 +289,7 @@ class ReactiveNeo4jClientTest { Map expectedParameters = new HashMap<>(); expectedParameters.put("name", "michael"); - verify(transaction).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters))); + verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters))); verify(result).records(); verify(record1).get("name"); verify(transaction).commit(); @@ -316,11 +308,11 @@ class ReactiveNeo4jClientTest { when(record1.get("name")).thenReturn(Values.value("michael")); ReactiveNeo4jClient client = ReactiveNeo4jClient.create(driver); - Flux bikeOwners = client + Flux bikeOwners = client .query("MATCH (n) RETURN n") - .fetchAs(BikeOwner.class).mappedBy((t, r) -> { + .fetchAs(Neo4jClientTest.BikeOwner.class).mappedBy((t, r) -> { if (r == record1) { - return new BikeOwner(r.get("name").asString(), Collections.emptyList()); + return new Neo4jClientTest.BikeOwner(r.get("name").asString(), Collections.emptyList()); } else { return null; } @@ -333,7 +325,7 @@ class ReactiveNeo4jClientTest { verifyDatabaseSelection(null); - verify(transaction).run(eq("MATCH (n) RETURN n"), argThat(new MapAssertionMatcher(Collections.emptyMap()))); + verify(transaction).run(eq("MATCH (n) RETURN n"), argThat(new Neo4jClientTest.MapAssertionMatcher(Collections.emptyMap()))); verify(result).records(); verify(record1).get("name"); verify(transaction).commit(); @@ -353,7 +345,7 @@ class ReactiveNeo4jClientTest { ReactiveNeo4jClient client = ReactiveNeo4jClient.create(driver); - BikeOwner michael = new BikeOwner("Michael", Arrays.asList(new Bike("Road"), new Bike("MTB"))); + Neo4jClientTest.BikeOwner michael = new Neo4jClientTest.BikeOwner("Michael", Arrays.asList(new Neo4jClientTest.Bike("Road"), new Neo4jClientTest.Bike("MTB"))); String cypher = "MERGE (u:User {name: 'Michael'}) " + "WITH u UNWIND $bikes as bike " + "MERGE (b:Bike {name: bike}) " @@ -361,7 +353,7 @@ class ReactiveNeo4jClientTest { Mono summary = client .query(cypher) - .bind(michael).with(new BikeOwnerBinder()) + .bind(michael).with(new Neo4jClientTest.BikeOwnerBinder()) .run(); StepVerifier.create(summary) @@ -373,7 +365,7 @@ class ReactiveNeo4jClientTest { Map expectedParameters = new HashMap<>(); expectedParameters.put("name", "Michael"); - verify(transaction).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters))); + verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters))); verify(result).consume(); verify(transaction).commit(); verify(transaction).rollback(); @@ -442,7 +434,7 @@ class ReactiveNeo4jClientTest { Map expectedParameters = new HashMap<>(); expectedParameters.put("name", "fixie"); - verify(transaction).run(eq(cypher), argThat(new MapAssertionMatcher(expectedParameters))); + verify(transaction).run(eq(cypher), argThat(new Neo4jClientTest.MapAssertionMatcher(expectedParameters))); verify(result).consume(); verify(transaction).commit(); verify(transaction).rollback(); diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/SingleValueMappingFunctionTest.java b/src/test/java/org/springframework/data/neo4j/core/SingleValueMappingFunctionTest.java similarity index 93% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/SingleValueMappingFunctionTest.java rename to src/test/java/org/springframework/data/neo4j/core/SingleValueMappingFunctionTest.java index 18fcf3662..7cd0e851b 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/SingleValueMappingFunctionTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/SingleValueMappingFunctionTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -32,11 +29,11 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.neo4j.driver.Record; import org.neo4j.driver.Values; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.converter.ConverterRegistry; import org.springframework.core.convert.support.DefaultConversionService; +import org.springframework.data.neo4j.core.convert.Neo4jConversions; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/TransactionHandlingTest.java b/src/test/java/org/springframework/data/neo4j/core/TransactionHandlingTest.java similarity index 96% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/TransactionHandlingTest.java rename to src/test/java/org/springframework/data/neo4j/core/TransactionHandlingTest.java index 8a227699b..c69603eb7 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/TransactionHandlingTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/TransactionHandlingTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core; +package org.springframework.data.neo4j.core; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -37,13 +34,13 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.neo4j.driver.Driver; import org.neo4j.driver.Session; +import org.neo4j.driver.SessionConfig; import org.neo4j.driver.Transaction; import org.neo4j.driver.TransactionConfig; -import org.neo4j.driver.SessionConfig; import org.neo4j.driver.reactive.RxSession; import org.neo4j.driver.reactive.RxTransaction; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.transaction.Neo4jTransactionManager; +import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager; import org.springframework.transaction.support.TransactionTemplate; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/convert/SpatialTypesTest.java b/src/test/java/org/springframework/data/neo4j/core/convert/SpatialTypesTest.java similarity index 78% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/convert/SpatialTypesTest.java rename to src/test/java/org/springframework/data/neo4j/core/convert/SpatialTypesTest.java index d56fb2838..f21f9b7d9 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/convert/SpatialTypesTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/convert/SpatialTypesTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import static org.assertj.core.api.Assertions.*; import org.junit.jupiter.api.Test; import org.neo4j.driver.types.Point; -import org.neo4j.springframework.data.types.CartesianPoint2d; -import org.neo4j.springframework.data.types.CartesianPoint3d; -import org.neo4j.springframework.data.types.GeographicPoint2d; -import org.neo4j.springframework.data.types.GeographicPoint3d; +import org.springframework.data.neo4j.types.CartesianPoint2d; +import org.springframework.data.neo4j.types.CartesianPoint3d; +import org.springframework.data.neo4j.types.GeographicPoint2d; +import org.springframework.data.neo4j.types.GeographicPoint3d; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/convert/TemporalAmountAdapterTest.java b/src/test/java/org/springframework/data/neo4j/core/convert/TemporalAmountAdapterTest.java similarity index 90% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/convert/TemporalAmountAdapterTest.java rename to src/test/java/org/springframework/data/neo4j/core/convert/TemporalAmountAdapterTest.java index 642d4a158..b9126f864 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/convert/TemporalAmountAdapterTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/convert/TemporalAmountAdapterTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.convert; +package org.springframework.data.neo4j.core.convert; import static java.time.temporal.ChronoUnit.*; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jConverterTest.java b/src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jConverterTest.java similarity index 84% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jConverterTest.java rename to src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jConverterTest.java index 84f70cc27..aefee7530 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jConverterTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jConverterTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import static org.assertj.core.api.Assertions.*; @@ -29,11 +26,11 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Value; import org.neo4j.driver.Values; import org.neo4j.driver.exceptions.value.Uncoercible; -import org.neo4j.springframework.data.core.ReactiveNeo4jClient; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; import org.springframework.core.convert.ConversionFailedException; import org.springframework.core.convert.ConverterNotFoundException; import org.springframework.dao.TypeMismatchDataAccessException; +import org.springframework.data.neo4j.core.ReactiveNeo4jClient; +import org.springframework.data.neo4j.core.convert.Neo4jConversions; import org.springframework.data.util.ClassTypeInformation; /** @@ -74,9 +71,10 @@ class DefaultNeo4jConverterTest { assertThatExceptionOfType(TypeMismatchDataAccessException.class) .isThrownBy( - () -> defaultNeo4jConverter.readValueForProperty(value, ClassTypeInformation.from(ReactiveNeo4jClient.class))) + () -> defaultNeo4jConverter.readValueForProperty(value, ClassTypeInformation.from( + ReactiveNeo4jClient.class))) .withMessageStartingWith( - "Could not convert \"Das funktioniert nicht.\" into org.neo4j.springframework.data.core.ReactiveNeo4jClient;") + "Could not convert \"Das funktioniert nicht.\" into org.springframework.data.neo4j.core.ReactiveNeo4jClient;") .withRootCauseInstanceOf(ConverterNotFoundException.class); } } diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jIsNewStrategyTest.java b/src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jIsNewStrategyTest.java similarity index 94% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jIsNewStrategyTest.java rename to src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jIsNewStrategyTest.java index 8c8912e29..3407f6c85 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jIsNewStrategyTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jIsNewStrategyTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -26,10 +23,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.neo4j.springframework.data.core.schema.IdDescription; -import org.neo4j.springframework.data.core.schema.IdGenerator; import org.springframework.data.mapping.IdentifierAccessor; import org.springframework.data.mapping.PersistentPropertyAccessor; +import org.springframework.data.neo4j.core.schema.IdDescription; +import org.springframework.data.neo4j.core.schema.IdGenerator; import org.springframework.data.support.IsNewStrategy; /** @@ -116,7 +113,7 @@ class DefaultNeo4jIsNewStrategyTest { assertThatIllegalArgumentException().isThrownBy(() -> DefaultNeo4jIsNewStrategy.basedOn(entityMetaData)) .withMessage( - "Cannot use org.neo4j.springframework.data.core.mapping.DefaultNeo4jIsNewStrategy with externally generated, primitive ids."); + "Cannot use org.springframework.data.neo4j.core.mapping.DefaultNeo4jIsNewStrategy with externally generated, primitive ids."); } } diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentEntityTest.java b/src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentEntityTest.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentEntityTest.java rename to src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentEntityTest.java index dac6d1474..0b2c44b70 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentEntityTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentEntityTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import static org.assertj.core.api.Assertions.*; @@ -25,16 +22,17 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Property; -import org.neo4j.springframework.data.core.schema.Relationship; -import org.neo4j.springframework.data.core.schema.DynamicLabels; +import org.springframework.data.neo4j.core.schema.DynamicLabels; +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.core.schema.Property; +import org.springframework.data.neo4j.core.schema.Relationship; /** * @author Gerrit Meier @@ -56,7 +54,7 @@ class DefaultNeo4jPersistentEntityTest { assertThatIllegalStateException() .isThrownBy(() -> new Neo4jMappingContext().getPersistentEntity(EntityWithDuplicatedProperties.class)) .withMessage("Duplicate definition of property [name] in entity class " - + "org.neo4j.springframework.data.core.mapping.DefaultNeo4jPersistentEntityTest$EntityWithDuplicatedProperties."); + + "org.springframework.data.neo4j.core.mapping.DefaultNeo4jPersistentEntityTest$EntityWithDuplicatedProperties."); } @Test @@ -65,7 +63,7 @@ class DefaultNeo4jPersistentEntityTest { .isThrownBy( () -> new Neo4jMappingContext().getPersistentEntity(EntityWithMultipleDuplicatedProperties.class)) .withMessage("Duplicate definition of properties [foo, name] in entity class " - + "org.neo4j.springframework.data.core.mapping.DefaultNeo4jPersistentEntityTest$EntityWithMultipleDuplicatedProperties."); + + "org.springframework.data.neo4j.core.mapping.DefaultNeo4jPersistentEntityTest$EntityWithMultipleDuplicatedProperties."); } } @@ -89,7 +87,7 @@ class DefaultNeo4jPersistentEntityTest { TypeWithInvalidDynamicRelationshipMappings2.class, TypeWithInvalidDynamicRelationshipMappings3.class }) void multipleDynamicAssociationsToTheSameEntityAreNotAllowed(Class entityToTest) { - String expectedMessage = ".*TypeWithInvalidDynamicRelationshipMappings\\d already contains a dynamic relationship to class org\\.neo4j\\.springframework\\.data\\.core\\.mapping\\.Neo4jMappingContextTest\\$BikeNode. Only one dynamic relationship between to entities is permitted\\."; + String expectedMessage = ".*TypeWithInvalidDynamicRelationshipMappings\\d already contains a dynamic relationship to class org\\.springframework\\.data\\.neo4j\\.core\\.mapping\\.Neo4jMappingContextTest\\$BikeNode. Only one dynamic relationship between to entities is permitted\\."; Neo4jMappingContext schema = new Neo4jMappingContext(); schema.setInitialEntitySet(new HashSet<>(Arrays.asList(entityToTest))); assertThatIllegalStateException() @@ -176,12 +174,12 @@ class DefaultNeo4jPersistentEntityTest { assertThat(persistentEntity.getPersistentProperty("relatedTo").isDynamicLabels()).isFalse(); assertThat(persistentEntity.getPersistentProperty("relatedTo").isAssociation()).isTrue(); assertThat(persistentEntity.getPersistentProperty("relatedTo").isIdProperty()).isFalse(); - assertThat(persistentEntity.getPersistentProperty("relatedTo").isRelationship()).isTrue(); + Assertions.assertThat(persistentEntity.getPersistentProperty("relatedTo").isRelationship()).isTrue(); assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isDynamicLabels()).isTrue(); assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isAssociation()).isFalse(); assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isIdProperty()).isFalse(); - assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isRelationship()).isFalse(); + Assertions.assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isRelationship()).isFalse(); assertThat(persistentEntity.getDynamicLabelsProperty()) .hasValueSatisfying(p -> p.getFieldName().equals("dynamicLabels")); @@ -199,12 +197,12 @@ class DefaultNeo4jPersistentEntityTest { assertThat(persistentEntity.getPersistentProperty("relatedTo").isDynamicLabels()).isFalse(); assertThat(persistentEntity.getPersistentProperty("relatedTo").isAssociation()).isTrue(); assertThat(persistentEntity.getPersistentProperty("relatedTo").isIdProperty()).isFalse(); - assertThat(persistentEntity.getPersistentProperty("relatedTo").isRelationship()).isTrue(); + Assertions.assertThat(persistentEntity.getPersistentProperty("relatedTo").isRelationship()).isTrue(); assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isDynamicLabels()).isTrue(); assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isAssociation()).isFalse(); assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isIdProperty()).isFalse(); - assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isRelationship()).isFalse(); + Assertions.assertThat(persistentEntity.getPersistentProperty("dynamicLabels").isRelationship()).isFalse(); assertThat(persistentEntity.getDynamicLabelsProperty()) .hasValueSatisfying(p -> p.getFieldName().equals("dynamicLabels")); diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentPropertyTest.java b/src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentPropertyTest.java similarity index 88% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentPropertyTest.java rename to src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentPropertyTest.java index 53273e2ef..bf214cf42 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/DefaultNeo4jPersistentPropertyTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentPropertyTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/Neo4jMappingContextTest.java b/src/test/java/org/springframework/data/neo4j/core/mapping/Neo4jMappingContextTest.java similarity index 89% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/Neo4jMappingContextTest.java rename to src/test/java/org/springframework/data/neo4j/core/mapping/Neo4jMappingContextTest.java index 5e766ab2c..051034588 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/mapping/Neo4jMappingContextTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/mapping/Neo4jMappingContextTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.mapping; +package org.springframework.data.neo4j.core.mapping; import static java.util.Collections.*; import static org.assertj.core.api.Assertions.*; @@ -29,22 +26,23 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.neo4j.driver.internal.value.StringValue; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.GraphPropertyDescription; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.IdGenerator; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.NodeDescription; -import org.neo4j.springframework.data.core.schema.Property; -import org.neo4j.springframework.data.core.schema.Relationship; -import org.neo4j.springframework.data.core.schema.RelationshipDescription; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.GenericConverter; import org.springframework.data.annotation.Transient; import org.springframework.data.mapping.Association; +import org.springframework.data.neo4j.core.convert.Neo4jConversions; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.GraphPropertyDescription; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.IdGenerator; +import org.springframework.data.neo4j.core.schema.Node; +import org.springframework.data.neo4j.core.schema.NodeDescription; +import org.springframework.data.neo4j.core.schema.Property; +import org.springframework.data.neo4j.core.schema.Relationship; +import org.springframework.data.neo4j.core.schema.RelationshipDescription; /** * @author Michael J. Simons @@ -143,7 +141,7 @@ class Neo4jMappingContextTest { Neo4jMappingContext schema = new Neo4jMappingContext(); Neo4jPersistentEntity bikeNodeEntity = schema.getPersistentEntity(BikeNode.class); bikeNodeEntity.doWithAssociations((Association association) -> - assertThat(schema.getRequiredMappingFunctionFor(association.getInverse().getAssociationTargetType())) + Assertions.assertThat(schema.getRequiredMappingFunctionFor(association.getInverse().getAssociationTargetType())) .isNotNull()); } @@ -192,7 +190,7 @@ class Neo4jMappingContextTest { new Neo4jConversions(singleton(new ConvertibleTypeConverter()))); Neo4jPersistentEntity entity = schema.getPersistentEntity(EntityWithConvertibleProperty.class); - assertThat(entity.getPersistentProperty("convertibleType").isRelationship()).isFalse(); + Assertions.assertThat(entity.getPersistentProperty("convertibleType").isRelationship()).isFalse(); } @Test @@ -201,7 +199,7 @@ class Neo4jMappingContextTest { Neo4jMappingContext schema = new Neo4jMappingContext(new Neo4jConversions()); Neo4jPersistentEntity entity = schema.getPersistentEntity(EntityWithConvertibleProperty.class); - assertThat(entity.getPersistentProperty("convertibleType").isRelationship()).isTrue(); + Assertions.assertThat(entity.getPersistentProperty("convertibleType").isRelationship()).isTrue(); } @Test diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/schema/CypherGeneratorTest.java b/src/test/java/org/springframework/data/neo4j/core/schema/CypherGeneratorTest.java similarity index 93% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/schema/CypherGeneratorTest.java rename to src/test/java/org/springframework/data/neo4j/core/schema/CypherGeneratorTest.java index 375d3d8b7..6bc9c046d 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/schema/CypherGeneratorTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/schema/CypherGeneratorTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,20 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; + +import static org.mockito.Mockito.*; + +import java.util.Map; import org.junit.Assert; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.neo4j.cypherdsl.core.Statement; import org.neo4j.cypherdsl.core.renderer.Renderer; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentProperty; - -import java.util.Map; - -import static org.mockito.Mockito.when; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty; /** * @author Davide Fantuzzi diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/schema/IdDescriptionTest.java b/src/test/java/org/springframework/data/neo4j/core/schema/IdDescriptionTest.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/schema/IdDescriptionTest.java rename to src/test/java/org/springframework/data/neo4j/core/schema/IdDescriptionTest.java index 45d543e73..d90f097bb 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/schema/IdDescriptionTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/schema/IdDescriptionTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.schema; +package org.springframework.data.neo4j.core.schema; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jBookmarkManagerTest.java b/src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jBookmarkManagerTest.java similarity index 92% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jBookmarkManagerTest.java rename to src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jBookmarkManagerTest.java index c4133a682..75e3a98ec 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jBookmarkManagerTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jBookmarkManagerTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import static java.util.Collections.*; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionManagerTest.java b/src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionManagerTest.java similarity index 92% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionManagerTest.java rename to src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionManagerTest.java index b71cc745a..65767f0fa 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionManagerTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionManagerTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionManager.*; import java.lang.reflect.Field; import java.util.Collections; @@ -45,8 +41,8 @@ import org.neo4j.driver.SessionConfig; import org.neo4j.driver.Transaction; import org.neo4j.driver.TransactionConfig; import org.neo4j.driver.types.TypeSystem; -import org.neo4j.springframework.data.core.DatabaseSelectionProvider; -import org.neo4j.springframework.data.core.Neo4jClient; +import org.springframework.data.neo4j.core.DatabaseSelectionProvider; +import org.springframework.data.neo4j.core.Neo4jClient; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.jta.JtaTransactionManager; @@ -80,7 +76,7 @@ class Neo4jTransactionManagerTest { @Test void shouldWorkWithoutSynchronizations() { - Transaction optionalTransaction = retrieveTransaction(driver, databaseName); + Transaction optionalTransaction = Neo4jTransactionManager.retrieveTransaction(driver, databaseName); assertThat(optionalTransaction).isNull(); @@ -216,7 +212,8 @@ class Neo4jTransactionManagerTest { assertThat(transactionStatus.isNewTransaction()).isTrue(); assertThat(TransactionSynchronizationManager.hasResource(driver)).isTrue(); - Transaction optionalTransaction = retrieveTransaction(driver, databaseName); + Transaction optionalTransaction = Neo4jTransactionManager + .retrieveTransaction(driver, databaseName); assertThat(optionalTransaction).isNotNull(); transactionStatus.setRollbackOnly(); @@ -245,7 +242,8 @@ class Neo4jTransactionManagerTest { @Override protected void doInTransactionWithoutResult(TransactionStatus outerStatus) { - Transaction outerNativeTransaction = retrieveTransaction(driver, databaseName); + Transaction outerNativeTransaction = Neo4jTransactionManager + .retrieveTransaction(driver, databaseName); assertThat(outerNativeTransaction).isNotNull(); assertThat(outerStatus.isNewTransaction()).isTrue(); @@ -256,7 +254,8 @@ class Neo4jTransactionManagerTest { assertThat(innerStatus.isNewTransaction()).isFalse(); - Transaction innerNativeTransaction = retrieveTransaction(driver, databaseName); + Transaction innerNativeTransaction = Neo4jTransactionManager + .retrieveTransaction(driver, databaseName); assertThat(innerNativeTransaction).isNotNull(); } }); @@ -299,7 +298,7 @@ class Neo4jTransactionManagerTest { assertThat(transactionStatus.isNewTransaction()).isTrue(); assertThat(TransactionSynchronizationManager.hasResource(driver)).isFalse(); - Transaction nativeTransaction = retrieveTransaction(driver, databaseName); + Transaction nativeTransaction = Neo4jTransactionManager.retrieveTransaction(driver, databaseName); assertThat(nativeTransaction).isNotNull(); assertThat(TransactionSynchronizationManager.hasResource(driver)).isTrue(); @@ -337,7 +336,7 @@ class Neo4jTransactionManagerTest { assertThat(transactionStatus.isNewTransaction()).isTrue(); assertThat(TransactionSynchronizationManager.hasResource(driver)).isFalse(); - Transaction nativeTransaction = retrieveTransaction(driver, databaseName); + Transaction nativeTransaction = Neo4jTransactionManager.retrieveTransaction(driver, databaseName); assertThat(nativeTransaction).isNotNull(); assertThat(TransactionSynchronizationManager.hasResource(driver)).isTrue(); diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionUtilsTest.java b/src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionUtilsTest.java similarity index 73% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionUtilsTest.java rename to src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionUtilsTest.java index 0466c7812..c74be9682 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/Neo4jTransactionUtilsTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/transaction/Neo4jTransactionUtilsTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; - -import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.core.transaction.Neo4jTransactionUtils.*; +package org.springframework.data.neo4j.core.transaction; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; @@ -46,7 +41,7 @@ class Neo4jTransactionUtilsTest { }) void nameComparisionShouldWorkForNamesTargetingTheSame(String name1, String name2) { - assertThat(namesMapToTheSameDatabase(name1, name2)).isTrue(); + Assertions.assertThat(Neo4jTransactionUtils.namesMapToTheSameDatabase(name1, name2)).isTrue(); } @ParameterizedTest @@ -57,7 +52,7 @@ class Neo4jTransactionUtilsTest { }) void nameComparisionShouldWorkForNamesTargetingOther(String name1, String name2) { - assertThat(namesMapToTheSameDatabase(name1, name2)).isFalse(); + Assertions.assertThat(Neo4jTransactionUtils.namesMapToTheSameDatabase(name1, name2)).isFalse(); } } diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionManagerTest.java b/src/test/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionManagerTest.java similarity index 89% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionManagerTest.java rename to src/test/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionManagerTest.java index c1b3244b0..255d47518 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/core/transaction/ReactiveNeo4jTransactionManagerTest.java +++ b/src/test/java/org/springframework/data/neo4j/core/transaction/ReactiveNeo4jTransactionManagerTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.transaction; +package org.springframework.data.neo4j.core.transaction; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; -import static org.neo4j.springframework.data.core.transaction.ReactiveNeo4jTransactionManager.*; import io.r2dbc.h2.H2ConnectionConfiguration; import io.r2dbc.h2.H2ConnectionFactory; @@ -46,7 +42,7 @@ import org.neo4j.driver.SessionConfig; import org.neo4j.driver.TransactionConfig; import org.neo4j.driver.reactive.RxSession; import org.neo4j.driver.reactive.RxTransaction; -import org.neo4j.springframework.data.core.ReactiveDatabaseSelectionProvider; +import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider; import org.springframework.data.r2dbc.connectionfactory.R2dbcTransactionManager; import org.springframework.transaction.reactive.TransactionSynchronizationManager; import org.springframework.transaction.reactive.TransactionalOperator; @@ -82,7 +78,8 @@ class ReactiveNeo4jTransactionManagerTest { @Test void shouldWorkWithoutSynchronizations() { - Mono transactionMono = retrieveReactiveTransaction(driver, databaseName); + Mono transactionMono = ReactiveNeo4jTransactionManager + .retrieveReactiveTransaction(driver, databaseName); StepVerifier.create(transactionMono) .verifyComplete(); @@ -102,7 +99,7 @@ class ReactiveNeo4jTransactionManagerTest { .forCurrentTransaction().doOnNext(tsm -> { assertThat(tsm.hasResource(driver)).isTrue(); transactionStatus.setRollbackOnly(); - }).then(retrieveReactiveTransaction(driver, databaseName)) + }).then(ReactiveNeo4jTransactionManager.retrieveReactiveTransaction(driver, databaseName)) ) .as(StepVerifier::create) .expectNextCount(1L) @@ -129,8 +126,8 @@ class ReactiveNeo4jTransactionManagerTest { outerStatus.setRollbackOnly(); return transactionalOperator.execute(innerStatus -> { assertThat(innerStatus.isNewTransaction()).isFalse(); - return retrieveReactiveTransaction(driver, databaseName); - }).then(retrieveReactiveTransaction(driver, databaseName)); + return ReactiveNeo4jTransactionManager.retrieveReactiveTransaction(driver, databaseName); + }).then(ReactiveNeo4jTransactionManager.retrieveReactiveTransaction(driver, databaseName)); }) .as(StepVerifier::create) .expectNextCount(1L) @@ -170,7 +167,7 @@ class ReactiveNeo4jTransactionManagerTest { .execute(transactionStatus -> TransactionSynchronizationManager .forCurrentTransaction() .doOnNext(tsm -> assertThat(tsm.hasResource(driver)).isTrue()) - .then(retrieveReactiveTransaction(driver, databaseName)) + .then(ReactiveNeo4jTransactionManager.retrieveReactiveTransaction(driver, databaseName)) ) .as(StepVerifier::create) .expectNextCount(1L) @@ -206,7 +203,7 @@ class ReactiveNeo4jTransactionManagerTest { transactionalOperator .execute(transactionStatus -> TransactionSynchronizationManager .forCurrentTransaction().doOnNext(tsm -> assertThat(tsm.hasResource(driver)).isFalse()) - .then(retrieveReactiveTransaction(driver, databaseName)) + .then(ReactiveNeo4jTransactionManager.retrieveReactiveTransaction(driver, databaseName)) .flatMap(ignoredNativeTx -> TransactionSynchronizationManager.forCurrentTransaction() .doOnNext(tsm -> assertThat(tsm.hasResource(driver)).isTrue())) ) @@ -237,7 +234,7 @@ class ReactiveNeo4jTransactionManagerTest { assertThat(tsm.hasResource(driver)).isFalse(); transactionStatus.setRollbackOnly(); }) - .then(retrieveReactiveTransaction(driver, databaseName)) + .then(ReactiveNeo4jTransactionManager.retrieveReactiveTransaction(driver, databaseName)) .flatMap(ignoredNativeTx -> TransactionSynchronizationManager.forCurrentTransaction() .doOnNext(tsm -> assertThat(tsm.hasResource(driver)).isTrue())) ) diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/Neo4jConversionsIT.java b/src/test/java/org/springframework/data/neo4j/integration/Neo4jConversionsIT.java similarity index 94% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/Neo4jConversionsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/Neo4jConversionsIT.java index d75398210..8da1f3138 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/Neo4jConversionsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/Neo4jConversionsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration; +package org.springframework.data.neo4j.integration; import static org.assertj.core.api.Assertions.*; import static org.junit.jupiter.api.DynamicTest.*; @@ -41,12 +38,12 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.neo4j.driver.Session; import org.neo4j.driver.Value; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.integration.shared.Neo4jConversionsITBase; -import org.neo4j.springframework.data.test.Neo4jExtension; 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.test.Neo4jExtension; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/AuditingIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/AuditingIT.java similarity index 87% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/AuditingIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/AuditingIT.java index 0c350bbe2..60d4b601d 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/AuditingIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/AuditingIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; @@ -24,18 +21,18 @@ import java.util.Optional; import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.config.EnableNeo4jAuditing; -import org.neo4j.springframework.data.integration.shared.AuditingITBase; -import org.neo4j.springframework.data.integration.shared.ImmutableAuditableThing; -import org.neo4j.springframework.data.integration.shared.ImmutableAuditableThingWithGeneratedId; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; 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.repository.Neo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; import org.springframework.transaction.annotation.EnableTransactionManagement; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CallbacksIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/CallbacksIT.java similarity index 80% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CallbacksIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/CallbacksIT.java index 58567ae2d..866308a38 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CallbacksIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/CallbacksIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; @@ -25,15 +22,15 @@ import java.util.Collections; import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.integration.imperative.repositories.ThingRepository; -import org.neo4j.springframework.data.integration.shared.CallbacksITBase; -import org.neo4j.springframework.data.integration.shared.ThingWithAssignedId; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.repository.event.BeforeBindCallback; 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.imperative.repositories.ThingRepository; +import org.springframework.data.neo4j.integration.shared.CallbacksITBase; +import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; +import org.springframework.data.neo4j.repository.event.BeforeBindCallback; import org.springframework.transaction.annotation.EnableTransactionManagement; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CausalClusterLoadTestIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/CausalClusterLoadTestIT.java similarity index 88% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CausalClusterLoadTestIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/CausalClusterLoadTestIT.java index 9f99d12ae..4b154bc71 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CausalClusterLoadTestIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/CausalClusterLoadTestIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static java.util.stream.Collectors.*; @@ -39,15 +36,15 @@ import org.neo4j.driver.Config; import org.neo4j.driver.Driver; import org.neo4j.driver.GraphDatabase; import org.neo4j.junit.jupiter.causal_cluster.Neo4jUri; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.Neo4jClient; -import org.neo4j.springframework.data.integration.shared.ThingWithSequence; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.test.CausalClusterIntegrationTest; 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.Neo4jClient; +import org.springframework.data.neo4j.integration.shared.ThingWithSequence; +import org.springframework.data.neo4j.repository.Neo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; +import org.springframework.data.neo4j.test.CausalClusterIntegrationTest; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CustomBaseRepositoryIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/CustomBaseRepositoryIT.java similarity index 77% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CustomBaseRepositoryIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/CustomBaseRepositoryIT.java index 5e5b0d4e2..0760c4df0 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/CustomBaseRepositoryIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/CustomBaseRepositoryIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,28 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; import java.util.List; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.Neo4jOperations; -import org.neo4j.springframework.data.integration.shared.PersonWithAllConstructor; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.repository.support.Neo4jEntityInformation; -import org.neo4j.springframework.data.repository.support.SimpleNeo4jRepository; -import org.neo4j.springframework.data.test.DriverMocks; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan.Filter; 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.repository.Neo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; +import org.springframework.data.neo4j.repository.support.Neo4jEntityInformation; +import org.springframework.data.neo4j.repository.support.SimpleNeo4jRepository; +import org.springframework.data.neo4j.test.DriverMocks; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -67,7 +65,7 @@ public class CustomBaseRepositoryIT { assertThat(neo4jOperations).isNotNull(); assertThat(entityInformation).isNotNull(); - assertThat(entityInformation.getEntityMetaData().getUnderlyingClass()) + Assertions.assertThat(entityInformation.getEntityMetaData().getUnderlyingClass()) .isEqualTo(PersonWithAllConstructor.class); } diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DefaultNeo4jConverterIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/DefaultNeo4jConverterIT.java similarity index 82% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DefaultNeo4jConverterIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/DefaultNeo4jConverterIT.java index 20da2c776..58a8b59d4 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DefaultNeo4jConverterIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/DefaultNeo4jConverterIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import java.util.Arrays; import java.util.HashSet; @@ -29,17 +26,17 @@ import java.util.Set; import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Property; -import org.neo4j.springframework.data.core.schema.Relationship; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; 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.Neo4jIntegrationTest; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DynamicLabelsIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicLabelsIT.java similarity index 96% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DynamicLabelsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicLabelsIT.java index d9b1d87ad..9c2b3eb43 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DynamicLabelsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicLabelsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; import static org.neo4j.cypherdsl.core.Conditions.not; @@ -33,22 +30,22 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.neo4j.cypherdsl.core.Condition; +import org.neo4j.cypherdsl.core.Cypher; +import org.neo4j.cypherdsl.core.Node; +import org.neo4j.cypherdsl.core.renderer.Renderer; import org.neo4j.driver.Driver; import org.neo4j.driver.Record; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; import org.neo4j.driver.Value; -import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Node; -import org.neo4j.cypherdsl.core.renderer.Renderer; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.Neo4jTemplate; -import org.neo4j.springframework.data.integration.shared.EntitiesWithDynamicLabels.*; -import org.neo4j.springframework.data.test.Neo4jExtension; 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.Neo4jTemplate; +import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.*; +import org.springframework.data.neo4j.test.Neo4jExtension; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DynamicRelationshipsIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicRelationshipsIT.java similarity index 90% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DynamicRelationshipsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicRelationshipsIT.java index c816e6b82..9b4b36659 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/DynamicRelationshipsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/DynamicRelationshipsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assumptions.*; @@ -30,17 +27,17 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Transaction; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.DynamicRelationshipsITBase; -import org.neo4j.springframework.data.integration.shared.Person; -import org.neo4j.springframework.data.integration.shared.PersonWithRelatives; -import org.neo4j.springframework.data.integration.shared.PersonWithRelatives.TypeOfPet; -import org.neo4j.springframework.data.integration.shared.PersonWithRelatives.TypeOfRelative; -import org.neo4j.springframework.data.integration.shared.Pet; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; 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.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.repository.config.EnableNeo4jRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/ExceptionTranslationIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/ExceptionTranslationIT.java similarity index 86% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/ExceptionTranslationIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/ExceptionTranslationIT.java index aa017dc50..be6c3d73d 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/ExceptionTranslationIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/ExceptionTranslationIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import java.util.Optional; @@ -30,15 +27,6 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.summary.ResultSummary; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.Neo4jClient; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.repository.support.Neo4jPersistenceExceptionTranslator; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -46,6 +34,15 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; 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.repository.Neo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; +import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/IdGeneratorsIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/IdGeneratorsIT.java similarity index 85% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/IdGeneratorsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/IdGeneratorsIT.java index ad31e5d0b..043b36cd1 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/IdGeneratorsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/IdGeneratorsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static java.util.stream.Collectors.*; import static org.assertj.core.api.Assertions.*; @@ -28,15 +25,15 @@ import java.util.stream.StreamSupport; import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.schema.IdGenerator; -import org.neo4j.springframework.data.integration.shared.IdGeneratorsITBase; -import org.neo4j.springframework.data.integration.shared.ThingWithGeneratedId; -import org.neo4j.springframework.data.integration.shared.ThingWithIdGeneratedByBean; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; 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.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.repository.config.EnableNeo4jRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/Neo4jOperationsIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/Neo4jOperationsIT.java similarity index 94% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/Neo4jOperationsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/Neo4jOperationsIT.java index d461f15bb..3d63c157f 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/Neo4jOperationsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/Neo4jOperationsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static java.util.Collections.*; import static org.assertj.core.api.Assertions.*; @@ -31,6 +28,10 @@ import java.util.function.Function; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.neo4j.cypherdsl.core.Cypher; +import org.neo4j.cypherdsl.core.Functions; +import org.neo4j.cypherdsl.core.Node; +import org.neo4j.cypherdsl.core.Statement; import org.neo4j.driver.Driver; import org.neo4j.driver.Record; import org.neo4j.driver.Result; @@ -39,19 +40,15 @@ import org.neo4j.driver.SessionConfig; import org.neo4j.driver.Transaction; import org.neo4j.driver.Value; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.Neo4jOperations; -import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; -import org.neo4j.cypherdsl.core.Node; -import org.neo4j.cypherdsl.core.Statement; -import org.neo4j.springframework.data.integration.shared.PersonWithAllConstructor; -import org.neo4j.springframework.data.integration.shared.ThingWithGeneratedId; -import org.neo4j.springframework.data.test.Neo4jExtension.Neo4jConnectionSupport; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; 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.integration.shared.PersonWithAllConstructor; +import org.springframework.data.neo4j.integration.shared.ThingWithGeneratedId; +import org.springframework.data.neo4j.test.Neo4jExtension.Neo4jConnectionSupport; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.transaction.annotation.EnableTransactionManagement; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/OptimisticLockingIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/OptimisticLockingIT.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/OptimisticLockingIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/OptimisticLockingIT.java index 27656b1a1..456d35341 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/OptimisticLockingIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/OptimisticLockingIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static java.util.Collections.*; import static org.assertj.core.api.Assertions.*; @@ -30,17 +27,17 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.SessionConfig; import org.neo4j.driver.Transaction; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.VersionedThing; -import org.neo4j.springframework.data.integration.shared.VersionedThingWithAssignedId; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; 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.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; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/ProjectionIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/ProjectionIT.java similarity index 87% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/ProjectionIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/ProjectionIT.java index d8e4875a6..4078a7602 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/ProjectionIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/ProjectionIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; @@ -27,18 +24,18 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.NamesOnly; -import org.neo4j.springframework.data.integration.shared.NamesOnlyDto; -import org.neo4j.springframework.data.integration.shared.Person; -import org.neo4j.springframework.data.integration.shared.PersonSummary; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; 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.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; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RelationshipsAsConstructorParametersIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/RelationshipsAsConstructorParametersIT.java similarity index 83% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RelationshipsAsConstructorParametersIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/RelationshipsAsConstructorParametersIT.java index bf0424a88..57529cec4 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RelationshipsAsConstructorParametersIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/RelationshipsAsConstructorParametersIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; @@ -27,14 +24,14 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.Neo4jTemplate; -import org.neo4j.springframework.data.integration.shared.RelationshipsAsConstructorParametersEntities; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; 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.Neo4jTemplate; +import org.springframework.data.neo4j.integration.shared.RelationshipsAsConstructorParametersEntities; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.transaction.annotation.EnableTransactionManagement; @Neo4jIntegrationTest diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RelationshipsIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/RelationshipsIT.java similarity index 94% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RelationshipsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/RelationshipsIT.java index cdcc74173..83d4bba41 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RelationshipsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/RelationshipsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; @@ -29,13 +26,13 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Record; import org.neo4j.driver.Session; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.MultipleRelationshipsThing; -import org.neo4j.springframework.data.integration.shared.RelationshipsITBase; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; 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.MultipleRelationshipsThing; +import org.springframework.data.neo4j.integration.shared.RelationshipsITBase; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RepositoryIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java similarity index 98% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RepositoryIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java index 69f8efa24..5f71578da 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RepositoryIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static java.util.Collections.*; import static java.util.stream.Collectors.*; @@ -31,6 +28,7 @@ import java.util.*; import java.util.stream.IntStream; import java.util.stream.StreamSupport; +import org.assertj.core.api.Assertions; import org.assertj.core.data.MapEntry; import org.assertj.core.groups.Tuple; import org.junit.jupiter.api.BeforeEach; @@ -47,20 +45,6 @@ import org.neo4j.driver.Values; import org.neo4j.driver.types.Node; import org.neo4j.driver.types.Point; import org.neo4j.driver.types.Relationship; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.DatabaseSelection; -import org.neo4j.springframework.data.core.DatabaseSelectionProvider; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.integration.imperative.repositories.PersonRepository; -import org.neo4j.springframework.data.integration.imperative.repositories.ThingRepository; -import org.neo4j.springframework.data.integration.shared.*; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.repository.query.BoundingBox; -import org.neo4j.springframework.data.repository.query.Query; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.types.CartesianPoint2d; -import org.neo4j.springframework.data.types.GeographicPoint2d; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -79,6 +63,20 @@ import org.springframework.data.geo.Circle; import org.springframework.data.geo.Distance; import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Polygon; +import org.springframework.data.neo4j.config.AbstractNeo4jConfig; +import org.springframework.data.neo4j.core.DatabaseSelection; +import org.springframework.data.neo4j.core.DatabaseSelectionProvider; +import org.springframework.data.neo4j.core.convert.Neo4jConversions; +import org.springframework.data.neo4j.integration.imperative.repositories.PersonRepository; +import org.springframework.data.neo4j.integration.imperative.repositories.ThingRepository; +import org.springframework.data.neo4j.integration.shared.*; +import org.springframework.data.neo4j.repository.Neo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; +import org.springframework.data.neo4j.repository.query.BoundingBox; +import org.springframework.data.neo4j.repository.query.Query; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.types.CartesianPoint2d; +import org.springframework.data.neo4j.types.GeographicPoint2d; import org.springframework.data.repository.query.Param; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @@ -2312,7 +2310,7 @@ class RepositoryIT { assertThatIllegalArgumentException().isThrownBy(() -> repository.findAllByPlaceWithin(p)) .withMessage( - "The WITHIN operation does not support a class org.springframework.data.geo.Polygon. You might want to pass a bounding box instead: class org.neo4j.springframework.data.repository.query.BoundingBox.of(polygon)."); + "The WITHIN operation does not support a class org.springframework.data.geo.Polygon. You might want to pass a bounding box instead: class org.springframework.data.neo4j.repository.query.BoundingBox.of(polygon)."); persons = repository.findAllByPlaceNear(CLARION, distance); assertThat(persons).isEmpty(); @@ -2499,9 +2497,9 @@ class RepositoryIT { n3Id = record.get("n3").asNode().id(); } - assertThat(multipleLabelRepository.findById(n1Id)).isPresent(); - assertThat(multipleLabelRepository.findById(n2Id)).isNotPresent(); - assertThat(multipleLabelRepository.findById(n3Id)).isNotPresent(); + Assertions.assertThat(multipleLabelRepository.findById(n1Id)).isPresent(); + Assertions.assertThat(multipleLabelRepository.findById(n2Id)).isNotPresent(); + Assertions.assertThat(multipleLabelRepository.findById(n3Id)).isNotPresent(); } @Test @@ -2583,9 +2581,9 @@ class RepositoryIT { n3Id = record.get("n3").asNode().get("id").asLong(); } - assertThat(multipleLabelRepository.findById(n1Id)).isPresent(); - assertThat(multipleLabelRepository.findById(n2Id)).isNotPresent(); - assertThat(multipleLabelRepository.findById(n3Id)).isNotPresent(); + Assertions.assertThat(multipleLabelRepository.findById(n1Id)).isPresent(); + Assertions.assertThat(multipleLabelRepository.findById(n2Id)).isNotPresent(); + Assertions.assertThat(multipleLabelRepository.findById(n3Id)).isNotPresent(); } @Test diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RepositoryWithADifferentDatabaseIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryWithADifferentDatabaseIT.java similarity index 81% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RepositoryWithADifferentDatabaseIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryWithADifferentDatabaseIT.java index 248336a35..7013e02cc 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/RepositoryWithADifferentDatabaseIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/RepositoryWithADifferentDatabaseIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.neo4j.driver.Session; import org.neo4j.driver.SessionConfig; -import org.neo4j.springframework.data.core.DatabaseSelection; +import org.springframework.data.neo4j.core.DatabaseSelection; import org.springframework.test.annotation.DirtiesContext; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/StringlyTypedDynamicRelationshipsIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/StringlyTypedDynamicRelationshipsIT.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/StringlyTypedDynamicRelationshipsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/StringlyTypedDynamicRelationshipsIT.java index d91dc9384..104832cff 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/StringlyTypedDynamicRelationshipsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/StringlyTypedDynamicRelationshipsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assumptions.*; @@ -30,15 +27,15 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Transaction; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.DynamicRelationshipsITBase; -import org.neo4j.springframework.data.integration.shared.Person; -import org.neo4j.springframework.data.integration.shared.PersonWithStringlyTypedRelatives; -import org.neo4j.springframework.data.integration.shared.Pet; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; 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.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.repository.config.EnableNeo4jRepositories; import org.springframework.data.repository.CrudRepository; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/TransactionManagerMixedDatabasesTest.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/TransactionManagerMixedDatabasesTest.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/TransactionManagerMixedDatabasesTest.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/TransactionManagerMixedDatabasesTest.java index 178102212..92f4e4a9e 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/TransactionManagerMixedDatabasesTest.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/TransactionManagerMixedDatabasesTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -36,16 +33,16 @@ import org.neo4j.driver.SessionConfig; import org.neo4j.driver.Transaction; import org.neo4j.driver.TransactionConfig; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.DatabaseSelectionProvider; -import org.neo4j.springframework.data.core.Neo4jClient; -import org.neo4j.springframework.data.core.transaction.Neo4jTransactionManager; -import org.neo4j.springframework.data.integration.imperative.repositories.PersonRepository; -import org.neo4j.springframework.data.integration.shared.PersonWithAllConstructor; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; 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.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.repository.config.EnableNeo4jRepositories; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/TypeConversionIT.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/TypeConversionIT.java similarity index 87% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/TypeConversionIT.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/TypeConversionIT.java index 5f0d33632..d3410fe23 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/TypeConversionIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/TypeConversionIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative; +package org.springframework.data.neo4j.integration.imperative; import static org.assertj.core.api.Assertions.*; import static org.junit.jupiter.api.DynamicTest.*; @@ -29,6 +26,7 @@ import java.util.Map; import java.util.UUID; import java.util.stream.Stream; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DynamicContainer; import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.Test; @@ -37,24 +35,24 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.Value; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.integration.shared.Neo4jConversionsITBase; -import org.neo4j.springframework.data.integration.shared.ThingWithAllAdditionalTypes; -import org.neo4j.springframework.data.integration.shared.ThingWithAllCypherTypes; -import org.neo4j.springframework.data.integration.shared.ThingWithAllSpatialTypes; -import org.neo4j.springframework.data.integration.shared.ThingWithCustomTypes; -import org.neo4j.springframework.data.integration.shared.ThingWithNonExistingPrimitives; -import org.neo4j.springframework.data.integration.shared.ThingWithUUIDID; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.data.mapping.MappingException; +import org.springframework.data.neo4j.config.AbstractNeo4jConfig; +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.ThingWithCustomTypes; +import org.springframework.data.neo4j.integration.shared.ThingWithNonExistingPrimitives; +import org.springframework.data.neo4j.integration.shared.ThingWithUUIDID; +import org.springframework.data.neo4j.repository.Neo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -195,7 +193,7 @@ class TypeConversionIT extends Neo4jConversionsITBase { ThingWithUUIDID thing = repository.save(new ThingWithUUIDID("a thing")); assertThat(thing.getId()).isNotNull(); - assertThat(repository.findById(thing.getId())).isPresent(); + Assertions.assertThat(repository.findById(thing.getId())).isPresent(); } @Test @@ -207,9 +205,9 @@ class TypeConversionIT extends Neo4jConversionsITBase { ThingWithUUIDID savedThing = repository.save(aThing); assertThat(savedThing.getId()).isNotNull(); - assertThat(repository.findById(savedThing.getId())).isPresent(); + Assertions.assertThat(repository.findById(savedThing.getId())).isPresent(); assertThat(savedThing.getAnotherThing().getId()).isNotNull(); - assertThat(repository.findById(savedThing.getAnotherThing().getId())).isPresent(); + Assertions.assertThat(repository.findById(savedThing.getAnotherThing().getId())).isPresent(); } public interface ConvertedIDsRepository diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/PersonRepository.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/PersonRepository.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/PersonRepository.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/PersonRepository.java index fb9e060f4..ca3ec58d8 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/PersonRepository.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/PersonRepository.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative.repositories; +package org.springframework.data.neo4j.integration.imperative.repositories; import java.time.Instant; import java.time.LocalDate; @@ -25,17 +22,6 @@ import java.util.Optional; import java.util.stream.Stream; import org.neo4j.driver.types.Point; -import org.neo4j.springframework.data.integration.shared.DtoPersonProjection; -import org.neo4j.springframework.data.integration.shared.KotlinPerson; -import org.neo4j.springframework.data.integration.shared.PersonProjection; -import org.neo4j.springframework.data.integration.shared.PersonWithAllConstructor; -import org.neo4j.springframework.data.integration.shared.PersonWithNoConstructor; -import org.neo4j.springframework.data.integration.shared.PersonWithWither; -import org.neo4j.springframework.data.integration.shared.ThingWithGeneratedId; -import org.neo4j.springframework.data.repository.Neo4jRepository; -import org.neo4j.springframework.data.repository.query.BoundingBox; -import org.neo4j.springframework.data.repository.query.Query; -import org.neo4j.springframework.data.types.GeographicPoint2d; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Range; @@ -43,6 +29,17 @@ 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.KotlinPerson; +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.repository.Neo4jRepository; +import org.springframework.data.neo4j.repository.query.BoundingBox; +import org.springframework.data.neo4j.repository.query.Query; +import org.springframework.data.neo4j.types.GeographicPoint2d; import org.springframework.data.repository.query.Param; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/ThingRepository.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/ThingRepository.java similarity index 74% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/ThingRepository.java rename to src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/ThingRepository.java index e5a6b9180..620b8eeb2 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/imperative/repositories/ThingRepository.java +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/ThingRepository.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative.repositories; +package org.springframework.data.neo4j.integration.imperative.repositories; import java.util.List; -import org.neo4j.springframework.data.integration.shared.ThingWithAssignedId; -import org.neo4j.springframework.data.repository.query.Query; +import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId; +import org.springframework.data.neo4j.repository.query.Query; import org.springframework.data.repository.CrudRepository; /** diff --git a/src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/package-info.java b/src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/package-info.java new file mode 100644 index 000000000..86cb6722a --- /dev/null +++ b/src/test/java/org/springframework/data/neo4j/integration/imperative/repositories/package-info.java @@ -0,0 +1,4 @@ +/** + * Repositories shared between tests. + */ +package org.springframework.data.neo4j.integration.imperative.repositories; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/kotlin/KotlinIT.java b/src/test/java/org/springframework/data/neo4j/integration/kotlin/KotlinIT.java similarity index 78% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/kotlin/KotlinIT.java rename to src/test/java/org/springframework/data/neo4j/integration/kotlin/KotlinIT.java index a0d9b18e1..70ae21f33 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/kotlin/KotlinIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/kotlin/KotlinIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.kotlin; +package org.springframework.data.neo4j.integration.kotlin; import static org.assertj.core.api.Assertions.*; @@ -26,15 +23,15 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.KotlinPerson; -import org.neo4j.springframework.data.integration.shared.KotlinRepository; -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories; -import org.neo4j.springframework.data.test.Neo4jExtension.Neo4jConnectionSupport; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; 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.KotlinPerson; +import org.springframework.data.neo4j.integration.shared.KotlinRepository; +import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; +import org.springframework.data.neo4j.test.Neo4jExtension.Neo4jConnectionSupport; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.transaction.annotation.EnableTransactionManagement; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/CustomReactiveBaseRepositoryIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/CustomReactiveBaseRepositoryIT.java similarity index 78% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/CustomReactiveBaseRepositoryIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/CustomReactiveBaseRepositoryIT.java index c96f30624..ce7e0e4cc 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/CustomReactiveBaseRepositoryIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/CustomReactiveBaseRepositoryIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,29 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.*; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.ReactiveNeo4jOperations; -import org.neo4j.springframework.data.integration.shared.PersonWithAllConstructor; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; -import org.neo4j.springframework.data.repository.support.Neo4jEntityInformation; -import org.neo4j.springframework.data.repository.support.SimpleReactiveNeo4jRepository; -import org.neo4j.springframework.data.test.DriverMocks; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan.Filter; 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.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; +import org.springframework.data.neo4j.repository.support.Neo4jEntityInformation; +import org.springframework.data.neo4j.repository.support.SimpleReactiveNeo4jRepository; +import org.springframework.data.neo4j.test.DriverMocks; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.EnableTransactionManagement; @@ -71,7 +69,7 @@ public class CustomReactiveBaseRepositoryIT { assertThat(neo4jOperations).isNotNull(); assertThat(entityInformation).isNotNull(); - assertThat(entityInformation.getEntityMetaData().getUnderlyingClass()) + Assertions.assertThat(entityInformation.getEntityMetaData().getUnderlyingClass()) .isEqualTo(PersonWithAllConstructor.class); } diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveAuditingIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveAuditingIT.java similarity index 90% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveAuditingIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveAuditingIT.java index 71daa6b67..c30282c04 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveAuditingIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveAuditingIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -31,18 +28,18 @@ import java.util.Optional; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.config.EnableNeo4jAuditing; -import org.neo4j.springframework.data.integration.shared.AuditingITBase; -import org.neo4j.springframework.data.integration.shared.ImmutableAuditableThing; -import org.neo4j.springframework.data.integration.shared.ImmutableAuditableThingWithGeneratedId; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.auditing.DateTimeProvider; import org.springframework.data.domain.AuditorAware; +import org.springframework.data.neo4j.config.AbstractReactiveNeo4jConfig; +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.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; import org.springframework.transaction.ReactiveTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.reactive.TransactionalOperator; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveCallbacksIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCallbacksIT.java similarity index 86% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveCallbacksIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCallbacksIT.java index b4bf5a8fa..7a4fcab7f 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveCallbacksIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCallbacksIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -31,16 +28,16 @@ import java.util.List; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.integration.reactive.repositories.ReactiveThingRepository; -import org.neo4j.springframework.data.integration.shared.CallbacksITBase; -import org.neo4j.springframework.data.integration.shared.ThingWithAssignedId; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; -import org.neo4j.springframework.data.repository.event.ReactiveBeforeBindCallback; -import org.neo4j.springframework.data.test.Neo4jExtension; 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.reactive.repositories.ReactiveThingRepository; +import org.springframework.data.neo4j.integration.shared.CallbacksITBase; +import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; +import org.springframework.data.neo4j.repository.event.ReactiveBeforeBindCallback; +import org.springframework.data.neo4j.test.Neo4jExtension; import org.springframework.transaction.ReactiveTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.reactive.TransactionalOperator; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveCausalClusterLoadTestIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCausalClusterLoadTestIT.java similarity index 89% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveCausalClusterLoadTestIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCausalClusterLoadTestIT.java index 933e6968a..0d5bc0bfd 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveCausalClusterLoadTestIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveCausalClusterLoadTestIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static java.util.stream.Collectors.*; @@ -42,15 +39,15 @@ import org.neo4j.driver.Config; import org.neo4j.driver.Driver; import org.neo4j.driver.GraphDatabase; import org.neo4j.junit.jupiter.causal_cluster.Neo4jUri; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.ReactiveNeo4jClient; -import org.neo4j.springframework.data.integration.shared.ThingWithSequence; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; -import org.neo4j.springframework.data.test.CausalClusterIntegrationTest; 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.ReactiveNeo4jClient; +import org.springframework.data.neo4j.integration.shared.ThingWithSequence; +import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; +import org.springframework.data.neo4j.test.CausalClusterIntegrationTest; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveDynamicLabelsIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicLabelsIT.java similarity index 96% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveDynamicLabelsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicLabelsIT.java index 145835599..c2c8af046 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveDynamicLabelsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicLabelsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.*; import static org.neo4j.cypherdsl.core.Conditions.not; import static org.neo4j.cypherdsl.core.Predicates.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -36,22 +33,22 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.neo4j.cypherdsl.core.Condition; +import org.neo4j.cypherdsl.core.Cypher; +import org.neo4j.cypherdsl.core.Node; +import org.neo4j.cypherdsl.core.renderer.Renderer; import org.neo4j.driver.Driver; import org.neo4j.driver.Record; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; import org.neo4j.driver.reactive.RxSession; -import org.neo4j.cypherdsl.core.Condition; -import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Node; -import org.neo4j.cypherdsl.core.renderer.Renderer; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.ReactiveNeo4jTemplate; -import org.neo4j.springframework.data.integration.shared.EntitiesWithDynamicLabels.*; -import org.neo4j.springframework.data.test.Neo4jExtension; 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.ReactiveNeo4jTemplate; +import org.springframework.data.neo4j.integration.shared.EntitiesWithDynamicLabels.*; +import org.springframework.data.neo4j.test.Neo4jExtension; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveDynamicRelationshipsIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicRelationshipsIT.java similarity index 90% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveDynamicRelationshipsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicRelationshipsIT.java index a50f79652..2850f0707 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveDynamicRelationshipsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveDynamicRelationshipsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assumptions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.test.StepVerifier; @@ -34,18 +31,18 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Transaction; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.DynamicRelationshipsITBase; -import org.neo4j.springframework.data.integration.shared.Person; -import org.neo4j.springframework.data.integration.shared.PersonWithRelatives; -import org.neo4j.springframework.data.integration.shared.PersonWithRelatives.TypeOfPet; -import org.neo4j.springframework.data.integration.shared.PersonWithRelatives.TypeOfRelative; -import org.neo4j.springframework.data.integration.shared.Pet; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; 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.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveExceptionTranslationIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveExceptionTranslationIT.java similarity index 85% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveExceptionTranslationIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveExceptionTranslationIT.java index 3294d2d34..f6513d832 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveExceptionTranslationIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveExceptionTranslationIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -35,20 +32,20 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.reactive.RxResult; import org.neo4j.driver.reactive.RxSession; import org.neo4j.driver.summary.ResultSummary; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.ReactiveNeo4jClient; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; -import org.neo4j.springframework.data.repository.support.Neo4jPersistenceExceptionTranslator; -import org.neo4j.springframework.data.repository.support.ReactivePersistenceExceptionTranslationPostProcessor; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; 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.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; +import org.springframework.data.neo4j.repository.support.Neo4jPersistenceExceptionTranslator; +import org.springframework.data.neo4j.repository.support.ReactivePersistenceExceptionTranslationPostProcessor; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveIdGeneratorsIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveIdGeneratorsIT.java similarity index 89% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveIdGeneratorsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveIdGeneratorsIT.java index c52ded968..b0b7abd77 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveIdGeneratorsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveIdGeneratorsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static java.util.stream.Collectors.*; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -34,15 +31,15 @@ import java.util.stream.IntStream; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.schema.IdGenerator; -import org.neo4j.springframework.data.integration.shared.IdGeneratorsITBase; -import org.neo4j.springframework.data.integration.shared.ThingWithGeneratedId; -import org.neo4j.springframework.data.integration.shared.ThingWithIdGeneratedByBean; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; 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.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.repository.config.EnableReactiveNeo4jRepositories; import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.transaction.ReactiveTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveNeo4jOperationsIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jOperationsIT.java similarity index 93% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveNeo4jOperationsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jOperationsIT.java index aadc1c101..97e759a0a 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveNeo4jOperationsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jOperationsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static java.util.Collections.*; import static org.assertj.core.api.Assertions.*; import static org.neo4j.cypherdsl.core.Cypher.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.test.StepVerifier; @@ -36,6 +33,10 @@ import java.util.function.Function; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.neo4j.cypherdsl.core.Cypher; +import org.neo4j.cypherdsl.core.Functions; +import org.neo4j.cypherdsl.core.Node; +import org.neo4j.cypherdsl.core.Statement; import org.neo4j.driver.Driver; import org.neo4j.driver.Record; import org.neo4j.driver.Result; @@ -44,19 +45,15 @@ import org.neo4j.driver.SessionConfig; import org.neo4j.driver.Transaction; import org.neo4j.driver.Value; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.ReactiveNeo4jOperations; -import org.neo4j.cypherdsl.core.Cypher; -import org.neo4j.cypherdsl.core.Functions; -import org.neo4j.cypherdsl.core.Node; -import org.neo4j.cypherdsl.core.Statement; -import org.neo4j.springframework.data.integration.shared.PersonWithAllConstructor; -import org.neo4j.springframework.data.integration.shared.ThingWithGeneratedId; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; -import org.neo4j.springframework.data.test.Neo4jExtension.*; 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.integration.shared.PersonWithAllConstructor; +import org.springframework.data.neo4j.integration.shared.ThingWithGeneratedId; +import org.springframework.data.neo4j.test.Neo4jExtension.*; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.transaction.annotation.EnableTransactionManagement; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveOptimisticLockingIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveOptimisticLockingIT.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveOptimisticLockingIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveOptimisticLockingIT.java index 69556272b..989c0f23e 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveOptimisticLockingIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveOptimisticLockingIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static java.util.Collections.*; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.test.StepVerifier; @@ -35,17 +32,17 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.SessionConfig; import org.neo4j.driver.Transaction; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.VersionedThing; -import org.neo4j.springframework.data.integration.shared.VersionedThingWithAssignedId; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; import org.springframework.beans.factory.annotation.Autowired; 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.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.transaction.annotation.EnableTransactionManagement; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveProjectionIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveProjectionIT.java similarity index 86% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveProjectionIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveProjectionIT.java index f3ce7cbf6..c7acfe005 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveProjectionIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveProjectionIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; @@ -30,18 +27,18 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.NamesOnly; -import org.neo4j.springframework.data.integration.shared.NamesOnlyDto; -import org.neo4j.springframework.data.integration.shared.Person; -import org.neo4j.springframework.data.integration.shared.PersonSummary; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; 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.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.transaction.annotation.EnableTransactionManagement; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRelationshipsIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRelationshipsIT.java similarity index 94% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRelationshipsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRelationshipsIT.java index 344f3738c..784bcfa39 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRelationshipsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRelationshipsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.test.StepVerifier; @@ -32,13 +29,13 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Record; import org.neo4j.driver.Session; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.MultipleRelationshipsThing; -import org.neo4j.springframework.data.integration.shared.RelationshipsITBase; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; 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.repository.config.EnableReactiveNeo4jRepositories; import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRepositoryIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryIT.java similarity index 98% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRepositoryIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryIT.java index d670a6508..53af44a11 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRepositoryIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static java.util.Collections.*; import static java.util.stream.Collectors.*; import static org.assertj.core.api.Assertions.*; import static org.neo4j.driver.Values.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -49,19 +46,6 @@ import org.neo4j.driver.reactive.RxSession; import org.neo4j.driver.types.Node; import org.neo4j.driver.types.Point; import org.neo4j.driver.types.Relationship; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.DatabaseSelection; -import org.neo4j.springframework.data.core.ReactiveDatabaseSelectionProvider; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.integration.reactive.repositories.ReactivePersonRepository; -import org.neo4j.springframework.data.integration.reactive.repositories.ReactiveThingRepository; -import org.neo4j.springframework.data.integration.shared.*; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; -import org.neo4j.springframework.data.repository.query.Query; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.types.CartesianPoint2d; -import org.neo4j.springframework.data.types.GeographicPoint2d; import org.reactivestreams.Publisher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -72,6 +56,19 @@ import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.data.domain.PageRequest; 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.*; +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.types.CartesianPoint2d; +import org.springframework.data.neo4j.types.GeographicPoint2d; import org.springframework.data.repository.query.Param; import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.test.annotation.DirtiesContext; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRepositoryWithADifferentDatabaseIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryWithADifferentDatabaseIT.java similarity index 82% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRepositoryWithADifferentDatabaseIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryWithADifferentDatabaseIT.java index 2fb440f9a..9afba6dab 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveRepositoryWithADifferentDatabaseIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveRepositoryWithADifferentDatabaseIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.neo4j.driver.Session; import org.neo4j.driver.SessionConfig; -import org.neo4j.springframework.data.core.DatabaseSelection; +import org.springframework.data.neo4j.core.DatabaseSelection; import org.springframework.test.annotation.DirtiesContext; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveStringlyTypeDynamicRelationshipsIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveStringlyTypeDynamicRelationshipsIT.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveStringlyTypeDynamicRelationshipsIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveStringlyTypeDynamicRelationshipsIT.java index 35125518c..33bc849a8 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveStringlyTypeDynamicRelationshipsIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveStringlyTypeDynamicRelationshipsIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assumptions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.test.StepVerifier; @@ -34,16 +31,16 @@ import org.junit.jupiter.api.Test; import org.neo4j.driver.Driver; import org.neo4j.driver.Transaction; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.integration.shared.DynamicRelationshipsITBase; -import org.neo4j.springframework.data.integration.shared.Person; -import org.neo4j.springframework.data.integration.shared.PersonWithStringlyTypedRelatives; -import org.neo4j.springframework.data.integration.shared.Pet; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; 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.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; import org.springframework.test.util.ReflectionTestUtils; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveTransactionManagerMixedDatabasesTest.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveTransactionManagerMixedDatabasesTest.java similarity index 92% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveTransactionManagerMixedDatabasesTest.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveTransactionManagerMixedDatabasesTest.java index 826c65bc9..10803cb3b 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveTransactionManagerMixedDatabasesTest.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveTransactionManagerMixedDatabasesTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; @@ -38,17 +35,17 @@ import org.neo4j.driver.Values; import org.neo4j.driver.reactive.RxResult; import org.neo4j.driver.reactive.RxSession; import org.neo4j.driver.reactive.RxTransaction; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.Neo4jClient; -import org.neo4j.springframework.data.core.ReactiveDatabaseSelectionProvider; -import org.neo4j.springframework.data.core.ReactiveNeo4jClient; -import org.neo4j.springframework.data.core.transaction.ReactiveNeo4jTransactionManager; -import org.neo4j.springframework.data.integration.reactive.repositories.ReactivePersonRepository; -import org.neo4j.springframework.data.integration.shared.PersonWithAllConstructor; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; 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.Neo4jClient; +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.repository.config.EnableReactiveNeo4jRepositories; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveTypeConversionIT.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveTypeConversionIT.java similarity index 82% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveTypeConversionIT.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveTypeConversionIT.java index 09a1c7dc8..13e7857a4 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/ReactiveTypeConversionIT.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/ReactiveTypeConversionIT.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive; +package org.springframework.data.neo4j.integration.reactive; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.test.Neo4jExtension.*; +import static org.springframework.data.neo4j.test.Neo4jExtension.*; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; @@ -33,16 +30,16 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig; -import org.neo4j.springframework.data.core.convert.Neo4jConversions; -import org.neo4j.springframework.data.integration.shared.ThingWithCustomTypes; -import org.neo4j.springframework.data.integration.shared.ThingWithUUIDID; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.config.EnableReactiveNeo4jRepositories; -import org.neo4j.springframework.data.test.Neo4jExtension; 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.ThingWithCustomTypes; +import org.springframework.data.neo4j.integration.shared.ThingWithUUIDID; +import org.springframework.data.neo4j.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.config.EnableReactiveNeo4jRepositories; +import org.springframework.data.neo4j.test.Neo4jExtension; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/ReactivePersonRepository.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/ReactivePersonRepository.java similarity index 80% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/ReactivePersonRepository.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/ReactivePersonRepository.java index c95bbf009..ce7e2a756 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/ReactivePersonRepository.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/ReactivePersonRepository.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,19 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive.repositories; +package org.springframework.data.neo4j.integration.reactive.repositories; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import org.neo4j.springframework.data.integration.shared.DtoPersonProjection; -import org.neo4j.springframework.data.integration.shared.PersonProjection; -import org.neo4j.springframework.data.integration.shared.PersonWithAllConstructor; -import org.neo4j.springframework.data.integration.shared.ThingWithGeneratedId; -import org.neo4j.springframework.data.repository.ReactiveNeo4jRepository; -import org.neo4j.springframework.data.repository.query.Query; -import org.neo4j.springframework.data.types.GeographicPoint2d; 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.repository.ReactiveNeo4jRepository; +import org.springframework.data.neo4j.repository.query.Query; +import org.springframework.data.neo4j.types.GeographicPoint2d; import org.springframework.data.repository.query.Param; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/ReactiveThingRepository.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/ReactiveThingRepository.java similarity index 72% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/ReactiveThingRepository.java rename to src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/ReactiveThingRepository.java index 406fc26cc..a63ca80fe 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/reactive/repositories/ReactiveThingRepository.java +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/ReactiveThingRepository.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive.repositories; +package org.springframework.data.neo4j.integration.reactive.repositories; import reactor.core.publisher.Mono; -import org.neo4j.springframework.data.integration.shared.ThingWithAssignedId; -import org.neo4j.springframework.data.repository.query.Query; +import org.springframework.data.neo4j.integration.shared.ThingWithAssignedId; +import org.springframework.data.neo4j.repository.query.Query; import org.springframework.data.repository.reactive.ReactiveCrudRepository; /** diff --git a/src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/package-info.java b/src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/package-info.java new file mode 100644 index 000000000..8c156bc8a --- /dev/null +++ b/src/test/java/org/springframework/data/neo4j/integration/reactive/repositories/package-info.java @@ -0,0 +1,4 @@ +/** + * Repositories shared between tests. + */ +package org.springframework.data.neo4j.integration.reactive.repositories; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AbstractNamedThing.java b/src/test/java/org/springframework/data/neo4j/integration/shared/AbstractNamedThing.java similarity index 76% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AbstractNamedThing.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/AbstractNamedThing.java index e0004bb6f..9992e82b2 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AbstractNamedThing.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/AbstractNamedThing.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AnotherThingWithAssignedId.java b/src/test/java/org/springframework/data/neo4j/integration/shared/AnotherThingWithAssignedId.java similarity index 79% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AnotherThingWithAssignedId.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/AnotherThingWithAssignedId.java index c6d1be269..334fb8a44 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AnotherThingWithAssignedId.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/AnotherThingWithAssignedId.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.Objects; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AuditableThing.java b/src/test/java/org/springframework/data/neo4j/integration/shared/AuditableThing.java similarity index 77% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AuditableThing.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/AuditableThing.java index fda4f4fbc..546c9a0d2 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AuditableThing.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/AuditableThing.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.time.LocalDateTime; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AuditingITBase.java b/src/test/java/org/springframework/data/neo4j/integration/shared/AuditingITBase.java similarity index 92% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AuditingITBase.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/AuditingITBase.java index a4e06cc00..e914631dc 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/AuditingITBase.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/AuditingITBase.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import static org.assertj.core.api.Assertions.*; @@ -29,8 +26,8 @@ import org.neo4j.driver.Transaction; import org.neo4j.driver.Value; import org.neo4j.driver.Values; import org.neo4j.driver.types.Node; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; /** * Shared information for both imperative and reactive auditing tests. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/BidirectionalEnd.java b/src/test/java/org/springframework/data/neo4j/integration/shared/BidirectionalEnd.java similarity index 58% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/BidirectionalEnd.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/BidirectionalEnd.java index a9b6f3eac..cddc3e98e 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/BidirectionalEnd.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/BidirectionalEnd.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import static org.neo4j.springframework.data.core.schema.Relationship.Direction.*; - -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Gerrit Meier @@ -36,10 +31,10 @@ public class BidirectionalEnd { private String name; - @Relationship(type = "CONNECTED", direction = INCOMING) + @Relationship(type = "CONNECTED", direction = Relationship.Direction.INCOMING) private BidirectionalStart start; - @Relationship(type = "ANOTHER_CONNECTION", direction = INCOMING) + @Relationship(type = "ANOTHER_CONNECTION", direction = Relationship.Direction.INCOMING) private BidirectionalStart anotherStart; public BidirectionalEnd(String name) { diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/BidirectionalStart.java b/src/test/java/org/springframework/data/neo4j/integration/shared/BidirectionalStart.java similarity index 67% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/BidirectionalStart.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/BidirectionalStart.java index 11cda5458..01eda4be2 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/BidirectionalStart.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/BidirectionalStart.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.Set; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/CallbacksITBase.java b/src/test/java/org/springframework/data/neo4j/integration/shared/CallbacksITBase.java similarity index 87% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/CallbacksITBase.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/CallbacksITBase.java index f7e4722cb..4dad0f3f5 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/CallbacksITBase.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/CallbacksITBase.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import static java.util.stream.Collectors.*; import static org.assertj.core.api.Assertions.*; @@ -32,8 +29,8 @@ import org.neo4j.driver.Transaction; import org.neo4j.driver.Value; import org.neo4j.driver.Values; import org.neo4j.driver.types.Node; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; /** * Shared information for both imperative and reactive callbacks tests. diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/stored_procedures/DocumentEntity.java b/src/test/java/org/springframework/data/neo4j/integration/shared/Club.java similarity index 71% rename from spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/stored_procedures/DocumentEntity.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/Club.java index 2e41056f5..0611c1fe3 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/queries/stored_procedures/DocumentEntity.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/Club.java @@ -13,13 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.neo4j.queries.stored_procedures; +package org.springframework.data.neo4j.integration.shared; + +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** - * @author Michael J. Simons + * @author Gerrit Meier */ -public class DocumentEntity { - private Long id; +@Node +public class Club { + + @Id @GeneratedValue private Long id; private String name; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DeepRelationships.java b/src/test/java/org/springframework/data/neo4j/integration/shared/DeepRelationships.java similarity index 83% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DeepRelationships.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/DeepRelationships.java index 0fe3265d2..01af1cb76 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DeepRelationships.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/DeepRelationships.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DtoPersonProjection.java b/src/test/java/org/springframework/data/neo4j/integration/shared/DtoPersonProjection.java similarity index 75% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DtoPersonProjection.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/DtoPersonProjection.java index 42bc57af4..115b77cf6 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DtoPersonProjection.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/DtoPersonProjection.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.Value; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DynamicRelationshipsITBase.java b/src/test/java/org/springframework/data/neo4j/integration/shared/DynamicRelationshipsITBase.java similarity index 87% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DynamicRelationshipsITBase.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/DynamicRelationshipsITBase.java index b84ef411f..d8cfd94b2 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/DynamicRelationshipsITBase.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/DynamicRelationshipsITBase.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; @@ -25,8 +22,8 @@ import org.junit.jupiter.api.BeforeEach; import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; /** * Make sure that dynamic relationships can be loaded and stored. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/EntitiesWithDynamicLabels.java b/src/test/java/org/springframework/data/neo4j/integration/shared/EntitiesWithDynamicLabels.java similarity index 88% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/EntitiesWithDynamicLabels.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/EntitiesWithDynamicLabels.java index 051bfecb1..bc50a9594 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/EntitiesWithDynamicLabels.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/EntitiesWithDynamicLabels.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.Set; -import org.neo4j.springframework.data.core.schema.DynamicLabels; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; import org.springframework.data.annotation.Version; +import org.springframework.data.neo4j.core.schema.DynamicLabels; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/EntityWithConvertedId.java b/src/test/java/org/springframework/data/neo4j/integration/shared/EntityWithConvertedId.java similarity index 77% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/EntityWithConvertedId.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/EntityWithConvertedId.java index 8bfaf7bd7..e94c6f250 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/EntityWithConvertedId.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/EntityWithConvertedId.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Id; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Hobby.java b/src/test/java/org/springframework/data/neo4j/integration/shared/Hobby.java similarity index 76% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Hobby.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/Hobby.java index c768f8558..bf933934f 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Hobby.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/Hobby.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.Objects; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/IdGeneratorsITBase.java b/src/test/java/org/springframework/data/neo4j/integration/shared/IdGeneratorsITBase.java similarity index 85% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/IdGeneratorsITBase.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/IdGeneratorsITBase.java index 069b1e192..a56570a82 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/IdGeneratorsITBase.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/IdGeneratorsITBase.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import static org.assertj.core.api.Assertions.*; @@ -26,8 +23,8 @@ import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; import org.neo4j.driver.Values; import org.neo4j.driver.types.Node; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutableAuditableThing.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ImmutableAuditableThing.java similarity index 84% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutableAuditableThing.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ImmutableAuditableThing.java index 543782c34..6a4df9664 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutableAuditableThing.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ImmutableAuditableThing.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.AllArgsConstructor; import lombok.Value; @@ -24,7 +21,6 @@ import lombok.With; import java.time.LocalDateTime; -import org.neo4j.springframework.data.core.schema.GeneratedValue; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.Id; @@ -32,6 +28,7 @@ import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.data.annotation.Persistent; +import org.springframework.data.neo4j.core.schema.GeneratedValue; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutableAuditableThingWithGeneratedId.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ImmutableAuditableThingWithGeneratedId.java similarity index 81% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutableAuditableThingWithGeneratedId.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ImmutableAuditableThingWithGeneratedId.java index 6491246fe..4da1fd9ac 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutableAuditableThingWithGeneratedId.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ImmutableAuditableThingWithGeneratedId.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.AllArgsConstructor; import lombok.Value; @@ -24,8 +21,6 @@ import lombok.With; import java.time.LocalDateTime; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.support.UUIDStringGenerator; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.Id; @@ -33,6 +28,8 @@ import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.data.annotation.Persistent; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.support.UUIDStringGenerator; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutablePerson.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ImmutablePerson.java similarity index 75% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutablePerson.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ImmutablePerson.java index 72a1bcd01..730e40a8a 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ImmutablePerson.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ImmutablePerson.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; /** * @author Gerrit Meier */ + import java.util.List; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; + +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; + /** * @author Michael J. Simons */ diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Inheritance.java b/src/test/java/org/springframework/data/neo4j/integration/shared/Inheritance.java similarity index 90% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Inheritance.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/Inheritance.java index c053f617b..0b383932d 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Inheritance.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/Inheritance.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.List; import java.util.Objects; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/LikesHobbyRelationship.java b/src/test/java/org/springframework/data/neo4j/integration/shared/LikesHobbyRelationship.java similarity index 84% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/LikesHobbyRelationship.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/LikesHobbyRelationship.java index e88eb03c7..039b0d2de 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/LikesHobbyRelationship.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/LikesHobbyRelationship.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.time.LocalDate; import java.util.Objects; -import org.neo4j.springframework.data.core.schema.RelationshipProperties; -import org.neo4j.springframework.data.types.CartesianPoint2d; +import org.springframework.data.neo4j.core.schema.RelationshipProperties; +import org.springframework.data.neo4j.types.CartesianPoint2d; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/MultipleLabels.java b/src/test/java/org/springframework/data/neo4j/integration/shared/MultipleLabels.java similarity index 70% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/MultipleLabels.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/MultipleLabels.java index 0fcda7b6a..f7e03e0c0 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/MultipleLabels.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/MultipleLabels.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/MultipleRelationshipsThing.java b/src/test/java/org/springframework/data/neo4j/integration/shared/MultipleRelationshipsThing.java similarity index 81% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/MultipleRelationshipsThing.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/MultipleRelationshipsThing.java index 4271c558d..8c1283640 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/MultipleRelationshipsThing.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/MultipleRelationshipsThing.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.List; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * This thing has several relationships to other things of the same kind but with a different type. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/NamesOnly.java b/src/test/java/org/springframework/data/neo4j/integration/shared/NamesOnly.java similarity index 77% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/NamesOnly.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/NamesOnly.java index ee2609b38..24de23779 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/NamesOnly.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/NamesOnly.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import org.springframework.beans.factory.annotation.Value; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/NamesOnlyDto.java b/src/test/java/org/springframework/data/neo4j/integration/shared/NamesOnlyDto.java similarity index 79% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/NamesOnlyDto.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/NamesOnlyDto.java index aeae9a938..f04f31a4c 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/NamesOnlyDto.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/NamesOnlyDto.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Neo4jConversionsITBase.java b/src/test/java/org/springframework/data/neo4j/integration/shared/Neo4jConversionsITBase.java similarity index 94% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Neo4jConversionsITBase.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/Neo4jConversionsITBase.java index 9a84ae674..a52afe8de 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Neo4jConversionsITBase.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/Neo4jConversionsITBase.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.Builder; @@ -28,13 +25,13 @@ import java.util.*; import org.junit.jupiter.api.BeforeAll; import org.neo4j.driver.Session; import org.neo4j.driver.Values; -import org.neo4j.springframework.data.integration.shared.ThingWithAllAdditionalTypes.SomeEnum; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.types.CartesianPoint2d; -import org.neo4j.springframework.data.types.CartesianPoint3d; -import org.neo4j.springframework.data.types.GeographicPoint2d; -import org.neo4j.springframework.data.types.GeographicPoint3d; import org.springframework.data.geo.Point; +import org.springframework.data.neo4j.integration.shared.ThingWithAllAdditionalTypes.SomeEnum; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.types.CartesianPoint2d; +import org.springframework.data.neo4j.types.CartesianPoint3d; +import org.springframework.data.neo4j.types.GeographicPoint2d; +import org.springframework.data.neo4j.types.GeographicPoint3d; /** * Provides some nodes spotting properties of all types we support. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Person.java b/src/test/java/org/springframework/data/neo4j/integration/shared/Person.java similarity index 73% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Person.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/Person.java index 1673edccb..09769440c 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Person.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/Person.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/domain/User.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonProjection.java similarity index 79% rename from spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/domain/User.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonProjection.java index 132a2b2c6..bbe1b5bc6 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/extensions/domain/User.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonProjection.java @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.neo4j.extensions.domain; +package org.springframework.data.neo4j.integration.shared; /** - * @author: Vince Bickers + * @author Gerrit Meier */ -public class User { +public interface PersonProjection { - Long id; + String getName(); + String getSameValue(); } diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonSummary.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonSummary.java similarity index 77% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonSummary.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonSummary.java index 99ec2d7e3..40e77d330 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonSummary.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonSummary.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithAllConstructor.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithAllConstructor.java similarity index 74% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithAllConstructor.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithAllConstructor.java index ce68b814b..31cb289bc 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithAllConstructor.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithAllConstructor.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -30,10 +27,10 @@ import java.time.LocalDate; import java.util.List; import org.neo4j.driver.types.Point; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Property; +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.core.schema.Property; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithNoConstructor.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithNoConstructor.java similarity index 64% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithNoConstructor.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithNoConstructor.java index db8dd21bd..f9fc85dcb 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithNoConstructor.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithNoConstructor.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Property; +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.core.schema.Property; /** * Example domain object with default constructor. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelationship.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelationship.java similarity index 75% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelationship.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelationship.java index 2b5f4b842..602434284 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelationship.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelationship.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.List; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelationshipWithProperties.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelationshipWithProperties.java similarity index 72% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelationshipWithProperties.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelationshipWithProperties.java index e791d6d0e..6880b665f 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelationshipWithProperties.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelationshipWithProperties.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.Map; import java.util.Set; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelatives.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelatives.java similarity index 78% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelatives.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelatives.java index 0c27c7367..d0dca52e8 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithRelatives.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithRelatives.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithStringlyTypedRelatives.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithStringlyTypedRelatives.java similarity index 74% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithStringlyTypedRelatives.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithStringlyTypedRelatives.java index 4e2b31de9..be238374e 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithStringlyTypedRelatives.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithStringlyTypedRelatives.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithWither.java b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithWither.java similarity index 75% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithWither.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithWither.java index 92bd2561f..03e5e1652 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/PersonWithWither.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/PersonWithWither.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * Example domain object that works with wither. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Pet.java b/src/test/java/org/springframework/data/neo4j/integration/shared/Pet.java similarity index 78% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Pet.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/Pet.java index 4c2de4f02..1d43a7c8d 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/Pet.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/Pet.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -25,11 +22,11 @@ import lombok.RequiredArgsConstructor; import java.util.List; import java.util.Set; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; import org.springframework.data.annotation.PersistenceConstructor; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/RelationshipsAsConstructorParametersEntities.java b/src/test/java/org/springframework/data/neo4j/integration/shared/RelationshipsAsConstructorParametersEntities.java similarity index 76% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/RelationshipsAsConstructorParametersEntities.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/RelationshipsAsConstructorParametersEntities.java index 1c3bcbd64..00ba0649a 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/RelationshipsAsConstructorParametersEntities.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/RelationshipsAsConstructorParametersEntities.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/RelationshipsITBase.java b/src/test/java/org/springframework/data/neo4j/integration/shared/RelationshipsITBase.java similarity index 77% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/RelationshipsITBase.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/RelationshipsITBase.java index eab5affef..04e9a8196 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/RelationshipsITBase.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/RelationshipsITBase.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import org.junit.jupiter.api.BeforeEach; import org.neo4j.driver.Driver; import org.neo4j.driver.Session; import org.neo4j.driver.Transaction; -import org.neo4j.springframework.data.test.Neo4jExtension; -import org.neo4j.springframework.data.test.Neo4jIntegrationTest; +import org.springframework.data.neo4j.test.Neo4jExtension; +import org.springframework.data.neo4j.test.Neo4jIntegrationTest; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/SimilarThing.java b/src/test/java/org/springframework/data/neo4j/integration/shared/SimilarThing.java similarity index 81% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/SimilarThing.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/SimilarThing.java index 2581ff768..bd1197488 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/SimilarThing.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/SimilarThing.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.List; import java.util.Objects; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/TestSequenceGenerator.java b/src/test/java/org/springframework/data/neo4j/integration/shared/TestSequenceGenerator.java similarity index 82% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/TestSequenceGenerator.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/TestSequenceGenerator.java index 46c1d16aa..a422b07a4 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/TestSequenceGenerator.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/TestSequenceGenerator.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.concurrent.atomic.AtomicInteger; import org.neo4j.driver.Driver; -import org.neo4j.springframework.data.core.schema.IdGenerator; +import org.springframework.data.neo4j.core.schema.IdGenerator; import org.springframework.util.StringUtils; /** diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllAdditionalTypes.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllAdditionalTypes.java similarity index 83% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllAdditionalTypes.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllAdditionalTypes.java index c958ac5ac..c1540d7ae 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllAdditionalTypes.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllAdditionalTypes.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -35,9 +32,9 @@ import java.util.Locale; import java.util.Set; import java.util.UUID; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * Contains properties of all additional types. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllCypherTypes.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllCypherTypes.java similarity index 79% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllCypherTypes.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllCypherTypes.java index 6a6996b5d..64dcea497 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllCypherTypes.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllCypherTypes.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -32,9 +29,9 @@ import java.time.ZonedDateTime; import org.neo4j.driver.types.IsoDuration; import org.neo4j.driver.types.Point; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * Contains properties of all cypher types. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllSpatialTypes.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllSpatialTypes.java similarity index 63% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllSpatialTypes.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllSpatialTypes.java index add32ea10..766c87bb1 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAllSpatialTypes.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAllSpatialTypes.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -24,14 +21,14 @@ import lombok.Builder; import lombok.Data; import lombok.With; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.types.CartesianPoint2d; -import org.neo4j.springframework.data.types.CartesianPoint3d; -import org.neo4j.springframework.data.types.GeographicPoint2d; -import org.neo4j.springframework.data.types.GeographicPoint3d; import org.springframework.data.geo.Point; +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.types.CartesianPoint2d; +import org.springframework.data.neo4j.types.CartesianPoint3d; +import org.springframework.data.neo4j.types.GeographicPoint2d; +import org.springframework.data.neo4j.types.GeographicPoint3d; /** * Contains properties of all spatial types. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAssignedId.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAssignedId.java similarity index 73% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAssignedId.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAssignedId.java index cee436a64..f2f237600 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithAssignedId.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithAssignedId.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.List; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; +import org.springframework.data.neo4j.core.schema.Relationship; /** * Has an assigned id. diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithCustomTypes.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithCustomTypes.java similarity index 90% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithCustomTypes.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithCustomTypes.java index e89a5d5d8..6874ffc3d 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithCustomTypes.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithCustomTypes.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.HashSet; import java.util.Objects; @@ -25,11 +22,11 @@ import java.util.Set; import org.neo4j.driver.Value; import org.neo4j.driver.Values; import org.neo4j.driver.internal.value.StringValue; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.converter.GenericConverter; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithGeneratedId.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithGeneratedId.java similarity index 67% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithGeneratedId.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithGeneratedId.java index 76bc178fc..0972cd08a 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithGeneratedId.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithGeneratedId.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithIdGeneratedByBean.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithIdGeneratedByBean.java similarity index 68% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithIdGeneratedByBean.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithIdGeneratedByBean.java index 314078467..d19634f67 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithIdGeneratedByBean.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithIdGeneratedByBean.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithNonExistingPrimitives.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithNonExistingPrimitives.java similarity index 68% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithNonExistingPrimitives.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithNonExistingPrimitives.java index e7bf9297b..54cdfe543 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithNonExistingPrimitives.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithNonExistingPrimitives.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithSequence.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithSequence.java similarity index 70% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithSequence.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithSequence.java index 0706f2a0d..153395545 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithSequence.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithSequence.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithUUIDID.java b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithUUIDID.java similarity index 73% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithUUIDID.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithUUIDID.java index c9e6100a3..7b07c733c 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/ThingWithUUIDID.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/ThingWithUUIDID.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.UUID; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/VersionedThing.java b/src/test/java/org/springframework/data/neo4j/integration/shared/VersionedThing.java similarity index 73% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/VersionedThing.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/VersionedThing.java index 69d05a7a8..1e654b90b 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/VersionedThing.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/VersionedThing.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.List; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; import org.springframework.data.annotation.Version; +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.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/VersionedThingWithAssignedId.java b/src/test/java/org/springframework/data/neo4j/integration/shared/VersionedThingWithAssignedId.java similarity index 77% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/VersionedThingWithAssignedId.java rename to src/test/java/org/springframework/data/neo4j/integration/shared/VersionedThingWithAssignedId.java index aeb14f635..59012314c 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/integration/shared/VersionedThingWithAssignedId.java +++ b/src/test/java/org/springframework/data/neo4j/integration/shared/VersionedThingWithAssignedId.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.shared; +package org.springframework.data.neo4j.integration.shared; import java.util.List; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.Node; -import org.neo4j.springframework.data.core.schema.Relationship; import org.springframework.data.annotation.Version; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; +import org.springframework.data.neo4j.core.schema.Relationship; /** * @author Gerrit Meier diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/config/EnableNeo4jRepositoriesTests.java b/src/test/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositoriesTests.java similarity index 89% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/config/EnableNeo4jRepositoriesTests.java rename to src/test/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositoriesTests.java index 16e645adf..59f49b7dd 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/config/EnableNeo4jRepositoriesTests.java +++ b/src/test/java/org/springframework/data/neo4j/repository/config/EnableNeo4jRepositoriesTests.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.config; +package org.springframework.data.neo4j.repository.config; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/package-info.java b/src/test/java/org/springframework/data/neo4j/repository/config/StartupLoggerTest.java similarity index 55% rename from spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/package-info.java rename to src/test/java/org/springframework/data/neo4j/repository/config/StartupLoggerTest.java index e04077b66..531fabdf2 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/config/package-info.java +++ b/src/test/java/org/springframework/data/neo4j/repository/config/StartupLoggerTest.java @@ -13,7 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * Classes for Neo4j namespace configuration. - */ package org.springframework.data.neo4j.repository.config; + +import static org.assertj.core.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * @author Michael J. Simons + * @soundtrack Helge & Hardcore - Jazz + */ +class StartupLoggerTest { + + @Test + void startingMessageShouldFit() { + + String message = new StartupLogger(StartupLogger.Mode.IMPERATIVE).getStartingMessage(); + assertThat(message).matches( + "Bootstrapping imperative Neo4j repositories based on an unknown version of SDN\\/RX with Spring Data Commons v2\\.\\d+\\.\\d+.(RELEASE|SNAPSHOT) and Neo4j Driver v4\\.\\d+\\.\\d+(?:-.*)\\."); + } +} diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/AuditingBeforeBindCallbackTest.java b/src/test/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallbackTest.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/AuditingBeforeBindCallbackTest.java rename to src/test/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallbackTest.java index 84c027823..ed94d85e3 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/AuditingBeforeBindCallbackTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/event/AuditingBeforeBindCallbackTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -27,10 +24,10 @@ import java.util.HashSet; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; import org.springframework.core.Ordered; import org.springframework.data.auditing.IsNewAwareAuditingHandler; import org.springframework.data.mapping.context.PersistentEntities; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/IdPopulatorTest.java b/src/test/java/org/springframework/data/neo4j/repository/event/IdPopulatorTest.java similarity index 82% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/IdPopulatorTest.java rename to src/test/java/org/springframework/data/neo4j/repository/event/IdPopulatorTest.java index dc42a56c8..41fa64623 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/IdPopulatorTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/event/IdPopulatorTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; @@ -26,13 +23,13 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.mapping.Neo4jPersistentEntity; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.core.schema.Id; -import org.neo4j.springframework.data.core.schema.IdDescription; -import org.neo4j.springframework.data.core.schema.IdGenerator; -import org.neo4j.springframework.data.core.schema.Node; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.mapping.Neo4jPersistentEntity; +import org.springframework.data.neo4j.core.schema.GeneratedValue; +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.IdDescription; +import org.springframework.data.neo4j.core.schema.IdGenerator; +import org.springframework.data.neo4j.core.schema.Node; @ExtendWith(MockitoExtension.class) class IdPopulatorTest { diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/ImmutableSample.java b/src/test/java/org/springframework/data/neo4j/repository/event/ImmutableSample.java similarity index 82% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/ImmutableSample.java rename to src/test/java/org/springframework/data/neo4j/repository/event/ImmutableSample.java index f58317378..a60b0ccef 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/ImmutableSample.java +++ b/src/test/java/org/springframework/data/neo4j/repository/event/ImmutableSample.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/ReactiveAuditingBeforeBindCallbackTest.java b/src/test/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallbackTest.java similarity index 92% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/ReactiveAuditingBeforeBindCallbackTest.java rename to src/test/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallbackTest.java index 64a4c78f0..4d3f3d82b 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/ReactiveAuditingBeforeBindCallbackTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/event/ReactiveAuditingBeforeBindCallbackTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -29,10 +26,10 @@ import java.util.HashSet; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; import org.springframework.core.Ordered; import org.springframework.data.auditing.IsNewAwareAuditingHandler; import org.springframework.data.mapping.context.PersistentEntities; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; /** * @author Michael J. Simons diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/Sample.java b/src/test/java/org/springframework/data/neo4j/repository/event/Sample.java similarity index 80% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/Sample.java rename to src/test/java/org/springframework/data/neo4j/repository/event/Sample.java index 126e66f79..fe13104e8 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/event/Sample.java +++ b/src/test/java/org/springframework/data/neo4j/repository/event/Sample.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.event; +package org.springframework.data.neo4j.repository.event; import java.util.Date; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/query/BoundingBoxTest.java b/src/test/java/org/springframework/data/neo4j/repository/query/BoundingBoxTest.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/query/BoundingBoxTest.java rename to src/test/java/org/springframework/data/neo4j/repository/query/BoundingBoxTest.java index 3fd56f3c0..6cc1f3488 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/query/BoundingBoxTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/query/BoundingBoxTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.query; +package org.springframework.data.neo4j.repository.query; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/query/RepositoryQueryTest.java b/src/test/java/org/springframework/data/neo4j/repository/query/RepositoryQueryTest.java similarity index 94% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/query/RepositoryQueryTest.java rename to src/test/java/org/springframework/data/neo4j/repository/query/RepositoryQueryTest.java index 8593b9b74..dad5e6007 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/query/RepositoryQueryTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/query/RepositoryQueryTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.query; +package org.springframework.data.neo4j.repository.query; import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assumptions.*; @@ -37,16 +34,15 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.neo4j.driver.Values; import org.neo4j.driver.types.Point; -import org.neo4j.springframework.data.core.Neo4jOperations; -import org.neo4j.springframework.data.core.mapping.Neo4jMappingContext; -import org.neo4j.springframework.data.core.schema.GeneratedValue; -import org.neo4j.springframework.data.repository.query.Neo4jQueryMethod.Neo4jParameters; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.annotation.Id; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.mapping.MappingException; +import org.springframework.data.neo4j.core.Neo4jOperations; +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; +import org.springframework.data.neo4j.core.schema.GeneratedValue; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.SpelAwareProxyProjectionFactory; import org.springframework.data.repository.CrudRepository; @@ -242,7 +238,7 @@ final class RepositoryQueryTest { Map resolveParameters = repositoryQuery .bindParameters(new Neo4jParameterAccessor( - (Neo4jParameters) method.getParameters(), new Object[] { "A String", "Another String" })); + (Neo4jQueryMethod.Neo4jParameters) method.getParameters(), new Object[] { "A String", "Another String" })); assertThat(resolveParameters) .containsEntry("0", "A String") @@ -265,7 +261,7 @@ final class RepositoryQueryTest { Point thePoint = Values.point(4223, 1, 2).asPoint(); Map resolveParameters = repositoryQuery.bindParameters( - new Neo4jParameterAccessor((Neo4jParameters) method.getParameters(), + new Neo4jParameterAccessor((Neo4jQueryMethod.Neo4jParameters) method.getParameters(), new Object[] { thePoint, "TheName", "TheFirstName" })); assertThat(resolveParameters) diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jPersistenceExceptionTranslatorTest.java b/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslatorTest.java similarity index 90% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jPersistenceExceptionTranslatorTest.java rename to src/test/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslatorTest.java index 99da97cc6..02c74c305 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jPersistenceExceptionTranslatorTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jPersistenceExceptionTranslatorTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactorySupportTest.java b/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactorySupportTest.java similarity index 70% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactorySupportTest.java rename to src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactorySupportTest.java index 1b3103953..61a35bb96 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactorySupportTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactorySupportTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,10 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static org.assertj.core.api.Assertions.*; -import static org.neo4j.springframework.data.repository.support.Neo4jRepositoryFactorySupport.*; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -36,7 +32,7 @@ class Neo4jRepositoryFactorySupportTest { void mismatchingClassTypes() { assertThatIllegalArgumentException() - .isThrownBy(() -> assertIdentifierType(String.class, Long.class)) + .isThrownBy(() -> Neo4jRepositoryFactorySupport.assertIdentifierType(String.class, Long.class)) .withMessage("The repository id type class java.lang.String differs from the entity id type class java.lang.Long."); } @@ -44,7 +40,7 @@ class Neo4jRepositoryFactorySupportTest { void mismatchingPrimitiveTypes() { assertThatIllegalArgumentException() - .isThrownBy(() -> assertIdentifierType(int.class, long.class)) + .isThrownBy(() -> Neo4jRepositoryFactorySupport.assertIdentifierType(int.class, long.class)) .withMessage("The repository id type int differs from the entity id type long."); } @@ -52,14 +48,14 @@ class Neo4jRepositoryFactorySupportTest { void mismatchingPrimitiveAndClassTypes() { assertThatIllegalArgumentException() - .isThrownBy(() -> assertIdentifierType(Integer.class, long.class)) + .isThrownBy(() -> Neo4jRepositoryFactorySupport.assertIdentifierType(Integer.class, long.class)) .withMessage("The repository id type class java.lang.Integer differs from the entity id type long."); } @Test void matchingPrimitiveLongTypes() { try { - assertIdentifierType(long.class, long.class); + Neo4jRepositoryFactorySupport.assertIdentifierType(long.class, long.class); } catch (Exception e) { fail("no exception should get thrown."); } @@ -68,7 +64,7 @@ class Neo4jRepositoryFactorySupportTest { @Test void matchingPrimitiveIntTypes() { try { - assertIdentifierType(int.class, int.class); + Neo4jRepositoryFactorySupport.assertIdentifierType(int.class, int.class); } catch (Exception e) { fail("no exception should get thrown."); } @@ -77,7 +73,7 @@ class Neo4jRepositoryFactorySupportTest { @Test void matchingPrimitiveIntAndIntegerClassTypes() { try { - assertIdentifierType(int.class, Integer.class); + Neo4jRepositoryFactorySupport.assertIdentifierType(int.class, Integer.class); } catch (Exception e) { fail("no exception should get thrown."); } @@ -86,7 +82,7 @@ class Neo4jRepositoryFactorySupportTest { @Test void matchingIntegerClassAndPrimitiveIntTypes() { try { - assertIdentifierType(Integer.class, int.class); + Neo4jRepositoryFactorySupport.assertIdentifierType(Integer.class, int.class); } catch (Exception e) { fail("no exception should get thrown."); } @@ -96,7 +92,7 @@ class Neo4jRepositoryFactorySupportTest { @Test void matchingPrimitiveLongAndLongClassTypes() { try { - assertIdentifierType(long.class, Long.class); + Neo4jRepositoryFactorySupport.assertIdentifierType(long.class, Long.class); } catch (Exception e) { fail("no exception should get thrown."); } @@ -105,7 +101,7 @@ class Neo4jRepositoryFactorySupportTest { @Test void matchingLongClassAndPrimitiveLongTypes() { try { - assertIdentifierType(Long.class, long.class); + Neo4jRepositoryFactorySupport.assertIdentifierType(Long.class, long.class); } catch (Exception e) { fail("no exception should get thrown."); } diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactoryTest.java b/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryTest.java similarity index 92% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactoryTest.java rename to src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryTest.java index 125036a3f..f0cc01f5d 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/Neo4jRepositoryFactoryTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactoryTest.java b/src/test/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactoryTest.java similarity index 92% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactoryTest.java rename to src/test/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactoryTest.java index 6b50bec0d..d2399d607 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/repository/support/ReactiveNeo4jRepositoryFactoryTest.java +++ b/src/test/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactoryTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.repository.support; +package org.springframework.data.neo4j.repository.support; import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/CausalClusterIntegrationTest.java b/src/test/java/org/springframework/data/neo4j/test/CausalClusterIntegrationTest.java similarity index 90% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/CausalClusterIntegrationTest.java rename to src/test/java/org/springframework/data/neo4j/test/CausalClusterIntegrationTest.java index 533e44334..2d9a6deb0 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/CausalClusterIntegrationTest.java +++ b/src/test/java/org/springframework/data/neo4j/test/CausalClusterIntegrationTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.test; +package org.springframework.data.neo4j.test; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/DriverMocks.java b/src/test/java/org/springframework/data/neo4j/test/DriverMocks.java similarity index 91% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/DriverMocks.java rename to src/test/java/org/springframework/data/neo4j/test/DriverMocks.java index 0fad5d63d..92006651c 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/DriverMocks.java +++ b/src/test/java/org/springframework/data/neo4j/test/DriverMocks.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.test; +package org.springframework.data.neo4j.test; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/Neo4jExtension.java b/src/test/java/org/springframework/data/neo4j/test/Neo4jExtension.java similarity index 97% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/Neo4jExtension.java rename to src/test/java/org/springframework/data/neo4j/test/Neo4jExtension.java index 3075fc3bd..2e2e472e6 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/Neo4jExtension.java +++ b/src/test/java/org/springframework/data/neo4j/test/Neo4jExtension.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.test; +package org.springframework.data.neo4j.test; import static org.assertj.core.api.Assumptions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/Neo4jIntegrationTest.java b/src/test/java/org/springframework/data/neo4j/test/Neo4jIntegrationTest.java similarity index 89% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/Neo4jIntegrationTest.java rename to src/test/java/org/springframework/data/neo4j/test/Neo4jIntegrationTest.java index 03bfd4fff..3347389da 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/test/Neo4jIntegrationTest.java +++ b/src/test/java/org/springframework/data/neo4j/test/Neo4jIntegrationTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.test; +package org.springframework.data.neo4j.test; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/types/GeographicPoint2dTest.java b/src/test/java/org/springframework/data/neo4j/types/GeographicPoint2dTest.java similarity index 83% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/types/GeographicPoint2dTest.java rename to src/test/java/org/springframework/data/neo4j/types/GeographicPoint2dTest.java index 47cdb4052..1e3187241 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/types/GeographicPoint2dTest.java +++ b/src/test/java/org/springframework/data/neo4j/types/GeographicPoint2dTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/types/GeographicPoint3dTest.java b/src/test/java/org/springframework/data/neo4j/types/GeographicPoint3dTest.java similarity index 84% rename from spring-data-neo4j/src/test/java/org/neo4j/springframework/data/types/GeographicPoint3dTest.java rename to src/test/java/org/springframework/data/neo4j/types/GeographicPoint3dTest.java index ea07876c5..21c58d0be 100644 --- a/spring-data-neo4j/src/test/java/org/neo4j/springframework/data/types/GeographicPoint3dTest.java +++ b/src/test/java/org/springframework/data/neo4j/types/GeographicPoint3dTest.java @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.types; +package org.springframework.data.neo4j.types; import static org.assertj.core.api.Assertions.*; diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/Neo4jClientExtensionsTest.kt b/src/test/kotlin/org/springframework/data/neo4j/core/Neo4jClientExtensionsTest.kt similarity index 89% rename from spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/Neo4jClientExtensionsTest.kt rename to src/test/kotlin/org/springframework/data/neo4j/core/Neo4jClientExtensionsTest.kt index 63de1a13b..77a5fb3f9 100644 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/Neo4jClientExtensionsTest.kt +++ b/src/test/kotlin/org/springframework/data/neo4j/core/Neo4jClientExtensionsTest.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core +package org.springframework.data.neo4j.core import io.mockk.mockk import io.mockk.verify diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/PreparedQueryExtensionsTest.kt b/src/test/kotlin/org/springframework/data/neo4j/core/PreparedQueryExtensionsTest.kt similarity index 82% rename from spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/PreparedQueryExtensionsTest.kt rename to src/test/kotlin/org/springframework/data/neo4j/core/PreparedQueryExtensionsTest.kt index 60b472971..63827e04b 100644 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/PreparedQueryExtensionsTest.kt +++ b/src/test/kotlin/org/springframework/data/neo4j/core/PreparedQueryExtensionsTest.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core +package org.springframework.data.neo4j.core import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jClientExtensionsTest.kt b/src/test/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jClientExtensionsTest.kt similarity index 96% rename from spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jClientExtensionsTest.kt rename to src/test/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jClientExtensionsTest.kt index 70b910b99..58457ec5b 100644 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jClientExtensionsTest.kt +++ b/src/test/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jClientExtensionsTest.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core +package org.springframework.data.neo4j.core import io.mockk.every import io.mockk.mockk diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jOperationsExtensionsTest.kt b/src/test/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jOperationsExtensionsTest.kt similarity index 91% rename from spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jOperationsExtensionsTest.kt rename to src/test/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jOperationsExtensionsTest.kt index 1bc2f4b4d..9515c5747 100644 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/ReactiveNeo4jOperationsExtensionsTest.kt +++ b/src/test/kotlin/org/springframework/data/neo4j/core/ReactiveNeo4jOperationsExtensionsTest.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core +package org.springframework.data.neo4j.core import io.mockk.every import io.mockk.mockk diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/cypher/ParametersTest.kt b/src/test/kotlin/org/springframework/data/neo4j/core/cypher/ParametersTest.kt similarity index 83% rename from spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/cypher/ParametersTest.kt rename to src/test/kotlin/org/springframework/data/neo4j/core/cypher/ParametersTest.kt index d966925b8..23ce535a7 100644 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/core/cypher/ParametersTest.kt +++ b/src/test/kotlin/org/springframework/data/neo4j/core/cypher/ParametersTest.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.core.cypher +package org.springframework.data.neo4j.core.cypher import org.assertj.core.api.Assertions.assertThat import org.junit.Test diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/imperative/ImmutableRelationshipsIT.kt b/src/test/kotlin/org/springframework/data/neo4j/integration/imperative/ImmutableRelationshipsIT.kt similarity index 83% rename from spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/imperative/ImmutableRelationshipsIT.kt rename to src/test/kotlin/org/springframework/data/neo4j/integration/imperative/ImmutableRelationshipsIT.kt index 35da6f548..818c2cbf2 100644 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/imperative/ImmutableRelationshipsIT.kt +++ b/src/test/kotlin/org/springframework/data/neo4j/integration/imperative/ImmutableRelationshipsIT.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -17,23 +14,23 @@ * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative +package org.springframework.data.neo4j.integration.imperative import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.neo4j.driver.Driver -import org.neo4j.springframework.data.config.AbstractNeo4jConfig -import org.neo4j.springframework.data.core.schema.GeneratedValue -import org.neo4j.springframework.data.core.schema.Id -import org.neo4j.springframework.data.core.schema.Node -import org.neo4j.springframework.data.core.schema.Relationship -import org.neo4j.springframework.data.repository.Neo4jRepository -import org.neo4j.springframework.data.repository.config.EnableNeo4jRepositories -import org.neo4j.springframework.data.test.Neo4jExtension -import org.neo4j.springframework.data.test.Neo4jIntegrationTest 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.GeneratedValue +import org.springframework.data.neo4j.core.schema.Id +import org.springframework.data.neo4j.core.schema.Node +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.transaction.annotation.EnableTransactionManagement /** @@ -46,9 +43,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement */ @Neo4jIntegrationTest class ImmutableRelationshipsIT @Autowired constructor( - private val repository: DeviceRepository, - private val personRepository: ImmutableKotlinPersonRepository, - private val driver: Driver + private val repository: DeviceRepository, + private val personRepository: ImmutableKotlinPersonRepository, + private val driver: Driver ) { companion object { diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/imperative/Neo4jClientKotlinInteropIT.kt b/src/test/kotlin/org/springframework/data/neo4j/integration/imperative/Neo4jClientKotlinInteropIT.kt similarity index 83% rename from spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/imperative/Neo4jClientKotlinInteropIT.kt rename to src/test/kotlin/org/springframework/data/neo4j/integration/imperative/Neo4jClientKotlinInteropIT.kt index 2448ef008..2eb4da5e9 100644 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/imperative/Neo4jClientKotlinInteropIT.kt +++ b/src/test/kotlin/org/springframework/data/neo4j/integration/imperative/Neo4jClientKotlinInteropIT.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.imperative +package org.springframework.data.neo4j.integration.imperative import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions.assertThat @@ -25,16 +22,16 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.neo4j.driver.Driver import org.neo4j.driver.Values -import org.neo4j.springframework.data.config.AbstractNeo4jConfig -import org.neo4j.springframework.data.core.Neo4jClient -import org.neo4j.springframework.data.core.cypher.asParam -import org.neo4j.springframework.data.core.fetchAs -import org.neo4j.springframework.data.core.mappedBy -import org.neo4j.springframework.data.test.Neo4jExtension -import org.neo4j.springframework.data.test.Neo4jIntegrationTest 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.Neo4jClient +import org.springframework.data.neo4j.core.cypher.asParam +import org.springframework.data.neo4j.core.fetchAs +import org.springframework.data.neo4j.core.mappedBy +import org.springframework.data.neo4j.test.Neo4jExtension +import org.springframework.data.neo4j.test.Neo4jIntegrationTest import org.springframework.transaction.annotation.EnableTransactionManagement /** @@ -92,7 +89,7 @@ class Neo4jClientKotlinInteropIT @Autowired constructor( .bind("Die Ärzte").to("name") .mappedBy { _, r -> val members = r["members"].asList { v -> Artist(v.asString()) } - Band(r["band"]["name"].asString(), members) + Band(r["band"]["name"].asString(), members) } .one() diff --git a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/reactive/ReactiveNeo4jClientKotlinInteropIT.kt b/src/test/kotlin/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jClientKotlinInteropIT.kt similarity index 83% rename from spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/reactive/ReactiveNeo4jClientKotlinInteropIT.kt rename to src/test/kotlin/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jClientKotlinInteropIT.kt index a28c3779a..e1bc1d8e3 100644 --- a/spring-data-neo4j/src/test/kotlin/org/neo4j/springframework/data/integration/reactive/ReactiveNeo4jClientKotlinInteropIT.kt +++ b/src/test/kotlin/org/springframework/data/neo4j/integration/reactive/ReactiveNeo4jClientKotlinInteropIT.kt @@ -1,14 +1,11 @@ /* - * Copyright (c) 2019-2020 "Neo4j," - * Neo4j Sweden AB [https://neo4j.com] - * - * This file is part of Neo4j. + * 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 + * 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, @@ -16,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.neo4j.springframework.data.integration.reactive +package org.springframework.data.neo4j.integration.reactive import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking @@ -29,19 +26,15 @@ import org.neo4j.driver.Driver import org.neo4j.driver.Record import org.neo4j.driver.Values import org.neo4j.driver.types.TypeSystem -import org.neo4j.springframework.data.config.AbstractReactiveNeo4jConfig -import org.neo4j.springframework.data.core.ReactiveNeo4jClient -import org.neo4j.springframework.data.core.awaitOneOrNull -import org.neo4j.springframework.data.core.cypher.asParam -import org.neo4j.springframework.data.core.fetchAll -import org.neo4j.springframework.data.core.fetchAs -import org.neo4j.springframework.data.core.mappedBy -import org.neo4j.springframework.data.test.Neo4jExtension -import org.neo4j.springframework.data.test.Neo4jExtension.NEEDS_REACTIVE_SUPPORT -import org.neo4j.springframework.data.test.Neo4jIntegrationTest 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.* +import org.springframework.data.neo4j.core.cypher.asParam +import org.springframework.data.neo4j.test.Neo4jExtension +import org.springframework.data.neo4j.test.Neo4jExtension.NEEDS_REACTIVE_SUPPORT +import org.springframework.data.neo4j.test.Neo4jIntegrationTest import org.springframework.transaction.annotation.EnableTransactionManagement import reactor.test.StepVerifier @@ -100,7 +93,7 @@ class ReactiveNeo4jClientKotlinInteropIT @Autowired constructor( .bind("Queen").to("name") .mappedBy { _, r -> val members = r["members"].asList { v -> Artist(v.asString()) } - Band(r["band"]["name"].asString(), members) + Band(r["band"]["name"].asString(), members) }.one() StepVerifier.create(queen) diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/CinemaAndBlockbuster.java b/src/test/kotlin/org/springframework/data/neo4j/integration/shared/KotlinPerson.kt similarity index 65% rename from spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/CinemaAndBlockbuster.java rename to src/test/kotlin/org/springframework/data/neo4j/integration/shared/KotlinPerson.kt index 872d18af5..d00f03680 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/examples/movies/domain/CinemaAndBlockbuster.java +++ b/src/test/kotlin/org/springframework/data/neo4j/integration/shared/KotlinPerson.kt @@ -13,18 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.neo4j.examples.movies.domain; + +package org.springframework.data.neo4j.integration.shared + +import org.springframework.data.neo4j.core.schema.GeneratedValue +import org.springframework.data.neo4j.core.schema.Id +import org.springframework.data.neo4j.core.schema.Node /** - * Projection interface for Cinema without users - * - * @author Nicolas Mervaillie + * @author Gerrit Meier */ -public interface CinemaAndBlockbuster { - - String getName(); - - String getLocation(); - - TempMovie getBlockbusterOfTheWeek(); -} +@Node +data class KotlinPerson(@Id @GeneratedValue val id: Long, val name: String) diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/EntityRepository.java b/src/test/kotlin/org/springframework/data/neo4j/integration/shared/KotlinRepository.kt similarity index 81% rename from spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/EntityRepository.java rename to src/test/kotlin/org/springframework/data/neo4j/integration/shared/KotlinRepository.kt index 1a53ecce8..03b08cf04 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/conversion/support/EntityRepository.java +++ b/src/test/kotlin/org/springframework/data/neo4j/integration/shared/KotlinRepository.kt @@ -13,10 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.data.neo4j.conversion.support; -import org.springframework.data.neo4j.repository.Neo4jRepository; +package org.springframework.data.neo4j.integration.shared -public interface EntityRepository extends Neo4jRepository { -} +import org.springframework.data.neo4j.repository.Neo4jRepository +/** + * @author Gerrit Meier + */ +interface KotlinRepository : Neo4jRepository diff --git a/spring-data-neo4j/src/test/resources/META-INF/neo4j-named-queries.properties b/src/test/resources/META-INF/neo4j-named-queries.properties similarity index 86% rename from spring-data-neo4j/src/test/resources/META-INF/neo4j-named-queries.properties rename to src/test/resources/META-INF/neo4j-named-queries.properties index df9fd704c..0e79749ca 100644 --- a/spring-data-neo4j/src/test/resources/META-INF/neo4j-named-queries.properties +++ b/src/test/resources/META-INF/neo4j-named-queries.properties @@ -1,9 +1,6 @@ # -# Copyright (c) 2019-2020 "Neo4j," -# Neo4j Sweden AB [https://neo4j.com] -# -# This file is part of Neo4j. -# +# 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 diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 000000000..4d35ad8e1 --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,40 @@ + + + + + + + + [%t] %d %5p %40.40c:%4L - %m%n + + + + + + + + + + + + + + + + + + diff --git a/spring-data-neo4j/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker similarity index 100% rename from spring-data-neo4j/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker rename to src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker