Search in sources :

Example 31 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method parseCollectionConfig.

@Test
public void parseCollectionConfig() throws Exception {
    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>"));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 32 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method incrementalBuildAnnotationRemoved.

@Test
public void incrementalBuildAnnotationRemoved() throws Exception {
    TestProject project = new TestProject(this.temporaryFolder, FooProperties.class, BarProperties.class);
    ConfigurationMetadata metadata = project.fullBuild();
    assertThat(metadata).has(Metadata.withProperty("foo.counter"));
    assertThat(metadata).has(Metadata.withProperty("bar.counter"));
    project.replaceText(BarProperties.class, "@ConfigurationProperties", "//@ConfigurationProperties");
    metadata = project.incrementalBuild(BarProperties.class);
    assertThat(metadata).has(Metadata.withProperty("foo.counter"));
    assertThat(metadata).isNotEqualTo(Metadata.withProperty("bar.counter"));
}
Also used : RenamedBarProperties(org.springframework.boot.configurationsample.incremental.RenamedBarProperties) BarProperties(org.springframework.boot.configurationsample.incremental.BarProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 33 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")
public void deprecatedProperties() throws Exception {
    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.Test)

Example 34 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method deprecatedMethodConfig.

@Test
public void deprecatedMethodConfig() throws Exception {
    Class<DeprecatedMethodConfig> type = DeprecatedMethodConfig.class;
    ConfigurationMetadata metadata = compile(type);
    assertThat(metadata).has(Metadata.withGroup("foo").fromSource(type));
    assertThat(metadata).has(Metadata.withProperty("foo.name", String.class).fromSource(DeprecatedMethodConfig.Foo.class).withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withProperty("foo.flag", Boolean.class).fromSource(DeprecatedMethodConfig.Foo.class).withDeprecation(null, null));
}
Also used : DeprecatedMethodConfig(org.springframework.boot.configurationsample.method.DeprecatedMethodConfig) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 35 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method lombokSimpleProperties.

@Test
public void lombokSimpleProperties() throws Exception {
    ConfigurationMetadata metadata = compile(LombokSimpleProperties.class);
    assertSimpleLombokProperties(metadata, LombokSimpleProperties.class, "simple");
}
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