Search in sources :

Example 41 with DataTreeSnapshot

use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project mdsal by opendaylight.

the class InMemoryDataStoreTest method testReadWithReadWriteTransactionFailure.

@SuppressWarnings("checkstyle:IllegalThrows")
@Test(expected = ReadFailedException.class)
public void testReadWithReadWriteTransactionFailure() throws Throwable {
    DataTreeSnapshot mockSnapshot = Mockito.mock(DataTreeSnapshot.class);
    DataTreeModification mockModification = Mockito.mock(DataTreeModification.class);
    Mockito.doThrow(new RuntimeException("mock ex")).when(mockModification).readNode(Mockito.any(YangInstanceIdentifier.class));
    Mockito.doReturn(mockModification).when(mockSnapshot).newModification();
    @SuppressWarnings("unchecked") TransactionReadyPrototype<String> mockReady = Mockito.mock(TransactionReadyPrototype.class);
    DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadWriteTransaction("1", false, mockSnapshot, mockReady);
    doReadAndThrowEx(readTx);
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DOMStoreReadTransaction(org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Aggregations

DataTreeSnapshot (org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot)41 DataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)36 Test (org.junit.Test)30 DataTreeCandidate (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate)25 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)18 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)11 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)11 ConflictingModificationAppliedException (org.opendaylight.yangtools.yang.data.tree.api.ConflictingModificationAppliedException)9 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)5 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)4 UserMapNode (org.opendaylight.yangtools.yang.data.api.schema.UserMapNode)4 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 DOMStoreReadTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction)2 QName (org.opendaylight.yangtools.yang.common.QName)2 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)2 NodeWithValue (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue)2 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)2 NormalizedNodeContainer (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer)2 SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)2