Search in sources :

Example 41 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method simpleProperties.

@Test
public void simpleProperties() throws Exception {
    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).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) LombokSimpleProperties(org.springframework.boot.configurationsample.lombok.LombokSimpleProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 42 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method mergingOfHintWithNonCanonicalName.

@Test
public void mergingOfHintWithNonCanonicalName() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.theName", new ItemHint.ValueHint("boot", "Bla bla")));
    ConfigurationMetadata metadata = compile(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.withHint("simple.the-name").withValue(0, "boot", "Bla bla"));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 43 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method simpleTypeProperties.

@Test
public void simpleTypeProperties() throws Exception {
    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));
    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));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-short", Short.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-short", Short.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-integer", Integer.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-integer", Integer.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-long", Long.class));
    assertThat(metadata).has(Metadata.withProperty("simple.type.my-primitive-long", Long.class));
    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.Test)

Example 44 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method innerClassRootConfig.

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

Aggregations

ConfigurationMetadata (org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata)44 Test (org.junit.Test)42 ItemMetadata (org.springframework.boot.configurationprocessor.metadata.ItemMetadata)5 ItemDeprecation (org.springframework.boot.configurationprocessor.metadata.ItemDeprecation)3 BarProperties (org.springframework.boot.configurationsample.incremental.BarProperties)3 RenamedBarProperties (org.springframework.boot.configurationsample.incremental.RenamedBarProperties)3 JSONObject (org.json.JSONObject)2 FooProperties (org.springframework.boot.configurationsample.incremental.FooProperties)2 LombokInnerClassProperties (org.springframework.boot.configurationsample.lombok.LombokInnerClassProperties)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileWriter (java.io.FileWriter)1 JSONArray (org.json.JSONArray)1 InvalidConfigurationMetadataException (org.springframework.boot.configurationprocessor.metadata.InvalidConfigurationMetadataException)1 ItemHint (org.springframework.boot.configurationprocessor.metadata.ItemHint)1 LombokSimpleProperties (org.springframework.boot.configurationsample.lombok.LombokSimpleProperties)1 DeprecatedMethodConfig (org.springframework.boot.configurationsample.method.DeprecatedMethodConfig)1 InvalidMethodConfig (org.springframework.boot.configurationsample.method.InvalidMethodConfig)1 MethodAndClassConfig (org.springframework.boot.configurationsample.method.MethodAndClassConfig)1 SimpleMethodConfig (org.springframework.boot.configurationsample.method.SimpleMethodConfig)1