Search in sources :

Example 1 with TransactionCallback

use of org.openkilda.persistence.tx.TransactionCallback in project open-kilda by telstra.

the class NetworkBfdSessionServiceTest method setUp.

@Before
public void setUp() throws Exception {
    RepositoryFactory repositoryFactory = Mockito.mock(RepositoryFactory.class);
    when(repositoryFactory.createSwitchRepository()).thenReturn(switchRepository);
    when(repositoryFactory.createBfdSessionRepository()).thenReturn(bfdSessionRepository);
    when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
    doAnswer(invocation -> {
        TransactionCallbackWithoutResult<?> tr = invocation.getArgument(0);
        tr.doInTransaction();
        return null;
    }).when(transactionManager).doInTransaction(Mockito.any(TransactionCallbackWithoutResult.class));
    doAnswer(invocation -> {
        TransactionCallback<?, ?> tr = invocation.getArgument(0);
        return tr.doInTransaction();
    }).when(transactionManager).doInTransaction(Mockito.any(TransactionCallback.class));
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    switchOnlineStatusMonitor = new SwitchOnlineStatusMonitor();
    endpointStatusMonitor = new EndpointStatusMonitor();
    setupCarrier();
    service = new NetworkBfdSessionService(persistenceManager, switchOnlineStatusMonitor, endpointStatusMonitor, carrier);
}
Also used : TransactionCallback(org.openkilda.persistence.tx.TransactionCallback) SwitchOnlineStatusMonitor(org.openkilda.wfm.topology.network.utils.SwitchOnlineStatusMonitor) EndpointStatusMonitor(org.openkilda.wfm.topology.network.utils.EndpointStatusMonitor) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) TransactionCallbackWithoutResult(org.openkilda.persistence.tx.TransactionCallbackWithoutResult) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)1 TransactionCallback (org.openkilda.persistence.tx.TransactionCallback)1 TransactionCallbackWithoutResult (org.openkilda.persistence.tx.TransactionCallbackWithoutResult)1 EndpointStatusMonitor (org.openkilda.wfm.topology.network.utils.EndpointStatusMonitor)1 SwitchOnlineStatusMonitor (org.openkilda.wfm.topology.network.utils.SwitchOnlineStatusMonitor)1