Bump yangtools to 4.0.1
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / impl / JSONRestconfServiceRfc8040ImplTest.java
index 4909e0ffbb2ab49636013fd451aecdce2433d8f9..8460fef39a6a0f4dfa4ea8b3ef33f439edfdff76 100644 (file)
@@ -10,56 +10,66 @@ package org.opendaylight.restconf.nb.rfc8040.rests.services.impl;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isNull;
-import static org.mockito.Matchers.notNull;
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.ArgumentMatchers.notNull;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
+import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFailedFluentFuture;
+import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFalseFluentFuture;
+import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture;
+import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateTrueFluentFuture;
 
-import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableClassToInstanceMap;
 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.List;
-import java.util.Map;
+import java.util.Optional;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-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.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMNotificationService;
+import org.opendaylight.mdsal.dom.api.DOMRpcException;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
 import org.opendaylight.restconf.nb.rfc8040.TestUtils;
+import org.opendaylight.restconf.nb.rfc8040.handlers.ActionServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
-import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl;
+import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapper;
 import org.opendaylight.yangtools.yang.common.OperationFailedException;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -115,39 +125,46 @@ public class JSONRestconfServiceRfc8040ImplTest {
     private DOMTransactionChain mockTxChain;
 
     @Mock
-    private DOMDataReadWriteTransaction mockReadWriteTx;
+    private DOMDataTreeReadWriteTransaction mockReadWriteTx;
 
     @Mock
-    private DOMDataReadOnlyTransaction mockReadOnlyTx;
+    private DOMDataTreeReadTransaction mockReadOnlyTx;
 
     @Mock
-    private DOMDataWriteTransaction mockWriteTx;
+    private DOMDataTreeWriteTransaction mockWriteTx;
 
     @Mock
     private DOMMountPointService mockMountPointService;
 
-    @Mock
-    private SchemaContextHandler mockSchemaContextHandler;
-
     @Mock
     private DOMDataBroker mockDOMDataBroker;
 
     @Mock
     private DOMRpcService mockRpcService;
 
+    @Mock
+    private DOMActionService mockActionService;
+
+    @Mock
+    private DOMSchemaService domSchemaService;
+
     private JSONRestconfServiceRfc8040Impl service;
 
+    private final SchemaContextHandler schemaContextHandler = TestUtils.newSchemaContextHandler(schemaContext);
+
     @BeforeClass
     public static void init() throws IOException, ReactorException {
         schemaContext = TestUtils.loadSchemaContext("/full-versions/yangs");
-        SchemaContextHandler.setActualSchemaContext(schemaContext);
     }
 
+    @SuppressWarnings("resource")
     @Before
     public void setup() throws Exception {
         MockitoAnnotations.initMocks(this);
 
-        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadOnlyTx).read(
+        doReturn(ImmutableClassToInstanceMap.of()).when(domSchemaService).getExtensions();
+
+        doReturn(immediateFluentFuture(Optional.empty())).when(mockReadOnlyTx).read(
                 eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class));
 
         doNothing().when(mockWriteTx).put(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class),
@@ -155,14 +172,14 @@ public class JSONRestconfServiceRfc8040ImplTest {
         doNothing().when(mockWriteTx).merge(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class),
                 any(NormalizedNode.class));
         doNothing().when(mockWriteTx).delete(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class));
-        doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
+        doReturn(CommitInfo.emptyFluentFuture()).when(mockWriteTx).commit();
 
         doNothing().when(mockReadWriteTx).put(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class),
                 any(NormalizedNode.class));
-        doReturn(Futures.immediateCheckedFuture(null)).when(mockReadWriteTx).submit();
-        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadWriteTx).read(
+        doReturn(CommitInfo.emptyFluentFuture()).when(mockReadWriteTx).commit();
+        doReturn(immediateFluentFuture(Optional.empty())).when(mockReadWriteTx).read(
                 eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class));
-        doReturn(Futures.immediateCheckedFuture(Boolean.FALSE)).when(mockReadWriteTx).exists(
+        doReturn(immediateFalseFluentFuture()).when(mockReadWriteTx).exists(
                 eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class));
 
         doReturn(mockReadOnlyTx).when(mockTxChain).newReadOnlyTransaction();
@@ -171,19 +188,19 @@ public class JSONRestconfServiceRfc8040ImplTest {
 
         doReturn(mockTxChain).when(mockDOMDataBroker).createTransactionChain(any());
 
-        doReturn(schemaContext).when(mockSchemaContextHandler).get();
-
-        final TransactionChainHandler txChainHandler = new TransactionChainHandler(mockTxChain);
+        final TransactionChainHandler txChainHandler = new TransactionChainHandler(mockDOMDataBroker);
 
         final DOMMountPointServiceHandler mountPointServiceHandler =
-                new DOMMountPointServiceHandler(mockMountPointService);
+                DOMMountPointServiceHandler.newInstance(mockMountPointService);
 
-        ServicesWrapperImpl.getInstance().setHandlers(mockSchemaContextHandler, mountPointServiceHandler,
-                txChainHandler, new DOMDataBrokerHandler(mockDOMDataBroker),
-                new RpcServiceHandler(mockRpcService),
-                new NotificationServiceHandler(mock(DOMNotificationService.class)));
+        final DOMNotificationService mockNotificationService = mock(DOMNotificationService.class);
+        final ServicesWrapper servicesWrapper = ServicesWrapper.newInstance(schemaContextHandler,
+                mountPointServiceHandler, txChainHandler, new DOMDataBrokerHandler(mockDOMDataBroker),
+                new RpcServiceHandler(mockRpcService), new ActionServiceHandler(mockActionService),
+                new NotificationServiceHandler(mockNotificationService), domSchemaService);
 
-        service = new JSONRestconfServiceRfc8040Impl(ServicesWrapperImpl.getInstance(), mountPointServiceHandler);
+        service = new JSONRestconfServiceRfc8040Impl(servicesWrapper, mountPointServiceHandler,
+                schemaContextHandler);
     }
 
     private static String loadData(final String path) throws IOException {
@@ -248,8 +265,8 @@ public class JSONRestconfServiceRfc8040ImplTest {
     @Test(expected = OperationFailedException.class)
     @SuppressWarnings("checkstyle:IllegalThrows")
     public void testPutFailure() throws Throwable {
-        doReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock")))
-                .when(mockReadWriteTx).submit();
+        doReturn(immediateFailedFluentFuture(new TransactionCommitFailedException("mock")))
+                .when(mockReadWriteTx).commit();
 
         final String uriPath = "ietf-interfaces:interfaces/interface=eth0";
         final String payload = loadData("/parts/ietf-interfaces_interfaces.json");
@@ -283,7 +300,7 @@ public class JSONRestconfServiceRfc8040ImplTest {
         assertTrue("Expected MapNode. Actual " + mapChild.get().getClass(), mapChild.get() instanceof MapNode);
         final MapNode mapNode = (MapNode)mapChild.get();
 
-        final NodeIdentifierWithPredicates entryNodeID = new NodeIdentifierWithPredicates(
+        final NodeIdentifierWithPredicates entryNodeID = NodeIdentifierWithPredicates.of(
                 INTERFACE_QNAME, NAME_QNAME, "eth0");
         final Optional<MapEntryNode> entryChild = mapNode.getChild(entryNodeID);
         assertEquals(entryNodeID.toString() + " present", true, entryChild.isPresent());
@@ -320,26 +337,97 @@ public class JSONRestconfServiceRfc8040ImplTest {
         verifyLeafNode(actualNode, TEST_LF12_QNAME, "lf12 data");
     }
 
-    @Test(expected = TransactionCommitFailedException.class)
-    @SuppressWarnings("checkstyle:IllegalThrows")
-    public void testPostFailure() throws Throwable {
-        doReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock")))
-                .when(mockReadWriteTx).submit();
+    @Test
+    public void testPostFailure() throws IOException {
+        final Exception failure = new TransactionCommitFailedException("mock");
+        doReturn(immediateFailedFluentFuture(failure)).when(mockReadWriteTx).commit();
 
-        final String uriPath = null;
         final String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
-
         try {
-            this.service.post(uriPath, payload);
+            this.service.post(null, payload);
+            fail();
         } catch (final OperationFailedException e) {
-            assertNotNull(e.getCause());
-            throw e.getCause();
+            final Throwable cause = e.getCause();
+            assertNotNull(cause);
+            assertSame(failure, cause.getCause());
         }
     }
 
+    @SuppressWarnings("rawtypes")
+    @Test
+    public void testPatch() throws Exception {
+        final String uriPath = "ietf-interfaces:interfaces/interface=eth0";
+        final String payload = loadData("/parts/ietf-interfaces_interfaces_patch.json");
+
+        final Optional<String> patchResult = this.service.patch(uriPath, payload);
+
+        final ArgumentCaptor<YangInstanceIdentifier> capturedPath =
+                ArgumentCaptor.forClass(YangInstanceIdentifier.class);
+        final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
+
+        verify(mockReadWriteTx).put(eq(LogicalDatastoreType.CONFIGURATION), capturedPath.capture(),
+                capturedNode.capture());
+
+        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);
+        final MapEntryNode actualNode = (MapEntryNode) capturedNode.getValue();
+        assertEquals("MapEntryNode node type", INTERFACE_QNAME, actualNode.getNodeType());
+        verifyLeafNode(actualNode, NAME_QNAME, "eth0");
+        verifyLeafNode(actualNode, TYPE_QNAME, "ethernetCsmacd");
+        verifyLeafNode(actualNode, ENABLED_QNAME, Boolean.FALSE);
+        verifyLeafNode(actualNode, DESC_QNAME, "some interface");
+        assertTrue(patchResult.get().contains("\"ok\":[null]"));
+    }
+
+    @SuppressWarnings("rawtypes")
+    @Test
+    public void testPatchBehindMountPoint() throws Exception {
+        setupTestMountPoint();
+
+        final String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1";
+        final String payload = loadData("/full-versions/testCont1DataPatch.json");
+
+        final Optional<String> patchResult = this.service.patch(uriPath, payload);
+
+        final ArgumentCaptor<YangInstanceIdentifier> capturedPath =
+                ArgumentCaptor.forClass(YangInstanceIdentifier.class);
+        final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
+
+        verify(mockReadWriteTx).put(eq(LogicalDatastoreType.CONFIGURATION), capturedPath.capture(),
+                capturedNode.capture());
+
+        verifyPath(capturedPath.getValue(), TEST_CONT_QNAME, TEST_CONT1_QNAME);
+
+        assertTrue("Expected ContainerNode", capturedNode.getValue() instanceof ContainerNode);
+        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");
+        assertTrue(patchResult.get().contains("\"ok\":[null]"));
+    }
+
+    @Test
+    @SuppressWarnings("checkstyle:IllegalThrows")
+    public void testPatchFailure() throws Throwable {
+        doReturn(immediateFailedFluentFuture(new TransactionCommitFailedException("mock")))
+                .when(mockReadWriteTx).commit();
+
+        final String uriPath = "ietf-interfaces:interfaces/interface=eth0";
+
+        final String payload = loadData("/parts/ietf-interfaces_interfaces_patch.json");
+
+        final Optional<String> patchResult = this.service.patch(uriPath, payload);
+        assertTrue("Patch output is not null", patchResult.isPresent());
+        String patch = patchResult.get();
+        assertTrue(patch.contains("mock"));
+    }
+
     @Test
     public void testDelete() throws Exception {
-        doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(mockReadWriteTx).exists(
+        doReturn(immediateTrueFluentFuture()).when(mockReadWriteTx).exists(
                 eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class));
 
         final String uriPath = "ietf-interfaces:interfaces/interface=eth0";
@@ -390,8 +478,7 @@ public class JSONRestconfServiceRfc8040ImplTest {
         final SchemaPath path = SchemaPath.create(true, MAKE_TOAST_QNAME);
 
         final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
-        doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path),
-                any(NormalizedNode.class));
+        doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), any(NormalizedNode.class));
 
         final String uriPath = "toaster:make-toast";
         final String input = loadData("/full-versions/make-toast-rpc-input.json");
@@ -406,7 +493,7 @@ public class JSONRestconfServiceRfc8040ImplTest {
         assertTrue("Expected ContainerNode. Actual " + capturedNode.getValue().getClass(),
                 capturedNode.getValue() instanceof ContainerNode);
         final ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
-        verifyLeafNode(actualNode, TOASTER_DONENESS_QNAME, Long.valueOf(10));
+        verifyLeafNode(actualNode, TOASTER_DONENESS_QNAME, Uint32.valueOf(10L));
         verifyLeafNode(actualNode, TOASTER_TYPE_QNAME, WHEAT_BREAD_QNAME);
     }
 
@@ -415,16 +502,15 @@ public class JSONRestconfServiceRfc8040ImplTest {
         final SchemaPath path = SchemaPath.create(true, CANCEL_TOAST_QNAME);
 
         final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
-        doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path),
-                any(NormalizedNode.class));
+        doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), isNull());
 
         final String uriPath = "toaster:cancel-toast";
 
-        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
+        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.empty());
 
         assertEquals("Output present", false, output.isPresent());
 
-        verify(mockRpcService).invokeRpc(eq(path), isNull(NormalizedNode.class));
+        verify(mockRpcService).invokeRpc(eq(path), isNull());
     }
 
     @Test
@@ -435,29 +521,29 @@ public class JSONRestconfServiceRfc8040ImplTest {
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_OUTPUT_QNAME))
                 .withChild(ImmutableNodes.leafNode(TEXT_OUT_QNAME, "foo")).build();
         final DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode);
-        doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path),
-                any(NormalizedNode.class));
+        doReturn(immediateFluentFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), isNull());
 
         final String uriPath = "toaster:testOutput";
 
-        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
+        final Optional<String> output = this.service.invokeRpc(uriPath, Optional.empty());
 
         assertEquals("Output present", true, output.isPresent());
         assertNotNull("Returned null response", output.get());
+        assertThat("Output element is missing namespace", output.get(), containsString("\"toaster:output\""));
         assertThat("Missing \"textOut\"", output.get(), containsString("\"textOut\":\"foo\""));
 
-        verify(mockRpcService).invokeRpc(eq(path), isNull(NormalizedNode.class));
+        verify(mockRpcService).invokeRpc(eq(path), isNull());
     }
 
     @Test(expected = OperationFailedException.class)
     public void testInvokeRpcFailure() throws Exception {
         final DOMRpcException exception = new DOMRpcImplementationNotAvailableException("testExeption");
-        doReturn(Futures.immediateFailedCheckedFuture(exception)).when(mockRpcService).invokeRpc(any(SchemaPath.class),
+        doReturn(immediateFailedFluentFuture(exception)).when(mockRpcService).invokeRpc(any(SchemaPath.class),
                 any(NormalizedNode.class));
 
         final String uriPath = "toaster:cancel-toast";
 
-        this.service.invokeRpc(uriPath, Optional.<String>absent());
+        this.service.invokeRpc(uriPath, Optional.empty());
     }
 
     void testGet(final LogicalDatastoreType datastoreType) throws OperationFailedException {
@@ -468,7 +554,7 @@ public class JSONRestconfServiceRfc8040ImplTest {
                 .withChild(ImmutableNodes.leafNode(DESC_QNAME, "eth interface"))
                 .build();
 
-        doReturn(Futures.immediateCheckedFuture(Optional.of(entryNode))).when(mockReadOnlyTx).read(
+        doReturn(immediateFluentFuture(Optional.of(entryNode))).when(mockReadOnlyTx).read(
                 eq(datastoreType), any(YangInstanceIdentifier.class));
 
         final String uriPath = "ietf-interfaces:interfaces/interface=eth0";
@@ -478,6 +564,8 @@ public class JSONRestconfServiceRfc8040ImplTest {
         final String jsonResp = optionalResp.get();
 
         assertNotNull("Returned null response", jsonResp);
+        assertThat("Top level module has incorrect format", jsonResp, containsString("\"ietf-interfaces:interface\""));
+        assertThat("Missing \"name\"", jsonResp, containsString("\"name\":\"eth0\""));
         assertThat("Missing \"name\"", jsonResp, containsString("\"name\":\"eth0\""));
         assertThat("Missing \"type\"", jsonResp, containsString("\"type\":\"ethernetCsmacd\""));
         assertThat("Missing \"enabled\"", jsonResp, containsString("\"enabled\":true"));
@@ -521,11 +609,12 @@ public class JSONRestconfServiceRfc8040ImplTest {
                 expNodeType = (QName) listEntry[0];
 
                 assertTrue(actual instanceof NodeIdentifierWithPredicates);
-                final Map<QName, Object> keyValues = ((NodeIdentifierWithPredicates)actual).getKeyValues();
-                assertEquals(String.format("Path arg %d keyValues size", index + 1), 1, keyValues.size());
+                final NodeIdentifierWithPredicates nip = (NodeIdentifierWithPredicates)actual;
+
+                assertEquals(String.format("Path arg %d keyValues size", index + 1), 1, nip.size());
                 final QName expKey = (QName) listEntry[1];
                 assertEquals(String.format("Path arg %d keyValue for %s", index + 1, expKey), listEntry[2],
-                        keyValues.get(expKey));
+                    nip.getValue(expKey));
             } else {
                 expNodeType = (QName) expArgs[index];
             }