use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project controller by opendaylight.
the class NormalizedNodeStreamReaderWriterTest method createTestContainer.
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();
byte[] bytes2 = {};
LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().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(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[] { 1, 2, 3, 4 })).withChild(ImmutableNodes.leafNode(TestModel.EMPTY_QNAME, Empty.getInstance())).withChild(Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.ORDERED_LIST_QNAME)).withChild(ImmutableNodes.mapEntry(TestModel.ORDERED_LIST_ENTRY_QNAME, TestModel.ID_QNAME, 11)).build()).build();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project controller by opendaylight.
the class NormalizedNodePrunerTest method testAnyXmlNodePrunedWhenHasNoParentAndSchemaMissing.
@Test
public void testAnyXmlNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
NormalizedNodePruner 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);
NormalizedNode<?, ?> actual = pruner.normalizedNode();
assertNull(actual);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project controller by opendaylight.
the class NormalizedNodePrunerTest method testLeafNodePrunedWhenHasAugmentationParentAndSchemaMissing.
@Test
public void testLeafNodePrunedWhenHasAugmentationParentAndSchemaMissing() throws IOException {
AugmentationIdentifier augId = new AugmentationIdentifier(Sets.newHashSet(TestModel.AUG_CONT_QNAME));
NormalizedNodePruner pruner = prunerFullSchema(YangInstanceIdentifier.builder().node(TestModel.TEST_QNAME).node(TestModel.AUGMENTED_LIST_QNAME).node(TestModel.AUGMENTED_LIST_QNAME).node(augId).build());
LeafNode<Object> child = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.INVALID_QNAME)).withValue("test").build();
NormalizedNode<?, ?> input = Builders.augmentationBuilder().withNodeIdentifier(augId).withChild(child).build();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
NormalizedNode<?, ?> actual = pruner.normalizedNode();
assertEquals("normalizedNode", Builders.augmentationBuilder().withNodeIdentifier(augId).build(), actual);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project controller by opendaylight.
the class NormalizedNodePrunerTest method testLeafNodePrunedWhenHasNoParentAndSchemaMissing.
@Test
public void testLeafNodePrunedWhenHasNoParentAndSchemaMissing() throws IOException {
NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
NormalizedNode<?, ?> input = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.INVALID_QNAME)).withValue("test").build();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
NormalizedNode<?, ?> actual = pruner.normalizedNode();
assertNull(actual);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project controller by opendaylight.
the class NormalizedNodePrunerTest method testAnyXMLNodeNotPrunedWhenHasNoParent.
@Test
public void testAnyXMLNodeNotPrunedWhenHasNoParent() throws IOException {
NormalizedNodePruner 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();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
NormalizedNode<?, ?> actual = pruner.normalizedNode();
assertEquals("normalizedNode", input, actual);
}
Aggregations