Search in sources :

Example 11 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method simplePrefixValueProperties.

@Test
public void simplePrefixValueProperties() throws Exception {
    ConfigurationMetadata metadata = compile(SimplePrefixValueProperties.class);
    assertThat(metadata).has(Metadata.withGroup("simple").fromSource(SimplePrefixValueProperties.class));
    assertThat(metadata).has(Metadata.withProperty("simple.name", String.class).fromSource(SimplePrefixValueProperties.class));
}
Also used : SimplePrefixValueProperties(org.springframework.boot.configurationsample.simple.SimplePrefixValueProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 12 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method innerClassProperties.

@Test
public void innerClassProperties() throws Exception {
    ConfigurationMetadata metadata = compile(InnerClassProperties.class);
    assertThat(metadata).has(Metadata.withGroup("config").fromSource(InnerClassProperties.class));
    assertThat(metadata).has(Metadata.withGroup("config.first").ofType(InnerClassProperties.Foo.class).fromSource(InnerClassProperties.class));
    assertThat(metadata).has(Metadata.withProperty("config.first.name"));
    assertThat(metadata).has(Metadata.withProperty("config.first.bar.name"));
    assertThat(metadata).has(Metadata.withGroup("config.the-second", InnerClassProperties.Foo.class).fromSource(InnerClassProperties.class));
    assertThat(metadata).has(Metadata.withProperty("config.the-second.name"));
    assertThat(metadata).has(Metadata.withProperty("config.the-second.bar.name"));
    assertThat(metadata).has(Metadata.withGroup("config.third").ofType(SimplePojo.class).fromSource(InnerClassProperties.class));
    assertThat(metadata).has(Metadata.withProperty("config.third.value"));
    assertThat(metadata).has(Metadata.withProperty("config.fourth"));
    assertThat(metadata).isNotEqualTo(Metadata.withGroup("config.fourth"));
}
Also used : InnerClassProperties(org.springframework.boot.configurationsample.specific.InnerClassProperties) LombokInnerClassProperties(org.springframework.boot.configurationsample.lombok.LombokInnerClassProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 13 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method boxingOnSetter.

@Test
public void boxingOnSetter() throws IOException {
    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).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.Test)

Example 14 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method invalidAccessor.

@Test
public void invalidAccessor() throws IOException {
    ConfigurationMetadata metadata = compile(InvalidAccessorProperties.class);
    assertThat(metadata).has(Metadata.withGroup("config"));
    assertThat(metadata.getItems()).hasSize(1);
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 15 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method mergingOfSimpleHint.

@Test
public void mergingOfSimpleHint() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.the-name", new ItemHint.ValueHint("boot", "Bla bla"), new ItemHint.ValueHint("spring", null)));
    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").withValue(1, "spring", null));
}
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