Search in sources :

Example 16 with DataTreeCandidateNode

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"));
}
Also used : DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) DataTreeModificationCursor(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor) Test(org.junit.Test)

Example 17 with DataTreeCandidateNode

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"));
}
Also used : DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) DataTreeModificationCursor(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor) Test(org.junit.Test)

Example 18 with DataTreeCandidateNode

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"));
}
Also used : DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) DataTreeModificationCursor(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor) Test(org.junit.Test)

Example 19 with DataTreeCandidateNode

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());
}
Also used : DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) DataTreeModificationCursor(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 20 with DataTreeCandidateNode

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());
}
Also used : DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) DataTreeModificationCursor(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Aggregations

DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode)63 Test (org.junit.Test)48 DataTreeCandidate (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate)36 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)23 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)15 DataTreeModificationCursor (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModificationCursor)13 DataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)9 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)7 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.CursorAwareDataTreeModification)7 CountDownLatch (java.util.concurrent.CountDownLatch)6 DOMDataTreeChangeService (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService)6 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)6 ArrayList (java.util.ArrayList)5 NonNull (org.eclipse.jdt.annotation.NonNull)3 ModificationType (org.opendaylight.yangtools.yang.data.tree.api.ModificationType)3 Objects.requireNonNull (java.util.Objects.requireNonNull)2 List (java.util.List)1 BindingCodecTreeNode (org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode)1 BindingDataObjectCodecTreeNode (org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode)1 DOMDataTreeChangeListener (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener)1