Bump upstreams for Silicon
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / controller / sal / rest / impl / test / providers / AbstractBodyReaderTest.java
index adc3ad3dbb7330f1b59c8912f3379b96e172fc2a..677ef51eca66c05a232a64ed0030864bfdca41fe 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.sal.rest.impl.test.providers;
 
 import static org.junit.Assert.assertNotNull;
@@ -15,19 +14,21 @@ import static org.mockito.Mockito.when;
 import java.lang.reflect.Field;
 import java.net.URI;
 import java.util.Collections;
+import java.util.Optional;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Request;
 import javax.ws.rs.core.UriInfo;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
 import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.netconf.sal.rest.api.RestconfConstants;
 import org.opendaylight.netconf.sal.rest.impl.AbstractIdentifierAwareJaxRsProvider;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.patch.PatchContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 
 public abstract class AbstractBodyReaderTest {
     private static Field uriField;
@@ -49,7 +50,7 @@ public abstract class AbstractBodyReaderTest {
     protected final ControllerContext controllerContext;
     protected final MediaType mediaType;
 
-    protected AbstractBodyReaderTest(SchemaContext schemaContext, DOMMountPoint mountInstance) {
+    protected AbstractBodyReaderTest(final EffectiveModelContext schemaContext, final DOMMountPoint mountInstance) {
         this.mediaType = getMediaType();
 
         controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mountInstance);
@@ -57,8 +58,8 @@ public abstract class AbstractBodyReaderTest {
 
     protected abstract MediaType getMediaType();
 
-    protected static SchemaContext schemaContextLoader(final String yangPath,
-            final SchemaContext schemaContext) {
+    protected static EffectiveModelContext schemaContextLoader(final String yangPath,
+            final EffectiveModelContext schemaContext) {
         return TestRestconfUtils.loadSchemaContext(yangPath, schemaContext);
     }
 
@@ -113,6 +114,12 @@ public abstract class AbstractBodyReaderTest {
     protected static void checkPatchContextMountPoint(final PatchContext patchContext) {
         checkPatchContext(patchContext);
         assertNotNull(patchContext.getInstanceIdentifierContext().getMountPoint());
-        assertNotNull(patchContext.getInstanceIdentifierContext().getMountPoint().getSchemaContext());
     }
+
+    protected static EffectiveModelContext modelContext(final DOMMountPoint mountPoint) {
+        return mountPoint.getService(DOMSchemaService.class)
+            .flatMap(svc -> Optional.ofNullable(svc.getGlobalContext()))
+            .orElse(null);
+    }
+
 }