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.controller.md.sal.test.model.util.ListsBindingUtils.top;
12 import static org.opendaylight.controller.md.sal.test.model.util.ListsBindingUtils.topLevelList;
13 import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.*;
14 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
15 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry;
16 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
17 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
18 import com.google.common.collect.Sets;
19 import java.util.ArrayList;
20 import java.util.HashSet;
21 import java.util.List;
24 import javassist.ClassPool;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TopChoiceAugment1;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TopChoiceAugment1Builder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TopChoiceAugment2;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TopChoiceAugment2Builder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexUsesAugment;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugment;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeLeafOnlyAugmentBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.augment.choice1.Case1Builder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.Case11Builder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.case11.Case11ChoiceCaseContainerBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.ChoiceContainer;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.ChoiceContainerBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.TopBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.choice.identifier.ExtendedBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.choice.identifier.extended.ExtendedIdBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.NestedList;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.top.level.list.NestedListKey;
49 import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
50 import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
51 import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
52 import org.opendaylight.yangtools.yang.binding.DataObject;
53 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
54 import org.opendaylight.yangtools.yang.common.QName;
55 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
56 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
57 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
58 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
59 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
60 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
61 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
62 import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
63 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
64 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
65 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
66 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
67 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
68 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
69 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
71 public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingRuntimeTest{
73 public static final String TOP_LEVEL_LIST_FOO_KEY_VALUE = "foo";
74 public static final TopLevelListKey TOP_LEVEL_LIST_FOO_KEY = new TopLevelListKey(TOP_LEVEL_LIST_FOO_KEY_VALUE);
76 public static final QName TOP_QNAME =
77 QName.create("urn:opendaylight:params:xml:ns:yang:yangtools:test:binding", "2014-07-01", "top");
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 =
84 QName.create("urn:opendaylight:params:xml:ns:yang:yangtools:test:binding", "2014-07-01", "choice-container");
85 public static final QName CHOICE_IDENTIFIER_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "identifier");
86 public static final QName CHOICE_IDENTIFIER_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "id");
87 public static final QName SIMPLE_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "simple-id");
88 public static final QName EXTENDED_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "extended-id");
89 private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
91 private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
92 .builder(Top.class).child(TopLevelList.class, TOP_LEVEL_LIST_FOO_KEY).build();
93 private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
94 BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
95 private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
96 BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
98 public static final YangInstanceIdentifier BI_TOP_PATH = YangInstanceIdentifier.of(TOP_QNAME);
99 public static final YangInstanceIdentifier BI_TOP_LEVEL_LIST_PATH = BI_TOP_PATH.node(TOP_LEVEL_LIST_QNAME);
100 public static final YangInstanceIdentifier BI_TOP_LEVEL_LIST_FOO_PATH = BI_TOP_LEVEL_LIST_PATH
101 .node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE));
102 public static final YangInstanceIdentifier BI_CHOICE_CONTAINER_PATH = YangInstanceIdentifier.of(CHOICE_CONTAINER_QNAME);
104 private BindingNormalizedNodeCodecRegistry registry;
107 public void setup() {
109 JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
110 registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
111 registry.onBindingRuntimeContextUpdated(getRuntimeContext());
115 public void containerToNormalized() {
116 Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
117 registry.toNormalizedNode(InstanceIdentifier.create(Top.class), top());
118 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 ContainerNode topNormalized = ImmutableContainerNodeBuilder.create()
127 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
128 .withChild(mapNodeBuilder(TOP_LEVEL_LIST_QNAME).build()).build();
129 Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topNormalized);
130 assertEquals(top(), entry.getValue());
134 public void listWithKeysToNormalized() {
135 Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
136 registry.toNormalizedNode(BA_TOP_LEVEL_LIST, topLevelList(TOP_LEVEL_LIST_FOO_KEY));
137 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 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 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 Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
162 registry.toNormalizedNode(BA_TREE_LEAF_ONLY, new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build());
163 Set<QName> augmentationChildren = new HashSet<>();
164 augmentationChildren.add(SIMPLE_VALUE_QNAME);
165 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 Set<QName> augmentationChildren = new HashSet<>();
175 augmentationChildren.add(SIMPLE_VALUE_QNAME);
176 AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
177 .withNodeIdentifier(new YangInstanceIdentifier.AugmentationIdentifier(augmentationChildren))
178 .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
180 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 List<String> topLevelLeafList = new ArrayList<>();
188 topLevelLeafList.add("foo");
189 Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
191 Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
192 registry.toNormalizedNode(InstanceIdentifier.create(Top.class), top);
193 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 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 Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
216 List<String> topLevelLeafList = new ArrayList<>();
217 topLevelLeafList.add("foo");
218 Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
219 assertEquals(top, entry.getValue());
223 public void choiceToNormalized() {
224 ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder().setExtendedId(
225 new ExtendedIdBuilder().setId("identifier_value").build()).build()).build();
226 Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry =
227 registry.toNormalizedNode(InstanceIdentifier.create(ChoiceContainer.class), choiceContainerBA);
228 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 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 Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_CHOICE_CONTAINER_PATH, choiceContainerBI);
246 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 InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
254 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 TopLevelList topLevelList = new TopLevelListBuilder().setKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(nestedLists).build();
258 Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(ii, topLevelList);
259 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 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 InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
280 Map.Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, foo);
281 List<NestedList> nestedLists = new ArrayList<>();
282 nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("foo")).build());
283 nestedLists.add(new NestedListBuilder().setKey(new NestedListKey("bar")).build());
284 TopLevelList topLevelList = new TopLevelListBuilder().setKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(nestedLists).build();
285 assertEquals(topLevelList, entry.getValue());
289 public void augmentMultipleChoices() {
290 QName augmentChoice1QName = QName.create("urn:opendaylight:params:xml:ns:yang:yangtools:test:augment",
291 "2014-07-09", "augment-choice1");
292 QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
293 final QName containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container");
294 final QName leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf");
296 final YangInstanceIdentifier.AugmentationIdentifier aug1Id =
297 new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice1QName));
298 final YangInstanceIdentifier.AugmentationIdentifier aug2Id =
299 new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice2QName));
300 final YangInstanceIdentifier.NodeIdentifier augmentChoice1Id =
301 new YangInstanceIdentifier.NodeIdentifier(augmentChoice1QName);
302 final YangInstanceIdentifier.NodeIdentifier augmentChoice2Id =
303 new YangInstanceIdentifier.NodeIdentifier(augmentChoice2QName);
304 final YangInstanceIdentifier.NodeIdentifier containerId =
305 new YangInstanceIdentifier.NodeIdentifier(containerQName);
307 TopBuilder tBuilder = new TopBuilder();
308 TopChoiceAugment1Builder tca1Builder = new TopChoiceAugment1Builder();
309 Case1Builder c1Builder = new Case1Builder();
310 TopChoiceAugment2Builder tca2Builder = new TopChoiceAugment2Builder();
311 Case11Builder c11Builder = new Case11Builder();
312 Case11ChoiceCaseContainerBuilder cccc1Builder = new Case11ChoiceCaseContainerBuilder();
313 cccc1Builder.setCase11ChoiceCaseLeaf("leaf-value");
314 c11Builder.setCase11ChoiceCaseContainer(cccc1Builder.build());
315 tca2Builder.setAugmentChoice2(c11Builder.build());
316 c1Builder.addAugmentation(TopChoiceAugment2.class, tca2Builder.build());
317 tca1Builder.setAugmentChoice1(c1Builder.build());
318 tBuilder.addAugmentation(TopChoiceAugment1.class, tca1Builder.build());
319 final Top top = tBuilder.build();
321 final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> biResult =
322 registry.toNormalizedNode(InstanceIdentifier.create(Top.class), top);
324 final NormalizedNode<?, ?> topNormalized =
325 containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TOP_QNAME))
326 .withChild(augmentationBuilder().withNodeIdentifier(aug1Id)
327 .withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id)
328 .withChild(augmentationBuilder().withNodeIdentifier(aug2Id)
329 .withChild(choiceBuilder().withNodeIdentifier(augmentChoice2Id)
330 .withChild(containerBuilder().withNodeIdentifier(containerId)
331 .withChild(leafNode(leafQName, "leaf-value"))
338 assertEquals(BI_TOP_PATH, biResult.getKey());
339 assertEquals(topNormalized, biResult.getValue());
341 final Map.Entry<InstanceIdentifier<?>, DataObject> baResult = registry.fromNormalizedNode(BI_TOP_PATH, topNormalized);
343 assertEquals(InstanceIdentifier.create(Top.class), baResult.getKey());
344 assertEquals(top, baResult.getValue());