Clean up use of Augmentation generics
[yangtools.git] / codec / yang-data-codec-xml / src / test / java / org / opendaylight / yangtools / yang / data / codec / xml / NormalizedNodesToXmlTest.java
index 60d07df58d8572f5290c70ba5fc38cf9e6a3779c..f11829854140e4c220c3fda9be7da063bf1f45c9 100644 (file)
@@ -7,44 +7,30 @@
  */
 package org.opendaylight.yangtools.yang.data.codec.xml;
 
-import java.io.IOException;
-import java.util.Collection;
 import java.util.Map;
 import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.dom.DOMResult;
 import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.IgnoreTextAndAttributeValuesDifferenceListener;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.XMLNamespace;
 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.ContainerNode;
 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;
-import org.xml.sax.SAXException;
 
-@RunWith(Parameterized.class)
 public class NormalizedNodesToXmlTest extends AbstractXmlTest {
-    @Parameterized.Parameters(name = "{0}")
-    public static Collection<Object[]> data() {
-        return TestFactories.junitParameters();
-    }
-
     private QNameModule bazModule;
 
     private QName outerContainer;
@@ -72,25 +58,19 @@ public class NormalizedNodesToXmlTest extends AbstractXmlTest {
 
     private static EffectiveModelContext SCHEMA_CONTEXT;
 
-    private final XMLOutputFactory factory;
-
-    public NormalizedNodesToXmlTest(final String factoryMode, final XMLOutputFactory factory) {
-        this.factory = factory;
-    }
-
-    @BeforeClass
-    public static void beforeClass() {
+    @BeforeAll
+    static void beforeClass() {
         SCHEMA_CONTEXT = YangParserTestUtils.parseYangResource("/baz.yang");
     }
 
-    @AfterClass
-    public static void afterClass() {
+    @AfterAll
+    static void afterClass() {
         SCHEMA_CONTEXT = null;
     }
 
-    @Before
-    public void setup() {
-        bazModule = QNameModule.create(XMLNamespace.of("baz-namespace"));
+    @BeforeEach
+    void setup() {
+        bazModule = QNameModule.of("baz-namespace");
 
         outerContainer = QName.create(bazModule, "outer-container");
 
@@ -116,8 +96,10 @@ public class NormalizedNodesToXmlTest extends AbstractXmlTest {
         myLeafInList3 = QName.create(bazModule, "my-leaf-in-list-3");
     }
 
-    @Test
-    public void testNormalizedNodeToXmlSerialization() throws XMLStreamException, IOException, SAXException {
+    @ParameterizedTest(name = "{0}")
+    @ArgumentsSource(TestFactories.class)
+    void testNormalizedNodeToXmlSerialization(final String factoryMode, final XMLOutputFactory factory)
+            throws Exception {
         final var doc = loadDocument("/baz.xml");
         final var domResult = new DOMResult(UntrustedXML.newDocumentBuilder().newDocument());
         final var xmlStreamWriter = factory.createXMLStreamWriter(domResult);
@@ -139,53 +121,47 @@ public class NormalizedNodesToXmlTest extends AbstractXmlTest {
     }
 
     private ContainerNode buildOuterContainerNode() {
-        return Builders.containerBuilder()
+        return ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(outerContainer))
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer1))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myKeyedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myKeyedList, myKeyLeaf, "listkeyvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList1, "listleafvalue1"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList2, "listleafvalue2"))
                         .build())
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myKeyedList, myKeyLeaf, "listkeyvalue2"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList1, "listleafvalue12"))
                         .withChild(ImmutableNodes.leafNode(myLeafInList2, "listleafvalue22"))
                         .build())
                     .build())
                 .withChild(ImmutableNodes.leafNode(myLeaf1, "value1"))
-                .withChild(Builders.leafSetBuilder()
+                .withChild(ImmutableNodes.newSystemLeafSetBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myLeafList))
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(myLeafList, "lflvalue1"))
-                        .withValue("lflvalue1")
-                        .build())
-                    .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(myLeafList, "lflvalue2"))
-                        .withValue("lflvalue2")
-                        .build())
+                    .withChild(ImmutableNodes.leafSetEntry(myLeafList, "lflvalue1"))
+                    .withChild(ImmutableNodes.leafSetEntry(myLeafList, "lflvalue2"))
                     .build())
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer2))
-                .withChild(Builders.containerBuilder()
+                .withChild(ImmutableNodes.newContainerBuilder()
                     .withNodeIdentifier(new NodeIdentifier(innerContainer))
                     .withChild(ImmutableNodes.leafNode(myLeaf2, "value2"))
                     .build())
                 .withChild(ImmutableNodes.leafNode(myLeaf3, "value3"))
-                .withChild(Builders.choiceBuilder()
+                .withChild(ImmutableNodes.newChoiceBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myChoice))
                     .withChild(ImmutableNodes.leafNode(myLeafInCase2, "case2value"))
                     .build())
                 .build())
-            .withChild(Builders.containerBuilder()
+            .withChild(ImmutableNodes.newContainerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(myContainer3))
-                .withChild(Builders.mapBuilder()
+                .withChild(ImmutableNodes.newSystemMapBuilder()
                     .withNodeIdentifier(new NodeIdentifier(myDoublyKeyedList))
-                    .withChild(Builders.mapEntryBuilder()
+                    .withChild(ImmutableNodes.newMapEntryBuilder()
                         .withNodeIdentifier(NodeIdentifierWithPredicates.of(myDoublyKeyedList,
                             Map.of(myFirstKeyLeaf, "listkeyvalue1", mySecondKeyLeaf, "listkeyvalue2")))
                         .withChild(ImmutableNodes.leafNode(myLeafInList3, "listleafvalue1"))