Search in sources :

Example 51 with ConfigurationMetadata

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

the class ImmutablePropertiesMetadataGenerationTests method immutableSimpleProperties.

@Test
void immutableSimpleProperties() {
    ConfigurationMetadata metadata = compile(ImmutableSimpleProperties.class);
    assertThat(metadata).has(Metadata.withGroup("immutable").fromSource(ImmutableSimpleProperties.class));
    assertThat(metadata).has(Metadata.withProperty("immutable.the-name", String.class).fromSource(ImmutableSimpleProperties.class).withDescription("The name of this simple properties.").withDefaultValue("boot"));
    assertThat(metadata).has(Metadata.withProperty("immutable.flag", Boolean.class).withDefaultValue(false).fromSource(ImmutableSimpleProperties.class).withDescription("A simple flag.").withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withProperty("immutable.comparator"));
    assertThat(metadata).has(Metadata.withProperty("immutable.counter"));
    assertThat(metadata.getItems()).hasSize(5);
}
Also used : ImmutableSimpleProperties(org.springframework.boot.configurationsample.immutable.ImmutableSimpleProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 52 with ConfigurationMetadata

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

the class MethodBasedMetadataGenerationTests method methodAndClassConfig.

@Test
void methodAndClassConfig() {
    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).withDefaultValue(false).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.jupiter.api.Test)

Example 53 with ConfigurationMetadata

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

the class MethodBasedMetadataGenerationTests method methodConfig.

private void methodConfig(Class<?> config, Class<?> properties) {
    ConfigurationMetadata metadata = compile(config);
    assertThat(metadata).has(Metadata.withGroup("foo").fromSource(config));
    assertThat(metadata).has(Metadata.withProperty("foo.name", String.class).fromSource(properties));
    assertThat(metadata).has(Metadata.withProperty("foo.flag", Boolean.class).withDefaultValue(false).fromSource(properties));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata)

Example 54 with ConfigurationMetadata

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

the class MethodBasedMetadataGenerationTests method privateMethodConfig.

@Test
void privateMethodConfig() {
    ConfigurationMetadata metadata = compile(PrivateMethodConfig.class);
    assertThat(metadata).doesNotHave(Metadata.withGroup("foo"));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 55 with ConfigurationMetadata

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

the class MethodBasedMetadataGenerationTests method singleConstructorMethodConfig.

@Test
void singleConstructorMethodConfig() {
    ConfigurationMetadata metadata = compile(SingleConstructorMethodConfig.class);
    assertThat(metadata).doesNotHave(Metadata.withProperty("foo.my-service", Object.class).fromSource(SingleConstructorMethodConfig.Foo.class));
    assertThat(metadata).has(Metadata.withProperty("foo.name", String.class).fromSource(SingleConstructorMethodConfig.Foo.class));
    assertThat(metadata).has(Metadata.withProperty("foo.flag", Boolean.class).withDefaultValue(false).fromSource(SingleConstructorMethodConfig.Foo.class));
}
Also used : ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.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