Search in sources :

Example 61 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 62 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 63 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)

Example 64 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 65 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)

Aggregations

ConfigurationMetadata (org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata)108 Test (org.junit.jupiter.api.Test)80 Test (org.junit.Test)25 ItemMetadata (org.springframework.boot.configurationprocessor.metadata.ItemMetadata)15 ItemDeprecation (org.springframework.boot.configurationprocessor.metadata.ItemDeprecation)8 RenamedBarProperties (org.springframework.boot.configurationsample.incremental.RenamedBarProperties)6 File (java.io.File)5 FileWriter (java.io.FileWriter)5 BarProperties (org.springframework.boot.configurationsample.incremental.BarProperties)5 ItemHint (org.springframework.boot.configurationprocessor.metadata.ItemHint)3 SimpleProperties (org.springframework.boot.configurationsample.simple.SimpleProperties)3 PrintWriter (java.io.PrintWriter)2 JSONObject (org.json.JSONObject)2 EnabledForJreRange (org.junit.jupiter.api.condition.EnabledForJreRange)2 JSONArray (org.springframework.boot.configurationprocessor.json.JSONArray)2 JSONObject (org.springframework.boot.configurationprocessor.json.JSONObject)2 SpecificEndpoint (org.springframework.boot.configurationsample.endpoint.SpecificEndpoint)2 IncrementalEndpoint (org.springframework.boot.configurationsample.endpoint.incremental.IncrementalEndpoint)2 FooProperties (org.springframework.boot.configurationsample.incremental.FooProperties)2 LombokInnerClassProperties (org.springframework.boot.configurationsample.lombok.LombokInnerClassProperties)2