Start building against Spring Data 2021.0.0-M5 snapshots

See gh-25548
pull/25617/head
Stephane Nicoll 4 years ago
parent c19e5c9212
commit 46baf462ac

@ -94,15 +94,14 @@ public class Neo4jDataAutoConfiguration {
@Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_CLIENT_BEAN_NAME) @Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_CLIENT_BEAN_NAME)
@ConditionalOnMissingBean @ConditionalOnMissingBean
public Neo4jClient neo4jClient(Driver driver) { public Neo4jClient neo4jClient(Driver driver, DatabaseSelectionProvider databaseNameProvider) {
return Neo4jClient.create(driver); return Neo4jClient.create(driver, databaseNameProvider);
} }
@Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME) @Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME)
@ConditionalOnMissingBean(Neo4jOperations.class) @ConditionalOnMissingBean(Neo4jOperations.class)
public Neo4jTemplate neo4jTemplate(Neo4jClient neo4jClient, Neo4jMappingContext neo4jMappingContext, public Neo4jTemplate neo4jTemplate(Neo4jClient neo4jClient, Neo4jMappingContext neo4jMappingContext) {
DatabaseSelectionProvider databaseNameProvider) { return new Neo4jTemplate(neo4jClient, neo4jMappingContext);
return new Neo4jTemplate(neo4jClient, neo4jMappingContext, databaseNameProvider);
} }
@Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME) @Bean(Neo4jRepositoryConfigurationExtension.DEFAULT_TRANSACTION_MANAGER_BEAN_NAME)

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -58,15 +58,16 @@ public class Neo4jReactiveDataAutoConfiguration {
@Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_CLIENT_BEAN_NAME) @Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_CLIENT_BEAN_NAME)
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ReactiveNeo4jClient reactiveNeo4jClient(Driver driver) { public ReactiveNeo4jClient reactiveNeo4jClient(Driver driver,
return ReactiveNeo4jClient.create(driver); ReactiveDatabaseSelectionProvider databaseNameProvider) {
return ReactiveNeo4jClient.create(driver, databaseNameProvider);
} }
@Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME) @Bean(ReactiveNeo4jRepositoryConfigurationExtension.DEFAULT_NEO4J_TEMPLATE_BEAN_NAME)
@ConditionalOnMissingBean(ReactiveNeo4jOperations.class) @ConditionalOnMissingBean(ReactiveNeo4jOperations.class)
public ReactiveNeo4jTemplate reactiveNeo4jTemplate(ReactiveNeo4jClient neo4jClient, public ReactiveNeo4jTemplate reactiveNeo4jTemplate(ReactiveNeo4jClient neo4jClient,
Neo4jMappingContext neo4jMappingContext, ReactiveDatabaseSelectionProvider databaseNameProvider) { Neo4jMappingContext neo4jMappingContext) {
return new ReactiveNeo4jTemplate(neo4jClient, neo4jMappingContext, databaseNameProvider); return new ReactiveNeo4jTemplate(neo4jClient, neo4jMappingContext);
} }
} }

@ -97,6 +97,15 @@ class Neo4jDataAutoConfigurationTests {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(Neo4jClient.class)); this.contextRunner.run((context) -> assertThat(context).hasSingleBean(Neo4jClient.class));
} }
@Test
void shouldProvideNeo4jClientWithCustomDatabaseSelectionProvider() {
this.contextRunner.withUserConfiguration(CustomDatabaseSelectionProviderConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(Neo4jClient.class);
assertThat(context.getBean(Neo4jClient.class)).extracting("databaseSelectionProvider")
.isSameAs(context.getBean(DatabaseSelectionProvider.class));
});
}
@Test @Test
void shouldReuseExistingNeo4jClient() { void shouldReuseExistingNeo4jClient() {
this.contextRunner.withBean("myCustomClient", Neo4jClient.class, () -> mock(Neo4jClient.class)) this.contextRunner.withBean("myCustomClient", Neo4jClient.class, () -> mock(Neo4jClient.class))
@ -105,11 +114,8 @@ class Neo4jDataAutoConfigurationTests {
@Test @Test
void shouldProvideNeo4jTemplate() { void shouldProvideNeo4jTemplate() {
this.contextRunner.withUserConfiguration(CustomDatabaseSelectionProviderConfiguration.class).run((context) -> { this.contextRunner.withUserConfiguration(CustomDatabaseSelectionProviderConfiguration.class)
assertThat(context).hasSingleBean(Neo4jTemplate.class); .run((context) -> assertThat(context).hasSingleBean(Neo4jTemplate.class));
assertThat(context.getBean(Neo4jTemplate.class)).extracting("databaseSelectionProvider")
.isSameAs(context.getBean(DatabaseSelectionProvider.class));
});
} }
@Test @Test

@ -91,6 +91,16 @@ class Neo4jReactiveDataAutoConfigurationTests {
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ReactiveNeo4jClient.class)); this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ReactiveNeo4jClient.class));
} }
@Test
void shouldProvideReactiveNeo4jClientWithCustomDatabaseSelectionProvider() {
this.contextRunner.withUserConfiguration(CustomReactiveDatabaseSelectionProviderConfiguration.class)
.run((context) -> {
assertThat(context).hasSingleBean(ReactiveNeo4jClient.class);
assertThat(context.getBean(ReactiveNeo4jClient.class)).extracting("databaseSelectionProvider")
.isSameAs(context.getBean(ReactiveDatabaseSelectionProvider.class));
});
}
@Test @Test
void shouldReuseExistingReactiveNeo4jClient() { void shouldReuseExistingReactiveNeo4jClient() {
this.contextRunner this.contextRunner
@ -102,11 +112,7 @@ class Neo4jReactiveDataAutoConfigurationTests {
@Test @Test
void shouldProvideReactiveNeo4jTemplate() { void shouldProvideReactiveNeo4jTemplate() {
this.contextRunner.withUserConfiguration(CustomReactiveDatabaseSelectionProviderConfiguration.class) this.contextRunner.withUserConfiguration(CustomReactiveDatabaseSelectionProviderConfiguration.class)
.run((context) -> { .run((context) -> assertThat(context).hasSingleBean(ReactiveNeo4jTemplate.class));
assertThat(context).hasSingleBean(ReactiveNeo4jTemplate.class);
assertThat(context.getBean(ReactiveNeo4jTemplate.class)).extracting("databaseSelectionProvider")
.isSameAs(context.getBean(ReactiveDatabaseSelectionProvider.class));
});
} }
@Test @Test

@ -1621,7 +1621,7 @@ bom {
] ]
} }
} }
library("Spring Data Bom", "2021.0.0-M4") { library("Spring Data Bom", "2021.0.0-SNAPSHOT") {
group("org.springframework.data") { group("org.springframework.data") {
imports = [ imports = [
"spring-data-bom" "spring-data-bom"

Loading…
Cancel
Save