Search in sources :

Example 76 with ConfigurationMetadata

use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.

the class ConfigurationMetadataAnnotationProcessorTests method typBoxing.

@Test
void typBoxing() {
    Class<?> type = BoxingPojo.class;
    ConfigurationMetadata metadata = compile(type);
    assertThat(metadata).has(Metadata.withGroup("boxing").fromSource(type));
    assertThat(metadata).has(Metadata.withProperty("boxing.flag", Boolean.class).withDefaultValue(false).fromSource(type));
    assertThat(metadata).has(Metadata.withProperty("boxing.another-flag", Boolean.class).fromSource(type));
    assertThat(metadata).has(Metadata.withProperty("boxing.counter", Integer.class).fromSource(type));
}
Also used : BoxingPojo(org.springframework.boot.configurationsample.specific.BoxingPojo) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 77 with ConfigurationMetadata

use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.

the class ConfigurationMetadataAnnotationProcessorTests method hierarchicalProperties.

@Test
void hierarchicalProperties() {
    ConfigurationMetadata metadata = compile(HierarchicalProperties.class, HierarchicalPropertiesParent.class, HierarchicalPropertiesGrandparent.class);
    assertThat(metadata).has(Metadata.withGroup("hierarchical").fromSource(HierarchicalProperties.class));
    assertThat(metadata).has(Metadata.withProperty("hierarchical.first", String.class).withDefaultValue("one").fromSource(HierarchicalProperties.class));
    assertThat(metadata).has(Metadata.withProperty("hierarchical.second", String.class).withDefaultValue("two").fromSource(HierarchicalProperties.class));
    assertThat(metadata).has(Metadata.withProperty("hierarchical.third", String.class).withDefaultValue("three").fromSource(HierarchicalProperties.class));
}
Also used : HierarchicalProperties(org.springframework.boot.configurationsample.simple.HierarchicalProperties) InnerClassHierarchicalProperties(org.springframework.boot.configurationsample.specific.InnerClassHierarchicalProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 78 with ConfigurationMetadata

use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.

the class ConfigurationMetadataAnnotationProcessorTests method descriptionProperties.

@Test
void descriptionProperties() {
    ConfigurationMetadata metadata = compile(DescriptionProperties.class);
    assertThat(metadata).has(Metadata.withGroup("description").fromSource(DescriptionProperties.class));
    assertThat(metadata).has(Metadata.withProperty("description.simple", String.class).fromSource(DescriptionProperties.class).withDescription("A simple description."));
    assertThat(metadata).has(Metadata.withProperty("description.multi-line", String.class).fromSource(DescriptionProperties.class).withDescription("This is a lengthy description that spans across multiple lines to showcase that the line separators are cleaned automatically."));
}
Also used : DescriptionProperties(org.springframework.boot.configurationsample.simple.DescriptionProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 79 with ConfigurationMetadata

use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.

the class ConfigurationMetadataAnnotationProcessorTests method deprecatedProperties.

@Test
@SuppressWarnings("deprecation")
void deprecatedProperties() {
    Class<?> type = org.springframework.boot.configurationsample.simple.DeprecatedProperties.class;
    ConfigurationMetadata metadata = compile(type);
    assertThat(metadata).has(Metadata.withGroup("deprecated").fromSource(type));
    assertThat(metadata).has(Metadata.withProperty("deprecated.name", String.class).fromSource(type).withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withProperty("deprecated.description", String.class).fromSource(type).withDeprecation(null, null));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 80 with ConfigurationMetadata

use of org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata in project spring-boot by spring-projects.

the class ConfigurationMetadataAnnotationProcessorTests method deprecatedOnUnrelatedSetter.

@Test
void deprecatedOnUnrelatedSetter() {
    Class<?> type = DeprecatedUnrelatedMethodPojo.class;
    ConfigurationMetadata metadata = compile(type);
    assertThat(metadata).has(Metadata.withGroup("not.deprecated").fromSource(type));
    assertThat(metadata).has(Metadata.withProperty("not.deprecated.counter", Integer.class).withNoDeprecation().fromSource(type));
    assertThat(metadata).has(Metadata.withProperty("not.deprecated.flag", Boolean.class).withDefaultValue(false).withNoDeprecation().fromSource(type));
}
Also used : DeprecatedUnrelatedMethodPojo(org.springframework.boot.configurationsample.specific.DeprecatedUnrelatedMethodPojo) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) 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