LocalProxyTransaction extends AbstractProxyTransaction { @Override void handleReplayedRemoteRequest(final TransactionRequest<?> request, final Consumer<Response<?, ?>> callback, final long enqueuedTicks) { if (request instanceof ModifyTransactionRequest) { replayModifyTransactionRequest((ModifyTransactionRequest) request, callback, enqueuedTicks); } else if (handleReadRequest(request, callback)) { } else if (request instanceof TransactionPurgeRequest) { enqueuePurge(callback, enqueuedTicks); } else if (request instanceof IncrementTransactionSequenceRequest) { LOG.debug("Not replaying {}", request); } else { throw new IllegalArgumentException("Unhandled request " + request); } } LocalProxyTransaction(final ProxyHistory parent, final TransactionIdentifier identifier, final boolean isDone); @Override final TransactionIdentifier getIdentifier();  }
@Test public void testHandleForwardedRemoteReadRequest() { final TestProbe probe = createProbe(); final ReadTransactionRequest request = new ReadTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, true); final Consumer<Response<?, ?>> callback = createCallbackMock(); setupExecuteInActor(); transaction.handleReplayedRemoteRequest(request, callback, Ticker.systemTicker().read()); final ArgumentCaptor<Response<?, ?>> captor = ArgumentCaptor.forClass(Response.class); verify(callback).accept(captor.capture()); final Response<?, ?> value = captor.getValue(); Assert.assertTrue(value instanceof ReadTransactionSuccess); final ReadTransactionSuccess success = (ReadTransactionSuccess) value; Assert.assertTrue(success.getData().isPresent()); Assert.assertEquals(DATA_1, success.getData().get()); }
@Test public void testHandleForwardedRemoteExistsRequest() { final TestProbe probe = createProbe(); final ExistsTransactionRequest request = new ExistsTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, true); final Consumer<Response<?, ?>> callback = createCallbackMock(); setupExecuteInActor(); transaction.handleReplayedRemoteRequest(request, callback, Ticker.systemTicker().read()); final ArgumentCaptor<Response<?, ?>> captor = ArgumentCaptor.forClass(Response.class); verify(callback).accept(captor.capture()); final Response<?, ?> value = captor.getValue(); Assert.assertTrue(value instanceof ExistsTransactionSuccess); final ExistsTransactionSuccess success = (ExistsTransactionSuccess) value; Assert.assertTrue(success.getExists()); }