Seal YangInstanceIdentifier
[yangtools.git] / data / yang-data-tree-spi / src / test / java / org / opendaylight / yangtools / yang / data / tree / spi / DataTreeCandidateNodesTest.java
index 0c8bfcc21988ddf199561491a5c59d1da1e7b902..c664b682b10c8deea21bf251eef80e161aa78ee0 100644 (file)
@@ -18,10 +18,11 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -29,6 +30,7 @@ import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor;
 import org.opendaylight.yangtools.yang.data.tree.api.ModificationType;
 
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class DataTreeCandidateNodesTest {
     @Test
     public void testFromNormalizedNode() {
@@ -80,9 +82,8 @@ public class DataTreeCandidateNodesTest {
         doReturn(ModificationType.DELETE).when(mockedChildNode3ChildNode).getModificationType();
         doReturn(List.of(mockedChildNode3ChildNode)).when(mockedChildNode3).getChildNodes();
 
-        final Collection<DataTreeCandidateNode> childNodes = List.of(mockedChildNode1, mockedChildNode2,
-                mockedChildNode3);
-        doReturn(childNodes).when(mockedDataTreeCandidateNode).getChildNodes();
+        doReturn(List.of(mockedChildNode1, mockedChildNode2, mockedChildNode3))
+            .when(mockedDataTreeCandidateNode).getChildNodes();
 
         DataTreeCandidateNodes.applyToCursor(mockedCursor, mockedDataTreeCandidateNode);
         verify(mockedCursor, times(2)).enter((PathArgument) isNull());
@@ -104,31 +105,30 @@ public class DataTreeCandidateNodesTest {
     @Test
     public void testApplyRootedNodeToCursorWithWriteModificationType() {
         final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
-        final YangInstanceIdentifier mockedRootPath = mock(YangInstanceIdentifier.class);
         final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
 
         doReturn(ModificationType.WRITE).when(mockedDataTreeCandidateNode).getModificationType();
         final NormalizedNode mockedNormalizedNode = mock(NormalizedNode.class);
         doReturn(Optional.of(mockedNormalizedNode)).when(mockedDataTreeCandidateNode).getDataAfter();
-        DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, mockedRootPath, mockedDataTreeCandidateNode);
+        DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, YangInstanceIdentifier.empty(),
+            mockedDataTreeCandidateNode);
         verify(mockedCursor, times(1)).write(isNull(), any(NormalizedNode.class));
     }
 
     @Test
     public void testApplyRootedNodeToCursorWithDeleteModificationType() {
         final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
-        final YangInstanceIdentifier mockedRootPath = mock(YangInstanceIdentifier.class);
         final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
 
         doReturn(ModificationType.DELETE).when(mockedDataTreeCandidateNode).getModificationType();
-        DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, mockedRootPath, mockedDataTreeCandidateNode);
+        DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, YangInstanceIdentifier.empty(),
+            mockedDataTreeCandidateNode);
         verify(mockedCursor, times(1)).delete(isNull());
     }
 
     @Test
     public void testApplyRootedNodeToCursorWithSubtreeModifiedModificationType() {
         final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
-        final YangInstanceIdentifier mockedRootPath = mock(YangInstanceIdentifier.class);
         final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
 
         doReturn(ModificationType.SUBTREE_MODIFIED).when(mockedDataTreeCandidateNode).getModificationType();
@@ -137,7 +137,8 @@ public class DataTreeCandidateNodesTest {
         doReturn(ModificationType.DELETE).when(mockedChildNode1).getModificationType();
         doReturn(List.of(mockedChildNode1)).when(mockedDataTreeCandidateNode).getChildNodes();
 
-        DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, mockedRootPath, mockedDataTreeCandidateNode);
+        DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, YangInstanceIdentifier.empty(),
+            mockedDataTreeCandidateNode);
         verify(mockedCursor, times(1)).enter((PathArgument) isNull());
         verify(mockedCursor, times(1)).delete(isNull());
     }
@@ -145,12 +146,11 @@ public class DataTreeCandidateNodesTest {
     @Test
     public void testApplyRootedNodeToCursorWithUnsupportedModificationType() {
         final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
-        final YangInstanceIdentifier mockedRootPath = mock(YangInstanceIdentifier.class);
         final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
 
         doReturn(ModificationType.APPEARED).when(mockedDataTreeCandidateNode).getModificationType();
         final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
-            () -> DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, mockedRootPath,
+            () -> DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, YangInstanceIdentifier.empty(),
                 mockedDataTreeCandidateNode));
         assertThat(ex.getMessage(), containsString("Unsupported modification"));
     }