use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidateNodesTest method testApplyRootedNodeToCursorWithUnsupportedModificationType.
@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, 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 testApplyToCursorWithWriteModificationType.
@Test
public void testApplyToCursorWithWriteModificationType() {
final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.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.applyToCursor(mockedCursor, mockedDataTreeCandidateNode);
verify(mockedCursor, times(1)).write(isNull(), any(NormalizedNode.class));
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidatesTest method testApplyToModificationWithUnsupportedModificationType.
@Test
public void testApplyToModificationWithUnsupportedModificationType() {
final DataTreeCandidate mockedDataTreeCandidate = mock(DataTreeCandidate.class);
final DataTreeModification mockedModification = mock(DataTreeModification.class);
final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
doReturn(mockedDataTreeCandidateNode).when(mockedDataTreeCandidate).getRootNode();
final YangInstanceIdentifier mockedRootPath = mock(YangInstanceIdentifier.class);
doReturn(mockedRootPath).when(mockedDataTreeCandidate).getRootPath();
doReturn(ModificationType.APPEARED).when(mockedDataTreeCandidateNode).getModificationType();
final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> DataTreeCandidates.applyToModification(mockedModification, mockedDataTreeCandidate));
assertThat(ex.getMessage(), containsString("Unsupported modification"));
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidatesTest method testApplyToModificationWithSubtreeModifiedModificationType.
@Test
public void testApplyToModificationWithSubtreeModifiedModificationType() {
final DataTreeCandidate mockedDataTreeCandidate = mock(DataTreeCandidate.class);
final DataTreeModification mockedModification = mock(DataTreeModification.class);
final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
doReturn(mockedDataTreeCandidateNode).when(mockedDataTreeCandidate).getRootNode();
final YangInstanceIdentifier mockedRootPath = mock(YangInstanceIdentifier.class);
doReturn(mockedRootPath).when(mockedDataTreeCandidate).getRootPath();
doReturn(ModificationType.SUBTREE_MODIFIED).when(mockedDataTreeCandidateNode).getModificationType();
final DataTreeCandidateNode mockedChildNode1 = mock(DataTreeCandidateNode.class);
doReturn(ModificationType.DELETE).when(mockedChildNode1).getModificationType();
final PathArgument mockedPathArgument1 = mock(PathArgument.class);
doReturn(mockedPathArgument1).when(mockedChildNode1).getIdentifier();
final DataTreeCandidateNode mockedChildNode2 = mock(DataTreeCandidateNode.class);
doReturn(ModificationType.WRITE).when(mockedChildNode2).getModificationType();
final NormalizedNode mockedNormalizedNode = mock(NormalizedNode.class);
doReturn(Optional.of(mockedNormalizedNode)).when(mockedChildNode2).getDataAfter();
final PathArgument mockedPathArgument2 = mock(PathArgument.class);
doReturn(mockedPathArgument2).when(mockedChildNode2).getIdentifier();
final DataTreeCandidateNode mockedChildNode3 = mock(DataTreeCandidateNode.class);
doReturn(ModificationType.SUBTREE_MODIFIED).when(mockedChildNode3).getModificationType();
final PathArgument mockedPathArgument3 = mock(PathArgument.class);
doReturn(mockedPathArgument3).when(mockedChildNode3).getIdentifier();
final DataTreeCandidateNode mockedChildNode3ChildNode = mock(DataTreeCandidateNode.class);
doReturn(ModificationType.DELETE).when(mockedChildNode3ChildNode).getModificationType();
final PathArgument mockedPathArgument31 = mock(PathArgument.class);
doReturn(mockedPathArgument3).when(mockedChildNode3).getIdentifier();
doReturn(mockedPathArgument31).when(mockedChildNode3ChildNode).getIdentifier();
doReturn(List.of(mockedChildNode3ChildNode)).when(mockedChildNode3).getChildNodes();
final List<DataTreeCandidateNode> childNodes = List.of(mockedChildNode1, mockedChildNode2, mockedChildNode3);
doReturn(childNodes).when(mockedDataTreeCandidateNode).getChildNodes();
DataTreeCandidates.applyToModification(mockedModification, mockedDataTreeCandidate);
verify(mockedModification, times(2)).delete(any(YangInstanceIdentifier.class));
verify(mockedModification, times(1)).write(any(YangInstanceIdentifier.class), any(NormalizedNode.class));
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidatesTest method testApplyToModificationWithWriteModificationType.
@Test
public void testApplyToModificationWithWriteModificationType() {
final DataTreeCandidate mockedDataTreeCandidate = mock(DataTreeCandidate.class);
final DataTreeModification mockedModification = mock(DataTreeModification.class);
final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
doReturn(mockedDataTreeCandidateNode).when(mockedDataTreeCandidate).getRootNode();
final YangInstanceIdentifier mockedRootPath = mock(YangInstanceIdentifier.class);
doReturn(mockedRootPath).when(mockedDataTreeCandidate).getRootPath();
final NormalizedNode mockedNormalizedNode = mock(NormalizedNode.class);
doReturn(Optional.of(mockedNormalizedNode)).when(mockedDataTreeCandidateNode).getDataAfter();
doReturn(ModificationType.WRITE).when(mockedDataTreeCandidateNode).getModificationType();
DataTreeCandidates.applyToModification(mockedModification, mockedDataTreeCandidate);
verify(mockedModification, times(1)).write(any(YangInstanceIdentifier.class), any(NormalizedNode.class));
}
Aggregations