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 <robert.varga@pantheon.tech>
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)
private static NormalizedNode createTestContainer() {
byte[] bytes1 = {1, 2, 3};
- LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
- new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).withValue(bytes1).build();
+ LeafSetEntryNode<Object> entry1 = Builders.leafSetEntryBuilder()
+ .withNodeIdentifier(new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1))
+ .withValue(bytes1)
+ .build();
byte[] bytes2 = {};
- LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
- new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).withValue(bytes2).build();
+ LeafSetEntryNode<Object> 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();
}
*/
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;
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;
}
public static DataContainerNodeBuilder<NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
- // Create a list of shoes
- // This is to test leaf list entry
- final LeafSetEntryNode<Object> nike = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
- new NodeWithValue<>(SHOE_QNAME, "nike")).withValue("nike").build();
-
- final LeafSetEntryNode<Object> puma = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(
- new NodeWithValue<>(SHOE_QNAME, "puma")).withValue("puma").build();
-
- final LeafSetNode<Object> 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<Object> cap1 =
- ImmutableLeafSetEntryNodeBuilder
- .create()
- .withNodeIdentifier(
- new NodeWithValue<>(QName.create(
- TEST_QNAME, "capability"), DESC_QNAME))
- .withValue(DESC_QNAME).build();
-
- final LeafSetNode<Object> 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<Object> five =
- ImmutableLeafSetEntryNodeBuilder
- .create()
- .withNodeIdentifier(
- new NodeWithValue<>(QName.create(
- TEST_QNAME, "number"), 5)).withValue(5).build();
- final LeafSetEntryNode<Object> fifteen =
- ImmutableLeafSetEntryNodeBuilder
- .create()
- .withNodeIdentifier(
- new NodeWithValue<>(QName.create(
- TEST_QNAME, "number"), 15)).withValue(15).build();
- final LeafSetNode<Object> 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<NodeIdentifier, Object, LeafNode<Object>>
- 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")),
QName.create(TEST_QNAME, "aug1"), QName.create(TEST_QNAME, "aug2"))),
new NodeWithValue<>(QName.create(TEST_QNAME, "leaf-list-entry"), "foo"));
- Map<QName, Object> 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.<MapEntryNode>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() {
}
public static MapEntryNode createAugmentedListEntry(final int id, final String name) {
- Set<QName> 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<NodeIdentifier, ContainerNode>
- familyContainerBuilder = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
- new NodeIdentifier(FAMILY_QNAME));
-
- final CollectionNodeBuilder<MapEntryNode, SystemMapNode> childrenBuilder = mapNodeBuilder()
- .withNodeIdentifier(new NodeIdentifier(CHILDREN_QNAME));
-
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
- firstChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
- secondChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
-
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
- firstGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
- FIRST_GRAND_CHILD_ID);
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
- 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();
}
}
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;
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);
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);
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",
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;
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();
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();
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();
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;
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);
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));
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;
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;
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);
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);
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.
* @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;
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.
@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);
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
@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());
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
@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;
@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;
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
@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());
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;
@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
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<String> 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());
}
public void testLeafNodeCandidate() throws Exception {
YangInstanceIdentifier leafPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH)
.node(TestModel.DESC_QNAME).build();
- LeafNode<Object> 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());
}
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;
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.
@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);
@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<Class<? extends ShardDataTreeSnapshotMetadata<?>>, 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)) {
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.
* @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);
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;
@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;
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<NormalizedNode> actual = dataTree.takeSnapshot().readNode(path);
assertTrue("After pruning present", actual.isPresent());
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());
@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;
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<NormalizedNode> actual = dataTree.takeSnapshot().readNode(path);
assertTrue("After pruning present", actual.isPresent());
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(
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<MapEntryNode, SystemMapNode> 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() {
}
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<MapEntryNode, SystemMapNode> 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);
}
}
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() {
*/
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;
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() {
}
public static ContainerNode createTestContainer() {
- final LeafSetEntryNode<Object> nike = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "nike"))
- .withValue("nike").build();
- final LeafSetEntryNode<Object> puma = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "puma"))
- .withValue("puma").build();
- final LeafSetNode<Object> 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<Object> five = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5))
- .withValue(5).build();
- final LeafSetEntryNode<Object> fifteen = ImmutableLeafSetEntryNodeBuilder.create()
- .withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15))
- .withValue(15).build();
- final LeafSetNode<Object> 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<QName> 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<NodeIdentifier, ContainerNode> familyContainerBuilder =
- ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(FAMILY_QNAME));
-
- final CollectionNodeBuilder<MapEntryNode, SystemMapNode> childrenBuilder = mapNodeBuilder(CHILDREN_QNAME);
-
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
- firstChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID);
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
- secondChildBuilder = mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, SECOND_CHILD_ID);
-
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
- firstGrandChildBuilder = mapEntryBuilder(GRAND_CHILDREN_QNAME, GRAND_CHILD_NUMBER_QNAME,
- FIRST_GRAND_CHILD_ID);
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode>
- 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();
}
}
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(
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<MapEntryNode, SystemMapNode> 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();
}
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();
}
}
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;
}
public static DataContainerChild outerNode(final int... ids) {
- CollectionNodeBuilder<MapEntryNode, SystemMapNode> 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));
}
}
public static DataContainerChild outerNode(final MapEntryNode... entries) {
- CollectionNodeBuilder<MapEntryNode, SystemMapNode> outer = ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME);
+ var outer = ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME);
for (MapEntryNode e: entries) {
outer.addChild(e);
}
}
public static DataContainerChild innerNode(final String... names) {
- CollectionNodeBuilder<MapEntryNode, SystemMapNode> 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));
}
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) {
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;
public ListenableFuture<DOMRpcResult> 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()));
}
}
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;
public ListenableFuture<DOMRpcResult> 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()));
}
}
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;
public ListenableFuture<DOMRpcResult> 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()));
}
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;
.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();
LOG.debug("Filling the item list with initial values.");
- final CollectionNodeBuilder<MapEntryNode, SystemMapNode> 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 {