Skip to content

Commit

Permalink
Align bean name with Spring Data Elasticsearch requirements
Browse files Browse the repository at this point in the history
Fixes gh-33651
  • Loading branch information
scottfrederick committed May 23, 2023
1 parent bf91ec1 commit 72fd94f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,7 @@ ElasticsearchCustomConversions elasticsearchCustomConversions() {

@Bean
@ConditionalOnMissingBean
SimpleElasticsearchMappingContext mappingContext(ApplicationContext applicationContext,
SimpleElasticsearchMappingContext elasticsearchMappingContext(ApplicationContext applicationContext,
ElasticsearchCustomConversions elasticsearchCustomConversions) throws ClassNotFoundException {
SimpleElasticsearchMappingContext mappingContext = new SimpleElasticsearchMappingContext();
mappingContext.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.config.EnableElasticsearchAuditing;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -45,6 +46,7 @@
* @author Phillip Webb
* @author Andy Wilkinson
* @author Brian Clozel
* @author Scott Frederick
*/
@Testcontainers(disabledWithoutDocker = true)
class ElasticsearchRepositoriesAutoConfigurationTests {
Expand Down Expand Up @@ -80,6 +82,12 @@ void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
.run((context) -> assertThat(context).hasSingleBean(CityElasticsearchDbRepository.class));
}

@Test
void testAuditingConfiguration() {
this.contextRunner.withUserConfiguration(AuditingConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(ElasticsearchTemplate.class));
}

@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(City.class)
static class TestConfiguration {
Expand All @@ -99,4 +107,12 @@ static class CustomizedConfiguration {

}

@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(ElasticsearchRepositoriesAutoConfigurationTests.class)
@EnableElasticsearchRepositories
@EnableElasticsearchAuditing
static class AuditingConfiguration {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.config.EnableElasticsearchAuditing;
import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -48,6 +49,7 @@
* @author Phillip Webb
* @author Andy Wilkinson
* @author Brian Clozel
* @author Scott Frederick
*/
@Testcontainers(disabledWithoutDocker = true)
class ReactiveElasticsearchRepositoriesAutoConfigurationTests {
Expand Down Expand Up @@ -87,6 +89,12 @@ void doesNotTriggerDefaultRepositoryDetectionIfCustomized() {
.run((context) -> assertThat(context).hasSingleBean(CityReactiveElasticsearchDbRepository.class));
}

@Test
void testAuditingConfiguration() {
this.contextRunner.withUserConfiguration(AuditingConfiguration.class)
.run((context) -> assertThat(context).hasSingleBean(ReactiveElasticsearchTemplate.class));
}

@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(City.class)
static class TestConfiguration {
Expand All @@ -106,4 +114,12 @@ static class CustomizedConfiguration {

}

@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(ElasticsearchRepositoriesAutoConfigurationTests.class)
@EnableReactiveElasticsearchRepositories
@EnableElasticsearchAuditing
static class AuditingConfiguration {

}

}

0 comments on commit 72fd94f

Please sign in to comment.