From f73a7a2f8e504b1aa2842f9633eb88d676cef084 Mon Sep 17 00:00:00 2001 From: Luis Gomez Date: Sun, 25 Mar 2018 16:52:28 +0000 Subject: [PATCH] Revert "Realign ImmutableMapNodeBuilder and XML JSON builder" This reverts commit 86d0422023815ba00acbd6bc73d0f6244ae7641e, which breaks data formatting. JIRA: YANGTOOLS-870 Change-Id: I1cd7ae954c1bebf1e55bf3ab5e78605160f52734 Signed-off-by: Luis Gomez --- .../data/codec/xml/XmlToNormalizedNodesTest.java | 15 +++++++++++++-- .../data/util/CompositeNodeDataWithSchema.java | 7 ++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java index bfd9ba517d..ecde264cda 100644 --- a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java +++ b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import com.google.common.collect.Sets; import java.io.IOException; import java.io.InputStream; import java.net.URI; @@ -29,9 +30,11 @@ import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; +import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; @@ -372,15 +375,23 @@ public class XmlToNormalizedNodesTest { new NodeIdentifier(myLeafInList3)).withValue("listleafvalue1").build()).build()) .build(); + AugmentationNode myDoublyKeyedListAugNode = Builders.augmentationBuilder().withNodeIdentifier( + new AugmentationIdentifier(Sets.newHashSet(myDoublyKeyedList))) + .withChild(myDoublyKeyedListNode).build(); + ContainerNode myContainer3Node = Builders.containerBuilder().withNodeIdentifier( new NodeIdentifier(myContainer3)) - .withChild(myDoublyKeyedListNode).build(); + .withChild(myDoublyKeyedListAugNode).build(); + + AugmentationNode myContainer3AugNode = Builders.augmentationBuilder().withNodeIdentifier( + new AugmentationIdentifier(Sets.newHashSet(myContainer3))) + .withChild(myContainer3Node).build(); ContainerNode outerContainerNode = Builders.containerBuilder().withNodeIdentifier( new NodeIdentifier(outerContainer)) .withChild(myContainer1Node) .withChild(myContainer2Node) - .withChild(myContainer3Node).build(); + .withChild(myContainer3AugNode).build(); return outerContainerNode; } diff --git a/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/CompositeNodeDataWithSchema.java b/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/CompositeNodeDataWithSchema.java index 6ee6fa5c61..45791b1eff 100644 --- a/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/CompositeNodeDataWithSchema.java +++ b/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/CompositeNodeDataWithSchema.java @@ -161,7 +161,12 @@ public class CompositeNodeDataWithSchema extends AbstractNodeDataWithSchema { } void addCompositeChild(final CompositeNodeDataWithSchema newChild) { - addChild(newChild); + AugmentationSchema augSchema = findCorrespondingAugment(getSchema(), newChild.getSchema()); + if (augSchema != null) { + augmentationsToChild.put(augSchema, newChild); + } else { + addChild(newChild); + } } private AbstractNodeDataWithSchema addChild(final DataSchemaNode schema) { -- 2.36.6