From 6cb5520bf2828671eee714aaae66b3a6b9038299 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 2 Nov 2022 23:17:39 +0100 Subject: [PATCH] Do not reference immutable node builders Use Builders/ImmutableNodes instead of direct implementation reference. Also use fluent nature of builders, which flushes out a number of unused constructs, which we remove here. Change-Id: I8803da6a244f4f4dceaf4da06934b0f8df24b827 Signed-off-by: Robert Varga --- .../transformer/NormalizedNodePrunerTest.java | 21 +- .../cluster/datastore/util/TestModel.java | 300 +++++++----------- ...ctDistributedDataStoreIntegrationTest.java | 25 +- ...butedDataStoreRemotingIntegrationTest.java | 25 +- .../cluster/datastore/ShardTest.java | 20 +- .../datastore/ShardTransactionTest.java | 30 +- .../messages/BatchedModificationsTest.java | 18 +- .../datastore/messages/ReadDataReplyTest.java | 12 +- .../modification/MergeModificationTest.java | 15 +- .../MutableCompositeModificationTest.java | 29 +- .../modification/WriteModificationTest.java | 15 +- .../CommitTransactionPayloadTest.java | 61 ++-- .../persisted/ShardDataTreeSnapshotTest.java | 16 +- .../persisted/ShardSnapshotStateTest.java | 14 +- .../PruningDataTreeModificationTest.java | 58 ++-- .../md/cluster/datastore/model/CarsModel.java | 62 ++-- .../datastore/model/CompositeModel.java | 141 ++++---- .../cluster/datastore/model/PeopleModel.java | 61 ++-- .../md/cluster/datastore/model/TestModel.java | 23 +- .../it/provider/impl/GetConstantService.java | 11 +- .../impl/RoutedGetConstantService.java | 11 +- .../impl/SingletonGetConstantService.java | 11 +- .../impl/WriteTransactionsHandler.java | 10 +- 23 files changed, 430 insertions(+), 559 deletions(-) diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java index 8001ebd051..ed98523df2 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePrunerTest.java @@ -37,8 +37,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; @RunWith(MockitoJUnitRunner.StrictStubs.class) @@ -372,17 +370,22 @@ public class NormalizedNodePrunerTest { private static NormalizedNode createTestContainer() { byte[] bytes1 = {1, 2, 3}; - LeafSetEntryNode entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( - new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).withValue(bytes1).build(); + LeafSetEntryNode entry1 = Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)) + .withValue(bytes1) + .build(); byte[] bytes2 = {}; - LeafSetEntryNode entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( - new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).withValue(bytes2).build(); + LeafSetEntryNode entry2 = Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)) + .withValue(bytes2).build(); return TestModel.createBaseTestContainerBuilder() - .withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier( - new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME)) - .withChild(entry1).withChild(entry2).build()) + .withChild(Builders.leafSetBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME)) + .withChild(entry1) + .withChild(entry2) + .build()) .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4})) .build(); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java index 7120c31de0..62bfe9f116 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java @@ -7,18 +7,16 @@ */ package org.opendaylight.controller.cluster.datastore.util; +import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode; import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry; import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder; import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import java.io.InputStream; -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; +import java.util.List; import java.util.Set; +import org.opendaylight.yangtools.yang.common.Decimal64; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -26,23 +24,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.Augmentat 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.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; -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.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; @@ -185,77 +170,6 @@ public final class TestModel { } public static DataContainerNodeBuilder createBaseTestContainerBuilder() { - // Create a list of shoes - // This is to test leaf list entry - final LeafSetEntryNode nike = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( - new NodeWithValue<>(SHOE_QNAME, "nike")).withValue("nike").build(); - - final LeafSetEntryNode puma = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( - new NodeWithValue<>(SHOE_QNAME, "puma")).withValue("puma").build(); - - final LeafSetNode shoes = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier( - new NodeIdentifier(SHOE_QNAME)).withChild(nike).withChild(puma).build(); - - // Test a leaf-list where each entry contains an identity - final LeafSetEntryNode cap1 = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - new NodeWithValue<>(QName.create( - TEST_QNAME, "capability"), DESC_QNAME)) - .withValue(DESC_QNAME).build(); - - final LeafSetNode capabilities = - ImmutableLeafSetNodeBuilder - .create() - .withNodeIdentifier( - new NodeIdentifier(QName.create( - TEST_QNAME, "capability"))).withChild(cap1).build(); - - ContainerNode switchFeatures = - ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier( - new NodeIdentifier(SWITCH_FEATURES_QNAME)) - .withChild(capabilities).build(); - - // Create a leaf list with numbers - final LeafSetEntryNode five = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - new NodeWithValue<>(QName.create( - TEST_QNAME, "number"), 5)).withValue(5).build(); - final LeafSetEntryNode fifteen = - ImmutableLeafSetEntryNodeBuilder - .create() - .withNodeIdentifier( - new NodeWithValue<>(QName.create( - TEST_QNAME, "number"), 15)).withValue(15).build(); - final LeafSetNode numbers = - ImmutableLeafSetNodeBuilder - .create() - .withNodeIdentifier( - new NodeIdentifier(QName.create( - TEST_QNAME, "number"))).withChild(five).withChild(fifteen) - .build(); - - - // Create augmentations - MapEntryNode augMapEntry = createAugmentedListEntry(1, "First Test"); - - // Create a bits leaf - NormalizedNodeBuilder> - myBits = Builders.leafBuilder() - .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "my-bits"))) - .withValue(ImmutableSet.of("foo", "bar")); - - // Create unkeyed list entry - UnkeyedListEntryNode unkeyedListEntry = Builders.unkeyedListEntryBuilder() - .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) - .withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed-entry-name")) - .build(); - // Create YangInstanceIdentifier with all path arg types. YangInstanceIdentifier instanceID = YangInstanceIdentifier.create( new NodeIdentifier(QName.create(TEST_QNAME, "qname")), @@ -265,43 +179,77 @@ public final class TestModel { QName.create(TEST_QNAME, "aug1"), QName.create(TEST_QNAME, "aug2"))), new NodeWithValue<>(QName.create(TEST_QNAME, "leaf-list-entry"), "foo")); - Map keyValues = new HashMap<>(); - keyValues.put(CHILDREN_QNAME, FIRST_CHILD_NAME); - - // Create the document - return ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) - .withChild(myBits.build()) - .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)) - .withChild(ImmutableNodes.leafNode(BOOLEAN_LEAF_QNAME, ENABLED)) - .withChild(ImmutableNodes.leafNode(SHORT_LEAF_QNAME, SHORT_ID)) - .withChild(ImmutableNodes.leafNode(BYTE_LEAF_QNAME, BYTE_ID)) - .withChild(ImmutableNodes.leafNode(TestModel.BIGINTEGER_LEAF_QNAME, Uint64.valueOf(100))) - .withChild(ImmutableNodes.leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, BigDecimal.valueOf(1.2))) - .withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, instanceID)) - .withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME)) - .withChild(Builders.unkeyedListBuilder() - .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) - .withChild(unkeyedListEntry).build()) - .withChild(Builders.choiceBuilder() - .withNodeIdentifier(new NodeIdentifier(TWO_THREE_QNAME)) - .withChild(ImmutableNodes.leafNode(TWO_QNAME, "two")).build()) - .withChild(Builders.orderedMapBuilder() - .withNodeIdentifier(new NodeIdentifier(ORDERED_LIST_QNAME)) - .withValue(ImmutableList.builder().add( - mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "1").build(), - mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "2").build()).build()) + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) + // Create a bits leaf + .withChild(leafNode(QName.create(TEST_QNAME, "my-bits"), ImmutableSet.of("foo", "bar"))) + .withChild(leafNode(DESC_QNAME, DESC)) + .withChild(leafNode(BOOLEAN_LEAF_QNAME, ENABLED)) + .withChild(leafNode(SHORT_LEAF_QNAME, SHORT_ID)) + .withChild(leafNode(BYTE_LEAF_QNAME, BYTE_ID)) + .withChild(leafNode(TestModel.BIGINTEGER_LEAF_QNAME, Uint64.valueOf(100))) + .withChild(leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, Decimal64.valueOf("1.2").scaleTo(2))) + .withChild(leafNode(SOME_REF_QNAME, instanceID)) + .withChild(leafNode(MYIDENTITY_QNAME, DESC_QNAME)) + .withChild(Builders.unkeyedListBuilder() + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) + // Create unkeyed list entry + .withChild(Builders.unkeyedListEntryBuilder() + .withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME)) + .withChild(leafNode(NAME_QNAME, "unkeyed-entry-name")) + .build()) + .build()) + .withChild(Builders.choiceBuilder() + .withNodeIdentifier(new NodeIdentifier(TWO_THREE_QNAME)) + .withChild(leafNode(TWO_QNAME, "two")).build()) + .withChild(Builders.orderedMapBuilder() + .withNodeIdentifier(new NodeIdentifier(ORDERED_LIST_QNAME)) + .withValue(List.of( + mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "1").build(), + mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "2").build())) + .build()) + .withChild(Builders.leafSetBuilder() + .withNodeIdentifier(new NodeIdentifier(SHOE_QNAME)) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(SHOE_QNAME, "nike")) + .withValue("nike") + .build()) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(SHOE_QNAME, "puma")) + .withValue("puma") + .build()) + .build()) + .withChild(Builders.leafSetBuilder() + .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "number"))) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5)) + .withValue(5) + .build()) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15)) + .withValue(15) + .build()) + .build()) + .withChild(Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(SWITCH_FEATURES_QNAME)) + // Test a leaf-list where each entry contains an identity + .withChild(Builders.leafSetBuilder() + .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "capability"))) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "capability"), DESC_QNAME)) + .withValue(DESC_QNAME) .build()) - .withChild(shoes) - .withChild(numbers) - .withChild(switchFeatures) - .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(augMapEntry).build()) - .withChild(mapNodeBuilder(OUTER_LIST_QNAME) - .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) - .withChild(BAR_NODE).build() - ); + .build()) + .build()) + .withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME) + // Create augmentations + .withChild(createAugmentedListEntry(1, "First Test")) + .build()) + .withChild(mapNodeBuilder(OUTER_LIST_QNAME) + .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) + .withChild(BAR_NODE) + .build()); } public static ContainerNode createTestContainer() { @@ -309,76 +257,44 @@ public final class TestModel { } public static MapEntryNode createAugmentedListEntry(final int id, final String name) { - Set childAugmentations = new HashSet<>(); - childAugmentations.add(AUG_CONT_QNAME); - - ContainerNode augCont = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(AUG_CONT_QNAME)) - .withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)) - .build(); - - - final AugmentationIdentifier augmentationIdentifier = new AugmentationIdentifier(childAugmentations); - final AugmentationNode augmentationNode = - Builders.augmentationBuilder() - .withNodeIdentifier(augmentationIdentifier).withChild(augCont) - .build(); - - return ImmutableMapEntryNodeBuilder.create() - .withNodeIdentifier(NodeIdentifierWithPredicates.of(AUGMENTED_LIST_QNAME, ID_QNAME, id)) - .withChild(ImmutableNodes.leafNode(ID_QNAME, id)) - .withChild(augmentationNode).build(); + return Builders.mapEntryBuilder() + .withNodeIdentifier(NodeIdentifierWithPredicates.of(AUGMENTED_LIST_QNAME, ID_QNAME, id)) + .withChild(leafNode(ID_QNAME, id)) + .withChild(Builders.augmentationBuilder() + .withNodeIdentifier(new AugmentationIdentifier(Set.of(AUG_CONT_QNAME))) + .withChild(Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(AUG_CONT_QNAME)) + .withChild(leafNode(AUG_NAME_QNAME, name)) + .build()) + .build()) + .build(); } public static ContainerNode createFamily() { - final DataContainerNodeBuilder - familyContainerBuilder = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new NodeIdentifier(FAMILY_QNAME)); - - final CollectionNodeBuilder childrenBuilder = mapNodeBuilder() - .withNodeIdentifier(new NodeIdentifier(CHILDREN_QNAME)); - - final DataContainerNodeBuilder - firstChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID); - final DataContainerNodeBuilder - secondChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID); - - final DataContainerNodeBuilder - firstGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID); - final DataContainerNodeBuilder - secondGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - SECOND_GRAND_CHILD_ID); - - firstGrandChildBuilder - .withChild( - ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID)).withChild( - ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, - FIRST_GRAND_CHILD_NAME)); - - secondGrandChildBuilder.withChild( - ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, SECOND_GRAND_CHILD_NAME)); - - firstChildBuilder - .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) - .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME) - .withChild(firstGrandChildBuilder.build()) - .build()); - - - secondChildBuilder - .withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) - .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME) - .withChild(firstGrandChildBuilder.build()) - .build()); - - childrenBuilder.withChild(firstChildBuilder.build()); - childrenBuilder.withChild(secondChildBuilder.build()); - - return familyContainerBuilder.withChild(childrenBuilder.build()).build(); + final var firstGrandChildBuilder = mapEntryBuilder( + GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, FIRST_GRAND_CHILD_ID) + .withChild(leafNode(GRAND_CHILD_NUMBER_QNAME,FIRST_GRAND_CHILD_ID)) + .withChild(leafNode(GRAND_CHILD_NAME_QNAME, FIRST_GRAND_CHILD_NAME)); + + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(FAMILY_QNAME)) + .withChild(mapNodeBuilder() + .withNodeIdentifier(new NodeIdentifier(CHILDREN_QNAME)) + .withChild(mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) + .withChild(leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) + .withChild(leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) + .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME) + .withChild(firstGrandChildBuilder.build()) + .build()) + .build()) + .withChild(mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) + .withChild(leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) + .withChild(leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) + .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME) + .withChild(firstGrandChildBuilder.build()) + .build()) + .build()) + .build()) + .build(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractDistributedDataStoreIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractDistributedDataStoreIntegrationTest.java index fa83bd010e..983dcda591 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractDistributedDataStoreIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractDistributedDataStoreIntegrationTest.java @@ -73,12 +73,13 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; 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.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.tree.api.DataTree; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration; import org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory; @@ -750,9 +751,10 @@ public abstract class AbstractDistributedDataStoreIntegrationTest { writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer()); - final ContainerNode invalidData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build(); + final ContainerNode invalidData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(CarsModel.BASE_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")) + .build(); writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData); @@ -790,9 +792,10 @@ public abstract class AbstractDistributedDataStoreIntegrationTest { writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer()); - final ContainerNode invalidData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build(); + final ContainerNode invalidData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(CarsModel.BASE_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")) + .build(); writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData); @@ -929,10 +932,10 @@ public abstract class AbstractDistributedDataStoreIntegrationTest { testParameter, "testRootOverwrite", "module-shards-default-cars-member1.conf", true, "cars", "default")) { - ContainerNode rootNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(YangInstanceIdentifier.NodeIdentifier.create(SchemaContext.NAME)) - .withChild(CarsModel.create()) - .build(); + ContainerNode rootNode = Builders.containerBuilder() + .withNodeIdentifier(NodeIdentifier.create(SchemaContext.NAME)) + .withChild(CarsModel.create()) + .build(); testKit.testWriteTransaction(dataStore, YangInstanceIdentifier.empty(), rootNode); IntegrationTestKit.verifyShardState(dataStore, "cars", diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java index bb2093bcc3..1cdca5aae0 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java @@ -115,13 +115,14 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; 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.SystemMapNode; import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.tree.api.ConflictingModificationAppliedException; import org.opendaylight.yangtools.yang.data.tree.api.DataTree; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration; @@ -654,11 +655,10 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { final DOMDataTreeWriteTransaction writeTx = txChain.newWriteOnlyTransaction(); - final ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build(); - - writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData); + writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(CarsModel.BASE_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")) + .build()); final var ex = assertThrows(ExecutionException.class, () -> writeTx.commit().get(5, TimeUnit.SECONDS)) .getCause(); @@ -686,13 +686,12 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer()); - final ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build(); - // Note that merge will validate the data and fail but put succeeds b/c deep validation is not // done for put for performance reasons. - writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData); + writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(CarsModel.BASE_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")) + .build()); final var ex = assertThrows(ExecutionException.class, () -> writeTx.commit().get(5, TimeUnit.SECONDS)) .getCause(); @@ -1444,8 +1443,8 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { followerDatastoreContextBuilder.snapshotOnRootOverwrite(true)); leaderTestKit.waitForMembersUp("member-2"); - final ContainerNode rootNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(YangInstanceIdentifier.NodeIdentifier.create(SchemaContext.NAME)) + final ContainerNode rootNode = Builders.containerBuilder() + .withNodeIdentifier(NodeIdentifier.create(SchemaContext.NAME)) .withChild(CarsModel.create()) .build(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java index fd88e4d186..2ac7c6ea59 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java @@ -106,11 +106,12 @@ import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelpe import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.yangtools.concepts.Identifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.tree.api.DataTree; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration; @@ -293,10 +294,12 @@ public class ShardTest extends AbstractShardTest { final DataTree store = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT); - final ContainerNode container = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).addChild( - ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build()).build(); + final ContainerNode container = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME) + .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)) + .build()) + .build(); writeToStore(store, TestModel.TEST_PATH, container); @@ -683,9 +686,10 @@ public class ShardTest extends AbstractShardTest { final TransactionIdentifier transactionID = nextTransactionId(); - final ContainerNode invalidData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build(); + final ContainerNode invalidData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")) + .build(); BatchedModifications batched = new BatchedModifications(transactionID, CURRENT_VERSION); batched.addModification(new MergeModification(TestModel.TEST_PATH, invalidData)); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java index 5da78530a1..7769f80e4f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java @@ -47,10 +47,11 @@ import org.opendaylight.controller.cluster.datastore.modification.WriteModificat import org.opendaylight.controller.cluster.raft.TestActorFactory; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; @@ -166,14 +167,15 @@ public class ShardTransactionTest extends AbstractActorTest { final ActorRef transaction = newTransactionActor(RW, mockWriteTx, "testOnReceiveBatchedModifications"); YangInstanceIdentifier writePath = TestModel.TEST_PATH; - NormalizedNode writeData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + NormalizedNode writeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build(); YangInstanceIdentifier mergePath = TestModel.OUTER_LIST_PATH; - NormalizedNode mergeData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)) - .build(); + NormalizedNode mergeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME)) + .build(); YangInstanceIdentifier deletePath = TestModel.TEST_PATH; @@ -204,9 +206,10 @@ public class ShardTransactionTest extends AbstractActorTest { watcher.watch(transaction); YangInstanceIdentifier writePath = TestModel.TEST_PATH; - NormalizedNode writeData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + NormalizedNode writeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build(); final TransactionIdentifier tx1 = nextTransactionId(); BatchedModifications batched = new BatchedModifications(tx1, DataStoreVersions.CURRENT_VERSION); @@ -235,9 +238,10 @@ public class ShardTransactionTest extends AbstractActorTest { watcher.watch(transaction); YangInstanceIdentifier writePath = TestModel.TEST_PATH; - NormalizedNode writeData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + NormalizedNode writeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build(); BatchedModifications batched = new BatchedModifications(nextTransactionId(), DataStoreVersions.CURRENT_VERSION); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/BatchedModificationsTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/BatchedModificationsTest.java index 2cb5c81e9d..fe4941a197 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/BatchedModificationsTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/BatchedModificationsTest.java @@ -25,9 +25,10 @@ import org.opendaylight.controller.cluster.datastore.modification.MergeModificat import org.opendaylight.controller.cluster.datastore.modification.WriteModification; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; /** * Unit tests for BatchedModifications. @@ -35,17 +36,18 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo * @author Thomas Pantelis */ public class BatchedModificationsTest extends AbstractTest { - @Test public void testSerialization() { YangInstanceIdentifier writePath = TestModel.TEST_PATH; - NormalizedNode writeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + ContainerNode writeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build(); YangInstanceIdentifier mergePath = TestModel.OUTER_LIST_PATH; - NormalizedNode mergeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).build(); + ContainerNode mergeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME)) + .build(); YangInstanceIdentifier deletePath = TestModel.TEST_PATH; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReplyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReplyTest.java index f01b09c716..d805e6afac 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReplyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ReadDataReplyTest.java @@ -16,10 +16,10 @@ import org.apache.commons.lang.SerializationUtils; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.DataStoreVersions; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; /** * Unit tests for ReadDataReply. @@ -30,9 +30,9 @@ public class ReadDataReplyTest { @Test public void testSerialization() { - NormalizedNode data = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + ContainerNode data = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); ReadDataReply expected = new ReadDataReply(data, DataStoreVersions.CURRENT_VERSION); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java index f5ada9ffe3..31e06b8054 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MergeModificationTest.java @@ -14,10 +14,9 @@ import org.apache.commons.lang.SerializationUtils; import org.junit.Test; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; public class MergeModificationTest extends AbstractModificationTest { @Test @@ -37,12 +36,10 @@ public class MergeModificationTest extends AbstractModificationTest { @Test public void testSerialization() { - YangInstanceIdentifier path = TestModel.TEST_PATH; - NormalizedNode data = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); - - MergeModification expected = new MergeModification(path, data); + MergeModification expected = new MergeModification(TestModel.TEST_PATH, Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build()); MergeModification clone = (MergeModification) SerializationUtils.clone(expected); assertEquals("getPath", expected.getPath(), clone.getPath()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java index 35ee8fc5bb..2d7258e9e8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModificationTest.java @@ -15,9 +15,10 @@ import org.opendaylight.controller.cluster.datastore.DataStoreVersions; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; public class MutableCompositeModificationTest extends AbstractModificationTest { @Test @@ -36,13 +37,15 @@ public class MutableCompositeModificationTest extends AbstractModificationTest { @Test public void testSerialization() { YangInstanceIdentifier writePath = TestModel.TEST_PATH; - NormalizedNode writeData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + ContainerNode writeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build(); YangInstanceIdentifier mergePath = TestModel.OUTER_LIST_PATH; - NormalizedNode mergeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).build(); + ContainerNode mergeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME)) + .build(); YangInstanceIdentifier deletePath = TestModel.TEST_PATH; @@ -78,13 +81,15 @@ public class MutableCompositeModificationTest extends AbstractModificationTest { @Test public void testSerializationModern() { YangInstanceIdentifier writePath = TestModel.TEST_PATH; - NormalizedNode writeData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + ContainerNode writeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build(); YangInstanceIdentifier mergePath = TestModel.OUTER_LIST_PATH; - NormalizedNode mergeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).build(); + ContainerNode mergeData = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.OUTER_LIST_QNAME)) + .build(); YangInstanceIdentifier deletePath = TestModel.TEST_PATH; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java index 416b9ae0ef..20409999d8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/modification/WriteModificationTest.java @@ -14,10 +14,9 @@ import org.apache.commons.lang.SerializationUtils; import org.junit.Test; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; public class WriteModificationTest extends AbstractModificationTest { @Test @@ -34,12 +33,10 @@ public class WriteModificationTest extends AbstractModificationTest { @Test public void testSerialization() { - YangInstanceIdentifier path = TestModel.TEST_PATH; - NormalizedNode data = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); - - WriteModification expected = new WriteModification(path, data); + WriteModification expected = new WriteModification(TestModel.TEST_PATH, Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build()); WriteModification clone = (WriteModification) SerializationUtils.clone(expected); assertEquals("getPath", expected.getPath(), clone.getPath()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayloadTest.java index 2306b4a31f..e3696e0fb7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayloadTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayloadTest.java @@ -23,13 +23,11 @@ import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelpe import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -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.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.tree.api.DataTree; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode; @@ -100,11 +98,10 @@ public class CommitTransactionPayloadTest extends AbstractTest { @Before public void setUp() { setUpStatic(); - final YangInstanceIdentifier writePath = TestModel.TEST_PATH; - final NormalizedNode writeData = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); - candidate = DataTreeCandidates.fromNormalizedNode(writePath, writeData); + candidate = DataTreeCandidates.fromNormalizedNode(TestModel.TEST_PATH, Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build()); } @Test @@ -125,49 +122,46 @@ public class CommitTransactionPayloadTest extends AbstractTest { assertCandidateEquals(candidate, SerializationUtils.clone(payload).getCandidate().getValue()); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testLeafSetEntryNodeCandidate() throws Exception { - YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one"); + NodeWithValue entryPathArg = new NodeWithValue<>(LEAF_SET, "one"); YangInstanceIdentifier leafSetEntryPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET) .node(entryPathArg).build(); - NormalizedNode leafSetEntryNode = Builders.leafSetEntryBuilder().withNodeIdentifier(entryPathArg) - .withValue("one").build(); - - candidate = DataTreeCandidates.fromNormalizedNode(leafSetEntryPath, leafSetEntryNode); + candidate = DataTreeCandidates.fromNormalizedNode(leafSetEntryPath, Builders.leafSetEntryBuilder() + .withNodeIdentifier(entryPathArg) + .withValue("one") + .build()); CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate); assertCandidateEquals(candidate, payload.getCandidate().getValue()); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testLeafSetNodeCandidate() throws Exception { - YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one"); YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build(); - LeafSetEntryNode leafSetEntryNode = Builders.leafSetEntryBuilder().withNodeIdentifier(entryPathArg) - .withValue("one").build(); - NormalizedNode leafSetNode = Builders.leafSetBuilder().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(LEAF_SET)).withChild(leafSetEntryNode).build(); - - candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, leafSetNode); + candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, Builders.leafSetBuilder() + .withNodeIdentifier(new NodeIdentifier(LEAF_SET)) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(LEAF_SET, "one")) + .withValue("one") + .build()) + .build()); CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate); assertCandidateEquals(candidate, payload.getCandidate().getValue()); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testOrderedLeafSetNodeCandidate() throws Exception { - YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one"); YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build(); - LeafSetEntryNode leafSetEntryNode = Builders.leafSetEntryBuilder().withNodeIdentifier(entryPathArg) - .withValue("one").build(); - NormalizedNode leafSetNode = Builders.orderedLeafSetBuilder().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(LEAF_SET)).withChild(leafSetEntryNode).build(); - - candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, leafSetNode); + candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, Builders.orderedLeafSetBuilder() + .withNodeIdentifier(new NodeIdentifier(LEAF_SET)) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(LEAF_SET, "one")) + .withValue("one") + .build()) + .build()); CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate); assertCandidateEquals(candidate, payload.getCandidate().getValue()); } @@ -176,10 +170,9 @@ public class CommitTransactionPayloadTest extends AbstractTest { public void testLeafNodeCandidate() throws Exception { YangInstanceIdentifier leafPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH) .node(TestModel.DESC_QNAME).build(); - LeafNode leafNode = Builders.leafBuilder().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TestModel.DESC_QNAME)).withValue("test").build(); - candidate = DataTreeCandidates.fromNormalizedNode(leafPath, leafNode); + candidate = DataTreeCandidates.fromNormalizedNode(leafPath, + ImmutableNodes.leafNode(TestModel.DESC_QNAME, "test")); CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate); assertCandidateEquals(candidate, payload.getCandidate().getValue()); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotTest.java index 3051194a6f..22d844a221 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotTest.java @@ -10,7 +10,6 @@ package org.opendaylight.controller.cluster.datastore.persisted; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import com.google.common.collect.ImmutableMap; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.Externalizable; @@ -23,10 +22,11 @@ import java.util.Map; import java.util.Optional; import org.junit.Test; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; /** * Unit tests for ShardDataTreeSnapshot. @@ -37,8 +37,8 @@ public class ShardDataTreeSnapshotTest { @Test public void testShardDataTreeSnapshotWithNoMetadata() throws Exception { - NormalizedNode expectedNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) + ContainerNode expectedNode = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); MetadataShardDataTreeSnapshot snapshot = new MetadataShardDataTreeSnapshot(expectedNode); @@ -64,12 +64,12 @@ public class ShardDataTreeSnapshotTest { @Test public void testShardDataTreeSnapshotWithMetadata() throws Exception { - NormalizedNode expectedNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) + ContainerNode expectedNode = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); Map>, ShardDataTreeSnapshotMetadata> expMetadata = - ImmutableMap.of(TestShardDataTreeSnapshotMetadata.class, new TestShardDataTreeSnapshotMetadata("test")); + Map.of(TestShardDataTreeSnapshotMetadata.class, new TestShardDataTreeSnapshotMetadata("test")); MetadataShardDataTreeSnapshot snapshot = new MetadataShardDataTreeSnapshot(expectedNode, expMetadata); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (ObjectOutputStream out = new ObjectOutputStream(bos)) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotStateTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotStateTest.java index 4b324ff29b..ec7b74bedf 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotStateTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotStateTest.java @@ -13,10 +13,10 @@ import static org.junit.Assert.assertNotNull; import org.apache.commons.lang.SerializationUtils; import org.junit.Test; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; /** * Unit tests for ShardSnapshotState. @@ -24,12 +24,12 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo * @author Thomas Pantelis */ public class ShardSnapshotStateTest { - @Test public void testSerialization() { - NormalizedNode expectedNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + ContainerNode expectedNode = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)) + .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")) + .build(); ShardSnapshotState expected = new ShardSnapshotState(new MetadataShardDataTreeSnapshot(expectedNode)); ShardSnapshotState cloned = (ShardSnapshotState) SerializationUtils.clone(expected); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java index 27aa60619a..4fe47ec635 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java @@ -41,11 +41,12 @@ import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelpe import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.tree.api.DataTree; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration; @@ -145,14 +146,16 @@ public class PruningDataTreeModificationTest { @Test public void testMergeWithInvalidChildNodeNames() throws DataValidationFailedException { - ContainerNode augContainer = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(AUG_CONTAINER)).withChild( - ImmutableNodes.containerNode(AUG_INNER_CONTAINER)).build(); - DataContainerChild outerNode = outerNode(outerNodeEntry(1, innerNode("one", "two"))); - ContainerNode normalizedNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode) - .withChild(augContainer).withChild(ImmutableNodes.leafNode(AUG_QNAME, "aug")).build(); + ContainerNode normalizedNode = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) + .withChild(outerNode) + .withChild(Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(AUG_CONTAINER)) + .withChild(ImmutableNodes.containerNode(AUG_INNER_CONTAINER)) + .build()) + .withChild(ImmutableNodes.leafNode(AUG_QNAME, "aug")) + .build(); YangInstanceIdentifier path = TestModel.TEST_PATH; @@ -160,8 +163,10 @@ public class PruningDataTreeModificationTest { dataTree.commit(getCandidate()); - ContainerNode prunedNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode).build(); + ContainerNode prunedNode = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) + .withChild(outerNode) + .build(); Optional actual = dataTree.takeSnapshot().readNode(path); assertTrue("After pruning present", actual.isPresent()); @@ -217,9 +222,10 @@ public class PruningDataTreeModificationTest { ShardDataTree shardDataTree = new ShardDataTree(mockShard, SCHEMA_CONTEXT, TreeType.CONFIGURATION); NormalizedNode root = shardDataTree.readNode(YangInstanceIdentifier.empty()).get(); - NormalizedNode normalizedNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(root.getIdentifier().getNodeType())).withChild( - ImmutableNodes.containerNode(AUG_CONTAINER)).build(); + NormalizedNode normalizedNode = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(root.getIdentifier().getNodeType())) + .withChild(ImmutableNodes.containerNode(AUG_CONTAINER)) + .build(); pruningDataTreeModification.write(YangInstanceIdentifier.empty(), normalizedNode); dataTree.commit(getCandidate()); @@ -244,15 +250,17 @@ public class PruningDataTreeModificationTest { @Test public void testWriteWithInvalidChildNodeNames() throws DataValidationFailedException { - ContainerNode augContainer = ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(AUG_CONTAINER)).withChild( - ImmutableNodes.containerNode(AUG_INNER_CONTAINER)).build(); - DataContainerChild outerNode = outerNode(outerNodeEntry(1, innerNode("one", "two"))); - ContainerNode normalizedNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode) - .withChild(augContainer).withChild(ImmutableNodes.leafNode(AUG_QNAME, "aug")) - .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name")).build(); + ContainerNode normalizedNode = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) + .withChild(outerNode) + .withChild(Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(AUG_CONTAINER)) + .withChild(ImmutableNodes.containerNode(AUG_INNER_CONTAINER)) + .build()) + .withChild(ImmutableNodes.leafNode(AUG_QNAME, "aug")) + .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name")) + .build(); YangInstanceIdentifier path = TestModel.TEST_PATH; @@ -260,9 +268,11 @@ public class PruningDataTreeModificationTest { dataTree.commit(getCandidate()); - ContainerNode prunedNode = ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outerNode) - .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name")).build(); + ContainerNode prunedNode = Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) + .withChild(outerNode) + .withChild(ImmutableNodes.leafNode(NAME_QNAME, "name")) + .build(); Optional actual = dataTree.takeSnapshot().readNode(path); assertTrue("After pruning present", actual.isPresent()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java index 0722fcdbae..4b37946161 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java @@ -10,15 +10,14 @@ package org.opendaylight.controller.md.cluster.datastore.model; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; 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.MapNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; public final class CarsModel { public static final QName BASE_QNAME = QName.create( @@ -33,38 +32,26 @@ public final class CarsModel { public static final YangInstanceIdentifier CAR_LIST_PATH = BASE_PATH.node(CAR_QNAME); private CarsModel() { - + // Hidden on purpose } public static ContainerNode create() { - - // Create a list builder - CollectionNodeBuilder cars = - ImmutableMapNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(CAR_QNAME)); - - // Create an entry for the car altima - MapEntryNode altima = - ImmutableNodes.mapEntryBuilder(CAR_QNAME, CAR_NAME_QNAME, "altima") - .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, "altima")) - .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, Uint64.valueOf(1000))) - .build(); - - // Create an entry for the car accord - MapEntryNode honda = - ImmutableNodes.mapEntryBuilder(CAR_QNAME, CAR_NAME_QNAME, "accord") - .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, "accord")) - .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, Uint64.valueOf("2000"))) - .build(); - - cars.withChild(altima); - cars.withChild(honda); - - return ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME)) - .withChild(cars.build()) + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(BASE_QNAME)) + .withChild(Builders.mapBuilder() + .withNodeIdentifier(new NodeIdentifier(CAR_QNAME)) + // Create an entry for the car altima + .withChild(ImmutableNodes.mapEntryBuilder(CAR_QNAME, CAR_NAME_QNAME, "altima") + .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, "altima")) + .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, Uint64.valueOf(1000))) + .build()) + // Create an entry for the car accord + .withChild(ImmutableNodes.mapEntryBuilder(CAR_QNAME, CAR_NAME_QNAME, "accord") + .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, "accord")) + .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, Uint64.valueOf("2000"))) + .build()) + .build()) .build(); - } public static NormalizedNode createEmptyCarsList() { @@ -72,13 +59,14 @@ public final class CarsModel { } public static ContainerNode newCarsNode(final MapNode carsList) { - return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier( - BASE_QNAME)).withChild(carsList).build(); + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(BASE_QNAME)) + .withChild(carsList) + .build(); } public static MapNode newCarsMapNode(final MapEntryNode... carEntries) { - CollectionNodeBuilder builder = ImmutableMapNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CAR_QNAME)); + var builder = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(CAR_QNAME)); for (MapEntryNode e : carEntries) { builder.withChild(e); } @@ -87,9 +75,7 @@ public final class CarsModel { } public static ContainerNode emptyContainer() { - return ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME)) - .build(); + return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(BASE_QNAME)).build(); } public static SystemMapNode newCarMapNode() { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java index 0e041e0af5..8515ef78b5 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java @@ -7,31 +7,20 @@ */ package org.opendaylight.controller.md.cluster.datastore.model; +import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode; import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry; 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.HashSet; import java.util.Set; 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.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; -import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; @@ -99,14 +88,14 @@ public final class CompositeModel { private static final String SECOND_GRAND_CHILD_NAME = "second grand child"; private static final MapEntryNode BAR_NODE = mapEntryBuilder(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) - .withChild(mapNodeBuilder(INNER_LIST_QNAME) - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) - .build()) - .build(); + .withChild(mapNodeBuilder(INNER_LIST_QNAME) + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) + .build()) + .build(); private CompositeModel() { - + // Hidden on purpose } public static SchemaContext createTestContext() { @@ -115,75 +104,63 @@ public final class CompositeModel { } public static ContainerNode createTestContainer() { - final LeafSetEntryNode nike = ImmutableLeafSetEntryNodeBuilder.create() - .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "nike")) - .withValue("nike").build(); - final LeafSetEntryNode puma = ImmutableLeafSetEntryNodeBuilder.create() - .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "puma")) - .withValue("puma").build(); - final LeafSetNode shoes = ImmutableLeafSetNodeBuilder.create() + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) + .withChild(leafNode(DESC_QNAME, DESC)) + .withChild(Builders.augmentationBuilder() + .withNodeIdentifier(new AugmentationIdentifier(Set.of(AUG_QNAME))) + .withChild(leafNode(AUG_QNAME, "First Test")) + .build()) + .withChild(Builders.leafSetBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "shoe"))) - .withChild(nike).withChild(puma).build(); - - final LeafSetEntryNode five = ImmutableLeafSetEntryNodeBuilder.create() - .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5)) - .withValue(5).build(); - final LeafSetEntryNode fifteen = ImmutableLeafSetEntryNodeBuilder.create() - .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15)) - .withValue(15).build(); - final LeafSetNode numbers = ImmutableLeafSetNodeBuilder.create() + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "nike")) + .withValue("nike") + .build()) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "puma")) + .withValue("puma") + .build()) + .build()) + .withChild(Builders.leafSetBuilder() .withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "number"))) - .withChild(five).withChild(fifteen).build(); - - Set childAugmentations = new HashSet<>(); - childAugmentations.add(AUG_QNAME); - final AugmentationIdentifier augmentationIdentifier = new AugmentationIdentifier(childAugmentations); - final AugmentationNode augmentationNode = Builders.augmentationBuilder() - .withNodeIdentifier(augmentationIdentifier).withChild(ImmutableNodes.leafNode(AUG_QNAME, "First Test")) - .build(); - return ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) - .withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)).withChild(augmentationNode).withChild(shoes) - .withChild(numbers).withChild(mapNodeBuilder(OUTER_LIST_QNAME) - .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)).withChild(BAR_NODE).build()) - .build(); + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5)) + .withValue(5) + .build()) + .withChild(Builders.leafSetEntryBuilder() + .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15)) + .withValue(15) + .build()) + .build()) + .withChild(mapNodeBuilder(OUTER_LIST_QNAME) + .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) + .withChild(BAR_NODE) + .build()) + .build(); } public static ContainerNode createFamily() { - final DataContainerNodeBuilder familyContainerBuilder = - ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(FAMILY_QNAME)); - - final CollectionNodeBuilder childrenBuilder = mapNodeBuilder(CHILDREN_QNAME); - - final DataContainerNodeBuilder - firstChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID); - final DataContainerNodeBuilder - secondChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID); - - final DataContainerNodeBuilder - firstGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - FIRST_GRAND_CHILD_ID); - final DataContainerNodeBuilder - secondGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, - SECOND_GRAND_CHILD_ID); - - firstGrandChildBuilder.withChild(ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, FIRST_GRAND_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, FIRST_GRAND_CHILD_NAME)); - - secondGrandChildBuilder.withChild(ImmutableNodes.leafNode(GRAND_CHILD_NUMBER_QNAME, SECOND_GRAND_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(GRAND_CHILD_NAME_QNAME, SECOND_GRAND_CHILD_NAME)); - - firstChildBuilder.withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) - .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(firstGrandChildBuilder.build()).build()); - - secondChildBuilder.withChild(ImmutableNodes.leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) - .withChild(ImmutableNodes.leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) - .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(firstGrandChildBuilder.build()).build()); - - childrenBuilder.withChild(firstChildBuilder.build()); - childrenBuilder.withChild(secondChildBuilder.build()); + final var firstGrandChild = + mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME, FIRST_GRAND_CHILD_ID) + .withChild(leafNode(GRAND_CHILD_NUMBER_QNAME, FIRST_GRAND_CHILD_ID)) + .withChild(leafNode(GRAND_CHILD_NAME_QNAME, FIRST_GRAND_CHILD_NAME)) + .build(); - return familyContainerBuilder.withChild(childrenBuilder.build()).build(); + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(FAMILY_QNAME)) + .withChild(mapNodeBuilder(CHILDREN_QNAME) + .withChild(mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID) + .withChild(leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID)) + .withChild(leafNode(CHILD_NAME_QNAME, FIRST_CHILD_NAME)) + .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(firstGrandChild).build()) + .build()) + .withChild(mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID) + .withChild(leafNode(CHILD_NUMBER_QNAME, SECOND_CHILD_ID)) + .withChild(leafNode(CHILD_NAME_QNAME, SECOND_CHILD_NAME)) + .withChild(mapNodeBuilder(GRAND_CHILDREN_QNAME).withChild(firstGrandChild).build()) + .build()) + .build()) + .build(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java index 2672943685..ee2a416cbc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java @@ -9,13 +9,12 @@ package org.opendaylight.controller.md.cluster.datastore.model; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; 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.SystemMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; public final class PeopleModel { public static final QName BASE_QNAME = QName.create( @@ -30,45 +29,31 @@ public final class PeopleModel { public static final YangInstanceIdentifier PERSON_LIST_PATH = BASE_PATH.node(PERSON_QNAME); private PeopleModel() { - + // Hidden on purpose } public static ContainerNode create() { - - // Create a list builder - CollectionNodeBuilder cars = - ImmutableMapNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier( - PERSON_QNAME)); - - // Create an entry for the person jack - MapEntryNode jack = - ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jack") - .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jack")) - .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 100L)) - .build(); - - // Create an entry for the person jill - MapEntryNode jill = - ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jill") - .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jill")) - .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 200L)) - .build(); - - cars.withChild(jack); - cars.withChild(jill); - - return ImmutableContainerNodeBuilder.create() - .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME)) - .withChild(cars.build()) + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(BASE_QNAME)) + .withChild(Builders.mapBuilder() + .withNodeIdentifier(new NodeIdentifier(PERSON_QNAME)) + // Create an entry for the person jack + .withChild(ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jack") + .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jack")) + .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 100L)) + .build()) + // Create an entry for the person jill + .withChild(ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, "jill") + .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, "jill")) + .withChild(ImmutableNodes.leafNode(PERSON_AGE_QNAME, 200L)) + .build()) + .build()) .build(); - } public static ContainerNode emptyContainer() { - return ImmutableContainerNodeBuilder.create() - .withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(BASE_QNAME)) + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(BASE_QNAME)) .build(); } @@ -78,11 +63,13 @@ public final class PeopleModel { public static MapEntryNode newPersonEntry(final String name) { return ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, name) - .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, name)).build(); + .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, name)) + .build(); } public static YangInstanceIdentifier newPersonPath(final String name) { return YangInstanceIdentifier.builder(PERSON_LIST_PATH) - .nodeWithKey(PERSON_QNAME, PERSON_NAME_QNAME, name).build(); + .nodeWithKey(PERSON_QNAME, PERSON_NAME_QNAME, name) + .build(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java index 5555b887d2..31a9282561 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java @@ -9,14 +9,13 @@ package org.opendaylight.controller.md.cluster.datastore.model; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +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.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; 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.SystemMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; @@ -65,7 +64,7 @@ public final class TestModel { } public static DataContainerChild outerNode(final int... ids) { - CollectionNodeBuilder outer = ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME); + var outer = ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME); for (int id: ids) { outer.addChild(ImmutableNodes.mapEntry(OUTER_LIST_QNAME, ID_QNAME, id)); } @@ -74,7 +73,7 @@ public final class TestModel { } public static DataContainerChild outerNode(final MapEntryNode... entries) { - CollectionNodeBuilder outer = ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME); + var outer = ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME); for (MapEntryNode e: entries) { outer.addChild(e); } @@ -83,7 +82,7 @@ public final class TestModel { } public static DataContainerChild innerNode(final String... names) { - CollectionNodeBuilder outer = ImmutableNodes.mapNodeBuilder(INNER_LIST_QNAME); + var outer = ImmutableNodes.mapNodeBuilder(INNER_LIST_QNAME); for (String name: names) { outer.addChild(ImmutableNodes.mapEntry(INNER_LIST_QNAME, NAME_QNAME, name)); } @@ -95,13 +94,15 @@ public final class TestModel { return ImmutableNodes.mapEntryBuilder(OUTER_LIST_QNAME, ID_QNAME, id).addChild(inner).build(); } - public static NormalizedNode testNodeWithOuter(final int... ids) { + public static ContainerNode testNodeWithOuter(final int... ids) { return testNodeWithOuter(outerNode(ids)); } - public static NormalizedNode testNodeWithOuter(final DataContainerChild outer) { - return ImmutableContainerNodeBuilder.create().withNodeIdentifier( - new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(outer).build(); + public static ContainerNode testNodeWithOuter(final DataContainerChild outer) { + return Builders.containerBuilder() + .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) + .withChild(outer) + .build(); } public static NodeIdentifierWithPredicates outerEntryKey(final int id) { diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java index d6c39f1996..284586c1cf 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/GetConstantService.java @@ -22,8 +22,8 @@ import org.opendaylight.yangtools.yang.common.XMLNamespace; import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,12 +55,9 @@ public final class GetConstantService implements DOMRpcImplementation { public ListenableFuture invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) { LOG.debug("get-constant invoked, current value: {}", constant); - return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create() + return Futures.immediateFuture(new DefaultDOMRpcResult(Builders.containerBuilder() .withNodeIdentifier(new NodeIdentifier(OUTPUT)) - .withChild(ImmutableLeafNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(CONSTANT)) - .withValue(constant) - .build()) + .withChild(ImmutableNodes.leafNode(CONSTANT, constant)) .build())); } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java index 72888cd10d..34a333521b 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/RoutedGetConstantService.java @@ -25,8 +25,8 @@ import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,12 +62,9 @@ public final class RoutedGetConstantService implements DOMRpcImplementation { public ListenableFuture invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) { LOG.debug("get-contexted-constant invoked, current value: {}", constant); - return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create() + return Futures.immediateFuture(new DefaultDOMRpcResult(Builders.containerBuilder() .withNodeIdentifier(new NodeIdentifier(OUTPUT)) - .withChild(ImmutableLeafNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(CONSTANT)) - .withValue(constant) - .build()) + .withChild(ImmutableNodes.leafNode(CONSTANT, constant)) .build())); } } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java index 31d002268c..d53b89e903 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/SingletonGetConstantService.java @@ -26,8 +26,8 @@ import org.opendaylight.yangtools.yang.common.XMLNamespace; import org.opendaylight.yangtools.yang.common.YangConstants; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,12 +68,9 @@ public final class SingletonGetConstantService implements DOMRpcImplementation, public ListenableFuture invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) { LOG.debug("get-singleton-constant invoked, current value: {}", constant); - return Futures.immediateFuture(new DefaultDOMRpcResult(ImmutableContainerNodeBuilder.create() + return Futures.immediateFuture(new DefaultDOMRpcResult(Builders.containerBuilder() .withNodeIdentifier(new NodeIdentifier(OUTPUT)) - .withChild(ImmutableLeafNodeBuilder.create() - .withNodeIdentifier(new NodeIdentifier(CONSTANT)) - .withValue(constant) - .build()) + .withChild(ImmutableNodes.leafNode(CONSTANT, constant)) .build())); } diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java index ad0a956820..7fc366e2e2 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java @@ -40,10 +40,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent 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.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode; -import org.opendaylight.yangtools.yang.data.api.schema.builder.CollectionNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -138,7 +136,7 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle .build(); final YangInstanceIdentifier idListItem = ID_INT_YID.node(entry.getIdentifier()); - final ContainerNode containerNode = ImmutableContainerNodeBuilder.create() + final ContainerNode containerNode = Builders.containerBuilder() .withNodeIdentifier(new NodeIdentifier(ID_INTS)) .withChild(ImmutableNodes.mapNodeBuilder(ID_INT).build()) .build(); @@ -181,11 +179,9 @@ public abstract class WriteTransactionsHandler extends AbstractTransactionHandle LOG.debug("Filling the item list with initial values."); - final CollectionNodeBuilder mapBuilder = ImmutableNodes.mapNodeBuilder(ITEM); - final YangInstanceIdentifier itemListId = idListItem.node(ITEM); tx = domDataBroker.newWriteOnlyTransaction(); - final MapNode itemListNode = mapBuilder.build(); + final MapNode itemListNode = ImmutableNodes.mapNodeBuilder(ITEM).build(); tx.put(LogicalDatastoreType.CONFIGURATION, itemListId, itemListNode); try { -- 2.36.6