Remove XmlElement.checkUnrecognisedElements() 00/105600/2
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 22 Apr 2023 15:04:37 +0000 (17:04 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 22 Apr 2023 15:28:34 +0000 (17:28 +0200)
These methods are only used in unit tests, remove them.

Change-Id: I14708977516d161f9bab11790cd8cac5a456293a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
protocol/netconf-api/src/main/java/org/opendaylight/netconf/api/xml/XmlElement.java
protocol/netconf-api/src/test/java/org/opendaylight/netconf/api/xml/XmlElementTest.java

index e907739d2eee3527680ff61aa5c6332a24241d06..e8e3577eca8860acc23b98f25dc7bd9c5f96c5f5 100644 (file)
@@ -387,23 +387,6 @@ public final class XmlElement {
         return new SimpleImmutableEntry<>(prefix, namespaces.get(prefix));
     }
 
-    public void checkUnrecognisedElements(final List<XmlElement> recognisedElements,
-                                          final XmlElement... additionalRecognisedElements) throws DocumentedException {
-        List<XmlElement> childElements = getChildElements();
-        childElements.removeAll(recognisedElements);
-        for (XmlElement additionalRecognisedElement : additionalRecognisedElements) {
-            childElements.remove(additionalRecognisedElement);
-        }
-        if (!childElements.isEmpty()) {
-            throw new DocumentedException(String.format("Unrecognised elements %s in %s", childElements, this),
-                    ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
-        }
-    }
-
-    public void checkUnrecognisedElements(final XmlElement... additionalRecognisedElements) throws DocumentedException {
-        checkUnrecognisedElements(List.of(), additionalRecognisedElements);
-    }
-
     public boolean hasNamespace() {
         return namespaceAttribute() != null || namespace() != null;
     }
index 056c243b090dfbe161eaedddb17d6d17e3752d94..268f13f0bfe1476771799b495d32db173ec1ef15 100644 (file)
@@ -7,9 +7,6 @@
  */
 package org.opendaylight.netconf.api.xml;
 
-import static org.hamcrest.CoreMatchers.both;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -111,16 +108,4 @@ public class XmlElementTest {
         assertEquals("", namespaceOfTextContent.getKey());
         assertEquals("innerNamespace", namespaceOfTextContent.getValue());
     }
-
-    @Test
-    public void testUnrecognisedElements() throws Exception {
-        xmlElement.checkUnrecognisedElements(xmlElement.getOnlyChildElement("inner"),
-                xmlElement.getOnlyChildElement("innerPrefixed"), xmlElement.getOnlyChildElement("innerNamespace"));
-
-        final DocumentedException e = assertThrows(DocumentedException.class,
-            () -> xmlElement.checkUnrecognisedElements(xmlElement.getOnlyChildElement("inner")));
-        assertThat(e.getMessage(),
-            // FIXME: this looks very suspect
-            both(containsString("innerNamespace")).and(containsString("innerNamespace")));
-    }
 }