Search in sources :

Example 26 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method methodAndClassConfig.

@Test
public void methodAndClassConfig() throws Exception {
    ConfigurationMetadata metadata = compile(MethodAndClassConfig.class);
    assertThat(metadata).has(Metadata.withProperty("conflict.name", String.class).fromSource(MethodAndClassConfig.Foo.class));
    assertThat(metadata).has(Metadata.withProperty("conflict.flag", Boolean.class).fromSource(MethodAndClassConfig.Foo.class));
    assertThat(metadata).has(Metadata.withProperty("conflict.value", String.class).fromSource(MethodAndClassConfig.class));
}
Also used : MethodAndClassConfig(org.springframework.boot.configurationsample.method.MethodAndClassConfig) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 27 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method genericTypes.

@Test
public void genericTypes() throws IOException {
    ConfigurationMetadata metadata = compile(GenericConfig.class);
    assertThat(metadata).has(Metadata.withGroup("generic").ofType("org.springframework.boot.configurationsample.specific.GenericConfig"));
    assertThat(metadata).has(Metadata.withGroup("generic.foo").ofType("org.springframework.boot.configurationsample.specific.GenericConfig$Foo"));
    assertThat(metadata).has(Metadata.withGroup("generic.foo.bar").ofType("org.springframework.boot.configurationsample.specific.GenericConfig$Bar"));
    assertThat(metadata).has(Metadata.withGroup("generic.foo.bar.biz").ofType("org.springframework.boot.configurationsample.specific.GenericConfig$Bar$Biz"));
    assertThat(metadata).has(Metadata.withProperty("generic.foo.name").ofType(String.class).fromSource(GenericConfig.Foo.class));
    assertThat(metadata).has(Metadata.withProperty("generic.foo.string-to-bar").ofType("java.util.Map<java.lang.String,org.springframework.boot.configurationsample.specific.GenericConfig.Bar<java.lang.Integer>>").fromSource(GenericConfig.Foo.class));
    assertThat(metadata).has(Metadata.withProperty("generic.foo.string-to-integer").ofType("java.util.Map<java.lang.String,java.lang.Integer>").fromSource(GenericConfig.Foo.class));
    assertThat(metadata).has(Metadata.withProperty("generic.foo.bar.name").ofType("java.lang.String").fromSource(GenericConfig.Bar.class));
    assertThat(metadata).has(Metadata.withProperty("generic.foo.bar.biz.name").ofType("java.lang.String").fromSource(GenericConfig.Bar.Biz.class));
    assertThat(metadata.getItems()).hasSize(9);
}
Also used : GenericConfig(org.springframework.boot.configurationsample.specific.GenericConfig) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 28 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method emptyTypeMethodConfig.

@Test
public void emptyTypeMethodConfig() throws Exception {
    ConfigurationMetadata metadata = compile(EmptyTypeMethodConfig.class);
    assertThat(metadata).isNotEqualTo(Metadata.withProperty("something.foo"));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 29 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method incrementalBuildTypeRenamed.

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

Example 30 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method lombokInnerClassProperties.

@Test
public void lombokInnerClassProperties() throws Exception {
    ConfigurationMetadata metadata = compile(LombokInnerClassProperties.class);
    assertThat(metadata).has(Metadata.withGroup("config").fromSource(LombokInnerClassProperties.class));
    assertThat(metadata).has(Metadata.withGroup("config.first").ofType(LombokInnerClassProperties.Foo.class).fromSource(LombokInnerClassProperties.class));
    assertThat(metadata).has(Metadata.withProperty("config.first.name"));
    assertThat(metadata).has(Metadata.withProperty("config.first.bar.name"));
    assertThat(metadata).has(Metadata.withGroup("config.second", LombokInnerClassProperties.Foo.class).fromSource(LombokInnerClassProperties.class));
    assertThat(metadata).has(Metadata.withProperty("config.second.name"));
    assertThat(metadata).has(Metadata.withProperty("config.second.bar.name"));
    assertThat(metadata).has(Metadata.withGroup("config.third").ofType(SimpleLombokPojo.class).fromSource(LombokInnerClassProperties.class));
    // For some reason the annotation processor resolves a type for SimpleLombokPojo
    // that is resolved (compiled) and the source annotations are gone. Because we
    // don't see the @Data annotation anymore, no field is harvested. What is crazy is
    // that a sample project works fine so this seem to be related to the unit test
    // environment for some reason. assertThat(metadata,
    // containsProperty("config.third.value"));
    assertThat(metadata).has(Metadata.withProperty("config.fourth"));
    assertThat(metadata).isNotEqualTo(Metadata.withGroup("config.fourth"));
}
Also used : LombokInnerClassProperties(org.springframework.boot.configurationsample.lombok.LombokInnerClassProperties) 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