pull/32880/head
Andy Wilkinson 2 years ago
parent b014039a34
commit 99edda735e

@ -25,7 +25,6 @@ import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.Configuration;
import org.gradle.api.file.RegularFile; import org.gradle.api.file.RegularFile;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider; import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.PathSensitivity;
@ -145,7 +144,7 @@ public class ConfigurationPropertiesPlugin implements Plugin<Project> {
TaskProvider<CheckSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks() TaskProvider<CheckSpringConfigurationMetadata> checkConfigurationMetadata = project.getTasks()
.register(CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME, CheckSpringConfigurationMetadata.class); .register(CHECK_SPRING_CONFIGURATION_METADATA_TASK_NAME, CheckSpringConfigurationMetadata.class);
checkConfigurationMetadata.configure((check) -> { checkConfigurationMetadata.configure((check) -> {
SourceSet mainSourceSet = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets() SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets()
.getByName(SourceSet.MAIN_SOURCE_SET_NAME); .getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Provider<RegularFile> metadataLocation = project.getTasks() Provider<RegularFile> metadataLocation = project.getTasks()
.named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class) .named(mainSourceSet.getCompileJavaTaskName(), JavaCompile.class)

@ -34,6 +34,7 @@ import org.springframework.http.observation.reactive.ServerRequestObservationCon
* @author Brian Clozel * @author Brian Clozel
*/ */
@SuppressWarnings("removal") @SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention { class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention {
private final String name; private final String name;

@ -36,7 +36,8 @@ import org.springframework.web.servlet.HandlerMapping;
* *
* @author Brian Clozel * @author Brian Clozel
*/ */
@SuppressWarnings({ "deprecation", "removal" }) @SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention { class ServerRequestObservationConventionAdapter implements ServerRequestObservationConvention {
private final String observationName; private final String observationName;

@ -77,7 +77,6 @@ class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
void showValuesCanBeConfiguredViaTheEnvironment() { void showValuesCanBeConfiguredViaTheEnvironment() {
this.contextRunner.withUserConfiguration(Config.class) this.contextRunner.withUserConfiguration(Config.class)
.withPropertyValues("management.endpoint.configprops.show-values: WHEN_AUTHORIZED") .withPropertyValues("management.endpoint.configprops.show-values: WHEN_AUTHORIZED")

@ -97,7 +97,6 @@ class EnvironmentEndpointAutoConfigurationTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
void showValuesCanBeConfiguredViaTheEnvironment() { void showValuesCanBeConfiguredViaTheEnvironment() {
this.contextRunner.withPropertyValues("management.endpoint.env.show-values: WHEN_AUTHORIZED") this.contextRunner.withPropertyValues("management.endpoint.env.show-values: WHEN_AUTHORIZED")
.withPropertyValues("management.endpoints.web.exposure.include=env") .withPropertyValues("management.endpoints.web.exposure.include=env")
@ -107,10 +106,8 @@ class EnvironmentEndpointAutoConfigurationTests {
EnvironmentEndpointWebExtension webExtension = context EnvironmentEndpointWebExtension webExtension = context
.getBean(EnvironmentEndpointWebExtension.class); .getBean(EnvironmentEndpointWebExtension.class);
EnvironmentEndpoint endpoint = context.getBean(EnvironmentEndpoint.class); EnvironmentEndpoint endpoint = context.getBean(EnvironmentEndpoint.class);
Show showValuesWebExtension = (Show) ReflectionTestUtils.getField(webExtension, "showValues"); assertThat(webExtension).extracting("showValues").isEqualTo(Show.WHEN_AUTHORIZED);
assertThat(showValuesWebExtension).isEqualTo(Show.WHEN_AUTHORIZED); assertThat(endpoint).extracting("showValues").isEqualTo(Show.WHEN_AUTHORIZED);
Show showValues = (Show) ReflectionTestUtils.getField(endpoint, "showValues");
assertThat(showValues).isEqualTo(Show.WHEN_AUTHORIZED);
}); });
} }

@ -54,7 +54,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
* @author Brian Clozel * @author Brian Clozel
*/ */
@ExtendWith(OutputCaptureExtension.class) @ExtendWith(OutputCaptureExtension.class)
@SuppressWarnings({ "deprecation", "removal" }) @SuppressWarnings("removal")
class RestTemplateObservationConfigurationTests { class RestTemplateObservationConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()

@ -55,7 +55,7 @@ import static org.mockito.Mockito.mock;
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@ExtendWith(OutputCaptureExtension.class) @ExtendWith(OutputCaptureExtension.class)
@SuppressWarnings({ "deprecation", "removal" }) @SuppressWarnings("removal")
class WebClientObservationConfigurationTests { class WebClientObservationConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple()) private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple())

@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Brian Clozel * @author Brian Clozel
*/ */
@SuppressWarnings("removal") @SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class ServerRequestObservationConventionAdapterTests { class ServerRequestObservationConventionAdapterTests {
private static final String TEST_METRIC_NAME = "test.metric.name"; private static final String TEST_METRIC_NAME = "test.metric.name";

@ -76,6 +76,7 @@ class WebFluxObservationAutoConfigurationTests {
}); });
} }
@Deprecated(since = "3.0.0", forRemoval = true)
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class CustomTagsProviderConfiguration { static class CustomTagsProviderConfiguration {
@ -96,6 +97,7 @@ class WebFluxObservationAutoConfigurationTests {
} }
@Deprecated(since = "3.0.0", forRemoval = true)
static class CustomTagsContributor implements WebFluxTagsContributor { static class CustomTagsContributor implements WebFluxTagsContributor {
@Override @Override

@ -41,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Brian Clozel * @author Brian Clozel
*/ */
@SuppressWarnings("removal") @SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class ServerRequestObservationConventionAdapterTests { class ServerRequestObservationConventionAdapterTests {
private static final String TEST_METRIC_NAME = "test.metric.name"; private static final String TEST_METRIC_NAME = "test.metric.name";

@ -210,6 +210,7 @@ class WebMvcObservationAutoConfigurationTests {
} }
@Deprecated(since = "3.0.0", forRemoval = true)
private static final class TestWebMvcTagsProvider implements WebMvcTagsProvider { private static final class TestWebMvcTagsProvider implements WebMvcTagsProvider {
@Override @Override

@ -101,16 +101,14 @@ class QuartzEndpointAutoConfigurationTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
void showValuesCanBeConfiguredViaTheEnvironment() { void showValuesCanBeConfiguredViaTheEnvironment() {
this.contextRunner.withBean(Scheduler.class, () -> mock(Scheduler.class)) this.contextRunner.withBean(Scheduler.class, () -> mock(Scheduler.class))
.withPropertyValues("management.endpoint.quartz.show-values: WHEN_AUTHORIZED") .withPropertyValues("management.endpoint.quartz.show-values: WHEN_AUTHORIZED")
.withPropertyValues("management.endpoints.web.exposure.include=quartz") .withPropertyValues("management.endpoints.web.exposure.include=quartz")
.withSystemProperties("dbPassword=123456", "apiKey=123456").run((context) -> { .withSystemProperties("dbPassword=123456", "apiKey=123456").run((context) -> {
assertThat(context).hasSingleBean(QuartzEndpointWebExtension.class); assertThat(context).hasSingleBean(QuartzEndpointWebExtension.class);
QuartzEndpointWebExtension webExtension = context.getBean(QuartzEndpointWebExtension.class); assertThat(context.getBean(QuartzEndpointWebExtension.class)).extracting("showValues")
Show showValuesWebExtension = (Show) ReflectionTestUtils.getField(webExtension, "showValues"); .isEqualTo(Show.WHEN_AUTHORIZED);
assertThat(showValuesWebExtension).isEqualTo(Show.WHEN_AUTHORIZED);
}); });
} }

@ -239,21 +239,16 @@ public class JerseyEndpointResourceFactory {
Status status = isGet ? Status.NOT_FOUND : Status.NO_CONTENT; Status status = isGet ? Status.NOT_FOUND : Status.NO_CONTENT;
return Response.status(status).build(); return Response.status(status).build();
} }
try { if (!(response instanceof WebEndpointResponse)) {
if (!(response instanceof WebEndpointResponse)) { return Response.status(Status.OK).entity(convertIfNecessary(response)).build();
return Response.status(Status.OK).entity(convertIfNecessary(response)).build();
}
WebEndpointResponse<?> webEndpointResponse = (WebEndpointResponse<?>) response;
return Response.status(webEndpointResponse.getStatus())
.header("Content-Type", webEndpointResponse.getContentType())
.entity(convertIfNecessary(webEndpointResponse.getBody())).build();
}
catch (IOException ex) {
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
} }
WebEndpointResponse<?> webEndpointResponse = (WebEndpointResponse<?>) response;
return Response.status(webEndpointResponse.getStatus())
.header("Content-Type", webEndpointResponse.getContentType())
.entity(convertIfNecessary(webEndpointResponse.getBody())).build();
} }
private Object convertIfNecessary(Object body) throws IOException { private Object convertIfNecessary(Object body) {
for (Function<Object, Object> converter : BODY_CONVERTERS) { for (Function<Object, Object> converter : BODY_CONVERTERS) {
body = converter.apply(body); body = converter.apply(body);
} }

@ -140,7 +140,6 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
} }
@Override @Override
@SuppressWarnings("deprecation")
public void afterPropertiesSet() { public void afterPropertiesSet() {
this.builderConfig = new RequestMappingInfo.BuilderConfiguration(); this.builderConfig = new RequestMappingInfo.BuilderConfiguration();
this.builderConfig.setPatternParser(getPatternParser()); this.builderConfig.setPatternParser(getPatternParser());

@ -58,7 +58,6 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
* @param endpoints the web endpoints * @param endpoints the web endpoints
* @param corsConfiguration the CORS configuration for the endpoints or {@code null} * @param corsConfiguration the CORS configuration for the endpoints or {@code null}
*/ */
@SuppressWarnings("deprecation")
public ControllerEndpointHandlerMapping(EndpointMapping endpointMapping, public ControllerEndpointHandlerMapping(EndpointMapping endpointMapping,
Collection<ExposableControllerEndpoint> endpoints, CorsConfiguration corsConfiguration) { Collection<ExposableControllerEndpoint> endpoints, CorsConfiguration corsConfiguration) {
Assert.notNull(endpointMapping, "EndpointMapping must not be null"); Assert.notNull(endpointMapping, "EndpointMapping must not be null");

@ -34,7 +34,7 @@ import org.springframework.util.StringUtils;
* {@link org.springframework.http.client.observation.DefaultClientRequestObservationConvention} * {@link org.springframework.http.client.observation.DefaultClientRequestObservationConvention}
*/ */
@Deprecated(since = "3.0.0", forRemoval = true) @Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings({ "deprecation", "removal" }) @SuppressWarnings("removal")
public class DefaultRestTemplateExchangeTagsProvider implements RestTemplateExchangeTagsProvider { public class DefaultRestTemplateExchangeTagsProvider implements RestTemplateExchangeTagsProvider {
@Override @Override

@ -33,7 +33,7 @@ import org.springframework.web.reactive.function.client.ClientResponse;
* {@link org.springframework.web.reactive.function.client.ClientRequestObservationConvention} * {@link org.springframework.web.reactive.function.client.ClientRequestObservationConvention}
*/ */
@Deprecated(since = "3.0.0", forRemoval = true) @Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings({ "deprecation", "removal" }) @SuppressWarnings("removal")
public class DefaultWebClientExchangeTagsProvider implements WebClientExchangeTagsProvider { public class DefaultWebClientExchangeTagsProvider implements WebClientExchangeTagsProvider {
@Override @Override

@ -41,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
@SuppressWarnings("removal") @SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class DefaultWebMvcTagsProviderTests { class DefaultWebMvcTagsProviderTests {
@Test @Test

@ -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"); * 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.
@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Michael McFadyen * @author Michael McFadyen
*/ */
@SuppressWarnings("removal") @SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class WebMvcTagsTests { class WebMvcTagsTests {
private final MockHttpServletRequest request = new MockHttpServletRequest(); private final MockHttpServletRequest request = new MockHttpServletRequest();

@ -30,7 +30,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Brian Clozel * @author Brian Clozel
*/ */
@SuppressWarnings("deprecation")
class ObservationWebClientCustomizerTests { class ObservationWebClientCustomizerTests {
private static final String TEST_METRIC_NAME = "http.test.metric.name"; private static final String TEST_METRIC_NAME = "http.test.metric.name";

@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
@SuppressWarnings("removal") @SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class DefaultWebFluxTagsProviderTests { class DefaultWebFluxTagsProviderTests {
@Test @Test

@ -45,6 +45,7 @@ import static org.mockito.Mockito.mock;
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@SuppressWarnings("removal") @SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
class WebFluxTagsTests { class WebFluxTagsTests {
private MockServerWebExchange exchange; private MockServerWebExchange exchange;

@ -180,7 +180,6 @@ public class GraphQlWebMvcAutoConfiguration {
} }
@Bean @Bean
@SuppressWarnings("deprecation")
public HandlerMapping graphQlWebSocketMapping(GraphQlWebSocketHandler handler, GraphQlProperties properties) { public HandlerMapping graphQlWebSocketMapping(GraphQlWebSocketHandler handler, GraphQlProperties properties) {
String path = properties.getWebsocket().getPath(); String path = properties.getWebsocket().getPath();
logger.info(LogMessage.format("GraphQL endpoint WebSocket %s", path)); logger.info(LogMessage.format("GraphQL endpoint WebSocket %s", path));

@ -423,7 +423,6 @@ class OAuth2ResourceServerAutoConfigurationTests {
.run((context) -> assertThat(context).doesNotHaveBean(OpaqueTokenIntrospector.class)); .run((context) -> assertThat(context).doesNotHaveBean(OpaqueTokenIntrospector.class));
} }
@SuppressWarnings("unchecked")
@Test @Test
void autoConfigurationShouldConfigureResourceServerUsingJwkSetUriAndIssuerUri() throws Exception { void autoConfigurationShouldConfigureResourceServerUsingJwkSetUriAndIssuerUri() throws Exception {
this.server = new MockWebServer(); this.server = new MockWebServer();
@ -445,7 +444,6 @@ class OAuth2ResourceServerAutoConfigurationTests {
}); });
} }
@SuppressWarnings("unchecked")
@Test @Test
void autoConfigurationShouldNotConfigureIssuerUriAndAudienceJwtValidatorIfPropertyNotConfigured() throws Exception { void autoConfigurationShouldNotConfigureIssuerUriAndAudienceJwtValidatorIfPropertyNotConfigured() throws Exception {
this.server = new MockWebServer(); this.server = new MockWebServer();
@ -523,7 +521,6 @@ class OAuth2ResourceServerAutoConfigurationTests {
validateDelegates(issuerUri, delegates); validateDelegates(issuerUri, delegates);
} }
@SuppressWarnings("unchecked")
private void validateDelegates(String issuerUri, Collection<OAuth2TokenValidator<Jwt>> delegates) { private void validateDelegates(String issuerUri, Collection<OAuth2TokenValidator<Jwt>> delegates) {
assertThat(delegates).hasAtLeastOneElementOfType(JwtClaimValidator.class); assertThat(delegates).hasAtLeastOneElementOfType(JwtClaimValidator.class);
OAuth2TokenValidator<Jwt> delegatingValidator = delegates.stream() OAuth2TokenValidator<Jwt> delegatingValidator = delegates.stream()

@ -99,8 +99,6 @@ public class LocalDevToolsAutoConfiguration {
@ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true) @ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true)
static class RestartConfiguration { static class RestartConfiguration {
private static final Log restarterLogger = LogFactory.getLog(Restarter.class);
private final DevToolsProperties properties; private final DevToolsProperties properties;
RestartConfiguration(DevToolsProperties properties) { RestartConfiguration(DevToolsProperties properties) {

@ -53,7 +53,7 @@ class SpringBootDependencyInjectionTestExecutionListenerTests {
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
void prepareFailingTestInstanceShouldPrintReport(CapturedOutput output) throws Exception { void prepareFailingTestInstanceShouldPrintReport(CapturedOutput output) throws Exception {
TestContext testContext = mock(TestContext.class); TestContext testContext = mock(TestContext.class);
given(testContext.getTestClass()).willReturn((Class) Config.class); given(testContext.getTestClass()).willReturn((Class) Config.class);
@ -73,7 +73,7 @@ class SpringBootDependencyInjectionTestExecutionListenerTests {
} }
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
void originalFailureIsThrownWhenReportGenerationFails() { void originalFailureIsThrownWhenReportGenerationFails() {
TestContext testContext = mock(TestContext.class); TestContext testContext = mock(TestContext.class);
given(testContext.getTestClass()).willReturn((Class) Config.class); given(testContext.getTestClass()).willReturn((Class) Config.class);

@ -17,7 +17,7 @@
package org.springframework.boot.test.autoconfigure.web.client; package org.springframework.boot.test.autoconfigure.web.client;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding; import org.springframework.boot.context.properties.bind.ConstructorBinding;
import org.springframework.boot.context.properties.bind.DefaultValue; import org.springframework.boot.context.properties.bind.DefaultValue;
/** /**

@ -39,7 +39,7 @@ import static org.junit.jupiter.api.Assertions.fail;
class AutoConfigureAnnotationProcessorTests { class AutoConfigureAnnotationProcessorTests {
@Test @Test
void annotatedClass() throws Exception { void annotatedClass() {
compile(TestClassConfiguration.class, (properties) -> { compile(TestClassConfiguration.class, (properties) -> {
assertThat(properties).hasSize(7); assertThat(properties).hasSize(7);
assertThat(properties).containsEntry( assertThat(properties).containsEntry(
@ -108,7 +108,7 @@ class AutoConfigureAnnotationProcessorTests {
} }
@Test @Test
void annotatedClassWithAutoConfiguration() throws Exception { void annotatedClassWithAutoConfiguration() {
compile(TestAutoConfigurationConfiguration.class, (properties) -> { compile(TestAutoConfigurationConfiguration.class, (properties) -> {
assertThat(properties).containsEntry( assertThat(properties).containsEntry(
"org.springframework.boot.autoconfigureprocessor.TestAutoConfigurationConfiguration", ""); "org.springframework.boot.autoconfigureprocessor.TestAutoConfigurationConfiguration", "");
@ -122,7 +122,7 @@ class AutoConfigureAnnotationProcessorTests {
} }
@Test @Test
void annotatedClassWithAutoConfigurationMerged() throws Exception { void annotatedClassWithAutoConfigurationMerged() {
compile(TestMergedAutoConfigurationConfiguration.class, (properties) -> { compile(TestMergedAutoConfigurationConfiguration.class, (properties) -> {
assertThat(properties).containsEntry( assertThat(properties).containsEntry(
"org.springframework.boot.autoconfigureprocessor.TestMergedAutoConfigurationConfiguration", ""); "org.springframework.boot.autoconfigureprocessor.TestMergedAutoConfigurationConfiguration", "");
@ -136,7 +136,7 @@ class AutoConfigureAnnotationProcessorTests {
} }
@Test // gh-19370 @Test // gh-19370
void propertiesAreFullRepeatable() throws Exception { void propertiesAreFullRepeatable() {
process(TestOrderedClassConfiguration.class, (firstFile) -> { process(TestOrderedClassConfiguration.class, (firstFile) -> {
String first = getFileContents(firstFile); String first = getFileContents(firstFile);
process(TestOrderedClassConfiguration.class, (secondFile) -> { process(TestOrderedClassConfiguration.class, (secondFile) -> {

@ -76,7 +76,7 @@ public class MetadataStore {
return readMetadata(getAdditionalMetadataStream()); return readMetadata(getAdditionalMetadataStream());
} }
private ConfigurationMetadata readMetadata(InputStream in) throws IOException { private ConfigurationMetadata readMetadata(InputStream in) {
try (in) { try (in) {
return new JsonMarshaller().read(in); return new JsonMarshaller().read(in);
} }

@ -16,8 +16,6 @@
package org.springframework.boot.configurationprocessor; package org.springframework.boot.configurationprocessor;
import java.io.IOException;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata; import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
@ -414,7 +412,7 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene
} }
@Test @Test
void recordProperties() throws IOException { void recordProperties() {
String source = """ String source = """
@org.springframework.boot.configurationsample.ConfigurationProperties("implicit") @org.springframework.boot.configurationsample.ConfigurationProperties("implicit")
public record ExampleRecord(String someString, Integer someInteger) { public record ExampleRecord(String someString, Integer someInteger) {
@ -426,7 +424,7 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene
} }
@Test @Test
void recordPropertiesWithDefaultValues() throws IOException { void recordPropertiesWithDefaultValues() {
String source = """ String source = """
@org.springframework.boot.configurationsample.ConfigurationProperties("record.defaults") @org.springframework.boot.configurationsample.ConfigurationProperties("record.defaults")
public record ExampleRecord( public record ExampleRecord(
@ -442,7 +440,7 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene
} }
@Test @Test
void multiConstructorRecordProperties() throws IOException { void multiConstructorRecordProperties() {
String source = """ String source = """
@org.springframework.boot.configurationsample.ConfigurationProperties("multi") @org.springframework.boot.configurationsample.ConfigurationProperties("multi")
public record ExampleRecord(String someString, Integer someInteger) { public record ExampleRecord(String someString, Integer someInteger) {

@ -16,7 +16,6 @@
package org.springframework.boot.configurationprocessor; package org.springframework.boot.configurationprocessor;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -44,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTests { class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTests {
@Test @Test
void constructorParameterSimpleProperty() throws IOException { void constructorParameterSimpleProperty() {
process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class);
ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName"); ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName");
@ -57,7 +56,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterNestedPropertySameClass() throws IOException { void constructorParameterNestedPropertySameClass() {
process(ImmutableInnerClassProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableInnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableInnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableInnerClassProperties.class);
ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first"); ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first");
@ -70,7 +69,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterNestedPropertyWithAnnotation() throws IOException { void constructorParameterNestedPropertyWithAnnotation() {
process(ImmutableInnerClassProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableInnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableInnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableInnerClassProperties.class);
ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "third"); ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "third");
@ -83,7 +82,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterSimplePropertyWithNoAccessorShouldBeExposed() throws IOException { void constructorParameterSimplePropertyWithNoAccessorShouldBeExposed() {
process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class);
ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "counter"); ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "counter");
@ -96,7 +95,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterMetadataSimpleProperty() throws IOException { void constructorParameterMetadataSimpleProperty() {
process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class);
ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "counter"); ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "counter");
@ -106,7 +105,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterMetadataNestedGroup() throws IOException { void constructorParameterMetadataNestedGroup() {
process(ImmutableInnerClassProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableInnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableInnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableInnerClassProperties.class);
ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first"); ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first");
@ -118,7 +117,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterDeprecatedPropertyOnGetter() throws IOException { void constructorParameterDeprecatedPropertyOnGetter() {
process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class);
ExecutableElement getter = getMethod(ownerElement, "isFlag"); ExecutableElement getter = getMethod(ownerElement, "isFlag");
@ -131,7 +130,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterPropertyWithDescription() throws IOException { void constructorParameterPropertyWithDescription() {
process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class);
ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName"); ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName");
@ -141,7 +140,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterPropertyWithDefaultValue() throws IOException { void constructorParameterPropertyWithDefaultValue() {
process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableSimpleProperties.class);
ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName"); ConstructorParameterPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName");
@ -150,7 +149,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterPropertyWithPrimitiveTypes() throws IOException { void constructorParameterPropertyWithPrimitiveTypes() {
process(ImmutablePrimitiveProperties.class, (roundEnv, metadataEnv) -> { process(ImmutablePrimitiveProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutablePrimitiveProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutablePrimitiveProperties.class);
assertItemMetadata(metadataEnv, createPropertyDescriptor(ownerElement, "flag")).hasDefaultValue(false); assertItemMetadata(metadataEnv, createPropertyDescriptor(ownerElement, "flag")).hasDefaultValue(false);
@ -166,7 +165,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterPropertyWithPrimitiveTypesAndDefaultValues() throws IOException { void constructorParameterPropertyWithPrimitiveTypesAndDefaultValues() {
process(ImmutablePrimitiveWithDefaultsProperties.class, (roundEnv, metadataEnv) -> { process(ImmutablePrimitiveWithDefaultsProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutablePrimitiveWithDefaultsProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutablePrimitiveWithDefaultsProperties.class);
assertItemMetadata(metadataEnv, createPropertyDescriptor(ownerElement, "flag")).hasDefaultValue(true); assertItemMetadata(metadataEnv, createPropertyDescriptor(ownerElement, "flag")).hasDefaultValue(true);
@ -183,7 +182,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterPropertyWithPrimitiveWrapperTypesAndDefaultValues() throws IOException { void constructorParameterPropertyWithPrimitiveWrapperTypesAndDefaultValues() {
process(ImmutablePrimitiveWrapperWithDefaultsProperties.class, (roundEnv, metadataEnv) -> { process(ImmutablePrimitiveWrapperWithDefaultsProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutablePrimitiveWrapperWithDefaultsProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutablePrimitiveWrapperWithDefaultsProperties.class);
assertItemMetadata(metadataEnv, createPropertyDescriptor(ownerElement, "flag")).hasDefaultValue(true); assertItemMetadata(metadataEnv, createPropertyDescriptor(ownerElement, "flag")).hasDefaultValue(true);
@ -200,7 +199,7 @@ class ConstructorParameterPropertyDescriptorTests extends PropertyDescriptorTest
} }
@Test @Test
void constructorParameterPropertyWithCollectionTypesAndDefaultValues() throws IOException { void constructorParameterPropertyWithCollectionTypesAndDefaultValues() {
process(ImmutableCollectionProperties.class, (roundEnv, metadataEnv) -> { process(ImmutableCollectionProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(ImmutableCollectionProperties.class); TypeElement ownerElement = roundEnv.getRootElement(ImmutableCollectionProperties.class);
assertItemMetadata(metadataEnv, createPropertyDescriptor(ownerElement, "names")).hasDefaultValue(null); assertItemMetadata(metadataEnv, createPropertyDescriptor(ownerElement, "names")).hasDefaultValue(null);

@ -96,7 +96,7 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
} }
@Test @Test
void incrementalEndpointBuildChangeGeneralEnabledFlag() throws Exception { void incrementalEndpointBuildChangeGeneralEnabledFlag() {
TestProject project = new TestProject(IncrementalEndpoint.class); TestProject project = new TestProject(IncrementalEndpoint.class);
ConfigurationMetadata metadata = project.compile(); ConfigurationMetadata metadata = project.compile();
assertThat(metadata) assertThat(metadata)
@ -115,7 +115,7 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
} }
@Test @Test
void incrementalEndpointBuildChangeCacheFlag() throws Exception { void incrementalEndpointBuildChangeCacheFlag() {
TestProject project = new TestProject(IncrementalEndpoint.class); TestProject project = new TestProject(IncrementalEndpoint.class);
ConfigurationMetadata metadata = project.compile(); ConfigurationMetadata metadata = project.compile();
assertThat(metadata) assertThat(metadata)
@ -132,7 +132,7 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
} }
@Test @Test
void incrementalEndpointBuildEnableSpecificEndpoint() throws Exception { void incrementalEndpointBuildEnableSpecificEndpoint() {
TestProject project = new TestProject(SpecificEndpoint.class); TestProject project = new TestProject(SpecificEndpoint.class);
ConfigurationMetadata metadata = project.compile(); ConfigurationMetadata metadata = project.compile();
assertThat(metadata).has(Metadata.withGroup("management.endpoint.specific").fromSource(SpecificEndpoint.class)); assertThat(metadata).has(Metadata.withGroup("management.endpoint.specific").fromSource(SpecificEndpoint.class));

@ -62,7 +62,7 @@ class IncrementalBuildMetadataGenerationTests extends AbstractMetadataGeneration
} }
@Test @Test
void incrementalBuildAnnotationRemoved() throws Exception { void incrementalBuildAnnotationRemoved() {
TestProject project = new TestProject(FooProperties.class, BarProperties.class); TestProject project = new TestProject(FooProperties.class, BarProperties.class);
ConfigurationMetadata metadata = project.compile(); ConfigurationMetadata metadata = project.compile();
assertThat(metadata).has(Metadata.withProperty("foo.counter").withDefaultValue(0)); assertThat(metadata).has(Metadata.withProperty("foo.counter").withDefaultValue(0));
@ -75,7 +75,7 @@ class IncrementalBuildMetadataGenerationTests extends AbstractMetadataGeneration
@Test @Test
@Disabled("gh-26271") @Disabled("gh-26271")
void incrementalBuildTypeRenamed() throws Exception { void incrementalBuildTypeRenamed() {
TestProject project = new TestProject(FooProperties.class, BarProperties.class); TestProject project = new TestProject(FooProperties.class, BarProperties.class);
ConfigurationMetadata metadata = project.compile(); ConfigurationMetadata metadata = project.compile();
assertThat(metadata) assertThat(metadata)
@ -95,7 +95,7 @@ class IncrementalBuildMetadataGenerationTests extends AbstractMetadataGeneration
} }
@Test @Test
void incrementalBuildDoesNotDeleteItems() throws Exception { void incrementalBuildDoesNotDeleteItems() {
TestProject project = new TestProject(ClassWithNestedProperties.class, FooProperties.class); TestProject project = new TestProject(ClassWithNestedProperties.class, FooProperties.class);
ConfigurationMetadata initialMetadata = project.compile(); ConfigurationMetadata initialMetadata = project.compile();
ConfigurationMetadata updatedMetadata = project.compile(); ConfigurationMetadata updatedMetadata = project.compile();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2022 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.
@ -16,8 +16,6 @@
package org.springframework.boot.configurationprocessor; package org.springframework.boot.configurationprocessor;
import java.io.IOException;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement; import javax.lang.model.element.VariableElement;
@ -40,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests { class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
@Test @Test
void javaBeanSimpleProperty() throws IOException { void javaBeanSimpleProperty() {
process(SimpleTypeProperties.class, (roundEnv, metadataEnv) -> { process(SimpleTypeProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleTypeProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleTypeProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "myString"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "myString");
@ -54,7 +52,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanCollectionProperty() throws IOException { void javaBeanCollectionProperty() {
process(SimpleCollectionProperties.class, (roundEnv, metadataEnv) -> { process(SimpleCollectionProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleCollectionProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleCollectionProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "doubles"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "doubles");
@ -67,7 +65,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanNestedPropertySameClass() throws IOException { void javaBeanNestedPropertySameClass() {
process(InnerClassProperties.class, (roundEnv, metadataEnv) -> { process(InnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(InnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(InnerClassProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first");
@ -80,7 +78,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanNestedPropertyWithAnnotation() throws IOException { void javaBeanNestedPropertyWithAnnotation() {
process(InnerClassProperties.class, (roundEnv, metadataEnv) -> { process(InnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(InnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(InnerClassProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "third"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "third");
@ -93,7 +91,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanSimplePropertyWithOnlyGetterShouldNotBeExposed() throws IOException { void javaBeanSimplePropertyWithOnlyGetterShouldNotBeExposed() {
process(SimpleProperties.class, (roundEnv, metadataEnv) -> { process(SimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class);
ExecutableElement getter = getMethod(ownerElement, "getSize"); ExecutableElement getter = getMethod(ownerElement, "getSize");
@ -110,7 +108,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanSimplePropertyWithOnlySetterShouldNotBeExposed() throws IOException { void javaBeanSimplePropertyWithOnlySetterShouldNotBeExposed() {
process(SimpleProperties.class, (roundEnv, metadataEnv) -> { process(SimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class);
VariableElement field = getField(ownerElement, "counter"); VariableElement field = getField(ownerElement, "counter");
@ -126,7 +124,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanMetadataSimpleProperty() throws IOException { void javaBeanMetadataSimpleProperty() {
process(SimpleTypeProperties.class, (roundEnv, metadataEnv) -> { process(SimpleTypeProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleTypeProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleTypeProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "myString"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "myString");
@ -136,7 +134,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanMetadataCollectionProperty() throws IOException { void javaBeanMetadataCollectionProperty() {
process(SimpleCollectionProperties.class, (roundEnv, metadataEnv) -> { process(SimpleCollectionProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleCollectionProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleCollectionProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "doubles"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "doubles");
@ -147,7 +145,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanMetadataNestedGroup() throws IOException { void javaBeanMetadataNestedGroup() {
process(InnerClassProperties.class, (roundEnv, metadataEnv) -> { process(InnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(InnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(InnerClassProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first");
@ -159,7 +157,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanMetadataNotACandidatePropertyShouldReturnNull() throws IOException { void javaBeanMetadataNotACandidatePropertyShouldReturnNull() {
process(SimpleProperties.class, (roundEnv, metadataEnv) -> { process(SimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class);
VariableElement field = getField(ownerElement, "counter"); VariableElement field = getField(ownerElement, "counter");
@ -171,7 +169,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
void javaBeanDeprecatedPropertyOnClass() throws IOException { void javaBeanDeprecatedPropertyOnClass() {
process(org.springframework.boot.configurationsample.simple.DeprecatedProperties.class, process(org.springframework.boot.configurationsample.simple.DeprecatedProperties.class,
(roundEnv, metadataEnv) -> { (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement( TypeElement ownerElement = roundEnv.getRootElement(
@ -182,7 +180,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanMetadataDeprecatedPropertyWithAnnotation() throws IOException { void javaBeanMetadataDeprecatedPropertyWithAnnotation() {
process(DeprecatedSingleProperty.class, (roundEnv, metadataEnv) -> { process(DeprecatedSingleProperty.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(DeprecatedSingleProperty.class); TypeElement ownerElement = roundEnv.getRootElement(DeprecatedSingleProperty.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "name"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "name");
@ -192,7 +190,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanDeprecatedPropertyOnGetter() throws IOException { void javaBeanDeprecatedPropertyOnGetter() {
process(SimpleProperties.class, (roundEnv, metadataEnv) -> { process(SimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "flag", "isFlag", "setFlag"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "flag", "isFlag", "setFlag");
@ -201,7 +199,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanDeprecatedPropertyOnSetter() throws IOException { void javaBeanDeprecatedPropertyOnSetter() {
process(SimpleProperties.class, (roundEnv, metadataEnv) -> { process(SimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName");
@ -210,7 +208,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanPropertyWithDescription() throws IOException { void javaBeanPropertyWithDescription() {
process(SimpleProperties.class, (roundEnv, metadataEnv) -> { process(SimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName");
@ -220,7 +218,7 @@ class JavaBeanPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void javaBeanPropertyWithDefaultValue() throws IOException { void javaBeanPropertyWithDefaultValue() {
process(SimpleProperties.class, (roundEnv, metadataEnv) -> { process(SimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class);
JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName"); JavaBeanPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName");

@ -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"); * 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.
@ -16,8 +16,6 @@
package org.springframework.boot.configurationprocessor; package org.springframework.boot.configurationprocessor;
import java.io.IOException;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement; import javax.lang.model.element.VariableElement;
@ -44,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class LombokPropertyDescriptorTests extends PropertyDescriptorTests { class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
@Test @Test
void lombokSimpleProperty() throws IOException { void lombokSimpleProperty() {
process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "name"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "name");
@ -57,7 +55,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokCollectionProperty() throws IOException { void lombokCollectionProperty() {
process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "items"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "items");
@ -70,7 +68,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokNestedPropertySameClass() throws IOException { void lombokNestedPropertySameClass() {
process(LombokInnerClassProperties.class, (roundEnv, metadataEnv) -> { process(LombokInnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokInnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokInnerClassProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first");
@ -83,7 +81,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokNestedPropertyWithAnnotation() throws IOException { void lombokNestedPropertyWithAnnotation() {
process(LombokInnerClassProperties.class, (roundEnv, metadataEnv) -> { process(LombokInnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokInnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokInnerClassProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "third"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "third");
@ -96,7 +94,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokSimplePropertyWithOnlyGetterOnClassShouldNotBeExposed() throws IOException { void lombokSimplePropertyWithOnlyGetterOnClassShouldNotBeExposed() {
process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignored"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignored");
@ -106,7 +104,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokSimplePropertyWithOnlyGetterOnDataClassShouldNotBeExposed() throws IOException { void lombokSimplePropertyWithOnlyGetterOnDataClassShouldNotBeExposed() {
process(LombokSimpleDataProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleDataProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleDataProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleDataProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignored"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignored");
@ -116,7 +114,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokSimplePropertyWithOnlyGetterOnValueClassShouldNotBeExposed() throws IOException { void lombokSimplePropertyWithOnlyGetterOnValueClassShouldNotBeExposed() {
process(LombokSimpleValueProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleValueProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleValueProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleValueProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignored"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignored");
@ -126,7 +124,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokSimplePropertyWithOnlyGetterOnFieldShouldNotBeExposed() throws IOException { void lombokSimplePropertyWithOnlyGetterOnFieldShouldNotBeExposed() {
process(LombokExplicitProperties.class, (roundEnv, metadataEnv) -> { process(LombokExplicitProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokExplicitProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokExplicitProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignoredOnlyGetter"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignoredOnlyGetter");
@ -136,7 +134,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokSimplePropertyWithOnlySetterOnFieldShouldNotBeExposed() throws IOException { void lombokSimplePropertyWithOnlySetterOnFieldShouldNotBeExposed() {
process(LombokExplicitProperties.class, (roundEnv, metadataEnv) -> { process(LombokExplicitProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokExplicitProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokExplicitProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignoredOnlySetter"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignoredOnlySetter");
@ -146,7 +144,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokMetadataSimpleProperty() throws IOException { void lombokMetadataSimpleProperty() {
process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "description"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "description");
@ -156,7 +154,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokMetadataCollectionProperty() throws IOException { void lombokMetadataCollectionProperty() {
process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "items"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "items");
@ -167,7 +165,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokMetadataNestedGroup() throws IOException { void lombokMetadataNestedGroup() {
process(LombokInnerClassProperties.class, (roundEnv, metadataEnv) -> { process(LombokInnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokInnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokInnerClassProperties.class);
VariableElement field = getField(ownerElement, "third"); VariableElement field = getField(ownerElement, "third");
@ -182,7 +180,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokMetadataNestedGroupNoGetter() throws IOException { void lombokMetadataNestedGroupNoGetter() {
process(LombokInnerClassProperties.class, (roundEnv, metadataEnv) -> { process(LombokInnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokInnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokInnerClassProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first");
@ -194,7 +192,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokMetadataNotACandidatePropertyShouldReturnNull() throws IOException { void lombokMetadataNotACandidatePropertyShouldReturnNull() {
process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignored"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "ignored");
@ -204,7 +202,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
@Test @Test
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
void lombokDeprecatedPropertyOnClass() throws IOException { void lombokDeprecatedPropertyOnClass() {
process(org.springframework.boot.configurationsample.lombok.LombokDeprecatedProperties.class, process(org.springframework.boot.configurationsample.lombok.LombokDeprecatedProperties.class,
(roundEnv, metadataEnv) -> { (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement( TypeElement ownerElement = roundEnv.getRootElement(
@ -215,7 +213,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokDeprecatedPropertyOnField() throws IOException { void lombokDeprecatedPropertyOnField() {
process(LombokDeprecatedSingleProperty.class, (roundEnv, metadataEnv) -> { process(LombokDeprecatedSingleProperty.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokDeprecatedSingleProperty.class); TypeElement ownerElement = roundEnv.getRootElement(LombokDeprecatedSingleProperty.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "name"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "name");
@ -224,7 +222,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokPropertyWithDescription() throws IOException { void lombokPropertyWithDescription() {
process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> { process(LombokSimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokSimpleProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "name"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "name");
@ -233,7 +231,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokPropertyWithDefaultValue() throws IOException { void lombokPropertyWithDefaultValue() {
process(LombokDefaultValueProperties.class, (roundEnv, metadataEnv) -> { process(LombokDefaultValueProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(LombokDefaultValueProperties.class); TypeElement ownerElement = roundEnv.getRootElement(LombokDefaultValueProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "description"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "description");
@ -242,7 +240,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokPropertyNotCandidate() throws IOException { void lombokPropertyNotCandidate() {
process(SimpleProperties.class, (roundEnv, metadataEnv) -> { process(SimpleProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class); TypeElement ownerElement = roundEnv.getRootElement(SimpleProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "theName");
@ -252,7 +250,7 @@ class LombokPropertyDescriptorTests extends PropertyDescriptorTests {
} }
@Test @Test
void lombokNestedPropertyNotCandidate() throws IOException { void lombokNestedPropertyNotCandidate() {
process(InnerClassProperties.class, (roundEnv, metadataEnv) -> { process(InnerClassProperties.class, (roundEnv, metadataEnv) -> {
TypeElement ownerElement = roundEnv.getRootElement(InnerClassProperties.class); TypeElement ownerElement = roundEnv.getRootElement(InnerClassProperties.class);
LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first"); LombokPropertyDescriptor property = createPropertyDescriptor(ownerElement, "first");

@ -16,7 +16,6 @@
package org.springframework.boot.configurationprocessor; package org.springframework.boot.configurationprocessor;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -149,7 +148,7 @@ class MergeMetadataGenerationTests extends AbstractMetadataGenerationTests {
} }
@Test @Test
void mergeOfInvalidAdditionalMetadata() throws IOException { void mergeOfInvalidAdditionalMetadata() {
String metadata = "Hello World"; String metadata = "Hello World";
assertThatExceptionOfType(CompilationException.class) assertThatExceptionOfType(CompilationException.class)
.isThrownBy(() -> compile(metadata, SimpleProperties.class)) .isThrownBy(() -> compile(metadata, SimpleProperties.class))

@ -16,7 +16,6 @@
package org.springframework.boot.configurationprocessor; package org.springframework.boot.configurationprocessor;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -32,7 +31,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.configurationprocessor.metadata.ItemMetadata; import org.springframework.boot.configurationprocessor.metadata.ItemMetadata;
import org.springframework.boot.configurationprocessor.test.RoundEnvironmentTester; import org.springframework.boot.configurationprocessor.test.RoundEnvironmentTester;
import org.springframework.boot.configurationprocessor.test.TestableAnnotationProcessor; import org.springframework.boot.configurationprocessor.test.TestableAnnotationProcessor;
import org.springframework.boot.configurationsample.immutable.DeprecatedImmutableMultiConstructorProperties;
import org.springframework.boot.configurationsample.immutable.ImmutableClassConstructorBindingProperties; import org.springframework.boot.configurationsample.immutable.ImmutableClassConstructorBindingProperties;
import org.springframework.boot.configurationsample.immutable.ImmutableDeducedConstructorBindingProperties; import org.springframework.boot.configurationsample.immutable.ImmutableDeducedConstructorBindingProperties;
import org.springframework.boot.configurationsample.immutable.ImmutableMultiConstructorProperties; import org.springframework.boot.configurationsample.immutable.ImmutableMultiConstructorProperties;
@ -62,13 +60,13 @@ import static org.assertj.core.api.Assertions.assertThat;
class PropertyDescriptorResolverTests { class PropertyDescriptorResolverTests {
@Test @Test
void propertiesWithJavaBeanProperties() throws IOException { void propertiesWithJavaBeanProperties() {
process(SimpleProperties.class, process(SimpleProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("theName", "flag", "comparator"))); propertyNames((stream) -> assertThat(stream).containsExactly("theName", "flag", "comparator")));
} }
@Test @Test
void propertiesWithJavaBeanHierarchicalProperties() throws IOException { void propertiesWithJavaBeanHierarchicalProperties() {
process(HierarchicalProperties.class, process(HierarchicalProperties.class,
Arrays.asList(HierarchicalPropertiesParent.class, HierarchicalPropertiesGrandparent.class), Arrays.asList(HierarchicalPropertiesParent.class, HierarchicalPropertiesGrandparent.class),
(type, metadataEnv) -> { (type, metadataEnv) -> {
@ -86,31 +84,31 @@ class PropertyDescriptorResolverTests {
} }
@Test @Test
void propertiesWithLombokGetterSetterAtClassLevel() throws IOException { void propertiesWithLombokGetterSetterAtClassLevel() {
process(LombokSimpleProperties.class, propertyNames( process(LombokSimpleProperties.class, propertyNames(
(stream) -> assertThat(stream).containsExactly("name", "description", "counter", "number", "items"))); (stream) -> assertThat(stream).containsExactly("name", "description", "counter", "number", "items")));
} }
@Test @Test
void propertiesWithLombokGetterSetterAtFieldLevel() throws IOException { void propertiesWithLombokGetterSetterAtFieldLevel() {
process(LombokExplicitProperties.class, propertyNames( process(LombokExplicitProperties.class, propertyNames(
(stream) -> assertThat(stream).containsExactly("name", "description", "counter", "number", "items"))); (stream) -> assertThat(stream).containsExactly("name", "description", "counter", "number", "items")));
} }
@Test @Test
void propertiesWithLombokDataClass() throws IOException { void propertiesWithLombokDataClass() {
process(LombokSimpleDataProperties.class, propertyNames( process(LombokSimpleDataProperties.class, propertyNames(
(stream) -> assertThat(stream).containsExactly("name", "description", "counter", "number", "items"))); (stream) -> assertThat(stream).containsExactly("name", "description", "counter", "number", "items")));
} }
@Test @Test
void propertiesWithLombokValueClass() throws IOException { void propertiesWithLombokValueClass() {
process(LombokSimpleValueProperties.class, propertyNames( process(LombokSimpleValueProperties.class, propertyNames(
(stream) -> assertThat(stream).containsExactly("name", "description", "counter", "number", "items"))); (stream) -> assertThat(stream).containsExactly("name", "description", "counter", "number", "items")));
} }
@Test @Test
void propertiesWithDeducedConstructorBinding() throws IOException { void propertiesWithDeducedConstructorBinding() {
process(ImmutableDeducedConstructorBindingProperties.class, process(ImmutableDeducedConstructorBindingProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("theName", "flag"))); propertyNames((stream) -> assertThat(stream).containsExactly("theName", "flag")));
process(ImmutableDeducedConstructorBindingProperties.class, properties((stream) -> assertThat(stream) process(ImmutableDeducedConstructorBindingProperties.class, properties((stream) -> assertThat(stream)
@ -118,7 +116,7 @@ class PropertyDescriptorResolverTests {
} }
@Test @Test
void propertiesWithConstructorWithConstructorBinding() throws IOException { void propertiesWithConstructorWithConstructorBinding() {
process(ImmutableSimpleProperties.class, propertyNames( process(ImmutableSimpleProperties.class, propertyNames(
(stream) -> assertThat(stream).containsExactly("theName", "flag", "comparator", "counter"))); (stream) -> assertThat(stream).containsExactly("theName", "flag", "comparator", "counter")));
process(ImmutableSimpleProperties.class, properties((stream) -> assertThat(stream) process(ImmutableSimpleProperties.class, properties((stream) -> assertThat(stream)
@ -126,7 +124,7 @@ class PropertyDescriptorResolverTests {
} }
@Test @Test
void propertiesWithConstructorAndClassConstructorBinding() throws IOException { void propertiesWithConstructorAndClassConstructorBinding() {
process(ImmutableClassConstructorBindingProperties.class, process(ImmutableClassConstructorBindingProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("name", "description"))); propertyNames((stream) -> assertThat(stream).containsExactly("name", "description")));
process(ImmutableClassConstructorBindingProperties.class, properties((stream) -> assertThat(stream) process(ImmutableClassConstructorBindingProperties.class, properties((stream) -> assertThat(stream)
@ -134,14 +132,14 @@ class PropertyDescriptorResolverTests {
} }
@Test @Test
void propertiesWithAutowiredConstructor() throws IOException { void propertiesWithAutowiredConstructor() {
process(AutowiredProperties.class, propertyNames((stream) -> assertThat(stream).containsExactly("theName"))); process(AutowiredProperties.class, propertyNames((stream) -> assertThat(stream).containsExactly("theName")));
process(AutowiredProperties.class, properties((stream) -> assertThat(stream) process(AutowiredProperties.class, properties((stream) -> assertThat(stream)
.allMatch((predicate) -> predicate instanceof JavaBeanPropertyDescriptor))); .allMatch((predicate) -> predicate instanceof JavaBeanPropertyDescriptor)));
} }
@Test @Test
void propertiesWithMultiConstructor() throws IOException { void propertiesWithMultiConstructor() {
process(ImmutableMultiConstructorProperties.class, process(ImmutableMultiConstructorProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("name", "description"))); propertyNames((stream) -> assertThat(stream).containsExactly("name", "description")));
process(ImmutableMultiConstructorProperties.class, properties((stream) -> assertThat(stream) process(ImmutableMultiConstructorProperties.class, properties((stream) -> assertThat(stream)
@ -151,22 +149,23 @@ class PropertyDescriptorResolverTests {
@Test @Test
@Deprecated(since = "3.0.0", forRemoval = true) @Deprecated(since = "3.0.0", forRemoval = true)
@SuppressWarnings("removal") @SuppressWarnings("removal")
void propertiesWithMultiConstructorAndDeprecatedAnnotation() throws IOException { void propertiesWithMultiConstructorAndDeprecatedAnnotation() {
process(DeprecatedImmutableMultiConstructorProperties.class, process(org.springframework.boot.configurationsample.immutable.DeprecatedImmutableMultiConstructorProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("name", "description"))); propertyNames((stream) -> assertThat(stream).containsExactly("name", "description")));
process(DeprecatedImmutableMultiConstructorProperties.class, properties((stream) -> assertThat(stream) process(org.springframework.boot.configurationsample.immutable.DeprecatedImmutableMultiConstructorProperties.class,
.allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor))); properties((stream) -> assertThat(stream)
.allMatch((predicate) -> predicate instanceof ConstructorParameterPropertyDescriptor)));
} }
@Test @Test
void propertiesWithMultiConstructorNoDirective() throws IOException { void propertiesWithMultiConstructorNoDirective() {
process(TwoConstructorsExample.class, propertyNames((stream) -> assertThat(stream).containsExactly("name"))); process(TwoConstructorsExample.class, propertyNames((stream) -> assertThat(stream).containsExactly("name")));
process(TwoConstructorsExample.class, process(TwoConstructorsExample.class,
properties((stream) -> assertThat(stream).element(0).isInstanceOf(JavaBeanPropertyDescriptor.class))); properties((stream) -> assertThat(stream).element(0).isInstanceOf(JavaBeanPropertyDescriptor.class)));
} }
@Test @Test
void propertiesWithNameAnnotationParameter() throws IOException { void propertiesWithNameAnnotationParameter() {
process(ImmutableNameAnnotationProperties.class, process(ImmutableNameAnnotationProperties.class,
propertyNames((stream) -> assertThat(stream).containsExactly("import"))); propertyNames((stream) -> assertThat(stream).containsExactly("import")));
} }
@ -183,8 +182,7 @@ class PropertyDescriptorResolverTests {
return properties((result) -> stream.accept(result.map(PropertyDescriptor::getName))); return properties((result) -> stream.accept(result.map(PropertyDescriptor::getName)));
} }
private void process(Class<?> target, BiConsumer<TypeElement, MetadataGenerationEnvironment> consumer) private void process(Class<?> target, BiConsumer<TypeElement, MetadataGenerationEnvironment> consumer) {
throws IOException {
process(target, Collections.emptyList(), consumer); process(target, Collections.emptyList(), consumer);
} }

@ -16,7 +16,6 @@
package org.springframework.boot.configurationprocessor; package org.springframework.boot.configurationprocessor;
import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
@ -42,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class TypeUtilsTests { class TypeUtilsTests {
@Test @Test
void resolveTypeDescriptorOnConcreteClass() throws IOException { void resolveTypeDescriptorOnConcreteClass() {
process(SimpleGenericProperties.class, (roundEnv, typeUtils) -> { process(SimpleGenericProperties.class, (roundEnv, typeUtils) -> {
TypeDescriptor typeDescriptor = typeUtils TypeDescriptor typeDescriptor = typeUtils
.resolveTypeDescriptor(roundEnv.getRootElement(SimpleGenericProperties.class)); .resolveTypeDescriptor(roundEnv.getRootElement(SimpleGenericProperties.class));
@ -56,7 +55,7 @@ class TypeUtilsTests {
} }
@Test @Test
void resolveTypeDescriptorOnIntermediateClass() throws IOException { void resolveTypeDescriptorOnIntermediateClass() {
process(AbstractIntermediateGenericProperties.class, (roundEnv, typeUtils) -> { process(AbstractIntermediateGenericProperties.class, (roundEnv, typeUtils) -> {
TypeDescriptor typeDescriptor = typeUtils TypeDescriptor typeDescriptor = typeUtils
.resolveTypeDescriptor(roundEnv.getRootElement(AbstractIntermediateGenericProperties.class)); .resolveTypeDescriptor(roundEnv.getRootElement(AbstractIntermediateGenericProperties.class));
@ -69,7 +68,7 @@ class TypeUtilsTests {
} }
@Test @Test
void resolveTypeDescriptorWithOnlyGenerics() throws IOException { void resolveTypeDescriptorWithOnlyGenerics() {
process(AbstractGenericProperties.class, (roundEnv, typeUtils) -> { process(AbstractGenericProperties.class, (roundEnv, typeUtils) -> {
TypeDescriptor typeDescriptor = typeUtils TypeDescriptor typeDescriptor = typeUtils
.resolveTypeDescriptor(roundEnv.getRootElement(AbstractGenericProperties.class)); .resolveTypeDescriptor(roundEnv.getRootElement(AbstractGenericProperties.class));

@ -16,7 +16,6 @@
package org.springframework.boot.logging.logback; package org.springframework.boot.logging.logback;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -49,7 +48,7 @@ class LogbackRuntimeHintsTests {
} }
@Test @Test
void registersHintsForBuiltInLogbackConverters() throws Exception { void registersHintsForBuiltInLogbackConverters() {
ReflectionHints reflection = registerHints(); ReflectionHints reflection = registerHints();
assertThat(logbackConverters()).allSatisfy(registeredForPublicConstructorInvocation(reflection)); assertThat(logbackConverters()).allSatisfy(registeredForPublicConstructorInvocation(reflection));
} }
@ -84,7 +83,7 @@ class LogbackRuntimeHintsTests {
}; };
} }
private List<Class<?>> logbackConverters() throws IOException { private List<Class<?>> logbackConverters() {
return List.of(DateTokenConverter.class, IntegerTokenConverter.class, SyslogStartConverter.class); return List.of(DateTokenConverter.class, IntegerTokenConverter.class, SyslogStartConverter.class);
} }

@ -21,7 +21,6 @@ import java.util.List;
import ch.qos.logback.core.Context; import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase; import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.joran.spi.ActionException;
import ch.qos.logback.core.model.processor.ModelHandlerException; import ch.qos.logback.core.model.processor.ModelHandlerException;
import ch.qos.logback.core.model.processor.ModelInterpretationContext; import ch.qos.logback.core.model.processor.ModelInterpretationContext;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -56,7 +55,7 @@ class SpringProfileModelHandlerTests {
} }
@Test @Test
void environmentIsQueriedWithProfileFromModelName() throws ActionException, ModelHandlerException { void environmentIsQueriedWithProfileFromModelName() throws ModelHandlerException {
SpringProfileModel model = new SpringProfileModel(); SpringProfileModel model = new SpringProfileModel();
model.setName("dev"); model.setName("dev");
this.action.handle(this.interpretationContext, model); this.action.handle(this.interpretationContext, model);

@ -68,7 +68,7 @@ class PaketoBuilderTests {
GradleBuild gradleBuild; GradleBuild gradleBuild;
@BeforeEach @BeforeEach
void configureGradleBuild() throws IOException { void configureGradleBuild() {
this.gradleBuild.scriptProperty("systemTestMavenRepository", this.gradleBuild.scriptProperty("systemTestMavenRepository",
new File("build/system-test-maven-repository").getAbsoluteFile().toURI().toASCIIString()); new File("build/system-test-maven-repository").getAbsoluteFile().toURI().toASCIIString());
this.gradleBuild.scriptPropertyFrom(new File("../../gradle.properties"), "nativeBuildToolsVersion"); this.gradleBuild.scriptPropertyFrom(new File("../../gradle.properties"), "nativeBuildToolsVersion");

@ -83,7 +83,6 @@ public class SampleSessionMongoApplicationTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
void health() { void health() {
ResponseEntity<String> entity = this.restTemplate ResponseEntity<String> entity = this.restTemplate
.getForEntity("http://localhost:" + this.port + "/actuator/health", String.class); .getForEntity("http://localhost:" + this.port + "/actuator/health", String.class);
@ -111,7 +110,7 @@ public class SampleSessionMongoApplicationTests {
private ResponseEntity<Map<String, Object>> getSessions() { private ResponseEntity<Map<String, Object>> getSessions() {
RequestEntity<Object> request = getRequestEntity(URI.create("/actuator/sessions?username=user")); RequestEntity<Object> request = getRequestEntity(URI.create("/actuator/sessions?username=user"));
ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<Map<String, Object>>() { ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<>() {
}; };
return this.restTemplate.exchange(request, stringObjectMap); return this.restTemplate.exchange(request, stringObjectMap);
} }

Loading…
Cancel
Save