This commit is contained in:
Andy Wilkinson
2022-10-25 12:25:03 +01:00
parent b014039a34
commit 99edda735e
42 changed files with 125 additions and 149 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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