use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidatesTest method testApplyToCursorAwareModificationRoot.
@Test
public void testApplyToCursorAwareModificationRoot() {
final DataTreeCandidate mockedDataTreeCandidate = mock(DataTreeCandidate.class);
final CursorAwareDataTreeModification mockedModification = mock(CursorAwareDataTreeModification.class);
final YangInstanceIdentifier mockedRootPath = mock(YangInstanceIdentifier.class);
final DataTreeCandidateNode mockedDataTreeCandidateNode = mock(DataTreeCandidateNode.class);
doReturn(mockedRootPath).when(mockedDataTreeCandidate).getRootPath();
doReturn(null).when(mockedRootPath).getParent();
doReturn(mockedDataTreeCandidateNode).when(mockedDataTreeCandidate).getRootNode();
doReturn(ModificationType.DELETE).when(mockedDataTreeCandidateNode).getModificationType();
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> DataTreeCandidates.applyToModification(mockedModification, mockedDataTreeCandidate));
assertEquals("Can not delete root.", thrown.getMessage());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidatesTest method testApplyToModificationWithDeleteModificationType.
@Test
public void testApplyToModificationWithDeleteModificationType() {
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.DELETE).when(mockedDataTreeCandidateNode).getModificationType();
DataTreeCandidates.applyToModification(mockedModification, mockedDataTreeCandidate);
verify(mockedModification, times(1)).delete(any(YangInstanceIdentifier.class));
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidatesAggregateTest method testLeafWriteWrite.
@Test
public void testLeafWriteWrite() {
NormalizedNode normalizedNode1 = normalizedNode("value1");
NormalizedNode normalizedNode2 = normalizedNode("value2");
NormalizedNode normalizedNode3 = normalizedNode("value3");
DataTreeCandidateNode node1 = dataTreeCandidateNode(normalizedNode1, normalizedNode2, ModificationType.WRITE);
DataTreeCandidate candidate1 = new DefaultDataTreeCandidate(ROOT_PATH, node1);
DataTreeCandidateNode node2 = dataTreeCandidateNode(normalizedNode2, normalizedNode3, ModificationType.WRITE);
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
DataTreeCandidate aggregationResult = DataTreeCandidates.aggregate(List.of(candidate1, candidate2));
assertEquals(ModificationType.WRITE, aggregationResult.getRootNode().getModificationType());
assertEquals("value1", aggregationResult.getRootNode().getDataBefore().get().body());
assertEquals("value3", aggregationResult.getRootNode().getDataAfter().get().body());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidatesAggregateTest method testLeafUnmodifiedDelete.
@Test
public void testLeafUnmodifiedDelete() {
NormalizedNode normalizedNode1 = normalizedNode("value1");
NormalizedNode normalizedNode2 = normalizedNode("value1");
DataTreeCandidateNode node1 = dataTreeCandidateNode(normalizedNode1, normalizedNode2, ModificationType.UNMODIFIED);
DataTreeCandidate candidate1 = new DefaultDataTreeCandidate(ROOT_PATH, node1);
DataTreeCandidateNode node2 = dataTreeCandidateNode(normalizedNode2, null, ModificationType.DELETE);
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
DataTreeCandidate aggregationResult = DataTreeCandidates.aggregate(List.of(candidate1, candidate2));
assertEquals(ModificationType.DELETE, aggregationResult.getRootNode().getModificationType());
assertEquals("value1", aggregationResult.getRootNode().getDataBefore().get().body());
assertEquals(Optional.empty(), aggregationResult.getRootNode().getDataAfter());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode in project yangtools by opendaylight.
the class DataTreeCandidatesAggregateTest method testLeafUnmodifiedUnmodified.
@Test
public void testLeafUnmodifiedUnmodified() {
NormalizedNode normalizedNode1 = normalizedNode("value1");
NormalizedNode normalizedNode2 = normalizedNode("value1");
NormalizedNode normalizedNode3 = normalizedNode("value1");
DataTreeCandidateNode node1 = dataTreeCandidateNode(normalizedNode1, normalizedNode2, ModificationType.UNMODIFIED);
DataTreeCandidate candidate1 = new DefaultDataTreeCandidate(ROOT_PATH, node1);
DataTreeCandidateNode node2 = dataTreeCandidateNode(normalizedNode2, normalizedNode3, ModificationType.UNMODIFIED);
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
DataTreeCandidate aggregationResult = DataTreeCandidates.aggregate(List.of(candidate1, candidate2));
assertEquals(ModificationType.UNMODIFIED, aggregationResult.getRootNode().getModificationType());
assertEquals("value1", aggregationResult.getRootNode().getDataBefore().get().body());
assertEquals("value1", aggregationResult.getRootNode().getDataAfter().get().body());
}
Aggregations