Polish 'Add origin support for empty YAML list and map'
See gh-21704
This commit is contained in:
@@ -105,15 +105,15 @@ class OriginTrackedYamlLoader extends YamlProcessor {
|
||||
|
||||
@Override
|
||||
protected Object constructObject(Node node) {
|
||||
if (node instanceof CollectionNode && ((CollectionNode<?>) node).getValue().isEmpty()) {
|
||||
return constructTrackedObject(node, super.constructObject(node));
|
||||
}
|
||||
if (node instanceof ScalarNode) {
|
||||
if (!(node instanceof KeyScalarNode)) {
|
||||
return constructTrackedObject(node, super.constructObject(node));
|
||||
}
|
||||
}
|
||||
else if (node instanceof CollectionNode && ((CollectionNode<?>) node).getValue().isEmpty()) {
|
||||
return constructTrackedObject(node, super.constructObject(node));
|
||||
}
|
||||
else if (node instanceof MappingNode) {
|
||||
if (node instanceof MappingNode) {
|
||||
replaceMappingNodeKeys((MappingNode) node);
|
||||
}
|
||||
return super.constructObject(node);
|
||||
|
||||
@@ -125,8 +125,8 @@ class OriginTrackedYamlLoaderTests {
|
||||
void processEmptyListAndMap() {
|
||||
OriginTrackedValue emptymap = getValue("emptymap");
|
||||
OriginTrackedValue emptylist = getValue("emptylist");
|
||||
assertThat(emptymap.getValue()).isEqualTo(Collections.EMPTY_MAP);
|
||||
assertThat(emptylist.getValue()).isEqualTo(Collections.EMPTY_LIST);
|
||||
assertThat(emptymap.getValue()).isEqualTo(Collections.emptyMap());
|
||||
assertThat(emptylist.getValue()).isEqualTo(Collections.emptyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user