use of org.openkilda.persistence.tx.TransactionCallbackWithoutResult in project open-kilda by telstra.
the class NetworkIslServiceTest method setUp.
@Before
public void setUp() {
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
when(repositoryFactory.createSwitchRepository()).thenReturn(switchRepository);
when(repositoryFactory.createIslRepository()).thenReturn(islRepository);
when(repositoryFactory.createLinkPropsRepository()).thenReturn(linkPropsRepository);
when(repositoryFactory.createFlowPathRepository()).thenReturn(flowPathRepository);
when(repositoryFactory.createFeatureTogglesRepository()).thenReturn(featureTogglesRepository);
when(repositoryFactory.createSwitchPropertiesRepository()).thenReturn(switchPropertiesRepository);
KildaFeatureToggles featureToggles = new KildaFeatureToggles(KildaFeatureToggles.DEFAULTS);
featureToggles.setFlowsRerouteOnIslDiscoveryEnabled(true);
when(featureTogglesRepository.getOrDefault()).thenReturn(featureToggles);
when(transactionManager.getDefaultRetryPolicy()).thenReturn(new RetryPolicy<>().withMaxRetries(2));
doAnswer(invocation -> {
TransactionCallbackWithoutResult<?> tr = invocation.getArgument(0);
tr.doInTransaction();
return null;
}).when(transactionManager).doInTransaction(Mockito.any(TransactionCallbackWithoutResult.class));
doAnswer(invocation -> {
RetryPolicy<?> retryPolicy = invocation.getArgument(0);
TransactionCallbackWithoutResult<?> tr = invocation.getArgument(1);
Failsafe.with(retryPolicy).run(tr::doInTransaction);
return null;
}).when(transactionManager).doInTransaction(Mockito.any(RetryPolicy.class), Mockito.any(TransactionCallbackWithoutResult.class));
NetworkTopologyDashboardLogger.Builder dashboardLoggerBuilder = mock(NetworkTopologyDashboardLogger.Builder.class);
when(dashboardLoggerBuilder.build(any())).thenReturn(dashboardLogger);
service = new NetworkIslService(carrier, persistenceManager, options, dashboardLoggerBuilder, clock);
}
use of org.openkilda.persistence.tx.TransactionCallbackWithoutResult 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);
}
use of org.openkilda.persistence.tx.TransactionCallbackWithoutResult in project open-kilda by telstra.
the class NetworkPortServiceTest method resetMocks.
private void resetMocks() {
reset(carrier);
reset(dashboardLogger);
reset(persistenceManager);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
doAnswer(invocation -> {
TransactionCallbackWithoutResult tr = invocation.getArgument(0);
tr.doInTransaction();
return null;
}).when(transactionManager).doInTransaction(any(TransactionCallbackWithoutResult.class));
reset(portPropertiesRepository);
doAnswer(invocation -> invocation.getArgument(0)).when(portPropertiesRepository).add(any());
reset(switchRepository);
reset(repositoryFactory);
when(repositoryFactory.createPortPropertiesRepository()).thenReturn(portPropertiesRepository);
when(repositoryFactory.createSwitchRepository()).thenReturn(switchRepository);
}
Aggregations