Search in sources :

Example 71 with ConfigurationMetadata

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));
}
Also used : DeprecatedFieldSingleProperty(org.springframework.boot.configurationsample.simple.DeprecatedFieldSingleProperty) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 72 with ConfigurationMetadata

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));
}
Also used : DeprecatedLessPreciseTypePojo(org.springframework.boot.configurationsample.specific.DeprecatedLessPreciseTypePojo) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 73 with ConfigurationMetadata

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));
}
Also used : AnnotatedGetter(org.springframework.boot.configurationsample.specific.AnnotatedGetter) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 74 with ConfigurationMetadata

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);
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 75 with ConfigurationMetadata

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"));
}
Also used : FileWriter(java.io.FileWriter) File(java.io.File) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) PrintWriter(java.io.PrintWriter) EnabledForJreRange(org.junit.jupiter.api.condition.EnabledForJreRange) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigurationMetadata (org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata)108 Test (org.junit.jupiter.api.Test)80 Test (org.junit.Test)25 ItemMetadata (org.springframework.boot.configurationprocessor.metadata.ItemMetadata)15 ItemDeprecation (org.springframework.boot.configurationprocessor.metadata.ItemDeprecation)8 RenamedBarProperties (org.springframework.boot.configurationsample.incremental.RenamedBarProperties)6 File (java.io.File)5 FileWriter (java.io.FileWriter)5 BarProperties (org.springframework.boot.configurationsample.incremental.BarProperties)5 ItemHint (org.springframework.boot.configurationprocessor.metadata.ItemHint)3 SimpleProperties (org.springframework.boot.configurationsample.simple.SimpleProperties)3 PrintWriter (java.io.PrintWriter)2 JSONObject (org.json.JSONObject)2 EnabledForJreRange (org.junit.jupiter.api.condition.EnabledForJreRange)2 JSONArray (org.springframework.boot.configurationprocessor.json.JSONArray)2 JSONObject (org.springframework.boot.configurationprocessor.json.JSONObject)2 SpecificEndpoint (org.springframework.boot.configurationsample.endpoint.SpecificEndpoint)2 IncrementalEndpoint (org.springframework.boot.configurationsample.endpoint.incremental.IncrementalEndpoint)2 FooProperties (org.springframework.boot.configurationsample.incremental.FooProperties)2 LombokInnerClassProperties (org.springframework.boot.configurationsample.lombok.LombokInnerClassProperties)2