X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-codec-gson%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fcodec%2Fgson%2FTestingNormalizedNodeStructuresCreator.java;h=294ac0232dc0d8ff51e095dc987000a694eec2d4;hb=807ab0252e9d18f390484d030c9b18baf6d8cefe;hp=941c55a104fd1578b60c4da731d935a7a6ad5a92;hpb=8fe36ef87f721d0e8052ddec466b36bb54dd9f64;p=yangtools.git diff --git a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java index 941c55a104..294ac0232d 100644 --- a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java +++ b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/TestingNormalizedNodeStructuresCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -12,8 +12,6 @@ import com.google.common.collect.Sets; import java.util.HashMap; import java.util.Map; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; @@ -27,12 +25,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode; -import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; -import org.opendaylight.yangtools.yang.data.impl.NodeFactory; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder; @@ -41,8 +36,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuil public class TestingNormalizedNodeStructuresCreator { + @SafeVarargs static NormalizedNode cont1Node( - DataContainerChild... children) { + final DataContainerChild... children) { DataContainerNodeAttrBuilder cont1 = Builders.containerBuilder(); cont1.withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "cont1"))); @@ -72,12 +68,6 @@ public class TestingNormalizedNodeStructuresCreator { DataContainerNodeBuilder choc12Builder = Builders.choiceBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "choc12"))); -// DataContainerNodeBuilder choc12Augmentation = Builders -// .augmentationBuilder(); -// choc12Augmentation.withNodeIdentifier(new AugmentationIdentifier(Sets.newHashSet(QName.create( -// "ns:complex:json", "2014-08-11", "c12B")))); -// choc12Augmentation.withChild(lf17Node()); - choc12Builder.withChild(lf17Node()); return choc12Builder.build(); } @@ -115,8 +105,9 @@ public class TestingNormalizedNodeStructuresCreator { .withValue("lf15_11 value from augmentation").build(); } + @SafeVarargs private static DataContainerChild choc11Node( - DataContainerChild... children) { + final DataContainerChild... children) { DataContainerNodeBuilder choc11Builder = Builders.choiceBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "choc11"))); choc11Builder.withValue(Lists.newArrayList(children)); @@ -133,13 +124,9 @@ public class TestingNormalizedNodeStructuresCreator { } private static DataContainerChild augmentC11AWithLf15_21Node() { - DataContainerNodeBuilder choc11_c11AugmentBuilder = Builders - .augmentationBuilder(); - choc11_c11AugmentBuilder.withNodeIdentifier(new AugmentationIdentifier(Sets.newHashSet(QName.create( - "ns:complex:json", "2014-08-11", "lf15_21")))); - - choc11_c11AugmentBuilder.withChild(lf15_21Node()); - return choc11_c11AugmentBuilder.build(); + return Builders.augmentationBuilder().withNodeIdentifier( + new AugmentationIdentifier(Sets.newHashSet(QName.create("ns:complex:json", "2014-08-11", "lf15_21")))) + .withChild(lf15_21Node()).build(); } private static LeafNode lf15_21Node() { @@ -149,14 +136,13 @@ public class TestingNormalizedNodeStructuresCreator { } private static DataContainerChild augmentC11AWithLf15_11AndLf15_12Node() { - DataContainerNodeBuilder choc11_c11AugmentBuilder = Builders - .augmentationBuilder(); - choc11_c11AugmentBuilder.withNodeIdentifier(new AugmentationIdentifier(Sets.newHashSet( - QName.create("ns:complex:json", "2014-08-11", "lf15_11"), - QName.create("ns:complex:json", "2014-08-11", "lf15_12")))); - choc11_c11AugmentBuilder.withChild(lf15_11Node()); - choc11_c11AugmentBuilder.withChild(lf15_12Node()); - return choc11_c11AugmentBuilder.build(); + return Builders.augmentationBuilder() + .withNodeIdentifier(new AugmentationIdentifier(Sets.newHashSet( + QName.create("ns:complex:json", "2014-08-11", "lf15_11"), + QName.create("ns:complex:json", "2014-08-11", "lf15_12")))) + .withChild(lf15_11Node()) + .withChild(lf15_12Node()) + .build(); } private static LeafNode lf15_12Node() { @@ -184,8 +170,6 @@ public class TestingNormalizedNodeStructuresCreator { } private static DataContainerChild childLst11() { - CollectionNodeBuilder lst11 = Builders.mapBuilder().withNodeIdentifier( - new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "lst11"))); DataContainerNodeAttrBuilder lst11Entry1Builder = Builders .mapEntryBuilder(); @@ -208,15 +192,15 @@ public class TestingNormalizedNodeStructuresCreator { lst11Entry1Builder.withChild(Builders.leafBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "lf111"))) .withValue("lf111 value").build()); - lst11.withChild(lst11Entry1Builder.build()); - return lst11.build(); + return Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier( + QName.create("ns:complex:json", "2014-08-11", "lst11"))).withChild(lst11Entry1Builder.build()).build(); } private static Object lf112Value() { return YangInstanceIdentifier.create( new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "cont1")), new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "lflst11")), - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"),"foo") + new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"),"foo") ); } @@ -225,13 +209,13 @@ public class TestingNormalizedNodeStructuresCreator { new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "lflst11"))); lflst11.withChild(Builders .leafSetEntryBuilder() - .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1")) + .withNodeIdentifier(new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), + "lflst11 value1")) .withValue("lflst11 value1").build()); lflst11.withChild(Builders .leafSetEntryBuilder() - .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2")) + .withNodeIdentifier(new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), + "lflst11 value2")) .withValue("lflst11 value2").build()); return lflst11.build(); } @@ -241,31 +225,17 @@ public class TestingNormalizedNodeStructuresCreator { new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "lflst11"))); lflst11.withChild(Builders .leafSetEntryBuilder() - .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value1\nanother line 1")) + .withNodeIdentifier(new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), + "lflst11 value1\nanother line 1")) .withValue("lflst11 value1\nanother line 1").build()); lflst11.withChild(Builders .leafSetEntryBuilder() - .withNodeIdentifier( - new NodeWithValue(QName.create("ns:complex:json", "2014-08-11", "lflst11"), "lflst11 value2\r\nanother line 2")) + .withNodeIdentifier(new NodeWithValue<>(QName.create("ns:complex:json", "2014-08-11", "lflst11"), + "lflst11 value2\r\nanother line 2")) .withValue("lflst11 value2\r\nanother line 2").build()); return lflst11.build(); } - private static CompositeNode prepareLf12Value() { - SimpleNode anyxmlInData = NodeFactory.createImmutableSimpleNode( - QName.create("ns:complex:json", "2014-08-11", "anyxml-in-data"), null, "foo"); - return ImmutableCompositeNode.builder().add(anyxmlInData) - .setQName(QName.create("ns:complex:json", "2014-08-11", "lf12-any")).build(); - } - - private static CompositeNode prepareLf13Value() { - SimpleNode anyxmlInData = NodeFactory.createImmutableSimpleNode( - QName.create("ns:complex:json", "2014-08-11", "anyxml-in-data"), null, "foo"); - return ImmutableCompositeNode.builder().add(anyxmlInData) - .setQName(QName.create("ns:complex:json", "2014-08-11", "lf13-any")).build(); - } - public static NormalizedNode leafNodeInContainer() { LeafNode lf11 = Builders.leafBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create("ns:complex:json", "2014-08-11", "lf11"))) @@ -276,6 +246,7 @@ public class TestingNormalizedNodeStructuresCreator { public static NormalizedNode leafListNodeInContainer() { return cont1Node(childLflst11()); } + public static NormalizedNode leafListNodeInContainerMultiline() { return cont1Node(childLflst11Multiline()); } @@ -293,16 +264,15 @@ public class TestingNormalizedNodeStructuresCreator { } /** - * choc11 contains lf13, lf15_11 and lf15_12 are added via external augmentation - * - * @return + * choc11 contains lf13, lf15_11 and lf15_12 are added via external augmentation. */ public static NormalizedNode caseNodeAugmentationInChoiceInContainer() { - return cont1Node(choc11Node(lf13Node(), lf15_11Node(), lf15_12Node(), lf15_21Node())); + return cont1Node(choc11Node(augmentC11AWithLf15_11AndLf15_12Node(), lf13Node(), augmentC11AWithLf15_21Node())); } public static NormalizedNode caseNodeExternalAugmentationInChoiceInContainer() { - return cont1Node(choc11Node(lf13Node(), lf15_11Node(), lf15_12Node(), lf15_11NodeExternal(), lf15_12NodeExternal())); + return cont1Node(choc11Node(lf13Node(), augmentC11AWithLf15_11AndLf15_12Node(), + externalAugmentC11AWithLf15_11AndLf15_12Node())); } public static NormalizedNode choiceNodeAugmentationInContainer() {