use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessorTests method singleDeprecatedFieldProperty.
@Test
void singleDeprecatedFieldProperty() {
Class<?> type = DeprecatedFieldSingleProperty.class;
ConfigurationMetadata metadata = compile(type);
assertThat(metadata).has(Metadata.withGroup("singlefielddeprecated").fromSource(type));
assertThat(metadata).has(Metadata.withProperty("singlefielddeprecated.name", String.class).fromSource(type).withDeprecation(null, null));
}
use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessorTests method deprecatedWithLessPreciseType.
@Test
void deprecatedWithLessPreciseType() {
Class<?> type = DeprecatedLessPreciseTypePojo.class;
ConfigurationMetadata metadata = compile(type);
assertThat(metadata).has(Metadata.withGroup("not.deprecated").fromSource(type));
assertThat(metadata).has(Metadata.withProperty("not.deprecated.flag", Boolean.class).withDefaultValue(false).withNoDeprecation().fromSource(type));
}
use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessorTests method annotatedGetter.
@Test
void annotatedGetter() {
ConfigurationMetadata metadata = compile(AnnotatedGetter.class);
assertThat(metadata).has(Metadata.withGroup("specific").fromSource(AnnotatedGetter.class));
assertThat(metadata).has(Metadata.withProperty("specific.name", String.class).fromSource(AnnotatedGetter.class));
}
use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessorTests method doubleRegistration.
@Test
void doubleRegistration() {
ConfigurationMetadata metadata = compile(DoubleRegistrationProperties.class);
assertThat(metadata).has(Metadata.withGroup("one"));
assertThat(metadata).has(Metadata.withGroup("two"));
assertThat(metadata).has(Metadata.withProperty("one.value"));
assertThat(metadata).has(Metadata.withProperty("two.value"));
assertThat(metadata.getItems()).hasSize(4);
}
use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessorTests method multiConstructorRecordProperties.
@Test
@EnabledForJreRange(min = JRE.JAVA_16)
void multiConstructorRecordProperties(@TempDir File temp) throws IOException {
File exampleRecord = new File(temp, "ExampleRecord.java");
try (PrintWriter writer = new PrintWriter(new FileWriter(exampleRecord))) {
writer.println("@org.springframework.boot.configurationsample.ConfigurationProperties(\"multi\")");
writer.println("public record ExampleRecord(String someString, Integer someInteger) {");
writer.println(" @org.springframework.boot.configurationsample.ConstructorBinding");
writer.println(" public ExampleRecord(String someString) {");
writer.println(" this(someString, 42);");
writer.println(" }");
writer.println(" public ExampleRecord(Integer someInteger) {");
writer.println(" this(\"someString\", someInteger);");
writer.println(" }");
writer.println("}");
}
ConfigurationMetadata metadata = compile(exampleRecord);
assertThat(metadata).has(Metadata.withProperty("multi.some-string"));
assertThat(metadata).doesNotHave(Metadata.withProperty("multi.some-integer"));
}
Aggregations