Migrate most users of deprecated Builders/ImmutableNodes.
Change-Id: I676f248cc524ebc51120352951e93e8539b1dd88
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
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.spi.node.ImmutableNodes;
import org.xmlunit.builder.DiffBuilder;
public class SerializationUtilsTest {
public void testSerializeDeserializeAnyXmlNode() throws Exception {
final var parse = UntrustedXML.newDocumentBuilder().parse(
new ByteArrayInputStream("<xml><data/></xml>".getBytes(StandardCharsets.UTF_8)));
- final var anyXmlNode = Builders.anyXmlBuilder()
+ final var anyXmlNode = ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
.withNodeIdentifier(id("anyXmlNode"))
.withValue(new DOMSource(parse))
.build();
private static ContainerNode createNormalizedNode() {
final var stringLeaf = createLeaf("stringLeaf", "stringValue");
- final var entry1 = Builders.mapEntryBuilder()
+ final var entry1 = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(listId("mapNode", "key", "key1"))
.withChild(stringLeaf)
.build();
- final var entry2 = Builders.mapEntryBuilder()
+ final var entry2 = ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(listId("mapNode", "key", "key2"))
.withChild(stringLeaf)
.build();
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONTAINER1))
.withChild(createLeaf("booleanLeaf", true))
.withChild(createLeaf("byteLeaf", (byte) 0))
.withChild(createLeaf("longStringLeaf", "0123456789".repeat(1000)))
.withChild(createLeaf("stringLeaf", QName.create("base", "qName")))
.withChild(createLeaf("stringLeaf", YangInstanceIdentifier.of(QName.create("test", "test"))))
- .withChild(Builders.mapBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(id("mapNode"))
.withChild(entry1)
.withChild(entry2)
.build())
- .withChild(Builders.orderedMapBuilder()
+ .withChild(ImmutableNodes.newUserMapBuilder()
.withNodeIdentifier(id("orderedMapNode"))
.withChild(entry2)
.withChild(entry1)
.build())
- .withChild(Builders.unkeyedListBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(id("unkeyedList"))
- .withChild(Builders.unkeyedListEntryBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(id("unkeyedList"))
.withChild(stringLeaf)
.build())
- .withChild(Builders.unkeyedListEntryBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(id("unkeyedList"))
.withChild(stringLeaf)
.build())
.build())
- .withChild(Builders.leafSetBuilder()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(id("leafSetNode"))
.withChild(createLeafSetEntry("leafSetNode", "leafSetValue1"))
.withChild(createLeafSetEntry("leafSetNode", "leafSetValue2"))
.build())
- .withChild(Builders.orderedLeafSetBuilder()
+ .withChild(ImmutableNodes.newUserLeafSetBuilder()
.withNodeIdentifier(id("orderedLeafSetNode"))
.withChild(createLeafSetEntry("orderedLeafSetNode", "value1"))
.withChild(createLeafSetEntry("orderedLeafSetNode", "value2"))
.build())
.withChild(createLeaf("aug1", "aug1Value"))
.withChild(createLeaf("aug2", "aug2Value"))
- .withChild(Builders.choiceBuilder()
+ .withChild(ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(id("choiceNode"))
.withChild(createLeaf("choiceLeaf", 12))
.build())
}
private static LeafSetEntryNode<Object> createLeafSetEntry(final String leafSet, final String value) {
- return Builders.leafSetEntryBuilder()
- .withNodeIdentifier(leafSetId(leafSet, value))
- .withValue(value)
- .build();
+ return ImmutableNodes.leafSetEntry(leafSetId(leafSet, value));
}
private static NodeIdentifier id(final String name) {
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.containerNode;
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 org.opendaylight.controller.cluster.datastore.util.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.YangInstanceIdentifier.NodeWithValue;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyxmlNode;
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.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.SystemLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode;
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.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
NormalizedNode actual = pruner.getResult().orElseThrow();
assertEquals(expected, actual);
-
}
@Test(expected = IllegalStateException.class)
assertEquals(expected, actual);
NormalizedNodeWriter.forStreamWriter(pruner).write(expected);
-
}
-
@Test
public void testNodesPrunedWhenAugmentationSchemaMissing() throws IOException {
AbstractNormalizedNodePruner pruner = prunerNoAugSchema(TestModel.TEST_PATH);
// Asserting true here instead of checking actual value because I don't want this assertion to be fragile
assertTrue(countNodes(expected, "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test") > 0);
-
}
private static int countNodes(final NormalizedNode normalizedNode, final String namespaceFilter) {
@Test
public void testLeafNodeNotPrunedWhenHasNoParent() throws IOException {
AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.DESC_QNAME));
- NormalizedNode input = Builders.leafBuilder().withNodeIdentifier(
- new NodeIdentifier(TestModel.DESC_QNAME)).withValue("test").build();
+ NormalizedNode input = ImmutableNodes.leafNode(TestModel.DESC_QNAME, "test");
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
assertEquals("normalizedNode", input, pruner.getResult().orElseThrow());
@Test
public void testLeafSetEntryNodeNotPrunedWhenHasNoParent() throws IOException {
AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
- LeafSetEntryNode<?> input = Builders.leafSetEntryBuilder().withValue("puma").withNodeIdentifier(
- new NodeWithValue<>(TestModel.SHOE_QNAME, "puma")).build();
+ LeafSetEntryNode<?> input = ImmutableNodes.leafSetEntry(TestModel.SHOE_QNAME, "puma");
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
NormalizedNode actual = pruner.getResult().orElseThrow();
@Test
public void testLeafSetEntryNodeNotPrunedWhenHasParent() throws IOException {
AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
- LeafSetEntryNode<Object> child = Builders.leafSetEntryBuilder().withValue("puma").withNodeIdentifier(
- new NodeWithValue<>(TestModel.SHOE_QNAME, "puma")).build();
- NormalizedNode input = Builders.leafSetBuilder().withNodeIdentifier(
- new NodeIdentifier(TestModel.SHOE_QNAME)).withChild(child).build();
+ SystemLeafSetNode<?> input = ImmutableNodes.<String>newSystemLeafSetBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.SHOE_QNAME))
+ .withChildValue("puma")
+ .build();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
NormalizedNode actual = pruner.getResult().orElseThrow();
@Test
public void testLeafSetEntryNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
- NormalizedNode input = Builders.leafSetEntryBuilder().withValue("test").withNodeIdentifier(
- new NodeWithValue<>(TestModel.INVALID_QNAME, "test")).build();
+ LeafSetEntryNode<?> input = ImmutableNodes.leafSetEntry(TestModel.INVALID_QNAME, "test");
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
assertEquals(Optional.empty(), pruner.getResult());
@Test
public void testLeafSetEntryNodePrunedWhenHasParentAndSchemaMissing() throws IOException {
AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
- LeafSetEntryNode<Object> child = Builders.leafSetEntryBuilder().withValue("test").withNodeIdentifier(
- new NodeWithValue<>(TestModel.INVALID_QNAME, "test")).build();
- NormalizedNode input = Builders.leafSetBuilder().withNodeIdentifier(
- new NodeIdentifier(TestModel.INVALID_QNAME)).withChild(child).build();
- NormalizedNodeWriter.forStreamWriter(pruner).write(input);
+ NormalizedNodeWriter.forStreamWriter(pruner).write(ImmutableNodes.<String>newSystemLeafSetBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.INVALID_QNAME))
+ .withChildValue("test")
+ .build());
assertEquals(Optional.empty(), pruner.getResult());
}
@Test
public void testAnyXMLNodeNotPrunedWhenHasNoParent() throws IOException {
AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.ANY_XML_QNAME));
- NormalizedNode input = Builders.anyXmlBuilder().withNodeIdentifier(
- new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build();
+ AnyxmlNode<DOMSource> input = ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
+ .withNodeIdentifier(new NodeIdentifier(TestModel.ANY_XML_QNAME))
+ .withValue(mock(DOMSource.class))
+ .build();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
- NormalizedNode actual = pruner.getResult().orElseThrow();
- assertEquals("normalizedNode", input, actual);
+ assertEquals(input, pruner.getResult().orElseThrow());
}
@Test
public void testAnyXMLNodeNotPrunedWhenHasParent() throws IOException {
final var pruner = prunerFullSchema(TestModel.TEST_PATH);
- final var child = Builders.anyXmlBuilder().withNodeIdentifier(
- new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build();
- final var input = Builders.containerBuilder().withNodeIdentifier(
- new NodeIdentifier(TestModel.TEST_QNAME)).withChild(child).build();
+ final var input = ImmutableNodes.newContainerBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
+ .withNodeIdentifier(new NodeIdentifier(TestModel.ANY_XML_QNAME))
+ .withValue(mock(DOMSource.class))
+ .build())
+ .build();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
- assertEquals("normalizedNode", input, pruner.getResult().orElseThrow());
+ assertEquals(input, pruner.getResult().orElseThrow());
}
@Test
public void testAnyXmlNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
AbstractNormalizedNodePruner pruner = prunerNoTestSchema(TestModel.TEST_PATH.node(TestModel.ANY_XML_QNAME));
- NormalizedNode input = Builders.anyXmlBuilder().withNodeIdentifier(
- new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build();
- NormalizedNodeWriter.forStreamWriter(pruner).write(input);
+ NormalizedNodeWriter.forStreamWriter(pruner).write(ImmutableNodes.newAnyxmlBuilder(DOMSource.class)
+ .withNodeIdentifier(new NodeIdentifier(TestModel.ANY_XML_QNAME))
+ .withValue(mock(DOMSource.class))
+ .build());
assertEquals(Optional.empty(), pruner.getResult());
}
.node(TestModel.INNER_CONTAINER_QNAME).build();
AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
- NormalizedNode input = ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME);
+ ContainerNode input = containerNode(TestModel.INNER_CONTAINER_QNAME);
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
- NormalizedNode actual = pruner.getResult().orElseThrow();
- assertEquals("normalizedNode", input, actual);
+ assertEquals(input, pruner.getResult().orElseThrow());
}
@Test
.node(TestModel.INVALID_QNAME).build();
AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
- ContainerNode input = ImmutableNodes.containerNode(TestModel.INVALID_QNAME);
- NormalizedNodeWriter.forStreamWriter(pruner).write(input);
+ NormalizedNodeWriter.forStreamWriter(pruner).write(containerNode(TestModel.INVALID_QNAME));
assertEquals(Optional.empty(), pruner.getResult());
}
.build();
AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
- MapNode innerList = mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder(
- TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").withChild(
- ImmutableNodes.containerNode(TestModel.INVALID_QNAME)).build()).build();
- MapEntryNode input = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
- .withChild(innerList).build();
- NormalizedNodeWriter.forStreamWriter(pruner).write(input);
+ NormalizedNodeWriter.forStreamWriter(pruner)
+ .write(mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
+ .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
+ .withChild(mapEntryBuilder(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one")
+ .withChild(containerNode(TestModel.INVALID_QNAME))
+ .build())
+ .build())
+ .build());
- MapEntryNode expected = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
- .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder(
- TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").build()).build()).build();
- NormalizedNode actual = pruner.getResult().orElseThrow();
- assertEquals("normalizedNode", expected, actual);
+ assertEquals(mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
+ .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
+ .withChild(mapEntryBuilder(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").build())
+ .build())
+ .build(), pruner.getResult().orElseThrow());
}
@Test
.node(TestModel.INNER_LIST_QNAME).build();
AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
- MapNode input = mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(mapEntryBuilder(
- TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one").withChild(
- ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME)).build()).build();
+ SystemMapNode input = mapNodeBuilder(TestModel.INNER_LIST_QNAME)
+ .withChild(mapEntryBuilder(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, "one")
+ .withChild(containerNode(TestModel.INNER_CONTAINER_QNAME))
+ .build())
+ .build();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
- NormalizedNode actual = pruner.getResult().orElseThrow();
- assertEquals("normalizedNode", input, actual);
+ assertEquals(input, pruner.getResult().orElseThrow());
}
@Test
.node(TestModel.INVALID_QNAME).build();
AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
- MapNode input = mapNodeBuilder(TestModel.INVALID_QNAME).withChild(mapEntryBuilder(
- TestModel.INVALID_QNAME, TestModel.NAME_QNAME, "one").withChild(
- ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME)).build()).build();
- NormalizedNodeWriter.forStreamWriter(pruner).write(input);
+ NormalizedNodeWriter.forStreamWriter(pruner).write(mapNodeBuilder(TestModel.INVALID_QNAME)
+ .withChild(mapEntryBuilder(TestModel.INVALID_QNAME, TestModel.NAME_QNAME, "one")
+ .withChild(containerNode(TestModel.INNER_CONTAINER_QNAME))
+ .build())
+ .build());
assertEquals(Optional.empty(), pruner.getResult());
}
.build();
AbstractNormalizedNodePruner pruner = prunerFullSchema(path);
- MapNode innerList = mapNodeBuilder(TestModel.INVALID_QNAME).withChild(mapEntryBuilder(
- TestModel.INVALID_QNAME, TestModel.NAME_QNAME, "one").withChild(
- ImmutableNodes.containerNode(TestModel.INNER_CONTAINER_QNAME)).build()).build();
- NormalizedNode input = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
- .withChild(innerList).build();
- NormalizedNodeWriter.forStreamWriter(pruner).write(input);
+ NormalizedNodeWriter.forStreamWriter(pruner)
+ .write(mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)
+ .withChild(mapNodeBuilder(TestModel.INVALID_QNAME)
+ .withChild(mapEntryBuilder(TestModel.INVALID_QNAME, TestModel.NAME_QNAME, "one")
+ .withChild(containerNode(TestModel.INNER_CONTAINER_QNAME))
+ .build())
+ .build())
+ .build());
- NormalizedNode expected = mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
- NormalizedNode actual = pruner.getResult().orElseThrow();
- assertEquals("normalizedNode", expected, actual);
+ assertEquals(mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1),
+ pruner.getResult().orElseThrow());
}
- private static NormalizedNode createTestContainer() {
- byte[] bytes1 = {1, 2, 3};
- LeafSetEntryNode<Object> entry1 = Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1))
- .withValue(bytes1)
- .build();
-
- byte[] bytes2 = {};
- LeafSetEntryNode<Object> entry2 = Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2))
- .withValue(bytes2).build();
-
+ private static ContainerNode createTestContainer() {
return TestModel.createBaseTestContainerBuilder()
- .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();
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
+ .withNodeIdentifier(new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME))
+ .withChildValue(new byte[] {1, 2, 3})
+ .withChildValue(new byte[0])
+ .build())
+ .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[] {1, 2, 3, 4}))
+ .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.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
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.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@Test
public void testListTranslation() throws IOException {
- assertEquals(Builders.mapBuilder()
+ assertEquals(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(LST))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(LST, ImmutableMap.<QName, Object>builder()
.put(A, (byte) 1)
.put(B, (short) 1)
.withChild(ImmutableNodes.leafNode(H, Uint64.ONE))
.build())
.build(),
- prune(Builders.mapBuilder()
+ prune(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(LST))
- .withChild(Builders.mapEntryBuilder()
+ .withChild(ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(LST, ImmutableMap.<QName, Object>builder()
.put(A, (byte) 1)
.put(B, (short) 1)
@Test
public void testContainerTranslation() throws IOException {
- assertEquals(Builders.containerBuilder()
+ assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT))
.withChild(ImmutableNodes.leafNode(A, (byte) 1))
.withChild(ImmutableNodes.leafNode(B, (short) 1))
.withChild(ImmutableNodes.leafNode(G, Uint32.ONE))
.withChild(ImmutableNodes.leafNode(H, Uint64.ONE))
.build(),
- prune(Builders.containerBuilder()
+ prune(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(CONT))
.withChild(ImmutableNodes.leafNode(A, (byte) 1))
.withChild(ImmutableNodes.leafNode(B, (short) 1))
@Test
public void testLeafList8() throws IOException {
- assertEquals(Builders.leafSetBuilder()
+ assertEquals(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST8))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LFLST8, Uint8.ONE))
- .withValue(Uint8.ONE)
- .build())
+ .withChildValue(Uint8.ONE)
.build(),
- prune(Builders.leafSetBuilder()
+ prune(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST8))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LFLST8, (short) 1))
- .withValue((short) 1)
- .build())
+ .withChildValue((short) 1)
.build()));
}
@Test
public void testLeafList16() throws IOException {
- assertEquals(Builders.leafSetBuilder()
+ assertEquals(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST16))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LFLST16, Uint16.ONE))
- .withValue(Uint16.ONE)
- .build())
+ .withChildValue(Uint16.ONE)
.build(),
- prune(Builders.leafSetBuilder()
+ prune(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST16))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LFLST16, 1))
- .withValue(1)
- .build())
+ .withChildValue(1)
.build()));
}
@Test
public void testLeafList32() throws IOException {
- assertEquals(Builders.leafSetBuilder()
+ assertEquals(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST32))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LFLST32, Uint32.ONE))
- .withValue(Uint32.ONE)
- .build())
+ .withChildValue(Uint32.ONE)
.build(),
- prune(Builders.leafSetBuilder()
+ prune(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST32))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LFLST32, 1L))
- .withValue(1L)
- .build())
+ .withChildValue(1L)
.build()));
}
@Test
public void testLeafList64() throws IOException {
- assertEquals(Builders.leafSetBuilder()
+ assertEquals(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST64))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LFLST64, Uint64.ONE))
- .withValue(Uint64.ONE)
- .build())
+ .withChildValue(Uint64.ONE)
.build(),
- prune(Builders.leafSetBuilder()
+ prune(ImmutableNodes.newSystemLeafSetBuilder()
.withNodeIdentifier(new NodeIdentifier(LFLST64))
- .withChild(Builders.leafSetEntryBuilder()
- .withNodeIdentifier(new NodeWithValue<>(LFLST64, BigInteger.ONE))
- .withValue(BigInteger.ONE)
- .build())
+ .withChildValue(BigInteger.ONE)
.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 static org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes.leafNode;
import com.google.common.collect.ImmutableSet;
import java.io.InputStream;
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.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
new NodeWithValue<>(QName.create(TEST_QNAME, "leaf-list-entry"), "foo"));
// Create the document
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(TEST_QNAME))
// Create a bits leaf
.withChild(leafNode(QName.create(TEST_QNAME, "my-bits"), ImmutableSet.of("foo", "bar")))
.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()
+ .withChild(ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
// Create unkeyed list entry
- .withChild(Builders.unkeyedListEntryBuilder()
+ .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
.withNodeIdentifier(new NodeIdentifier(UNKEYED_LIST_QNAME))
.withChild(leafNode(NAME_QNAME, "unkeyed-entry-name"))
.build())
.build())
- .withChild(Builders.choiceBuilder()
+ .withChild(ImmutableNodes.newChoiceBuilder()
.withNodeIdentifier(new NodeIdentifier(TWO_THREE_QNAME))
.withChild(leafNode(TWO_QNAME, "two")).build())
- .withChild(Builders.orderedMapBuilder()
+ .withChild(ImmutableNodes.newUserMapBuilder()
.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()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.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())
+ .withChildValue("nike")
+ .withChildValue("puma")
.build())
- .withChild(Builders.leafSetBuilder()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.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())
+ .withChildValue(5)
+ .withChildValue(15)
.build())
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(SWITCH_FEATURES_QNAME))
// Test a leaf-list where each entry contains an identity
- .withChild(Builders.leafSetBuilder()
+ .withChild(ImmutableNodes.newSystemLeafSetBuilder()
.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())
+ .withChildValue(DESC_QNAME)
.build())
.build())
.withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME)
}
public static MapEntryNode createAugmentedListEntry(final int id, final String name) {
- return Builders.mapEntryBuilder()
+ return ImmutableNodes.newMapEntryBuilder()
.withNodeIdentifier(NodeIdentifierWithPredicates.of(AUGMENTED_LIST_QNAME, ID_QNAME, id))
.withChild(leafNode(ID_QNAME, id))
- .withChild(Builders.containerBuilder()
+ .withChild(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(AUG_CONT_QNAME))
.withChild(leafNode(AUG_NAME_QNAME, name))
.build())
.withChild(leafNode(GRAND_CHILD_NUMBER_QNAME,FIRST_GRAND_CHILD_ID))
.withChild(leafNode(GRAND_CHILD_NAME_QNAME, FIRST_GRAND_CHILD_NAME));
- return Builders.containerBuilder()
+ return ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(new NodeIdentifier(FAMILY_QNAME))
- .withChild(mapNodeBuilder()
+ .withChild(ImmutableNodes.newSystemMapBuilder()
.withNodeIdentifier(new NodeIdentifier(CHILDREN_QNAME))
.withChild(mapEntryBuilder(CHILDREN_QNAME, CHILD_NUMBER_QNAME, FIRST_CHILD_ID)
.withChild(leafNode(CHILD_NUMBER_QNAME, FIRST_CHILD_ID))