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));
}
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);
}
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"));
}
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));
}
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"));
}
Aggregations