Eliminate schemaContextLoader() 92/107492/3
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Aug 2023 10:36:49 +0000 (12:36 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Aug 2023 12:52:16 +0000 (14:52 +0200)
This is a superfluous method, replace it with a proper constructor
defaulting to the shared baseline context.

Change-Id: I5629bf33ce2af941693c2ca17b2a4438a2b861fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java

index eefc57eaef69062a5adbb89fa68c6ea763ba5cad..7b00f2c78e0ae32a7efbc6c9becf5ba434d60a3d 100644 (file)
@@ -13,22 +13,18 @@ import static org.junit.Assert.assertThrows;
 
 import java.io.InputStream;
 import javax.ws.rs.core.MediaType;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.JsonBodyReaderTest;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
     private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
-    private static EffectiveModelContext schemaContext;
 
     private final JsonPatchBodyReader jsonToPatchBodyReader;
 
     public JsonPatchBodyReaderMountPointTest() {
-        super(schemaContext);
         jsonToPatchBodyReader = new JsonPatchBodyReader(databindProvider, mountPointService);
     }
 
@@ -37,11 +33,6 @@ public class JsonPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
         return new MediaType(APPLICATION_JSON, null);
     }
 
-    @BeforeClass
-    public static void initialization() {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-    }
-
     @Test
     public void modulePatchDataTest() throws Exception {
         final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
index acf17f2ddf0420f4b28bf31b85d08f82c411c737..6efd06c5db6d29d72f7c38197c11dae5ec7b35e2 100644 (file)
@@ -15,7 +15,6 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import javax.ws.rs.core.MediaType;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.patch.PatchContext;
@@ -27,15 +26,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest {
-
     private final JsonPatchBodyReader jsonToPatchBodyReader;
-    private static EffectiveModelContext schemaContext;
 
     public JsonPatchBodyReaderTest() {
-        super(schemaContext);
         jsonToPatchBodyReader = new JsonPatchBodyReader(databindProvider, mountPointService);
     }
 
@@ -44,11 +39,6 @@ public class JsonPatchBodyReaderTest extends AbstractBodyReaderTest {
         return new MediaType(APPLICATION_JSON, null);
     }
 
-    @BeforeClass
-    public static void initialization() {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-    }
-
     @Test
     public void modulePatchDataTest() throws Exception {
         final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
index 375657259d17a409e4b0512081767408eb9bf54a..7c01deb0d83a420a32ed1f45b82dcc294857c762 100644 (file)
@@ -12,24 +12,19 @@ import static org.junit.Assert.assertThrows;
 
 import java.io.InputStream;
 import javax.ws.rs.core.MediaType;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.XmlBodyReaderTest;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
     private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
 
-    private static EffectiveModelContext schemaContext;
-
     private final XmlPatchBodyReader xmlToPatchBodyReader;
 
     public XmlPatchBodyReaderMountPointTest() {
-        super(schemaContext);
         xmlToPatchBodyReader = new XmlPatchBodyReader(databindProvider, mountPointService);
     }
 
@@ -38,11 +33,6 @@ public class XmlPatchBodyReaderMountPointTest extends AbstractBodyReaderTest {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
-    @BeforeClass
-    public static void initialization() {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-    }
-
     @Test
     public void moduleDataTest() throws Exception {
         final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
index 5fae1412fb362c6cda8302e0c3e890e13c0fe2f8..936b8c659226dd3dee5e6deb2f35a5cc3d7252f8 100644 (file)
@@ -14,7 +14,6 @@ import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import javax.ws.rs.core.MediaType;
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.patch.PatchContext;
@@ -26,15 +25,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest {
-    private static EffectiveModelContext schemaContext;
-
     private final XmlPatchBodyReader xmlToPatchBodyReader;
 
     public XmlPatchBodyReaderTest() {
-        super(schemaContext);
         xmlToPatchBodyReader = new XmlPatchBodyReader(databindProvider, mountPointService);
     }
 
@@ -43,11 +38,6 @@ public class XmlPatchBodyReaderTest extends AbstractBodyReaderTest {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
-    @BeforeClass
-    public static void initialization() {
-        schemaContext = schemaContextLoader("/instanceidentifier/yang", schemaContext);
-    }
-
     @Test
     public void moduleDataTest() throws Exception {
         mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=leaf1", xmlToPatchBodyReader, false);
index 7955f4af8b7c09d6f4eee231e26065740f374bad..fd7ddf04d3a30b199c7562f0c1445b15eec22a90 100644 (file)
@@ -23,6 +23,7 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.UriInfo;
+import org.junit.BeforeClass;
 import org.junit.function.ThrowingRunnable;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
@@ -31,7 +32,6 @@ import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
 import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindContext;
 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.spi.AbstractIdentifierAwareJaxRsProvider;
@@ -41,6 +41,7 @@ import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public abstract class AbstractBodyReaderTest {
     protected static final QName CONT_AUG_QNAME = QName.create("test-ns-aug", "container-aug").intern();
@@ -65,10 +66,16 @@ public abstract class AbstractBodyReaderTest {
     protected static final QName MY_LEAF12_QNAME = QName.create("instance:identifier:patch:module",
             "2015-11-21", "my-leaf12").intern();
 
+    private static EffectiveModelContext BASELINE_CONTEXT;
+
     protected final MediaType mediaType;
     protected final DatabindProvider databindProvider;
     protected final DOMMountPointService mountPointService;
 
+    protected AbstractBodyReaderTest() {
+        this(BASELINE_CONTEXT);
+    }
+
     protected AbstractBodyReaderTest(final EffectiveModelContext schemaContext) {
         mediaType = getMediaType();
 
@@ -82,13 +89,13 @@ public abstract class AbstractBodyReaderTest {
             .getService(DOMSchemaService.class);
     }
 
-    protected abstract MediaType getMediaType();
-
-    protected static EffectiveModelContext schemaContextLoader(final String yangPath,
-            final EffectiveModelContext schemaContext) {
-        return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext);
+    @BeforeClass
+    public static final void initBaselineContext() {
+        BASELINE_CONTEXT = YangParserTestUtils.parseYangResourceDirectory("/instanceidentifier/yang");
     }
 
+    protected abstract MediaType getMediaType();
+
     protected static <T extends AbstractIdentifierAwareJaxRsProvider<?>> void mockBodyReader(
             final String identifier, final T normalizedNodeProvider, final boolean isPost) {
         final UriInfo uriInfoMock = mock(UriInfo.class);