From 7f00378eafad4d592782d0e3d386fb79540266d1 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 7 Jul 2022 16:32:13 +0100 Subject: [PATCH] Polish "Start building against Spring Data 2022.0.0-M5 snapshots" See gh-31582 --- .../build.gradle | 4 ++++ ...activeHealthContributorAutoConfiguration.java | 2 +- .../ElasticsearchReactiveHealthIndicator.java | 4 ++-- ...lasticsearchReactiveHealthIndicatorTests.java | 6 +++--- .../ElasticsearchDataConfiguration.java | 16 +++++++--------- ...asticsearchRepositoriesAutoConfiguration.java | 1 - ...tiveElasticsearchClientAutoConfiguration.java | 8 ++++---- .../CassandraDataAutoConfigurationTests.java | 2 -- ...sandraReactiveDataAutoConfigurationTests.java | 1 - ...activeRepositoriesAutoConfigurationTests.java | 3 --- ...sandraRepositoriesAutoConfigurationTests.java | 1 - .../CouchbaseDataAutoConfigurationTests.java | 2 -- ...chbaseReactiveDataAutoConfigurationTests.java | 2 -- .../JdbcRepositoriesAutoConfigurationTests.java | 3 +-- .../mongo/MongoDataAutoConfigurationTests.java | 3 --- ...activeRepositoriesAutoConfigurationTests.java | 3 --- .../MongoRepositoriesAutoConfigurationTests.java | 5 +---- .../redis/RedisAutoConfigurationJedisTests.java | 6 +++--- ...lasticsearchClientAutoConfigurationTests.java | 2 -- ...tClientAutoConfigurationIntegrationTests.java | 1 - .../connectingusingspringdata/MyBean.java | 6 +++--- .../connectingusingspringdata/MyBean.kt | 4 ++-- .../DataElasticsearchTestIntegrationTests.java | 4 ++-- ...lasticsearchTestReactiveIntegrationTests.java | 4 ++-- .../data/elasticsearch/ExampleService.java | 7 ++++--- 25 files changed, 39 insertions(+), 61 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle index d41b142fa7..84e2b7fefc 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle @@ -166,6 +166,9 @@ dependencies { testImplementation("org.eclipse.jetty:jetty-webapp") { exclude group: "javax.servlet", module: "javax.servlet-api" } + testImplementation("org.elasticsearch.client:elasticsearch-rest-high-level-client") { + exclude(group: "commons-logging", module: "commons-logging") + } testImplementation("org.hamcrest:hamcrest") testImplementation("org.hsqldb:hsqldb") testImplementation("org.junit.jupiter:junit-jupiter") @@ -186,6 +189,7 @@ dependencies { testRuntimeOnly("jakarta.management.j2ee:jakarta.management.j2ee-api") testRuntimeOnly("jakarta.transaction:jakarta.transaction-api") testRuntimeOnly("org.cache2k:cache2k-core") + testRuntimeOnly("org.springframework:spring-aspects") testRuntimeOnly("org.springframework.security:spring-security-oauth2-jose") testRuntimeOnly("org.springframework.security:spring-security-oauth2-resource-server") testRuntimeOnly("org.springframework.security:spring-security-saml2-service-provider") diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchReactiveHealthContributorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchReactiveHealthContributorAutoConfiguration.java index f90b77cd77..e9ff1c9e5e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchReactiveHealthContributorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticSearchReactiveHealthContributorAutoConfiguration.java @@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.elasticsearch.ReactiveElasticsearchClientAutoConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; +import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient; /** * {@link EnableAutoConfiguration Auto-configuration} for diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicator.java index caf2973709..a64bce3877 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicator.java @@ -25,7 +25,7 @@ import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.Status; import org.springframework.core.ParameterizedTypeReference; -import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; +import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient; import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatusCode; import org.springframework.web.reactive.function.client.ClientResponse; @@ -42,7 +42,7 @@ import org.springframework.web.reactive.function.client.WebClient; */ public class ElasticsearchReactiveHealthIndicator extends AbstractReactiveHealthIndicator { - private static final ParameterizedTypeReference> STRING_OBJECT_MAP = new ParameterizedTypeReference>() { + private static final ParameterizedTypeReference> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() { }; private static final String RED_STATUS = "red"; diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicatorTests.java index 9c6ab674c1..87a9cdfc9e 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchReactiveHealthIndicatorTests.java @@ -28,8 +28,7 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Status; import org.springframework.data.elasticsearch.client.ClientConfiguration; -import org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient; -import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; +import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -51,11 +50,12 @@ class ElasticsearchReactiveHealthIndicatorTests { private ElasticsearchReactiveHealthIndicator healthIndicator; + @SuppressWarnings("deprecation") @BeforeEach void setup() throws Exception { this.server = new MockWebServer(); this.server.start(); - ReactiveElasticsearchClient client = DefaultReactiveElasticsearchClient + ReactiveElasticsearchClient client = org.springframework.data.elasticsearch.client.erhlc.DefaultReactiveElasticsearchClient .create(ClientConfiguration.create(this.server.getHostName() + ":" + this.server.getPort())); this.healthIndicator = new ElasticsearchReactiveHealthIndicator(client); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataConfiguration.java index c60833a1b6..1fc7d1b5e4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataConfiguration.java @@ -26,9 +26,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.elasticsearch.annotations.Document; -import org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient; -import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; @@ -87,10 +85,9 @@ abstract class ElasticsearchDataConfiguration { @Bean @ConditionalOnMissingBean(value = ElasticsearchOperations.class, name = "elasticsearchTemplate") @ConditionalOnBean(org.elasticsearch.client.RestHighLevelClient.class) - @SuppressWarnings("deprecation") - ElasticsearchRestTemplate elasticsearchTemplate(org.elasticsearch.client.RestHighLevelClient client, - ElasticsearchConverter converter) { - return new ElasticsearchRestTemplate(client, converter); + org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate elasticsearchTemplate( + org.elasticsearch.client.RestHighLevelClient client, ElasticsearchConverter converter) { + return new org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate(client, converter); } } @@ -103,9 +100,10 @@ abstract class ElasticsearchDataConfiguration { @ConditionalOnMissingBean(value = ReactiveElasticsearchOperations.class, name = "reactiveElasticsearchTemplate") @ConditionalOnBean(ReactiveElasticsearchClient.class) @SuppressWarnings("deprecation") - ReactiveElasticsearchTemplate reactiveElasticsearchTemplate(ReactiveElasticsearchClient client, - ElasticsearchConverter converter) { - return new ReactiveElasticsearchTemplate(client, converter); + org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate reactiveElasticsearchTemplate( + ReactiveElasticsearchClient client, ElasticsearchConverter converter) { + return new org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate(client, + converter); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRepositoriesAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRepositoriesAutoConfiguration.java index 2888b0ed65..b2ea0ceb88 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRepositoriesAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRepositoriesAutoConfiguration.java @@ -41,7 +41,6 @@ import org.springframework.data.elasticsearch.repository.support.ReactiveElastic matchIfMissing = true) @ConditionalOnMissingBean(ReactiveElasticsearchRepositoryFactoryBean.class) @Import(ReactiveElasticsearchRepositoriesRegistrar.class) -@SuppressWarnings("deprecation") public class ReactiveElasticsearchRepositoriesAutoConfiguration { } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfiguration.java index 6ce7aafba2..42420e9652 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfiguration.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.elasticsearch.ElasticsearchException; import reactor.netty.http.client.HttpClient; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -32,6 +33,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.context.annotation.Bean; import org.springframework.data.elasticsearch.client.ClientConfiguration; +import org.springframework.data.elasticsearch.client.elc.ElasticsearchClients; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.client.erhlc.ReactiveRestClients; import org.springframework.util.Assert; @@ -40,8 +42,6 @@ import org.springframework.util.unit.DataSize; import org.springframework.web.reactive.function.client.ExchangeStrategies; import org.springframework.web.reactive.function.client.WebClient; -import static org.springframework.data.elasticsearch.client.elc.ElasticsearchClients.WebClientConfigurationCallback; - /** * {@link EnableAutoConfiguration Auto-configuration} for Elasticsearch Reactive REST * clients. @@ -50,7 +50,7 @@ import static org.springframework.data.elasticsearch.client.elc.ElasticsearchCli * @since 3.0.0 */ @AutoConfiguration -@ConditionalOnClass({ ReactiveRestClients.class, WebClient.class, HttpClient.class }) +@ConditionalOnClass({ ReactiveRestClients.class, ElasticsearchException.class, WebClient.class, HttpClient.class }) @EnableConfigurationProperties(ElasticsearchProperties.class) @SuppressWarnings("deprecation") public class ReactiveElasticsearchClientAutoConfiguration { @@ -80,7 +80,7 @@ public class ReactiveElasticsearchClientAutoConfiguration { private void configureExchangeStrategies(PropertyMapper map, ClientConfiguration.TerminalClientConfigurationBuilder builder) { map.from(this.properties.getMaxInMemorySize()).asInt(DataSize::toBytes).to((maxInMemorySize) -> { - builder.withClientConfigurer(WebClientConfigurationCallback.from((webClient) -> { + builder.withClientConfigurer(ElasticsearchClients.WebClientConfigurationCallback.from((webClient) -> { ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() .codecs((configurer) -> configurer.defaultCodecs().maxInMemorySize(maxInMemorySize)).build(); return webClient.mutate().exchangeStrategies(exchangeStrategies).build(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationTests.java index eb6a58be62..f43d3e4fbf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfigurationTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.data.cassandra; import java.util.Collections; -import java.util.Set; import com.datastax.oss.driver.api.core.CqlSession; import org.junit.jupiter.api.AfterEach; @@ -67,7 +66,6 @@ class CassandraDataAutoConfigurationTests { } @Test - @SuppressWarnings("unchecked") void entityScanShouldSetManagedTypes() { load(EntityScanConfig.class); CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfigurationTests.java index 9e45ece8e1..d689f9158a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfigurationTests.java @@ -59,7 +59,6 @@ class CassandraReactiveDataAutoConfigurationTests { } @Test - @SuppressWarnings("unchecked") void entityScanShouldSetManagedTypes() { load(EntityScanConfig.class, "spring.data.cassandra.keyspaceName:boot_test"); CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfigurationTests.java index 7ea2bb1734..159309d6bf 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfigurationTests.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.data.cassandra; -import java.util.Set; - import com.datastax.oss.driver.api.core.CqlSessionBuilder; import org.junit.jupiter.api.Test; @@ -94,7 +92,6 @@ class CassandraReactiveRepositoriesAutoConfigurationTests { .run((context) -> assertThat(context).doesNotHaveBean(ReactiveCityRepository.class)); } - @SuppressWarnings("unchecked") private ManagedTypes getManagedTypes(ApplicationContext context) { CassandraMappingContext mappingContext = context.getBean(CassandraMappingContext.class); return (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes"); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfigurationTests.java index bbf12d4e0b..6d2f1bc9ab 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfigurationTests.java @@ -90,7 +90,6 @@ class CassandraRepositoriesAutoConfigurationTests { .run((context) -> assertThat(context).doesNotHaveBean(CityCassandraRepository.class)); } - @SuppressWarnings("unchecked") private ManagedTypes getManagedTypes(AssertableApplicationContext context) { CassandraMappingContext mappingContext = context.getBean(CassandraMappingContext.class); return (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes"); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfigurationTests.java index 005a3d0f88..20deec96d9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfigurationTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.data.couchbase; import java.util.Collections; -import java.util.Set; import org.junit.jupiter.api.Test; @@ -66,7 +65,6 @@ class CouchbaseDataAutoConfigurationTests { } @Test - @SuppressWarnings("unchecked") void entityScanShouldSetInitialEntitySet() { this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> { CouchbaseMappingContext mappingContext = context.getBean(CouchbaseMappingContext.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveDataAutoConfigurationTests.java index fb4e5d1b2c..22a9d0fc7c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveDataAutoConfigurationTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.autoconfigure.data.couchbase; import java.util.Collections; -import java.util.Set; import org.junit.jupiter.api.Test; @@ -65,7 +64,6 @@ class CouchbaseReactiveDataAutoConfigurationTests { } @Test - @SuppressWarnings("unchecked") void entityScanShouldSetInitialEntitySet() { this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> { CouchbaseMappingContext mappingContext = context.getBean(CouchbaseMappingContext.class); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfigurationTests.java index 6da7998308..e0ccf5543f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,6 @@ import org.springframework.data.domain.ManagedTypes; import org.springframework.data.jdbc.core.mapping.JdbcMappingContext; import org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration; import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; -import org.springframework.data.r2dbc.mapping.R2dbcMappingContext; import org.springframework.data.repository.Repository; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; import org.springframework.test.util.ReflectionTestUtils; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java index 82ef5d0029..fcb96868ee 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.data.mongo; import java.time.LocalDateTime; import java.util.Arrays; -import java.util.Set; import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; @@ -161,7 +160,6 @@ class MongoDataAutoConfigurationTests { } @Test - @SuppressWarnings("unchecked") void entityScanShouldSetManagedTypes() { this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> { MongoMappingContext mappingContext = context.getBean(MongoMappingContext.class); @@ -211,7 +209,6 @@ class MongoDataAutoConfigurationTests { .run((context) -> assertThat(context).hasSingleBean(MongoTemplate.class)); } - @SuppressWarnings("unchecked") private static void assertDomainTypesDiscovered(MongoMappingContext mappingContext, Class... types) { ManagedTypes managedTypes = (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes"); assertThat(managedTypes.toList()).containsOnly(types); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveRepositoriesAutoConfigurationTests.java index ecaa9bbb88..f4dbc80ef5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveRepositoriesAutoConfigurationTests.java @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.data.mongo; -import java.util.Set; - import com.mongodb.reactivestreams.client.MongoClient; import org.junit.jupiter.api.Test; @@ -60,7 +58,6 @@ class MongoReactiveRepositoriesAutoConfigurationTests { assertThat(context).hasSingleBean(ReactiveCityRepository.class); assertThat(context).hasSingleBean(MongoClient.class); MongoMappingContext mappingContext = context.getBean(MongoMappingContext.class); - @SuppressWarnings("unchecked") ManagedTypes managedTypes = (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes"); assertThat(managedTypes.toList()).hasSize(1); }); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java index c2d4f8108a..33fd80382c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ package org.springframework.boot.autoconfigure.data.mongo; -import java.util.Set; - import com.mongodb.client.MongoClient; import org.junit.jupiter.api.Test; @@ -56,7 +54,6 @@ class MongoRepositoriesAutoConfigurationTests { assertThat(context).hasSingleBean(CityRepository.class); assertThat(context).hasSingleBean(MongoClient.class); MongoMappingContext mappingContext = context.getBean(MongoMappingContext.class); - @SuppressWarnings("unchecked") ManagedTypes managedTypes = (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes"); assertThat(managedTypes.toList()).hasSize(1); }); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java index d06d1d4df2..dec8ee50a0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java @@ -191,9 +191,9 @@ class RedisAutoConfigurationJedisTests { this.contextRunner .withPropertyValues("spring.redis.sentinel.master:mymaster", "spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380") - .withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class).run((context) -> { - assertThat(JedisConnectionFactoryCaptor.connectionFactory.isRedisSentinelAware()).isTrue(); - }); + .withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class) + .run((context) -> assertThat(JedisConnectionFactoryCaptor.connectionFactory.isRedisSentinelAware()) + .isTrue()); } @Test diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfigurationTests.java index faa6080b83..4df9e6c9eb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfigurationTests.java @@ -32,7 +32,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.elasticsearch.client.ClientConfiguration; import org.springframework.data.elasticsearch.client.ClientConfiguration.ClientConfigurationCallback; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient; -import org.springframework.data.elasticsearch.client.erhlc.ReactiveRestClients; import org.springframework.http.HttpHeaders; import org.springframework.http.codec.CodecConfigurer.DefaultCodecConfig; import org.springframework.web.reactive.function.client.WebClient; @@ -45,7 +44,6 @@ import static org.mockito.Mockito.mock; * * @author Brian Clozel */ -@SuppressWarnings("deprecation") class ReactiveElasticsearchClientAutoConfigurationTests { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchRestClientAutoConfigurationIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchRestClientAutoConfigurationIntegrationTests.java index 67a28fee5d..969d68cbb2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchRestClientAutoConfigurationIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchRestClientAutoConfigurationIntegrationTests.java @@ -41,7 +41,6 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Brian Clozel */ @Testcontainers(disabledWithoutDocker = true) -@SuppressWarnings("deprecation") class ReactiveElasticsearchRestClientAutoConfigurationIntegrationTests { @Container diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.java index e2f0633baf..7a54d1cd24 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.java @@ -16,15 +16,15 @@ package org.springframework.boot.docs.data.nosql.elasticsearch.connectingusingspringdata; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.stereotype.Component; @Component +@SuppressWarnings("deprecation") public class MyBean { - private final ElasticsearchRestTemplate template; + private final org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate template; - public MyBean(ElasticsearchRestTemplate template) { + public MyBean(org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate template) { this.template = template; } diff --git a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.kt b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.kt index 8b8f95888e..95442da426 100644 --- a/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.kt +++ b/spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/data/nosql/elasticsearch/connectingusingspringdata/MyBean.kt @@ -16,11 +16,11 @@ package org.springframework.boot.docs.data.nosql.elasticsearch.connectingusingspringdata -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate import org.springframework.stereotype.Component @Component -class MyBean(private val template: ElasticsearchRestTemplate) { +@Suppress("DEPRECATION") +class MyBean(private val template: org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate ) { // @fold:on // ... fun someMethod(id: String): Boolean { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestIntegrationTests.java index fdd3311f0b..9ad2f73c23 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestIntegrationTests.java @@ -28,7 +28,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.testsupport.testcontainers.DockerImageNames; import org.springframework.context.ApplicationContext; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; @@ -54,7 +53,8 @@ class DataElasticsearchTestIntegrationTests { } @Autowired - private ElasticsearchRestTemplate elasticsearchRestTemplate; + @SuppressWarnings("deprecation") + private org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate elasticsearchRestTemplate; @Autowired private ExampleRepository exampleRepository; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestReactiveIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestReactiveIntegrationTests.java index e82e0474fd..5c180fc16a 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestReactiveIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/DataElasticsearchTestReactiveIntegrationTests.java @@ -25,7 +25,6 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.testsupport.testcontainers.DockerImageNames; -import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; @@ -51,7 +50,8 @@ class DataElasticsearchTestReactiveIntegrationTests { } @Autowired - private ReactiveElasticsearchTemplate elasticsearchTemplate; + @SuppressWarnings("deprecation") + private org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate elasticsearchTemplate; @Autowired private ExampleReactiveRepository exampleReactiveRepository; diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleService.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleService.java index b27989ebe6..58ee668b06 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleService.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/elasticsearch/ExampleService.java @@ -16,7 +16,6 @@ package org.springframework.boot.test.autoconfigure.data.elasticsearch; -import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.stereotype.Service; /** @@ -25,11 +24,13 @@ import org.springframework.stereotype.Service; * @author EddĂș MelĂ©ndez */ @Service +@SuppressWarnings("deprecation") public class ExampleService { - private final ElasticsearchRestTemplate elasticsearchRestTemplate; + private final org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate elasticsearchRestTemplate; - public ExampleService(ElasticsearchRestTemplate elasticsearchRestTemplate) { + public ExampleService( + org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate elasticsearchRestTemplate) { this.elasticsearchRestTemplate = elasticsearchRestTemplate; }