Skip to content

Commit

Permalink
delete test case testCanAcknowledgeAndCommitForTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
poorbarcode committed Sep 27, 2022
1 parent 9ad5808 commit cca82b7
Showing 1 changed file with 0 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,53 +223,6 @@ public void teardown() throws Exception {
store.close();
}

@Test
public void testCanAcknowledgeAndCommitForTransaction() throws ExecutionException, InterruptedException {
doAnswer((invocationOnMock) -> {
((AsyncCallbacks.DeleteCallback) invocationOnMock.getArguments()[1])
.deleteComplete(invocationOnMock.getArguments()[2]);
return null;
}).when(cursorMock).asyncDelete(any(List.class), any(AsyncCallbacks.DeleteCallback.class), any());

List<MutablePair<PositionImpl, Integer>> positionsPair = new ArrayList<>();
positionsPair.add(new MutablePair<>(new PositionImpl(1, 1), 0));
positionsPair.add(new MutablePair<>(new PositionImpl(1, 3), 0));
positionsPair.add(new MutablePair<>(new PositionImpl(1, 5), 0));

doAnswer((invocationOnMock) -> {
assertTrue(Arrays.deepEquals(((List)invocationOnMock.getArguments()[0]).toArray(),
positionsPair.toArray()));
((AsyncCallbacks.MarkDeleteCallback) invocationOnMock.getArguments()[2])
.markDeleteComplete(invocationOnMock.getArguments()[3]);
return null;
}).when(cursorMock).asyncMarkDelete(any(), any(), any(AsyncCallbacks.MarkDeleteCallback.class), any());

List<CompletableFuture<?>> runningTask = new ArrayList<>();

// Single ack for txn
runningTask.add(persistentSubscription.transactionIndividualAcknowledge(txnID1, positionsPair));

// Commit txn
persistentSubscription.endTxn(txnID1.getMostSigBits(), txnID1.getLeastSigBits(), TxnAction.COMMIT_VALUE, -1).get();

List<PositionImpl> positions = new ArrayList<>();
positions.add(new PositionImpl(3, 100));

// Cumulative ack for txn
runningTask.add(persistentSubscription.transactionCumulativeAcknowledge(txnID1, positions));

FutureUtil.waitForAll(runningTask).get();
doAnswer((invocationOnMock) -> {
assertEquals(((PositionImpl) invocationOnMock.getArguments()[0]).compareTo(new PositionImpl(3, 100)), 0);
((AsyncCallbacks.MarkDeleteCallback) invocationOnMock.getArguments()[2])
.markDeleteComplete(invocationOnMock.getArguments()[3]);
return null;
}).when(cursorMock).asyncMarkDelete(any(), any(), any(AsyncCallbacks.MarkDeleteCallback.class), any());

// Commit txn
persistentSubscription.endTxn(txnID1.getMostSigBits(), txnID1.getLeastSigBits(), TxnAction.COMMIT_VALUE, -1).get();
}

@Test
public void testCanAcknowledgeAndAbortForTransaction() throws Exception {
List<MutablePair<PositionImpl, Integer>> positionsPair = new ArrayList<>();
Expand Down

0 comments on commit cca82b7

Please sign in to comment.