Search in sources :

Example 6 with ConcurrentDOMDataBroker

use of org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker in project controller by opendaylight.

the class LegacyDOMDataBrokerAdapterTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    ConcurrentDOMDataBroker backendBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL, mockOperStore, org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, mockConfigStore), MoreExecutors.newDirectExecutorService());
    adapter = new LegacyDOMDataBrokerAdapter(backendBroker);
    doReturn(Futures.immediateFuture(Boolean.TRUE)).when(mockCommitCohort).canCommit();
    doReturn(Futures.immediateFuture(null)).when(mockCommitCohort).preCommit();
    doReturn(Futures.immediateFuture(null)).when(mockCommitCohort).commit();
    doReturn(Futures.immediateFuture(null)).when(mockCommitCohort).abort();
    dataNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
    doReturn(mockWriteTx).when(mockConfigStore).newWriteOnlyTransaction();
    doNothing().when(mockWriteTx).write(TestModel.TEST_PATH, dataNode);
    doNothing().when(mockWriteTx).merge(TestModel.TEST_PATH, dataNode);
    doNothing().when(mockWriteTx).delete(TestModel.TEST_PATH);
    doNothing().when(mockWriteTx).close();
    doReturn(mockCommitCohort).when(mockWriteTx).ready();
    doReturn(mockReadTx).when(mockConfigStore).newReadOnlyTransaction();
    doReturn(Futures.immediateCheckedFuture(Optional.of(dataNode))).when(mockReadTx).read(TestModel.TEST_PATH);
    doReturn(Futures.immediateCheckedFuture(Boolean.TRUE)).when(mockReadTx).exists(TestModel.TEST_PATH);
    doReturn(mockReadWriteTx).when(mockConfigStore).newReadWriteTransaction();
    doNothing().when(mockReadWriteTx).write(TestModel.TEST_PATH, dataNode);
    doReturn(mockCommitCohort).when(mockReadWriteTx).ready();
    doReturn(Futures.immediateCheckedFuture(Optional.of(dataNode))).when(mockReadWriteTx).read(TestModel.TEST_PATH);
    DOMStoreTransactionChain mockTxChain = mock(DOMStoreTransactionChain.class);
    doReturn(mockReadTx).when(mockTxChain).newReadOnlyTransaction();
    doReturn(mockWriteTx).when(mockTxChain).newWriteOnlyTransaction();
    doReturn(mockReadWriteTx).when(mockTxChain).newReadWriteTransaction();
    doReturn(mockTxChain).when(mockConfigStore).createTransactionChain();
    doReturn(mock(DOMStoreTransactionChain.class)).when(mockOperStore).createTransactionChain();
}
Also used : ConcurrentDOMDataBroker(org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker) DOMStoreTransactionChain(org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain) Before(org.junit.Before)

Aggregations

ConcurrentDOMDataBroker (org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker)6 Test (org.junit.Test)5 TransactionChainListener (org.opendaylight.mdsal.common.api.TransactionChainListener)5 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)5 DOMTransactionChain (org.opendaylight.mdsal.dom.api.DOMTransactionChain)5 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)4 DOMDataTreeReadWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction)2 CheckedFuture (com.google.common.util.concurrent.CheckedFuture)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 DOMStoreTransactionChain (org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1