Search in sources :

Example 6 with ItemMetadata

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

the class ConfigurationMetadataAnnotationProcessorTests method writeAdditionalMetadata.

private void writeAdditionalMetadata(ItemMetadata... metadata) throws Exception {
    TestJsonConverter converter = new TestJsonConverter();
    File additionalMetadataFile = createAdditionalMetadataFile();
    JSONObject additionalMetadata = new JSONObject();
    JSONArray properties = new JSONArray();
    for (ItemMetadata itemMetadata : metadata) {
        properties.put(converter.toJsonObject(itemMetadata));
    }
    additionalMetadata.put("properties", properties);
    writeMetadata(additionalMetadataFile, additionalMetadata);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) File(java.io.File) TestJsonConverter(org.springframework.boot.configurationprocessor.metadata.TestJsonConverter) ItemMetadata(org.springframework.boot.configurationprocessor.metadata.ItemMetadata)

Example 7 with ItemMetadata

use of org.springframework.boot.configurationprocessor.metadata.ItemMetadata 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 8 with ItemMetadata

use of org.springframework.boot.configurationprocessor.metadata.ItemMetadata 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

ItemMetadata (org.springframework.boot.configurationprocessor.metadata.ItemMetadata)8 Test (org.junit.Test)5 ConfigurationMetadata (org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata)5 ItemDeprecation (org.springframework.boot.configurationprocessor.metadata.ItemDeprecation)3 File (java.io.File)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1 VariableElement (javax.lang.model.element.VariableElement)1 TestJsonConverter (org.springframework.boot.configurationprocessor.metadata.TestJsonConverter)1