Search in sources :

Example 81 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method nestedClassChildProperties.

@Test
void nestedClassChildProperties() {
    ConfigurationMetadata metadata = compile(ClassWithNestedProperties.class);
    assertThat(metadata).has(Metadata.withGroup("nestedChildProps").fromSource(ClassWithNestedProperties.NestedChildClass.class));
    assertThat(metadata).has(Metadata.withProperty("nestedChildProps.child-class-property", Integer.class).fromSource(ClassWithNestedProperties.NestedChildClass.class).withDefaultValue(20));
    assertThat(metadata).has(Metadata.withProperty("nestedChildProps.parent-class-property", Integer.class).fromSource(ClassWithNestedProperties.NestedChildClass.class).withDefaultValue(10));
}
Also used : ClassWithNestedProperties(org.springframework.boot.configurationsample.simple.ClassWithNestedProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 82 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method simpleTypeProperties.

@Test
void simpleTypeProperties() {
    ConfigurationMetadata metadata = compile(SimpleTypeProperties.class);
    assertThat(metadata).has(Metadata.withGroup("simple.type").fromSource(SimpleTypeProperties.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-string", String.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-byte", Byte.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-byte", Byte.class).withDefaultValue(0));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-char", Character.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-char", Character.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-boolean", Boolean.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-boolean", Boolean.class).withDefaultValue(false));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-short", Short.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-short", Short.class).withDefaultValue(0));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-integer", Integer.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-integer", Integer.class).withDefaultValue(0));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-long", Long.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-long", Long.class).withDefaultValue(0));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-double", Double.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-double", Double.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-float", Float.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-float", Float.class));
    assertThat(metadata.getItems().size()).isEqualTo(18);
}
Also used : SimpleTypeProperties(org.springframework.boot.configurationsample.simple.SimpleTypeProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 83 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method innerClassRootConfig.

@Test
void innerClassRootConfig() {
    ConfigurationMetadata metadata = compile(InnerClassRootConfig.class);
    assertThat(metadata).has(Metadata.withProperty("config.name"));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 84 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method simpleProperties.

@Test
void simpleProperties() {
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withGroup("simple").fromSource(SimpleProperties.class));
    assertThat(metadata).has(Metadata.withProperty("simple.the-name", String.class).fromSource(SimpleProperties.class).withDescription("The name of this simple properties.").withDefaultValue("boot").withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withProperty("simple.flag", Boolean.class).withDefaultValue(false).fromSource(SimpleProperties.class).withDescription("A simple flag.").withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withProperty("simple.comparator"));
    assertThat(metadata).doesNotHave(Metadata.withProperty("simple.counter"));
    assertThat(metadata).doesNotHave(Metadata.withProperty("simple.size"));
}
Also used : SimpleProperties(org.springframework.boot.configurationsample.simple.SimpleProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 85 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method parseCollectionConfig.

@Test
void parseCollectionConfig() {
    ConfigurationMetadata metadata = compile(SimpleCollectionProperties.class);
    // getter and setter
    assertThat(metadata).has(Metadata.withProperty("collection.integers-to-names", "java.util.Map<java.lang.Integer,java.lang.String>"));
    assertThat(metadata).has(Metadata.withProperty("collection.longs", "java.util.Collection<java.lang.Long>"));
    assertThat(metadata).has(Metadata.withProperty("collection.floats", "java.util.List<java.lang.Float>"));
    // getter only
    assertThat(metadata).has(Metadata.withProperty("collection.names-to-integers", "java.util.Map<java.lang.String,java.lang.Integer>"));
    assertThat(metadata).has(Metadata.withProperty("collection.bytes", "java.util.Collection<java.lang.Byte>"));
    assertThat(metadata).has(Metadata.withProperty("collection.doubles", "java.util.List<java.lang.Double>"));
    assertThat(metadata).has(Metadata.withProperty("collection.names-to-holders", "java.util.Map<java.lang.String,org.springframework.boot.configurationsample.simple.SimpleCollectionProperties$Holder<java.lang.String>>"));
}
Also used : 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