import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.TopChoiceAugment1;
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.TopChoiceAugment2;
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.AugmentChoice1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.Case1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.Case11Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.augment.choice1.case1.augment.choice2.case11.Case11ChoiceCaseContainerBuilder;
+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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment2.augment.choice2.Case11Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.augment.rev140709.top.choice.augment2.augment.choice2.case11.Case11ChoiceCaseContainerBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.ChoiceContainer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.ChoiceContainerBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.top.level.list.NestedListKey;
import org.opendaylight.yang.gen.v1.urn.test.foo4798.rev160101.Root;
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.builder.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserLeafSetNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUserMapNodeBuilder;
public class NormalizedNodeSerializeDeserializeTest extends AbstractBindingCodecTest {
@Test
public void containerToNormalized() {
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(
+ final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
InstanceIdentifier.create(Top.class), top());
final ContainerNode topNormalized = getEmptyTop();
assertEquals(topNormalized, entry.getValue());
@Test
public void containerFromNormalized() {
final ContainerNode topNormalized = getEmptyTop();
- final Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topNormalized);
+ final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH,
+ topNormalized);
assertEquals(top(), entry.getValue());
}
.build());
final ContainerNode topNormalized = getEmptyTop();
- final Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topNormalized);
- final Entry<InstanceIdentifier<?>, DataObject> entryWithAugments = registry.fromNormalizedNode(BI_TOP_PATH,
+ final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH,
+ topNormalized);
+ final Entry<InstanceIdentifier<?>, DataObject> entryWithAugments = codecContext.fromNormalizedNode(BI_TOP_PATH,
topNormalizedWithAugments);
// Equals on other with no augmentation should be false
// Equals on other(lazy, reversed) with no augmentation should be false
assertNotEquals(entryWithAugments.getValue(), entry.getValue());
- final Top topWithAugments = topWithAugments(Collections.<Class<? extends Augmentation<Top>>, Augmentation<Top>>
- singletonMap(Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build()));
+ final Top topWithAugments = topWithAugments(
+ Map.of(Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build()));
// Equals other with same augment should be true
assertEquals(topWithAugments, entryWithAugments.getValue());
// Equals other with same augment should be true
assertEquals(entryWithAugments.getValue(), entryWithAugments.getValue());
final Top topWithAugmentsDiffValue = topWithAugments(
- Collections.<Class<? extends Augmentation<Top>>, Augmentation<Top>>singletonMap(Top1.class,
- new Top1Builder().setAugmentedString("differentValue").build()));
+ Map.of(Top1.class, new Top1Builder().setAugmentedString("differentValue").build()));
assertNotEquals(topWithAugmentsDiffValue, entryWithAugments.getValue());
assertNotEquals(entryWithAugments.getValue(), topWithAugmentsDiffValue);
}
.withChild(ImmutableNodes.leafNode(AUGMENT_INT_Q, AUGMENT_INT_VALUE))
.build());
- final Entry<InstanceIdentifier<?>, DataObject> entryWithAugments = registry.fromNormalizedNode(BI_TOP_PATH,
+ final Entry<InstanceIdentifier<?>, DataObject> entryWithAugments = codecContext.fromNormalizedNode(BI_TOP_PATH,
topNormalizedWithAugments);
- Map<Class<? extends Augmentation<Top>>, Augmentation<Top>> augments = new HashMap<>();
- augments.put(Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build());
- augments.put(Top2.class, new Top2Builder().setAugmentedInt(AUGMENT_INT_VALUE).build());
- Top topWithAugments = topWithAugments(augments);
+ Top topWithAugments = topWithAugments(Map.of(
+ Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build(),
+ Top2.class, new Top2Builder().setAugmentedInt(AUGMENT_INT_VALUE).build()));
assertEquals(topWithAugments, entryWithAugments.getValue());
assertEquals(entryWithAugments.getValue(), topWithAugments);
- augments = new HashMap<>();
- augments.put(Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build());
- augments.put(Top2.class, new Top2Builder().setAugmentedInt(999).build());
- topWithAugments = topWithAugments(augments);
+ topWithAugments = topWithAugments(Map.of(
+ Top1.class, new Top1Builder().setAugmentedString(AUGMENT_STRING_VALUE).build(),
+ Top2.class, new Top2Builder().setAugmentedInt(999).build()));
assertNotEquals(topWithAugments, entryWithAugments.getValue());
assertNotEquals(entryWithAugments.getValue(), topWithAugments);
private static Top topWithAugments(
final Map<Class<? extends Augmentation<Top>>, ? extends Augmentation<Top>> augments) {
final TopBuilder topBuilder = new TopBuilder();
- for (Entry<Class<? extends Augmentation<Top>>, ? extends Augmentation<Top>> augment : augments.entrySet()) {
- topBuilder.addAugmentation(augment.getKey(), augment.getValue());
+ for (Augmentation<Top> augment : augments.values()) {
+ topBuilder.addAugmentation(augment);
}
- return topBuilder.setTopLevelList(Collections.emptyMap()).build();
+ return topBuilder.build();
}
@Test
public void listWithKeysToNormalized() {
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(BA_TOP_LEVEL_LIST,
- topLevelList(TOP_LEVEL_LIST_FOO_KEY));
+ final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
+ BA_TOP_LEVEL_LIST, topLevelList(TOP_LEVEL_LIST_FOO_KEY));
final MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME,
TOP_LEVEL_LIST_FOO_KEY_VALUE))
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 = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH,
- topLevelListNormalized);
+ final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
+ BI_TOP_LEVEL_LIST_FOO_PATH, topLevelListNormalized);
assertEquals(topLevelList(TOP_LEVEL_LIST_FOO_KEY), entry.getValue());
}
@Test
public void leafOnlyAugmentationToNormalized() {
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(BA_TREE_LEAF_ONLY,
- new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build());
- final Set<QName> augmentationChildren = new HashSet<>();
- augmentationChildren.add(SIMPLE_VALUE_QNAME);
+ final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
+ BA_TREE_LEAF_ONLY, new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build());
final AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
- .withNodeIdentifier(new AugmentationIdentifier(augmentationChildren))
+ .withNodeIdentifier(new AugmentationIdentifier(Set.of(SIMPLE_VALUE_QNAME)))
.withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
.build();
assertEquals(augmentationNode, entry.getValue());
@Test
public void leafOnlyAugmentationFromNormalized() {
- final Set<QName> augmentationChildren = new HashSet<>();
- augmentationChildren.add(SIMPLE_VALUE_QNAME);
+ final AugmentationIdentifier augmentationId = new AugmentationIdentifier(Set.of(SIMPLE_VALUE_QNAME));
final AugmentationNode augmentationNode = ImmutableAugmentationNodeBuilder.create()
- .withNodeIdentifier(new AugmentationIdentifier(augmentationChildren))
+ .withNodeIdentifier(augmentationId)
.withChild(leafNode(SIMPLE_VALUE_QNAME, "simpleValue"))
.build();
- final Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(
- BI_TOP_LEVEL_LIST_FOO_PATH.node(new AugmentationIdentifier(augmentationChildren)),
- augmentationNode);
+ final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
+ BI_TOP_LEVEL_LIST_FOO_PATH.node(augmentationId), augmentationNode);
assertEquals(new TreeLeafOnlyAugmentBuilder().setSimpleValue("simpleValue").build(), entry.getValue());
}
@Test
public void orderedleafListToNormalized() {
- List<String> topLevelLeafList = new ArrayList<>();
- topLevelLeafList.add("foo");
- Top top = new TopBuilder().setTopLevelOrderedLeafList(topLevelLeafList).build();
+ Top top = new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build();
- Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(
+ Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
InstanceIdentifier.create(Top.class), top);
ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(ImmutableOrderedLeafSetNodeBuilder.create()
+ .withChild(ImmutableUserLeafSetNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
.withChild(
ImmutableLeafSetEntryNodeBuilder.create()
@Test
public void leafListToNormalized() {
- final List<String> topLevelLeafList = new ArrayList<>();
- topLevelLeafList.add("foo");
- final Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
+ final Top top = new TopBuilder().setTopLevelLeafList(Set.of("foo")).build();
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(
+ final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
InstanceIdentifier.create(Top.class), top);
final ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
.withNodeIdentifier(new NodeWithValue<>(TOP_LEVEL_LEAF_LIST_QNAME, "foo"))
.withValue("foo").build()).build())
.build();
- final Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH,
+ final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH,
topWithLeafList);
- final List<String> topLevelLeafList = new ArrayList<>();
- topLevelLeafList.add("foo");
- final Top top = new TopBuilder().setTopLevelLeafList(topLevelLeafList).build();
+ final Top top = new TopBuilder().setTopLevelLeafList(Set.of("foo")).build();
assertEquals(top, entry.getValue());
}
public void orderedLeafListFromNormalized() {
ContainerNode topWithLeafList = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
- .withChild(ImmutableOrderedLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(
+ .withChild(ImmutableUserLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(
TOP_LEVEL_ORDERED_LEAF_LIST_QNAME))
.withChild(ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
new NodeWithValue<>(TOP_LEVEL_ORDERED_LEAF_LIST_QNAME, "foo")).withValue("foo").build())
.build())
.build();
- Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
- List<String> topLevelLeafList = new ArrayList<>();
- topLevelLeafList.add("foo");
- Top top = new TopBuilder().setTopLevelOrderedLeafList(topLevelLeafList).build();
+ Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_TOP_PATH, topWithLeafList);
+ Top top = new TopBuilder().setTopLevelOrderedLeafList(List.of("foo")).build();
assertEquals(top, entry.getValue());
}
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 = registry.toNormalizedNode(
+ final Entry<YangInstanceIdentifier, NormalizedNode> entry = codecContext.toNormalizedNode(
InstanceIdentifier.create(ChoiceContainer.class), choiceContainerBA);
final ContainerNode choiceContainer = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(CHOICE_CONTAINER_QNAME))
.withChild(leafNode(nestedContainerLeafOuterQname, "bar"))
.build())
.build();
- final Entry<InstanceIdentifier<?>, DataObject> entryContainer = registry.fromNormalizedNode(
+ final Entry<InstanceIdentifier<?>, DataObject> entryContainer = codecContext.fromNormalizedNode(
yangInstanceIdentifierOuter, containerNodeOuter);
assertNotNull(entryContainer.getValue());
assertNotNull(entryContainer.getKey());
.build())
.build();
try {
- registry.fromNormalizedNode(yangInstanceIdentifierValid, containerNodeValid);
+ codecContext.fromNormalizedNode(yangInstanceIdentifierValid, containerNodeValid);
fail("Incorect YangInstanceIdentifier should fail");
} catch (IllegalStateException e) {
// Expected
.build())
.build();
try {
- registry.fromNormalizedNode(yangInstanceIdentifier4798, containerNode4798);
+ codecContext.fromNormalizedNode(yangInstanceIdentifier4798, containerNode4798);
fail("Incorect YangInstanceIdentifier should fail");
} catch (IllegalStateException e) {
// Expected
.withNodeIdentifier(new NodeIdentifier(EXTENDED_ID_QNAME))
.withChild(leafNode(CHOICE_IDENTIFIER_ID_QNAME, "identifier_value")).build()).build())
.build();
- final Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_CHOICE_CONTAINER_PATH,
+ final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(BI_CHOICE_CONTAINER_PATH,
choiceContainerBI);
final ChoiceContainer choiceContainerBA = new ChoiceContainerBuilder().setIdentifier(new ExtendedBuilder()
.setExtendedId(new ExtendedIdBuilder().setId("identifier_value").build()).build()).build();
@Test
public void orderedLisToNormalized() {
- final InstanceIdentifier<TopLevelList> ii = BA_TOP_LEVEL_LIST;
- final List<NestedList> nestedLists = new ArrayList<>();
- nestedLists.add(new NestedListBuilder().withKey(new NestedListKey("foo")).build());
- nestedLists.add(new NestedListBuilder().withKey(new NestedListKey("bar")).build());
- final TopLevelList topLevelList = new TopLevelListBuilder().withKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(
- nestedLists).build();
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry = registry.toNormalizedNode(ii, topLevelList);
+ final TopLevelList topLevelList = 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(ImmutableOrderedMapNodeBuilder.create()
+ .withChild(ImmutableUserMapNodeBuilder.create()
.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();
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(ImmutableOrderedMapNodeBuilder.create()
+ .withChild(ImmutableUserMapNodeBuilder.create()
.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();
- final Entry<InstanceIdentifier<?>, DataObject> entry = registry.fromNormalizedNode(BI_TOP_LEVEL_LIST_FOO_PATH,
- foo);
- final List<NestedList> nestedLists = new ArrayList<>();
- nestedLists.add(new NestedListBuilder().withKey(new NestedListKey("foo")).build());
- nestedLists.add(new NestedListBuilder().withKey(new NestedListKey("bar")).build());
- final TopLevelList topLevelList = new TopLevelListBuilder().withKey(TOP_LEVEL_LIST_FOO_KEY).setNestedList(
- nestedLists).build();
+ final Entry<InstanceIdentifier<?>, DataObject> entry = codecContext.fromNormalizedNode(
+ BI_TOP_LEVEL_LIST_FOO_PATH, foo);
+ final TopLevelList topLevelList = 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());
}
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(Collections.singleton(augmentChoice1QName));
- final AugmentationIdentifier aug2Id = new AugmentationIdentifier(Collections.singleton(augmentChoice2QName));
+ 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);
cccc1Builder.setCase11ChoiceCaseLeaf("leaf-value");
c11Builder.setCase11ChoiceCaseContainer(cccc1Builder.build());
tca2Builder.setAugmentChoice2(c11Builder.build());
- c1Builder.addAugmentation(TopChoiceAugment2.class, tca2Builder.build());
+ c1Builder.addAugmentation(tca2Builder.build());
tca1Builder.setAugmentChoice1(c1Builder.build());
- tBuilder.addAugmentation(TopChoiceAugment1.class, tca1Builder.build());
+ tBuilder.addAugmentation(tca1Builder.build());
final Top top = tBuilder.build();
- final Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> biResult = registry.toNormalizedNode(
+ final Entry<YangInstanceIdentifier, NormalizedNode> biResult = codecContext.toNormalizedNode(
InstanceIdentifier.create(Top.class), top);
- final NormalizedNode<?, ?> topNormalized =
- containerBuilder().withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
+ final NormalizedNode topNormalized = containerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TOP_QNAME))
.withChild(augmentationBuilder().withNodeIdentifier(aug1Id)
.withChild(choiceBuilder().withNodeIdentifier(augmentChoice1Id)
.withChild(augmentationBuilder().withNodeIdentifier(aug2Id)
assertEquals(BI_TOP_PATH, biResult.getKey());
assertEquals(topNormalized, biResult.getValue());
- final Entry<InstanceIdentifier<?>, DataObject> baResult = registry.fromNormalizedNode(BI_TOP_PATH,
+ final Entry<InstanceIdentifier<?>, DataObject> baResult = codecContext.fromNormalizedNode(BI_TOP_PATH,
topNormalized);
assertEquals(InstanceIdentifier.create(Top.class), baResult.getKey());