Search in sources :

Example 16 with DataTreeSnapshot

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

the class ShardRecoveryCoordinatorTest method createCar.

private DataTreeCandidate createCar() {
    final DataTree dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, carsSchemaContext);
    final DataTreeSnapshot snapshot = dataTree.takeSnapshot();
    final DataTreeModification modification = snapshot.newModification();
    modification.merge(CarsModel.BASE_PATH, CarsModel.create());
    modification.ready();
    return dataTree.prepare(modification);
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification) DataTree(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot) MetadataShardDataTreeSnapshot(org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory)

Example 17 with DataTreeSnapshot

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

the class TransactionProxyTest method createDataTree.

private static DataTree createDataTree() {
    DataTree dataTree = mock(DataTree.class);
    DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class);
    DataTreeModification dataTreeModification = mock(DataTreeModification.class);
    doReturn(dataTreeSnapshot).when(dataTree).takeSnapshot();
    doReturn(dataTreeModification).when(dataTreeSnapshot).newModification();
    return dataTree;
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification) DataTree(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot)

Example 18 with DataTreeSnapshot

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

the class InMemoryDataStoreTest method testReadWithReadWriteTransactionFailure.

@Test(expected = ReadFailedException.class)
public void testReadWithReadWriteTransactionFailure() throws Exception {
    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.api.schema.tree.DataTreeModification) DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Aggregations

DataTreeSnapshot (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot)18 Test (org.junit.Test)8 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)7 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)7 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)6 DataTree (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree)5 BigInteger (java.math.BigInteger)4 InOrder (org.mockito.InOrder)4 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)4 UnsignedLong (com.google.common.primitives.UnsignedLong)3 CommitTransactionPayload (org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload)3 TestProbe (akka.testkit.TestProbe)2 MetadataShardDataTreeSnapshot (org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot)2 DOMStoreReadTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction)2 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification)2 DataTreeCandidate (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)2 InMemoryDataTreeFactory (org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory)2 ClientActorContext (org.opendaylight.controller.cluster.access.client.ClientActorContext)1 ConnectClientRequest (org.opendaylight.controller.cluster.access.commands.ConnectClientRequest)1 ConnectClientSuccess (org.opendaylight.controller.cluster.access.commands.ConnectClientSuccess)1