Search in sources :

Example 1 with LockAwareTransactionManager

use of com.palantir.atlasdb.transaction.api.LockAwareTransactionManager in project atlasdb by palantir.

the class SweeperTestSetup method mockTxManager.

public static LockAwareTransactionManager mockTxManager() {
    LockAwareTransactionManager txManager = mock(LockAwareTransactionManager.class);
    Answer runTaskAnswer = inv -> {
        Object[] args = inv.getArguments();
        TransactionTask<?, ?> task = (TransactionTask<?, ?>) args[0];
        return task.execute(mock(Transaction.class));
    };
    doAnswer(runTaskAnswer).when(txManager).runTaskReadOnly(any());
    doAnswer(runTaskAnswer).when(txManager).runTaskWithRetry(any());
    return txManager;
}
Also used : LockAwareTransactionManager(com.palantir.atlasdb.transaction.api.LockAwareTransactionManager) SweepProgress(com.palantir.atlasdb.sweep.progress.SweepProgress) BeforeClass(org.junit.BeforeClass) SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults) SweepProgressStore(com.palantir.atlasdb.sweep.progress.SweepProgressStore) Matchers.any(org.mockito.Matchers.any) NextTableToSweepProvider(com.palantir.atlasdb.sweep.priority.NextTableToSweepProvider) Answer(org.mockito.stubbing.Answer) Transaction(com.palantir.atlasdb.transaction.api.Transaction) LockService(com.palantir.lock.LockService) Matchers.eq(org.mockito.Matchers.eq) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Matchers.anyLong(org.mockito.Matchers.anyLong) Optional(java.util.Optional) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Mockito.doReturn(org.mockito.Mockito.doReturn) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) SweepMetricsManager(com.palantir.atlasdb.sweep.metrics.SweepMetricsManager) SweepPriorityStore(com.palantir.atlasdb.sweep.priority.SweepPriorityStore) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) LockAwareTransactionManager(com.palantir.atlasdb.transaction.api.LockAwareTransactionManager) TransactionTask(com.palantir.atlasdb.transaction.api.TransactionTask)

Aggregations

KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)1 SweepResults (com.palantir.atlasdb.keyvalue.api.SweepResults)1 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)1 SweepMetricsManager (com.palantir.atlasdb.sweep.metrics.SweepMetricsManager)1 NextTableToSweepProvider (com.palantir.atlasdb.sweep.priority.NextTableToSweepProvider)1 SweepPriorityStore (com.palantir.atlasdb.sweep.priority.SweepPriorityStore)1 SweepProgress (com.palantir.atlasdb.sweep.progress.SweepProgress)1 SweepProgressStore (com.palantir.atlasdb.sweep.progress.SweepProgressStore)1 LockAwareTransactionManager (com.palantir.atlasdb.transaction.api.LockAwareTransactionManager)1 Transaction (com.palantir.atlasdb.transaction.api.Transaction)1 TransactionTask (com.palantir.atlasdb.transaction.api.TransactionTask)1 LockService (com.palantir.lock.LockService)1 Optional (java.util.Optional)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Matchers.any (org.mockito.Matchers.any)1 Matchers.anyLong (org.mockito.Matchers.anyLong)1 Matchers.eq (org.mockito.Matchers.eq)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 Mockito.doReturn (org.mockito.Mockito.doReturn)1