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();
}
Aggregations