Search in sources :

Example 66 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)

Example 67 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method incrementalBuild.

@Test
public void incrementalBuild() throws Exception {
    TestProject project = new TestProject(this.temporaryFolder, FooProperties.class, BarProperties.class);
    assertThat(project.getOutputFile(MetadataStore.METADATA_PATH).exists()).isFalse();
    ConfigurationMetadata metadata = project.fullBuild();
    assertThat(project.getOutputFile(MetadataStore.METADATA_PATH).exists()).isTrue();
    assertThat(metadata).has(Metadata.withProperty("foo.counter").fromSource(FooProperties.class));
    assertThat(metadata).has(Metadata.withProperty("bar.counter").fromSource(BarProperties.class));
    metadata = project.incrementalBuild(BarProperties.class);
    assertThat(metadata).has(Metadata.withProperty("foo.counter").fromSource(FooProperties.class));
    assertThat(metadata).has(Metadata.withProperty("bar.counter").fromSource(BarProperties.class));
    project.addSourceCode(BarProperties.class, BarProperties.class.getResourceAsStream("BarProperties.snippet"));
    metadata = project.incrementalBuild(BarProperties.class);
    assertThat(metadata).has(Metadata.withProperty("bar.extra"));
    assertThat(metadata).has(Metadata.withProperty("foo.counter"));
    assertThat(metadata).has(Metadata.withProperty("bar.counter"));
    project.revert(BarProperties.class);
    metadata = project.incrementalBuild(BarProperties.class);
    assertThat(metadata).isNotEqualTo(Metadata.withProperty("bar.extra"));
    assertThat(metadata).has(Metadata.withProperty("foo.counter"));
    assertThat(metadata).has(Metadata.withProperty("bar.counter"));
}
Also used : RenamedBarProperties(org.springframework.boot.configurationsample.incremental.RenamedBarProperties) BarProperties(org.springframework.boot.configurationsample.incremental.BarProperties) FooProperties(org.springframework.boot.configurationsample.incremental.FooProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 68 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method mergingOfAdditionalProperty.

@Test
public void mergingOfAdditionalProperty() throws Exception {
    ItemMetadata property = ItemMetadata.newProperty(null, "foo", "java.lang.String", AdditionalMetadata.class.getName(), null, null, null, null);
    writeAdditionalMetadata(property);
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.comparator"));
    assertThat(metadata).has(Metadata.withProperty("foo", String.class).fromSource(AdditionalMetadata.class));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) ItemMetadata(org.springframework.boot.configurationprocessor.metadata.ItemMetadata) Test(org.junit.Test)

Example 69 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method mergeExistingPropertyDeprecationOverride.

@Test
public void mergeExistingPropertyDeprecationOverride() throws Exception {
    ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name", null, null, null, null, null, new ItemDeprecation("Don't use this.", "single.name"));
    writeAdditionalMetadata(property);
    ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
    assertThat(metadata).has(Metadata.withProperty("singledeprecated.name", String.class.getName()).fromSource(DeprecatedSingleProperty.class).withDeprecation("Don't use this.", "single.name"));
    assertThat(metadata.getItems()).hasSize(3);
}
Also used : ItemDeprecation(org.springframework.boot.configurationprocessor.metadata.ItemDeprecation) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) ItemMetadata(org.springframework.boot.configurationprocessor.metadata.ItemMetadata) Test(org.junit.Test)

Example 70 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method mergingOfHintWithNonCanonicalName.

@Test
public void mergingOfHintWithNonCanonicalName() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.theName", new ItemHint.ValueHint("boot", "Bla bla")));
    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"));
}
Also used : 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