TransactionStarter implements AutoCloseable { List<StartIdentifiedAtlasDbTransactionResponse> startIdentifiedAtlasDbTransactionBatch(int count) { Preconditions.checkArgument(count > 0, "Cannot start 0 or fewer transactions"); return AtlasFutures.getUnchecked(autobatcher.apply(count)); } private  TransactionStarter(
            DisruptorAutobatcher<Integer, List<StartIdentifiedAtlasDbTransactionResponse>> autobatcher,
            LockLeaseService lockLeaseService); @Override void close();  }
@Test public void shouldDeriveStartTransactionResponseFromBatchedResponse_singleTransaction() { ConjureStartTransactionsResponse startTransactionResponse = getStartTransactionResponse(12, 1); when(lockLeaseService.startTransactionsWithWatches(version, 1)).thenReturn(startTransactionResponse); StartIdentifiedAtlasDbTransactionResponse response = Iterables.getOnlyElement(transactionStarter.startIdentifiedAtlasDbTransactionBatch(1)); assertDerivableFromBatchedResponse(response, startTransactionResponse); }
@Test public void shouldDeriveStartTransactionResponseBatchFromBatchedResponse_multipleTransactions() { ConjureStartTransactionsResponse batchResponse = getStartTransactionResponse(12, 5); when(lockLeaseService.startTransactionsWithWatches(version, 5)).thenReturn(batchResponse); List<StartIdentifiedAtlasDbTransactionResponse> responses = transactionStarter.startIdentifiedAtlasDbTransactionBatch(5); assertThat(responses) .satisfies(TransactionStarterTest::assertThatStartTransactionResponsesAreUnique) .hasSize(5) .allSatisfy(startTxnResponse -> assertDerivableFromBatchedResponse(startTxnResponse, batchResponse)); }
@Test public void shouldThrowWhenTryingToStartIllegalNumberOfTransactions() { assertThatThrownBy(() -> transactionStarter.startIdentifiedAtlasDbTransactionBatch(0)) .isInstanceOf(SafeIllegalArgumentException.class) .hasMessage("Cannot start 0 or fewer transactions"); }