Search in sources :

Example 86 with ConfigurationMetadata

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

the class DeducedImmutablePropertiesMetadataGenerationTests method immutableSimpleProperties.

@Test
void immutableSimpleProperties() {
    ConfigurationMetadata metadata = compile(DeducedImmutableClassProperties.class);
    assertThat(metadata).has(Metadata.withGroup("test").fromSource(DeducedImmutableClassProperties.class));
    assertThat(metadata).has(Metadata.withGroup("test.nested", DeducedImmutableClassProperties.Nested.class).fromSource(DeducedImmutableClassProperties.class));
    assertThat(metadata).has(Metadata.withProperty("test.nested.name", String.class).fromSource(DeducedImmutableClassProperties.Nested.class));
    ItemMetadata nestedMetadata = metadata.getItems().stream().filter((item) -> item.getName().equals("test.nested")).findFirst().get();
    assertThat(nestedMetadata.getDefaultValue()).isNull();
}
Also used : DeducedImmutableClassProperties(org.springframework.boot.configurationsample.immutable.DeducedImmutableClassProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) ItemMetadata(org.springframework.boot.configurationprocessor.metadata.ItemMetadata) Test(org.junit.jupiter.api.Test)

Example 87 with ConfigurationMetadata

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

the class GenericsMetadataGenerationTests method complexGenericProperties.

@Test
void complexGenericProperties() {
    ConfigurationMetadata metadata = compile(ComplexGenericProperties.class);
    assertThat(metadata).has(Metadata.withGroup("generic").fromSource(ComplexGenericProperties.class));
    assertThat(metadata).has(Metadata.withGroup("generic.test").ofType(UpperBoundGenericPojo.class).fromSource(ComplexGenericProperties.class));
    assertThat(metadata).has(Metadata.withProperty("generic.test.mappings", "java.util.Map<java.lang.Enum<T>,java.lang.String>").fromSource(UpperBoundGenericPojo.class));
    assertThat(metadata.getItems()).hasSize(3);
}
Also used : ComplexGenericProperties(org.springframework.boot.configurationsample.generic.ComplexGenericProperties) UpperBoundGenericPojo(org.springframework.boot.configurationsample.generic.UpperBoundGenericPojo) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 88 with ConfigurationMetadata

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

the class GenericsMetadataGenerationTests method unresolvedGenericProperties.

@Test
void unresolvedGenericProperties() {
    ConfigurationMetadata metadata = compile(AbstractGenericProperties.class, UnresolvedGenericProperties.class);
    assertThat(metadata).has(Metadata.withGroup("generic").fromSource(UnresolvedGenericProperties.class));
    assertThat(metadata).has(Metadata.withProperty("generic.name", String.class).fromSource(UnresolvedGenericProperties.class).withDescription("Generic name.").withDefaultValue(null));
    assertThat(metadata).has(Metadata.withProperty("generic.mappings", "java.util.Map<java.lang.Number,java.lang.Object>").fromSource(UnresolvedGenericProperties.class).withDescription("Generic mappings.").withDefaultValue(null));
    assertThat(metadata.getItems()).hasSize(3);
}
Also used : UnresolvedGenericProperties(org.springframework.boot.configurationsample.generic.UnresolvedGenericProperties) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 89 with ConfigurationMetadata

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

the class GenericsMetadataGenerationTests method genericTypes.

@Test
void genericTypes() {
    ConfigurationMetadata metadata = compile(GenericConfig.class);
    assertThat(metadata).has(Metadata.withGroup("generic").ofType("org.springframework.boot.configurationsample.generic.GenericConfig"));
    assertThat(metadata).has(Metadata.withGroup("generic.foo").ofType("org.springframework.boot.configurationsample.generic.GenericConfig$Foo"));
    assertThat(metadata).has(Metadata.withGroup("generic.foo.bar").ofType("org.springframework.boot.configurationsample.generic.GenericConfig$Bar"));
    assertThat(metadata).has(Metadata.withGroup("generic.foo.bar.biz").ofType("org.springframework.boot.configurationsample.generic.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.generic.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);
}
Also used : GenericConfig(org.springframework.boot.configurationsample.generic.GenericConfig) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) Test(org.junit.jupiter.api.Test)

Example 90 with ConfigurationMetadata

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

the class GenericsMetadataGenerationTests method simpleGenericProperties.

@Test
void simpleGenericProperties() {
    ConfigurationMetadata metadata = compile(AbstractGenericProperties.class, SimpleGenericProperties.class);
    assertThat(metadata).has(Metadata.withGroup("generic").fromSource(SimpleGenericProperties.class));
    assertThat(metadata).has(Metadata.withProperty("generic.name", String.class).fromSource(SimpleGenericProperties.class).withDescription("Generic name.").withDefaultValue(null));
    assertThat(metadata).has(Metadata.withProperty("generic.mappings", "java.util.Map<java.lang.Integer,java.time.Duration>").fromSource(SimpleGenericProperties.class).withDescription("Generic mappings.").withDefaultValue(null));
    assertThat(metadata.getItems()).hasSize(3);
}
Also used : SimpleGenericProperties(org.springframework.boot.configurationsample.generic.SimpleGenericProperties) 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