Fix error reporting for PUT/POST
[netconf.git] / restconf / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / JSONRestconfServiceImplTest.java
index 89608e06aceb222619cfc6eb20ede8afc27bd614..fa788c61a01afd4708311277f5770f3dff0d1a26 100644 (file)
@@ -21,18 +21,26 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import com.google.common.base.Optional;
 import com.google.common.io.Resources;
 import com.google.common.util.concurrent.Futures;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
@@ -44,6 +52,7 @@ import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
 import org.opendaylight.netconf.sal.restconf.impl.JSONRestconfServiceImpl;
+import org.opendaylight.netconf.sal.restconf.impl.PutResult;
 import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
 import org.opendaylight.yangtools.yang.common.OperationFailedException;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -61,12 +70,14 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 /**
  * Unit tests for JSONRestconfServiceImpl.
  *
  * @author Thomas Pantelis
  */
+@Deprecated
 public class JSONRestconfServiceImplTest {
     static final String IETF_INTERFACES_NS = "urn:ietf:params:xml:ns:yang:ietf-interfaces";
     static final String IETF_INTERFACES_VERSION = "2013-07-04";
@@ -99,7 +110,7 @@ public class JSONRestconfServiceImplTest {
     private final JSONRestconfServiceImpl service = new JSONRestconfServiceImpl();
 
     @BeforeClass
-    public static void init() throws IOException {
+    public static void init() throws IOException, ReactorException {
         ControllerContext.getInstance().setSchemas(TestUtils.loadSchemaContext("/full-versions/yangs"));
         brokerFacade = mock(BrokerFacade.class);
         RestconfImpl.getInstance().setBroker(brokerFacade);
@@ -118,25 +129,32 @@ public class JSONRestconfServiceImplTest {
     @SuppressWarnings("rawtypes")
     @Test
     public void testPut() throws Exception {
-        doReturn(Futures.immediateCheckedFuture(null)).when(brokerFacade).commitConfigurationDataPut(
-                notNull(SchemaContext.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class));
-
-        String uriPath = "ietf-interfaces:interfaces/interface/eth0";
-        String payload = loadData("/parts/ietf-interfaces_interfaces.json");
-
-        service.put(uriPath, payload);
-
-        ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
-        ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
+        final PutResult result = mock(PutResult.class);
+        when(brokerFacade.commitConfigurationDataPut(notNull(SchemaContext.class),
+                notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), Mockito.anyString(),
+                Mockito.anyString())).thenReturn(result);
+        when(result.getFutureOfPutData())
+                .thenReturn(Futures.immediateCheckedFuture(null));
+        when(result.getStatus()).thenReturn(Status.OK);
+        final String uriPath = "ietf-interfaces:interfaces/interface/eth0";
+        final String payload = loadData("/parts/ietf-interfaces_interfaces.json");
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        this.service.put(uriPath, payload, uriInfo);
+
+        final ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
+        final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
         verify(brokerFacade).commitConfigurationDataPut(notNull(SchemaContext.class), capturedPath.capture(),
-                capturedNode.capture());
+                capturedNode.capture(), Mockito.anyString(), Mockito.anyString());
 
         verifyPath(capturedPath.getValue(), INTERFACES_QNAME, INTERFACE_QNAME,
                 new Object[]{INTERFACE_QNAME, NAME_QNAME, "eth0"});
 
         assertTrue("Expected MapEntryNode. Actual " + capturedNode.getValue().getClass(),
                 capturedNode.getValue() instanceof MapEntryNode);
-        MapEntryNode actualNode = (MapEntryNode) capturedNode.getValue();
+        final MapEntryNode actualNode = (MapEntryNode) capturedNode.getValue();
         assertEquals("MapEntryNode node type", INTERFACE_QNAME, actualNode.getNodeType());
         verifyLeafNode(actualNode, NAME_QNAME, "eth0");
         verifyLeafNode(actualNode, TYPE_QNAME, "ethernetCsmacd");
@@ -147,79 +165,96 @@ public class JSONRestconfServiceImplTest {
     @SuppressWarnings("rawtypes")
     @Test
     public void testPutBehindMountPoint() throws Exception {
-        DOMMountPoint mockMountPoint = setupTestMountPoint();
-
-        doReturn(Futures.immediateCheckedFuture(null)).when(brokerFacade).commitConfigurationDataPut(
-                notNull(DOMMountPoint.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class));
-
-        String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1";
-        String payload = loadData("/full-versions/testCont1Data.json");
-
-        service.put(uriPath, payload);
-
-        ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
-        ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
-        verify(brokerFacade).commitConfigurationDataPut(same(mockMountPoint), capturedPath.capture(),
-                capturedNode.capture());
+        final DOMMountPoint mockMountPoint = setupTestMountPoint();
+        final PutResult result = mock(PutResult.class);
+        when(brokerFacade.commitMountPointDataPut(notNull(DOMMountPoint.class),
+                notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), Mockito.anyString(),
+                Mockito.anyString())).thenReturn(result);
+        when(result.getFutureOfPutData()).thenReturn(Futures.immediateCheckedFuture(null));
+        when(result.getStatus()).thenReturn(Status.OK);
+        final String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1";
+        final String payload = loadData("/full-versions/testCont1Data.json");
+
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        this.service.put(uriPath, payload, uriInfo);
+
+        final ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
+        final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
+        verify(brokerFacade).commitMountPointDataPut(same(mockMountPoint), capturedPath.capture(),
+                capturedNode.capture(), Mockito.anyString(), Mockito.anyString());
 
         verifyPath(capturedPath.getValue(), TEST_CONT_QNAME, TEST_CONT1_QNAME);
 
         assertTrue("Expected ContainerNode", capturedNode.getValue() instanceof ContainerNode);
-        ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
+        final ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
         assertEquals("ContainerNode node type", TEST_CONT1_QNAME, actualNode.getNodeType());
         verifyLeafNode(actualNode, TEST_LF11_QNAME, "lf11 data");
         verifyLeafNode(actualNode, TEST_LF12_QNAME, "lf12 data");
     }
 
-    @Test(expected=TransactionCommitFailedException.class)
+    @Test(expected = OperationFailedException.class)
     public void testPutFailure() throws Throwable {
-        doReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock")))
-                .when(brokerFacade).commitConfigurationDataPut(notNull(SchemaContext.class),
-                        notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class));
-
-        String uriPath = "ietf-interfaces:interfaces/interface/eth0";
-        String payload = loadData("/parts/ietf-interfaces_interfaces.json");
-
-        try {
-            service.put(uriPath, payload);
-        } catch (OperationFailedException e) {
-            assertNotNull(e.getCause());
-            throw e.getCause();
-        }
+        final PutResult result = mock(PutResult.class);
+
+        when(result.getFutureOfPutData())
+                .thenReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock")));
+        when(result.getStatus()).thenReturn(Status.OK);
+        when(brokerFacade.commitConfigurationDataPut(notNull(SchemaContext.class),
+                notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), Mockito.anyString(),
+                Mockito.anyString())).thenReturn(result);
+
+        final String uriPath = "ietf-interfaces:interfaces/interface/eth0";
+        final String payload = loadData("/parts/ietf-interfaces_interfaces.json");
+
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        this.service.put(uriPath, payload, uriInfo);
     }
 
     @SuppressWarnings("rawtypes")
     @Test
     public void testPost() throws Exception {
         doReturn(Futures.immediateCheckedFuture(null)).when(brokerFacade).commitConfigurationDataPost(
-                any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
-
-        String uriPath = null;
-        String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
-
-        service.post(uriPath, payload);
-
-        ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
-        ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
+                any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class),
+                Mockito.anyString(), Mockito.anyString());
+
+        final String uriPath = null;
+        final String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
+
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        final UriBuilder uriBuilder = UriBuilder.fromPath("");
+        Mockito.when(uriInfo.getBaseUriBuilder()).thenReturn(uriBuilder);
+        this.service.post(uriPath, payload, uriInfo);
+
+        final ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
+        final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
         verify(brokerFacade).commitConfigurationDataPost(notNull(SchemaContext.class), capturedPath.capture(),
-                capturedNode.capture());
+                capturedNode.capture(), Mockito.anyString(), Mockito.anyString());
 
         verifyPath(capturedPath.getValue(), INTERFACES_QNAME);
 
         assertTrue("Expected ContainerNode", capturedNode.getValue() instanceof ContainerNode);
-        ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
+        final ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
         assertEquals("ContainerNode node type", INTERFACES_QNAME, actualNode.getNodeType());
 
-        Optional<DataContainerChild<?, ?>> mapChild = actualNode.getChild(new NodeIdentifier(INTERFACE_QNAME));
+        final Optional<DataContainerChild<?, ?>> mapChild = actualNode.getChild(new NodeIdentifier(INTERFACE_QNAME));
         assertEquals(INTERFACE_QNAME.toString() + " present", true, mapChild.isPresent());
         assertTrue("Expected MapNode. Actual " + mapChild.get().getClass(), mapChild.get() instanceof MapNode);
-        MapNode mapNode = (MapNode)mapChild.get();
+        final MapNode mapNode = (MapNode)mapChild.get();
 
-        NodeIdentifierWithPredicates entryNodeID = new NodeIdentifierWithPredicates(
+        final NodeIdentifierWithPredicates entryNodeID = new NodeIdentifierWithPredicates(
                 INTERFACE_QNAME, NAME_QNAME, "eth0");
-        Optional<MapEntryNode> entryChild = mapNode.getChild(entryNodeID);
+        final Optional<MapEntryNode> entryChild = mapNode.getChild(entryNodeID);
         assertEquals(entryNodeID.toString() + " present", true, entryChild.isPresent());
-        MapEntryNode entryNode = entryChild.get();
+        final MapEntryNode entryNode = entryChild.get();
         verifyLeafNode(entryNode, NAME_QNAME, "eth0");
         verifyLeafNode(entryNode, TYPE_QNAME, "ethernetCsmacd");
         verifyLeafNode(entryNode, ENABLED_QNAME, Boolean.FALSE);
@@ -229,42 +264,55 @@ public class JSONRestconfServiceImplTest {
     @SuppressWarnings("rawtypes")
     @Test
     public void testPostBehindMountPoint() throws Exception {
-        DOMMountPoint mockMountPoint = setupTestMountPoint();
-
+        final DOMMountPoint mockMountPoint = setupTestMountPoint();
         doReturn(Futures.immediateCheckedFuture(null)).when(brokerFacade).commitConfigurationDataPost(
-                notNull(DOMMountPoint.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class));
-
-        String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont";
-        String payload = loadData("/full-versions/testCont1Data.json");
-
-        service.post(uriPath, payload);
-
-        ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
-        ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
+                notNull(DOMMountPoint.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class),
+                Mockito.anyString(), Mockito.anyString());
+
+        final String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont";
+        final String payload = loadData("/full-versions/testCont1Data.json");
+
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        final UriBuilder uriBuilder = UriBuilder.fromPath("");
+        Mockito.when(uriInfo.getBaseUriBuilder()).thenReturn(uriBuilder);
+        this.service.post(uriPath, payload, uriInfo);
+
+        final ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
+        final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
         verify(brokerFacade).commitConfigurationDataPost(same(mockMountPoint), capturedPath.capture(),
-                capturedNode.capture());
+                capturedNode.capture(), Mockito.anyString(), Mockito.anyString());
 
         verifyPath(capturedPath.getValue(), TEST_CONT_QNAME, TEST_CONT1_QNAME);
 
         assertTrue("Expected ContainerNode", capturedNode.getValue() instanceof ContainerNode);
-        ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
+        final ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
         assertEquals("ContainerNode node type", TEST_CONT1_QNAME, actualNode.getNodeType());
         verifyLeafNode(actualNode, TEST_LF11_QNAME, "lf11 data");
         verifyLeafNode(actualNode, TEST_LF12_QNAME, "lf12 data");
     }
 
-    @Test(expected=TransactionCommitFailedException.class)
+    @Test(expected = TransactionCommitFailedException.class)
     public void testPostFailure() throws Throwable {
-        doReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock")))
-                .when(brokerFacade).commitConfigurationDataPost(any(SchemaContext.class),
-                        any(YangInstanceIdentifier.class), any(NormalizedNode.class));
+        doReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock"))).when(brokerFacade)
+                .commitConfigurationDataPost(any(SchemaContext.class), any(YangInstanceIdentifier.class),
+                        any(NormalizedNode.class), Mockito.anyString(), Mockito.anyString());
+
+        final String uriPath = null;
+        final String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
 
-        String uriPath = null;
-        String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        final UriBuilder uriBuilder = UriBuilder.fromPath("");
+        Mockito.when(uriInfo.getBaseUriBuilder()).thenReturn(uriBuilder);
 
         try {
-            service.post(uriPath, payload);
-        } catch (OperationFailedException e) {
+            this.service.post(uriPath, payload, uriInfo);
+        } catch (final OperationFailedException e) {
             assertNotNull(e.getCause());
             throw e.getCause();
         }
@@ -272,14 +320,14 @@ public class JSONRestconfServiceImplTest {
 
     @Test
     public void testDelete() throws Exception {
-        doReturn(Futures.immediateCheckedFuture(null)).when(brokerFacade).commitConfigurationDataDelete(
-                notNull(YangInstanceIdentifier.class));
+        doReturn(Futures.immediateCheckedFuture(null)).when(brokerFacade)
+                .commitConfigurationDataDelete(notNull(YangInstanceIdentifier.class));
 
-        String uriPath = "ietf-interfaces:interfaces/interface/eth0";
+        final String uriPath = "ietf-interfaces:interfaces/interface/eth0";
 
-        service.delete(uriPath);
+        this.service.delete(uriPath);
 
-        ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
+        final ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
         verify(brokerFacade).commitConfigurationDataDelete(capturedPath.capture());
 
         verifyPath(capturedPath.getValue(), INTERFACES_QNAME, INTERFACE_QNAME,
@@ -288,9 +336,9 @@ public class JSONRestconfServiceImplTest {
 
     @Test(expected=OperationFailedException.class)
     public void testDeleteFailure() throws Exception {
-        String invalidUriPath = "ietf-interfaces:interfaces/invalid";
+        final String invalidUriPath = "ietf-interfaces:interfaces/invalid";
 
-        service.delete(invalidUriPath);
+        this.service.delete(invalidUriPath);
     }
 
     @Test
@@ -304,60 +352,64 @@ public class JSONRestconfServiceImplTest {
     }
 
     @Test
-    public void testGetWithNoData() throws Exception {
-        doReturn(null).when(brokerFacade).readConfigurationData(notNull(YangInstanceIdentifier.class));
-
-        String uriPath = "ietf-interfaces:interfaces";
-
-        Optional<String> optionalResp = service.get(uriPath, LogicalDatastoreType.CONFIGURATION);
-
-        assertEquals("Response present", false, optionalResp.isPresent());
+    public void testGetWithNoData() throws OperationFailedException {
+        doReturn(null).when(brokerFacade).readConfigurationData(notNull(YangInstanceIdentifier.class),
+                Mockito.anyString());
+        final String uriPath = "ietf-interfaces:interfaces";
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        this.service.get(uriPath, LogicalDatastoreType.CONFIGURATION, uriInfo);
     }
 
     @Test(expected=OperationFailedException.class)
     public void testGetFailure() throws Exception {
-        String invalidUriPath = "/ietf-interfaces:interfaces/invalid";
-
-        service.get(invalidUriPath, LogicalDatastoreType.CONFIGURATION);
+        final String invalidUriPath = "/ietf-interfaces:interfaces/invalid";
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        this.service.get(invalidUriPath, LogicalDatastoreType.CONFIGURATION, uriInfo);
     }
 
     @SuppressWarnings("rawtypes")
     @Test
     public void testInvokeRpcWithInput() throws Exception {
-        SchemaPath path = SchemaPath.create(true, MAKE_TOAST_QNAME);
+        final SchemaPath path = SchemaPath.create(true, MAKE_TOAST_QNAME);
 
-        DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
+        final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
         doReturn(Futures.immediateCheckedFuture(expResult)).when(brokerFacade).invokeRpc(eq(path),
                 any(NormalizedNode.class));
 
-        String uriPath = "toaster:make-toast";
-        String input = loadData("/full-versions/make-toast-rpc-input.json");
+        final String uriPath = "toaster:make-toast";
+        final String input = loadData("/full-versions/make-toast-rpc-input.json");
 
-        Optional<String> output = service.invokeRpc(uriPath, Optional.of(input));
+        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.of(input));
 
         assertEquals("Output present", false, output.isPresent());
 
-        ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
+        final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
         verify(brokerFacade).invokeRpc(eq(path), capturedNode.capture());
 
         assertTrue("Expected ContainerNode. Actual " + capturedNode.getValue().getClass(),
                 capturedNode.getValue() instanceof ContainerNode);
-        ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
+        final ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
         verifyLeafNode(actualNode, TOASTER_DONENESS_QNAME, Long.valueOf(10));
         verifyLeafNode(actualNode, TOASTER_TYPE_QNAME, WHEAT_BREAD_QNAME);
     }
 
     @Test
     public void testInvokeRpcWithNoInput() throws Exception {
-        SchemaPath path = SchemaPath.create(true, CANCEL_TOAST_QNAME);
+        final SchemaPath path = SchemaPath.create(true, CANCEL_TOAST_QNAME);
 
-        DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
+        final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
         doReturn(Futures.immediateCheckedFuture(expResult)).when(brokerFacade).invokeRpc(any(SchemaPath.class),
                 any(NormalizedNode.class));
 
-        String uriPath = "toaster:cancel-toast";
+        final String uriPath = "toaster:cancel-toast";
 
-        Optional<String> output = service.invokeRpc(uriPath, Optional.<String>absent());
+        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
 
         assertEquals("Output present", false, output.isPresent());
 
@@ -366,18 +418,18 @@ public class JSONRestconfServiceImplTest {
 
     @Test
     public void testInvokeRpcWithOutput() throws Exception {
-        SchemaPath path = SchemaPath.create(true, TEST_OUTPUT_QNAME);
+        final SchemaPath path = SchemaPath.create(true, TEST_OUTPUT_QNAME);
 
-        NormalizedNode<?, ?> outputNode = ImmutableContainerNodeBuilder.create()
+        final NormalizedNode<?, ?> outputNode = ImmutableContainerNodeBuilder.create()
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_OUTPUT_QNAME))
                 .withChild(ImmutableNodes.leafNode(TEXT_OUT_QNAME, "foo")).build();
-        DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode);
+        final DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode);
         doReturn(Futures.immediateCheckedFuture(expResult)).when(brokerFacade).invokeRpc(any(SchemaPath.class),
                 any(NormalizedNode.class));
 
-        String uriPath = "toaster:testOutput";
+        final String uriPath = "toaster:testOutput";
 
-        Optional<String> output = service.invokeRpc(uriPath, Optional.<String>absent());
+        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
 
         assertEquals("Output present", true, output.isPresent());
         assertNotNull("Returned null response", output.get());
@@ -388,17 +440,17 @@ public class JSONRestconfServiceImplTest {
 
     @Test(expected=OperationFailedException.class)
     public void testInvokeRpcFailure() throws Exception {
-        DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption");
+        final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption");
         doReturn(Futures.immediateFailedCheckedFuture(exception)).when(brokerFacade).invokeRpc(any(SchemaPath.class),
                 any(NormalizedNode.class));
 
-        String uriPath = "toaster:cancel-toast";
+        final String uriPath = "toaster:cancel-toast";
 
-        service.invokeRpc(uriPath, Optional.<String>absent());
+        this.service.invokeRpc(uriPath, Optional.<String>absent());
     }
 
     void testGet(final LogicalDatastoreType datastoreType) throws OperationFailedException {
-        MapEntryNode entryNode = ImmutableNodes.mapEntryBuilder(INTERFACE_QNAME, NAME_QNAME, "eth0")
+        final MapEntryNode entryNode = ImmutableNodes.mapEntryBuilder(INTERFACE_QNAME, NAME_QNAME, "eth0")
                 .withChild(ImmutableNodes.leafNode(NAME_QNAME, "eth0"))
                 .withChild(ImmutableNodes.leafNode(TYPE_QNAME, "ethernetCsmacd"))
                 .withChild(ImmutableNodes.leafNode(ENABLED_QNAME, Boolean.TRUE))
@@ -406,16 +458,23 @@ public class JSONRestconfServiceImplTest {
                 .build();
 
         if(datastoreType == LogicalDatastoreType.CONFIGURATION) {
-            doReturn(entryNode).when(brokerFacade).readConfigurationData(notNull(YangInstanceIdentifier.class));
+            doReturn(entryNode).when(brokerFacade).readConfigurationData(notNull(YangInstanceIdentifier.class),
+                    Mockito.anyString());
         } else {
             doReturn(entryNode).when(brokerFacade).readOperationalData(notNull(YangInstanceIdentifier.class));
         }
 
-        String uriPath = "/ietf-interfaces:interfaces/interface/eth0";
+        final String uriPath = "/ietf-interfaces:interfaces/interface/eth0";
+        final UriInfo uriInfo = Mockito.mock(UriInfo.class);
+        final MultivaluedMap<String, String> value = Mockito.mock(MultivaluedMap.class);
+        Mockito.when(value.entrySet()).thenReturn(new HashSet<>());
+        Mockito.when(uriInfo.getQueryParameters()).thenReturn(value);
+        Mockito.when(uriInfo.getQueryParameters(false)).thenReturn(value);
+        Mockito.when(value.getFirst("depth")).thenReturn("");
 
-        Optional<String> optionalResp = service.get(uriPath, datastoreType);
+        final Optional<String> optionalResp = this.service.get(uriPath, datastoreType, uriInfo);
         assertEquals("Response present", true, optionalResp.isPresent());
-        String jsonResp = optionalResp.get();
+        final String jsonResp = optionalResp.get();
 
         assertNotNull("Returned null response", jsonResp);
         assertThat("Missing \"name\"", jsonResp, containsString("\"name\":\"eth0\""));
@@ -423,9 +482,9 @@ public class JSONRestconfServiceImplTest {
         assertThat("Missing \"enabled\"", jsonResp, containsString("\"enabled\":true"));
         assertThat("Missing \"description\"", jsonResp, containsString("\"description\":\"eth interface\""));
 
-        ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
+        final ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
         if (datastoreType == LogicalDatastoreType.CONFIGURATION) {
-            verify(brokerFacade).readConfigurationData(capturedPath.capture());
+            verify(brokerFacade).readConfigurationData(capturedPath.capture(), Mockito.anyString());
         } else {
             verify(brokerFacade).readOperationalData(capturedPath.capture());
         }
@@ -434,12 +493,12 @@ public class JSONRestconfServiceImplTest {
                 new Object[]{INTERFACE_QNAME, NAME_QNAME, "eth0"});
     }
 
-    DOMMountPoint setupTestMountPoint() throws FileNotFoundException {
-        SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module");
-        DOMMountPoint mockMountPoint = mock(DOMMountPoint.class);
+    DOMMountPoint setupTestMountPoint() throws FileNotFoundException, ReactorException {
+        final SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module");
+        final DOMMountPoint mockMountPoint = mock(DOMMountPoint.class);
         doReturn(schemaContextTestModule).when(mockMountPoint).getSchemaContext();
 
-        DOMMountPointService mockMountService = mock(DOMMountPointService.class);
+        final DOMMountPointService mockMountService = mock(DOMMountPointService.class);
         doReturn(Optional.of(mockMountPoint)).when(mockMountService).getMountPoint(notNull(YangInstanceIdentifier.class));
 
         ControllerContext.getInstance().setMountService(mockMountService);
@@ -447,25 +506,25 @@ public class JSONRestconfServiceImplTest {
     }
 
     void verifyLeafNode(final DataContainerNode<?> parent, final QName leafType, final Object leafValue) {
-        Optional<DataContainerChild<?, ?>> leafChild = parent.getChild(new NodeIdentifier(leafType));
+        final Optional<DataContainerChild<?, ?>> leafChild = parent.getChild(new NodeIdentifier(leafType));
         assertEquals(leafType.toString() + " present", true, leafChild.isPresent());
         assertEquals(leafType.toString() + " value", leafValue, leafChild.get().getValue());
     }
 
     void verifyPath(final YangInstanceIdentifier path, final Object... expArgs) {
-        List<PathArgument> pathArgs = path.getPathArguments();
+        final List<PathArgument> pathArgs = path.getPathArguments();
         assertEquals("Arg count for actual path " + path, expArgs.length, pathArgs.size());
         int i = 0;
-        for(PathArgument actual: pathArgs) {
+        for(final PathArgument actual: pathArgs) {
             QName expNodeType;
             if(expArgs[i] instanceof Object[]) {
-                Object[] listEntry = (Object[]) expArgs[i];
+                final Object[] listEntry = (Object[]) expArgs[i];
                 expNodeType = (QName) listEntry[0];
 
                 assertTrue(actual instanceof NodeIdentifierWithPredicates);
-                Map<QName, Object> keyValues = ((NodeIdentifierWithPredicates)actual).getKeyValues();
+                final Map<QName, Object> keyValues = ((NodeIdentifierWithPredicates)actual).getKeyValues();
                 assertEquals(String.format("Path arg %d keyValues size", i + 1), 1, keyValues.size());
-                QName expKey = (QName) listEntry[1];
+                final QName expKey = (QName) listEntry[1];
                 assertEquals(String.format("Path arg %d keyValue for %s", i + 1, expKey), listEntry[2],
                         keyValues.get(expKey));
             } else {