use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidateNodesTest method testApplyRootToCursorWithUnsupportedModificationType.
@Test
public void testApplyRootToCursorWithUnsupportedModificationType() {
final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
doReturn(ModificationType.APPEARED).when(mockedDataTreeCandidateNode).getModificationType();
final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> DataTreeCandidateNodes.applyRootToCursor(mockedCursor, mockedDataTreeCandidateNode));
assertThat(ex.getMessage(), containsString("Unsupported modification"));
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidateNodesTest method testApplyRootToCursorWithDeleteModificationType.
@Test
public void testApplyRootToCursorWithDeleteModificationType() {
final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
doReturn(ModificationType.DELETE).when(mockedDataTreeCandidateNode).getModificationType();
final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> DataTreeCandidateNodes.applyRootToCursor(mockedCursor, mockedDataTreeCandidateNode));
assertThat(ex.getMessage(), containsString("Can not delete root"));
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidateNodesTest method testApplyToCursorWithUnsupportedModificationType.
@Test
public void testApplyToCursorWithUnsupportedModificationType() {
final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
doReturn(ModificationType.APPEARED).when(mockedDataTreeCandidateNode).getModificationType();
final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> DataTreeCandidateNodes.applyToCursor(mockedCursor, mockedDataTreeCandidateNode));
assertThat(ex.getMessage(), containsString("Unsupported modification"));
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidateNodesTest method testApplyRootedNodeToCursorWithDeleteModificationType.
@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);
verify(mockedCursor, times(1)).delete(isNull());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidateNodesTest method testApplyRootedNodeToCursorWithSubtreeModifiedModificationType.
@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();
final DataTreeCandidateNode mockedChildNode1 = mock(DataTreeCandidateNode.class);
doReturn(ModificationType.DELETE).when(mockedChildNode1).getModificationType();
doReturn(List.of(mockedChildNode1)).when(mockedDataTreeCandidateNode).getChildNodes();
DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, mockedRootPath, mockedDataTreeCandidateNode);
verify(mockedCursor, times(1)).enter((PathArgument) isNull());
verify(mockedCursor, times(1)).delete(isNull());
}
Aggregations