use of org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode in project controller by opendaylight.
the class NormalizedNodePrunerTest method testAnyXMLNodeNotPrunedWhenHasParent.
@Test
public void testAnyXMLNodeNotPrunedWhenHasParent() throws IOException {
AbstractNormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH);
DOMSourceAnyxmlNode child = Builders.anyXmlBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build();
NormalizedNode input = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).withChild(child).build();
NormalizedNodeWriter.forStreamWriter(pruner).write(input);
NormalizedNode actual = pruner.getResult().orElseThrow();
assertEquals("normalizedNode", input, actual);
}
use of org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode in project yangtools by opendaylight.
the class AnyXmlSupportTest method getParsedAnyXmlValue.
private static DOMSource getParsedAnyXmlValue(final NormalizedNode transformedInput, final QName anyxmlName) {
assertTrue(transformedInput instanceof ContainerNode);
final ContainerNode cont1 = (ContainerNode) transformedInput;
final DataContainerChild child = cont1.childByArg(new NodeIdentifier(anyxmlName));
assertTrue(child instanceof DOMSourceAnyxmlNode);
final DOMSourceAnyxmlNode anyXmlNode = (DOMSourceAnyxmlNode) child;
return anyXmlNode.body();
}
use of org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode in project netconf by opendaylight.
the class NetconfMessageTransformerTest method testGetSchemaResponse.
@Test
public void testGetSchemaResponse() throws Exception {
final NetconfMessageTransformer transformer = getTransformer(SCHEMA);
final NetconfMessage response = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\"\n" + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" + "<data\n" + "xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">\n" + "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" + "Random YANG SCHEMA\n" + "</xs:schema>\n" + "</data>\n" + "</rpc-reply>"));
final DOMRpcResult compositeNodeRpcResult = transformer.toRpcResult(response, GET_SCHEMA_QNAME);
assertTrue(compositeNodeRpcResult.getErrors().isEmpty());
assertNotNull(compositeNodeRpcResult.getResult());
final DOMSource schemaContent = ((DOMSourceAnyxmlNode) ((ContainerNode) compositeNodeRpcResult.getResult()).body().iterator().next()).body();
assertThat(schemaContent.getNode().getTextContent(), CoreMatchers.containsString("Random YANG SCHEMA"));
}
use of org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode in project netconf by opendaylight.
the class FieldsSchemalessRpcStructureTransformerTest method toFilterStructureWithSingleRootTest.
@Test
public void toFilterStructureWithSingleRootTest() throws SAXException, IOException, URISyntaxException {
final YangInstanceIdentifier rootPath = YangInstanceIdentifier.create(C1_NID);
final YangInstanceIdentifier leaf1Field = YangInstanceIdentifier.create(LEAF1_NID);
final YangInstanceIdentifier leaf3Field = YangInstanceIdentifier.create(NodeIdentifierWithPredicates.of(LIST1_QNAME, Map.of(KEY1_QNAME, "key1", KEY2_QNAME, "key2")), C2_NID, LEAF3_NID);
final YangInstanceIdentifier key1Field = YangInstanceIdentifier.create(NodeIdentifierWithPredicates.of(LIST1_QNAME, Map.of(KEY1_QNAME, "key1", KEY2_QNAME, "key2")), KEY1_NID);
final FieldsFilter filter = FieldsFilter.of(rootPath, List.of(leaf1Field, leaf3Field, key1Field));
final DOMSourceAnyxmlNode filterStructure = (DOMSourceAnyxmlNode) transformer.toFilterStructure(Collections.singletonList(filter));
final Diff diff = getDiff("one-root-filter.xml", filterStructure);
assertTrue(diff.similar());
}
use of org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode in project netconf by opendaylight.
the class FieldsSchemalessRpcStructureTransformerTest method toFilterStructureWithTwoRootContainersTest.
@Test
public void toFilterStructureWithTwoRootContainersTest() throws SAXException, IOException, URISyntaxException {
final YangInstanceIdentifier c1RootPath = YangInstanceIdentifier.create(C1_NID);
final YangInstanceIdentifier cxRootPath = YangInstanceIdentifier.create(CX_NID);
final YangInstanceIdentifier c2Field = YangInstanceIdentifier.create(LIST1_NID, C2_NID);
final YangInstanceIdentifier leaf2Field = YangInstanceIdentifier.create(LIST1_NID, C2_NID, LEAF2_NID);
final YangInstanceIdentifier lxField = YangInstanceIdentifier.create(LX_NID);
final FieldsFilter filter1 = FieldsFilter.of(c1RootPath, List.of(c2Field, leaf2Field));
final FieldsFilter filter2 = FieldsFilter.of(cxRootPath, Collections.singletonList(lxField));
final DOMSourceAnyxmlNode filterStructure = (DOMSourceAnyxmlNode) transformer.toFilterStructure(List.of(filter1, filter2));
final Diff diff = getDiff("two-roots-filter.xml", filterStructure);
assertTrue(diff.similar());
}
Aggregations