Search in sources :

Example 36 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 37 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 38 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method nestedClassChildProperties.

@Test
public void nestedClassChildProperties() throws Exception {
    ConfigurationMetadata metadata = compile(ClassWithNestedProperties.class);
    assertThat(metadata).has(Metadata.withGroup("nestedChildProps").fromSource(ClassWithNestedProperties.NestedChildClass.class));
    assertThat(metadata).has(Metadata.withProperty("nestedChildProps.child-class-property", Integer.class).fromSource(ClassWithNestedProperties.NestedChildClass.class).withDefaultValue(20));
    assertThat(metadata).has(Metadata.withProperty("nestedChildProps.parent-class-property", Integer.class).fromSource(ClassWithNestedProperties.NestedChildClass.class).withDefaultValue(10));
}
Also used : ClassWithNestedProperties(org.springframework.boot.configurationsample.simple.ClassWithNestedProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

Example 39 with ConfigurationMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method doubleRegistration.

@Test
public void doubleRegistration() throws IOException {
    ConfigurationMetadata metadata = compile(DoubleRegistrationProperties.class);
    assertThat(metadata).has(Metadata.withGroup("one"));
    assertThat(metadata).has(Metadata.withGroup("two"));
    assertThat(metadata).has(Metadata.withProperty("one.value"));
    assertThat(metadata).has(Metadata.withProperty("two.value"));
    assertThat(metadata.getItems()).hasSize(4);
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.Test)

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

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