2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.binding.data.codec.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.top;
12 import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList;
13 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.augmentationBuilder;
14 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
15 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
16 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
17 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
18 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
19 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
21 import com.google.common.collect.Sets;
22 import java.util.ArrayList;
23 import java.util.HashSet;
24 import java.util.List;
27 import javassist.ClassPool;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1Builder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment2;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment2Builder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugmentBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.AugmentChoice1;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.Case1Builder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.Case11Builder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.case11.Case11ChoiceCaseContainerBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.ChoiceContainer;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.ChoiceContainerBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TopBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.choice.identifier.ExtendedBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.choice.identifier.extended.ExtendedIdBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListKey;
53 import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
54 import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
55 import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
56 import org.opendaylight.yangtools.yang.binding.DataObject;
57 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
58 import org.opendaylight.yangtools.yang.common.QName;
59 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
60 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
61 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
62 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
63 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
64 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
65 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
66 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
67 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
68 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
69 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
70 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
72 public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingRuntimeTest{
74 public static final String TOP_LEVEL_LIST_FOO_KEY_VALUE = "foo";
75 public static final TopLevelListKey TOP_LEVEL_LIST_FOO_KEY = new TopLevelListKey(TOP_LEVEL_LIST_FOO_KEY_VALUE);
77 public static final QName TOP_QNAME = Top.QNAME;
78 public static final QName TOP_LEVEL_LIST_QNAME = QName.create(TOP_QNAME, "top-level-list");
79 public static final QName TOP_LEVEL_LIST_KEY_QNAME = QName.create(TOP_QNAME, "name");
80 public static final QName TOP_LEVEL_LEAF_LIST_QNAME = QName.create(TOP_QNAME, "top-level-leaf-list");
81 public static final QName NESTED_LIST_QNAME = QName.create(TOP_QNAME, "nested-list");
82 public static final QName NESTED_LIST_KEY_QNAME = QName.create(TOP_QNAME, "name");
83 public static final QName CHOICE_CONTAINER_QNAME = ChoiceContainer.QNAME;
84 public static final QName CHOICE_IDENTIFIER_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "identifier");
85 public static final QName CHOICE_IDENTIFIER_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "id");
86 public static final QName SIMPLE_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "simple-id");
87 public static final QName EXTENDED_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "extended-id");
88 private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
90 private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
91 .builder(Top.class).child(TopLevelList.class, TOP_LEVEL_LIST_FOO_KEY).build();
92 private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
93 BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
94 private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
95 BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
97 public static final YangInstanceIdentifier BI_TOP_PATH = YangInstanceIdentifier.of(TOP_QNAME);
98 public static final YangInstanceIdentifier BI_TOP_LEVEL_LIST_PATH = BI_TOP_PATH.node(TOP_LEVEL_LIST_QNAME);
99 public static final YangInstanceIdentifier BI_TOP_LEVEL_LIST_FOO_PATH = BI_TOP_LEVEL_LIST_PATH
100 .node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE));
101 public static final YangInstanceIdentifier BI_CHOICE_CONTAINER_PATH = YangInstanceIdentifier.of(CHOICE_CONTAINER_QNAME);
103 private BindingNormalizedNodeCodecRegistry registry;
107 public void setup() {
109 final JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
110 registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
111 registry.onBindingRuntimeContextUpdated(getRuntimeContext());
115 public void containerToNormalized() {
116 final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
117 registry.toNormalizedNode(InstanceIdentifier.create(Top.class), top());
118 final ContainerNode topNormalized = ImmutableContainerNodeBuilder.create()
119 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
120 .withChild(mapNodeBuilder(TOP_LEVEL_LIST_QNAME).build()).build();
121 assertEquals(topNormalized, entry.getValue());
125 public void containerFromNormalized() {
126 final ContainerNode topNormalized = ImmutableContainerNodeBuilder.create()
127 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
128 .withChild(mapNodeBuilder(TOP_LEVEL_LIST_QNAME).build()).build();
129 final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topNormalized);
130 assertEquals(top(), entry.getValue());
134 public void listWithKeysToNormalized() {
135 final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
136 registry.toNormalizedNode(BA_TOP_LEVEL_LIST, topLevelList(TOP_LEVEL_LIST_FOO_KEY));
137 final MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
139 new YangInstanceIdentifier.NodeIdentifierWithPredicates(
140 TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
141 .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
143 assertEquals(topLevelListNormalized, entry.getValue());
147 public void listWithKeysFromNormalized() {
148 final MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
150 new YangInstanceIdentifier.NodeIdentifierWithPredicates(
151 TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
152 .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
154 final Map.Entry<InstanceIdentifier<?>, DataObject> entry =
155 registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, topLevelListNormalized);
156 assertEquals(topLevelList(TOP_LEVEL_LIST_FOO_KEY), entry.getValue());
160 public void leafOnlyAugmentationToNormalized() {
161 final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
162 registry.toNormalizedNode(BA_TREE_LEAF_ONLY, new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build());
163 final Set<QName> augmentationChildren = new HashSet<>();
164 augmentationChildren.add(SIMPLE_VALUE_QNAME);
165 final AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
166 .withNodeIdentifier(new YangInstanceIdentifier.AugmentationIdentifier(augmentationChildren))
167 .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
169 assertEquals(augmentationNode, entry.getValue());
173 public void leafOnlyAugmentationFromNormalized() {
174 final Set<QName> augmentationChildren = new HashSet<>();
175 augmentationChildren.add(SIMPLE_VALUE_QNAME);
176 final AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
177 .withNodeIdentifier(new YangInstanceIdentifier.AugmentationIdentifier(augmentationChildren))
178 .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
180 final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH.node(
181 new YangInstanceIdentifier.AugmentationIdentifier(augmentationChildren)), augmentationNode);
182 assertEquals(new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build(), entry.getValue());
186 public void leafListToNormalized() {
187 final List<String> topLevelLeafList = new ArrayList<>();
188 topLevelLeafList.add("foo");
189 final Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
191 final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
192 registry.toNormalizedNode(InstanceIdentifier.create(Top.class), top);
193 final ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
194 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
195 .withChild(ImmutableLeafSetNodeBuilder.create()
196 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
198 ImmutableLeafSetEntryNodeBuilder.create()
199 .withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
204 assertEquals(containerNode, entry.getValue());
208 public void leafListFromNormalized() {
209 final ContainerNode topWithLeafList = ImmutableContainerNodeBuilder.create()
210 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
211 .withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
212 .withChild(ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
213 new YangInstanceIdentifier.NodeWithValue(TOP_LEVEL_LEAF_LIST_QNAME, "foo")).withValue("foo").build()).build())
215 final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
216 final List<String> topLevelLeafList = new ArrayList<>();
217 topLevelLeafList.add("foo");
218 final Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
219 assertEquals(top, entry.getValue());
223 public void choiceToNormalized() {
224 final ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder().setExtendedId(
225 new ExtendedIdBuilder().setId("identifier_value").build()).build()).build();
226 final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
227 registry.toNormalizedNode(InstanceIdentifier.create(ChoiceContainer.class), choiceContainerBA);
228 final ContainerNode choiceContainer = ImmutableContainerNodeBuilder.create()
229 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_CONTAINER_QNAME))
230 .withChild(ImmutableChoiceNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
231 .withChild(ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(EXTENDED_ID_QNAME))
232 .withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value")).build()).build())
234 assertEquals(choiceContainer, entry.getValue());
238 public void choiceFromNormalized() {
239 final ContainerNode choiceContainerBI = ImmutableContainerNodeBuilder.create()
240 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_CONTAINER_QNAME))
241 .withChild(ImmutableChoiceNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
242 .withChild(ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(EXTENDED_ID_QNAME))
243 .withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value")).build()).build())
245 final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_CHOICE_CONTAINER_PATH, choiceContainerBI);
246 final ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder().setExtendedId(
247 new ExtendedIdBuilder().setId("identifier_value").build()).build()).build();
248 assertEquals(choiceContainerBA, entry.getValue());
252 public void orderedLisToNormalized() {
253 final InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
254 final List<NestedList> nestedLists = new ArrayList<>();
255 nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("foo")).build());
256 nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("bar")).build());
257 final TopLevelList topLevelList = new TopLevelListBuilder().setKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(nestedLists).build();
258 final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(ii, topLevelList);
259 final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
260 TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
261 .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
263 ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NESTED_LIST_QNAME))
264 .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
265 .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar")).build()).build();
266 assertEquals(foo, entry.getValue());
270 public void orderedLisFromNormalized() {
271 final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
272 TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
273 .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
275 ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NESTED_LIST_QNAME))
276 .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
277 .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar")).build()).build();
278 final InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
280 final Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, foo);
281 final List<NestedList> nestedLists = new ArrayList<>();
282 nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("foo")).setType("").build());
283 nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("bar")).setType("").build());
284 final TopLevelList topLevelList = new TopLevelListBuilder().setKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(nestedLists).build();
285 assertEquals(topLevelList, entry.getValue());
289 public void augmentMultipleChoices() {
290 final QName augmentChoice1QName = AugmentChoice1.QNAME;
291 final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
292 final QName containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container");
293 final QName leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf");
295 final YangInstanceIdentifier.AugmentationIdentifier aug1Id =
296 new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice1QName));
297 final YangInstanceIdentifier.AugmentationIdentifier aug2Id =
298 new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice2QName));
299 final YangInstanceIdentifier.NodeIdentifier augmentChoice1Id =
300 new YangInstanceIdentifier.NodeIdentifier(augmentChoice1QName);
301 final YangInstanceIdentifier.NodeIdentifier augmentChoice2Id =
302 new YangInstanceIdentifier.NodeIdentifier(augmentChoice2QName);
303 final YangInstanceIdentifier.NodeIdentifier containerId =
304 new YangInstanceIdentifier.NodeIdentifier(containerQName);
306 final TopBuilder tBuilder = new TopBuilder();
307 final TopChoiceAugment1Builder tca1Builder = new TopChoiceAugment1Builder();
308 final Case1Builder c1Builder = new Case1Builder();
309 final TopChoiceAugment2Builder tca2Builder = new TopChoiceAugment2Builder();
310 final Case11Builder c11Builder = new Case11Builder();
311 final Case11ChoiceCaseContainerBuilder cccc1Builder = new Case11ChoiceCaseContainerBuilder();
312 cccc1Builder.setCase11ChoiceCaseLeaf("leaf-value");
313 c11Builder.setCase11ChoiceCaseContainer(cccc1Builder.build());
314 tca2Builder.setAugmentChoice2(c11Builder.build());
315 c1Builder.addAugmentation(TopChoiceAugment2.class, tca2Builder.build());
316 tca1Builder.setAugmentChoice1(c1Builder.build());
317 tBuilder.addAugmentation(TopChoiceAugment1.class, tca1Builder.build());
318 final Top top = tBuilder.build();
320 final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> biResult =
321 registry.toNormalizedNode(InstanceIdentifier.create(Top.class), top);
323 final NormalizedNode<?, ?> topNormalized =
324 containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
325 .withChild(augmentationBuilder().withNodeIdentifier(aug1Id)
326 .withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id)
327 .withChild(augmentationBuilder().withNodeIdentifier(aug2Id)
328 .withChild(choiceBuilder().withNodeIdentifier(augmentChoice2Id)
329 .withChild(containerBuilder().withNodeIdentifier(containerId)
330 .withChild(leafNode(leafQName, "leaf-value"))
337 assertEquals(BI_TOP_PATH, biResult.getKey());
338 assertEquals(topNormalized, biResult.getValue());
340 final Map.Entry<InstanceIdentifier<?>, DataObject> baResult = registry.fromNormalizedNode(BI_TOP_PATH, topNormalized);
342 assertEquals(InstanceIdentifier.create(Top.class), baResult.getKey());
343 assertEquals(top, baResult.getValue());