Merge branch '1.5.x'

This commit is contained in:
Stephane Nicoll
2017-06-14 09:30:06 +02:00
6 changed files with 52 additions and 6 deletions

View File

@@ -557,13 +557,15 @@ public class ConfigurationMetadataAnnotationProcessorTests {
public void mergeExistingPropertyDeprecation() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,
null, null, null, null,
new ItemDeprecation("Don't use this.", "simple.complex-comparator"));
new ItemDeprecation("Don't use this.", "simple.complex-comparator",
"error"));
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata)
.has(Metadata.withProperty("simple.comparator", "java.util.Comparator<?>")
.fromSource(SimpleProperties.class)
.withDeprecation("Don't use this.", "simple.complex-comparator"));
.withDeprecation("Don't use this.", "simple.complex-comparator",
"error"));
assertThat(metadata.getItems()).hasSize(4);
}
@@ -581,6 +583,19 @@ public class ConfigurationMetadataAnnotationProcessorTests {
assertThat(metadata.getItems()).hasSize(3);
}
@Test
public void mergeExistingPropertyDeprecationOverrideLevel() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name", null,
null, null, null, null, new ItemDeprecation(null, null, "error"));
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
assertThat(metadata).has(
Metadata.withProperty("singledeprecated.name", String.class.getName())
.fromSource(DeprecatedSingleProperty.class)
.withDeprecation("renamed", "singledeprecated.new-name", "error"));
assertThat(metadata.getItems()).hasSize(3);
}
@Test
public void mergeOfInvalidAdditionalMetadata() throws IOException {
File additionalMetadataFile = createAdditionalMetadataFile();

View File

@@ -198,9 +198,14 @@ public final class Metadata {
}
public MetadataItemCondition withDeprecation(String reason, String replacement) {
return withDeprecation(reason, replacement, null);
}
public MetadataItemCondition withDeprecation(String reason, String replacement,
String level) {
return new MetadataItemCondition(this.itemType, this.name, this.type,
this.sourceType, this.sourceMethod, this.description,
this.defaultValue, new ItemDeprecation(reason, replacement));
this.defaultValue, new ItemDeprecation(reason, replacement, level));
}
public MetadataItemCondition withNoDeprecation() {