@Test public void loadShouldPutRollbackIfCommitTsIsNull() throws Exception { AtomicLong answerCount = new AtomicLong(); doAnswer((invocation) -> answerCount.get() > 0 ? ROLLBACK_TIMESTAMP : NO_TIMESTAMP) .when(mockTransactionService).get(VALID_START_TIMESTAMP); doAnswer((invocation) -> { answerCount.set(1); return null; }).when(mockTransactionService).putUnlessExists(VALID_START_TIMESTAMP, ROLLBACK_TIMESTAMP); assertThat(loader.load(VALID_START_TIMESTAMP)).isEqualTo(ROLLBACK_TIMESTAMP); verify(mockTransactionService).putUnlessExists(VALID_START_TIMESTAMP, ROLLBACK_TIMESTAMP); }
public long load(long startTs) { return cache.get(startTs); }
CommitTsCache { public long load(long startTs) { return cache.get(startTs); } }
CommitTsCache { public long load(long startTs) { return cache.get(startTs); } private  CommitTsCache(TransactionService transactionService, long maxSize); }
CommitTsCache { public long load(long startTs) { return cache.get(startTs); } private  CommitTsCache(TransactionService transactionService, long maxSize); static CommitTsCache create(TransactionService transactionService); Optional<Long> loadIfCached(long startTs); long load(long startTs); Map<Long, Long> loadBatch(Collection<Long> timestamps); }
CommitTsCache { public long load(long startTs) { return cache.get(startTs); } private  CommitTsCache(TransactionService transactionService, long maxSize); static CommitTsCache create(TransactionService transactionService); Optional<Long> loadIfCached(long startTs); long load(long startTs); Map<Long, Long> loadBatch(Collection<Long> timestamps);  }