Eliminate SchemasStream.EntityType
[netconf.git] / plugins / netconf-client-mdsal / src / test / java / org / opendaylight / netconf / client / mdsal / impl / NC881Test.java
1 /*
2  * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netconf.client.mdsal.impl;
9
10 import static org.junit.jupiter.api.Assertions.assertFalse;
11
12 import javax.xml.transform.dom.DOMSource;
13 import org.junit.jupiter.api.Test;
14 import org.opendaylight.netconf.api.xml.XmlUtil;
15 import org.xmlunit.builder.DiffBuilder;
16
17 class NC881Test {
18     @Test
19     void testFilterDomNamespaces() throws Exception {
20         final var source = XmlUtil.readXmlToDocument(NC881Test.class.getResourceAsStream("/nc881/netconf-state.xml"));
21         final var expected = XmlUtil.readXmlToDocument(
22             NC881Test.class.getResourceAsStream("/nc881/netconf-state-filtered.xml"));
23
24         final var filteredDom = NetconfStateSchemasResolverImpl.ietfMonitoringCopy(
25             new DOMSource(source.getDocumentElement()));
26         final var filtered = XmlUtil.newDocument();
27         filtered.appendChild(filtered.importNode(filteredDom.getNode(), true));
28
29         final var diff = DiffBuilder.compare(expected)
30             .withTest(filtered)
31             .ignoreWhitespace()
32             .checkForIdentical()
33             .build();
34         assertFalse(diff.hasDifferences(), diff.toString());
35     }
36 }