import static org.junit.Assert.assertThrows;
import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.top;
import static org.opendaylight.mdsal.binding.test.model.util.ListsBindingUtils.topLevelList;
-import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.augmentationBuilder;
import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.choiceBuilder;
import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.containerBuilder;
import static org.opendaylight.yangtools.yang.data.impl.schema.Builders.leafSetBuilder;
import java.util.Map.Entry;
import java.util.Set;
import org.junit.Test;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer.NodeResult;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment2Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeComplexUsesAugment;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugment;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TreeLeafOnlyAugmentBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment1.AugmentChoice1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment1.augment.choice1.Case1Builder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
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;
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.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodecTest {
public static final String TOP_LEVEL_LIST_FOO_KEY_VALUE = "foo";
public static final QName CHOICE_CONTAINER_QNAME = ChoiceContainer.QNAME;
public static final QName CHOICE_IDENTIFIER_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "identifier");
public static final QName CHOICE_IDENTIFIER_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "id");
- public static final QName SIMPLE_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "simple-id");
public static final QName EXTENDED_ID_QNAME = QName.create(CHOICE_CONTAINER_QNAME, "extended-id");
private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
.builder(Top.class).child(TopLevelList.class, TOP_LEVEL_LIST_FOO_KEY).build();
- private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
- BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
- private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
- BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
public static final YangInstanceIdentifier BI_TOP_PATH = YangInstanceIdentifier.of(TOP_QNAME);
public static final YangInstanceIdentifier BI_TOP_LEVEL_LIST_PATH = BI_TOP_PATH.node(TOP_LEVEL_LIST_QNAME);
@Test
public void containerToNormalized() {
- final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
- InstanceIdentifier.create(Top.class), top());
- final ContainerNode topNormalized = getEmptyTop();
- assertEquals(topNormalized, entry.getValue());
+ final var entry = (NodeResult) codecContext.toNormalizedNode(InstanceIdentifier.create(Top.class), top());
+ assertEquals(getEmptyTop(), entry.node());
}
@Test
public void containerFromNormalized() {
- final ContainerNode topNormalized = getEmptyTop();
- final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH,
- topNormalized);
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_PATH, getEmptyTop());
assertEquals(top(), entry.getValue());
}
@Test
public void equalsWithAugment() {
- final ContainerNode topNormalizedWithAugments = getNormalizedTopWithAugments(augmentationBuilder()
- .withNodeIdentifier(new AugmentationIdentifier(Set.of(AGUMENT_STRING_Q)))
- .withChild(leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE))
- .build());
+ final ContainerNode topNormalizedWithAugments =
+ getNormalizedTopWithChildren(leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE));
final ContainerNode topNormalized = getEmptyTop();
final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH,
@Test
public void equalsWithMultipleAugments() {
- final ContainerNode topNormalizedWithAugments = getNormalizedTopWithAugments(
- augmentationBuilder()
- .withNodeIdentifier(new AugmentationIdentifier(Set.of(AGUMENT_STRING_Q)))
- .withChild(leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE))
- .build(),
- augmentationBuilder()
- .withNodeIdentifier(new AugmentationIdentifier(Set.of(AUGMENT_INT_Q)))
- .withChild(leafNode(AUGMENT_INT_Q, AUGMENT_INT_VALUE))
- .build());
-
+ final ContainerNode topNormalizedWithAugments = getNormalizedTopWithChildren(
+ leafNode(AGUMENT_STRING_Q, AUGMENT_STRING_VALUE),
+ leafNode(AUGMENT_INT_Q, AUGMENT_INT_VALUE));
final Entry<InstanceIdentifier<?>, DataObject> entryWithAugments = codecContext.fromNormalizedNode(BI_TOP_PATH,
topNormalizedWithAugments);
Top topWithAugments = topWithAugments(Map.of(
assertNotEquals(entryWithAugments.getValue(), topWithAugments);
}
- private static ContainerNode getNormalizedTopWithAugments(final AugmentationNode... augChild) {
+ private static ContainerNode getNormalizedTopWithChildren(final DataContainerChild... children) {
final var builder = containerBuilder();
-
- for (AugmentationNode augmentationNode : augChild) {
- builder.withChild(augmentationNode);
+ for (DataContainerChild child : children) {
+ builder.withChild(child);
}
return builder.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
.withChild(mapNodeBuilder(TOP_LEVEL_LIST_QNAME).build()).build();
@Test
public void listWithKeysToNormalized() {
- final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
- BA_TOP_LEVEL_LIST, topLevelList(TOP_LEVEL_LIST_FOO_KEY));
- final MapEntryNode topLevelListNormalized = mapEntryBuilder()
+ final var entry = (NodeResult) codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST,
+ topLevelList(TOP_LEVEL_LIST_FOO_KEY));
+ assertEquals(mapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .build();
- assertEquals(topLevelListNormalized, entry.getValue());
+ .build(),
+ entry.node());
}
@Test
public void listWithKeysFromNormalized() {
- final MapEntryNode topLevelListNormalized = mapEntryBuilder()
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, mapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .build();
- final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
- BI_TOP_LEVEL_LIST_FOO_PATH, topLevelListNormalized);
+ .build());
assertEquals(topLevelList(TOP_LEVEL_LIST_FOO_KEY), entry.getValue());
}
@Test
public void leafOnlyAugmentationToNormalized() {
- final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
- BA_TREE_LEAF_ONLY, new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build());
- final AugmentationNode augmentationNode = augmentationBuilder()
- .withNodeIdentifier(new AugmentationIdentifier(Set.of(SIMPLE_VALUE_QNAME)))
- .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
- .build();
- assertEquals(augmentationNode, entry.getValue());
+ final var entry = (NodeResult) codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST,
+ topLevelList(TOP_LEVEL_LIST_FOO_KEY,
+ new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build()));
+ assertEquals(mapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
+ TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue")) // augmentation child
+ .build(),
+ entry.node());
}
@Test
public void leafOnlyAugmentationFromNormalized() {
- final AugmentationIdentifier augmentationId = new AugmentationIdentifier(Set.of(SIMPLE_VALUE_QNAME));
- final AugmentationNode augmentationNode = augmentationBuilder()
- .withNodeIdentifier(augmentationId)
- .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
- .build();
- final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
- BI_TOP_LEVEL_LIST_FOO_PATH.node(augmentationId), augmentationNode);
- assertEquals(new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build(), entry.getValue());
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, mapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
+ TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue")) // augmentation child
+ .build());
+ assertEquals(
+ topLevelList(TOP_LEVEL_LIST_FOO_KEY,
+ new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build()),
+ entry.getValue());
}
@Test
public void orderedleafListToNormalized() {
- Top top = new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build();
-
- Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
- InstanceIdentifier.create(Top.class), top);
- ContainerNode containerNode = containerBuilder()
+ final var entry = (NodeResult) codecContext.toNormalizedNode(InstanceIdentifier.create(Top.class),
+ new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build());
+ assertEquals(containerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
.withChild(orderedLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
.withValue("foo")
.build())
.build())
- .build();
- assertEquals(containerNode, entry.getValue());
+ .build(),
+ entry.node());
}
@Test
public void leafListToNormalized() {
- final Top top = new TopBuilder().setTopLevelLeafList(Set.of("foo")).build();
-
- final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
- InstanceIdentifier.create(Top.class), top);
- final ContainerNode containerNode = containerBuilder()
+ final var entry = (NodeResult) codecContext.toNormalizedNode(
+ InstanceIdentifier.create(Top.class), new TopBuilder().setTopLevelLeafList(Set.of("foo")).build());
+ assertEquals(containerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
.withChild(leafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
.withValue("foo")
.build())
.build())
- .build();
- assertEquals(containerNode, entry.getValue());
+ .build(),
+ entry.node());
}
@Test
public void leafListFromNormalized() {
- final ContainerNode topWithLeafList = containerBuilder()
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_PATH, containerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
.withChild(leafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_LEAF_LIST_QNAME))
.withValue("foo")
.build())
.build())
- .build();
- final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH,
- topWithLeafList);
- final Top top = new TopBuilder().setTopLevelLeafList(Set.of("foo")).build();
- assertEquals(top, entry.getValue());
+ .build());
+ assertEquals(new TopBuilder().setTopLevelLeafList(Set.of("foo")).build(), entry.getValue());
}
@Test
public void orderedLeafListFromNormalized() {
- ContainerNode topWithLeafList = containerBuilder()
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_PATH, containerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
.withChild(orderedLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
.withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo"))
.withValue("foo").build())
.build())
- .build();
- Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
- Top top = new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build();
- assertEquals(top, entry.getValue());
+ .build());
+ assertEquals(new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build(), entry.getValue());
}
@Test
public void choiceToNormalized() {
- final ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder()
- .setExtendedId(new ExtendedIdBuilder().setId("identifier_value").build()).build()).build();
- final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
- InstanceIdentifier.create(ChoiceContainer.class), choiceContainerBA);
- final ContainerNode choiceContainer = containerBuilder()
+ final var entry = (NodeResult) codecContext.toNormalizedNode(InstanceIdentifier.create(ChoiceContainer.class),
+ new ChoiceContainerBuilder()
+ .setIdentifier(new ExtendedBuilder()
+ .setExtendedId(new ExtendedIdBuilder().setId("identifier_value").build())
+ .build())
+ .build());
+ assertEquals(containerBuilder()
.withNodeIdentifier(new NodeIdentifier(CHOICE_CONTAINER_QNAME))
.withChild(choiceBuilder()
.withNodeIdentifier(new NodeIdentifier(CHOICE_IDENTIFIER_QNAME))
.withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value"))
.build())
.build())
- .build();
- assertEquals(choiceContainer, entry.getValue());
+ .build(),
+ entry.node());
}
@Test
@Test
public void orderedLisToNormalized() {
- final TopLevelList topLevelList = new TopLevelListBuilder()
+ final var entry = (NodeResult) codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST, new TopLevelListBuilder()
.withKey(TOP_LEVEL_LIST_FOO_KEY)
.setNestedList(List.of(
new NestedListBuilder().withKey(new NestedListKey("foo")).build(),
new NestedListBuilder().withKey(new NestedListKey("bar")).build()))
- .build();
- final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(BA_TOP_LEVEL_LIST,
- topLevelList);
- final MapEntryNode foo = mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(
- TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
- .withChild(orderedMapBuilder()
- .withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME))
- .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
- .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar")).build()).build();
- assertEquals(foo, entry.getValue());
+ .build());
+ assertEquals(mapEntryBuilder()
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME,
+ TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(orderedMapBuilder()
+ .withNodeIdentifier(new NodeIdentifier(NESTED_LIST_QNAME))
+ .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
+ .withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar"))
+ .build())
+ .build(),
+ entry.node());
}
@Test
public void orderedLisFromNormalized() {
- final MapEntryNode foo = mapEntryBuilder()
+ final var entry = codecContext.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH, mapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(
TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
.withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "foo"))
.withChild(mapEntry(NESTED_LIST_QNAME, NESTED_LIST_KEY_QNAME, "bar"))
.build())
- .build();
- final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
- BI_TOP_LEVEL_LIST_FOO_PATH, foo);
- final TopLevelList topLevelList = new TopLevelListBuilder()
+ .build());
+ assertEquals(new TopLevelListBuilder()
.withKey(TOP_LEVEL_LIST_FOO_KEY)
.setNestedList(List.of(
new NestedListBuilder().withKey(new NestedListKey("foo")).build(),
new NestedListBuilder().withKey(new NestedListKey("bar")).build()))
- .build();
- assertEquals(topLevelList, entry.getValue());
+ .build(),
+ entry.getValue());
}
@Test
final QName containerQName = QName.create(augmentChoice1QName, "case11-choice-case-container");
final QName leafQName = QName.create(augmentChoice1QName, "case11-choice-case-leaf");
- final AugmentationIdentifier aug1Id = new AugmentationIdentifier(Set.of(augmentChoice1QName));
- final AugmentationIdentifier aug2Id = new AugmentationIdentifier(Set.of(augmentChoice2QName));
final NodeIdentifier augmentChoice1Id = new NodeIdentifier(augmentChoice1QName);
final NodeIdentifier augmentChoice2Id = new NodeIdentifier(augmentChoice2QName);
final NodeIdentifier containerId = new NodeIdentifier(containerQName);
- final TopBuilder tBuilder = new TopBuilder();
- final TopChoiceAugment1Builder tca1Builder = new TopChoiceAugment1Builder();
- final Case1Builder c1Builder = new Case1Builder();
- final TopChoiceAugment2Builder tca2Builder = new TopChoiceAugment2Builder();
- final Case11Builder c11Builder = new Case11Builder();
- final Case11ChoiceCaseContainerBuilder cccc1Builder = new Case11ChoiceCaseContainerBuilder();
- cccc1Builder.setCase11ChoiceCaseLeaf("leaf-value");
- c11Builder.setCase11ChoiceCaseContainer(cccc1Builder.build());
- tca2Builder.setAugmentChoice2(c11Builder.build());
- c1Builder.addAugmentation(tca2Builder.build());
- tca1Builder.setAugmentChoice1(c1Builder.build());
- tBuilder.addAugmentation(tca1Builder.build());
- final Top top = tBuilder.build();
-
- final Entry<YangInstanceIdentifier, NormalizedNode> biResult = codecContext.toNormalizedNode(
- InstanceIdentifier.create(Top.class), top);
-
- final NormalizedNode topNormalized = containerBuilder()
+ final Top top = new TopBuilder().addAugmentation(
+ // top is augmented with choice1 having case1
+ new TopChoiceAugment1Builder().setAugmentChoice1(
+ new Case1Builder().addAugmentation(
+ // case1 is augmented with choice2 having case11 (with container having leaf)
+ new TopChoiceAugment2Builder().setAugmentChoice2(
+ new Case11Builder().setCase11ChoiceCaseContainer(
+ new Case11ChoiceCaseContainerBuilder()
+ .setCase11ChoiceCaseLeaf("leaf-value").build()
+ ).build()
+ ).build()
+ ).build()
+ ).build()
+ ).build();
+
+ final var biResult = (NodeResult) codecContext.toNormalizedNode(InstanceIdentifier.create(Top.class), top);
+
+ final var topNormalized = containerBuilder()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(augmentationBuilder().withNodeIdentifier(aug1Id)
- .withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id)
- .withChild(augmentationBuilder().withNodeIdentifier(aug2Id)
- .withChild(choiceBuilder().withNodeIdentifier(augmentChoice2Id)
- .withChild(containerBuilder().withNodeIdentifier(containerId)
- .withChild(leafNode(leafQName, "leaf-value"))
- .build())
- .build())
- .build())
+ .withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id) // choice 1
+ .withChild(choiceBuilder().withNodeIdentifier(augmentChoice2Id) // choice 2
+ .withChild(containerBuilder().withNodeIdentifier(containerId)
+ .withChild(leafNode(leafQName, "leaf-value")).build())
.build())
.build())
.build();
- assertEquals(BI_TOP_PATH, biResult.getKey());
- assertEquals(topNormalized, biResult.getValue());
+ assertEquals(BI_TOP_PATH, biResult.path());
+ assertEquals(topNormalized, biResult.node());
- final Entry<InstanceIdentifier<?>, DataObject> baResult = codecContext.fromNormalizedNode(BI_TOP_PATH,
- topNormalized);
+ final var baResult = codecContext.fromNormalizedNode(BI_TOP_PATH, topNormalized);
assertEquals(InstanceIdentifier.create(Top.class), baResult.getKey());
assertEquals(top, baResult.getValue());