@Test
public void testReplayMessages() {

    final TestProbe probe = new TestProbe(system);
    final List<ConnectionEntry> entries = new ArrayList<>();
    final Consumer<Response<?, ?>> callback = createCallbackMock();
    final ReadTransactionRequest request1 =
            new ReadTransactionRequest(TRANSACTION_ID, 2L, probe.ref(), PATH_2, true);
    final ExistsTransactionRequest request2 =
            new ExistsTransactionRequest(TRANSACTION_ID, 3L, probe.ref(), PATH_3, true);
    entries.add(AccessClientUtil.createConnectionEntry(request1, callback, 0L));
    entries.add(AccessClientUtil.createConnectionEntry(request2, callback, 0L));
    final TransactionTester<RemoteProxyTransaction> successor = createRemoteProxyTransactionTester();
    final AbortLocalTransactionRequest successful1 = new AbortLocalTransactionRequest(TRANSACTION_ID, probe.ref());
    transaction.recordSuccessfulRequest(successful1);
    final ReadTransactionRequest successful2 =
            new ReadTransactionRequest(TRANSACTION_ID, 1L, probe.ref(), PATH_1, true);
    transaction.recordSuccessfulRequest(successful2);
    transaction.startReconnect();
    final ProxyHistory mockSuccessor = mock(ProxyHistory.class);
    when(mockSuccessor.createTransactionProxy(TRANSACTION_ID, transaction.isSnapshotOnly(), false))
        .thenReturn(successor.getTransaction());
    transaction.replayMessages(mockSuccessor, entries);
    final ModifyTransactionRequest transformed = successor.expectTransactionRequest(ModifyTransactionRequest.class);
    assertNotNull(transformed);
    assertEquals(successful1.getSequence(), transformed.getSequence());
    assertTrue(transformed.getPersistenceProtocol().isPresent());
    assertEquals(PersistenceProtocol.ABORT, transformed.getPersistenceProtocol().get());
    ReadTransactionRequest tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
    assertNotNull(tmpRead);
    assertEquals(successful2.getTarget(), tmpRead.getTarget());
    assertEquals(successful2.getSequence(), tmpRead.getSequence());
    assertEquals(successful2.getPath(), tmpRead.getPath());
    assertEquals(successor.localActor(), tmpRead.getReplyTo());
    tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
    assertNotNull(tmpRead);
    assertEquals(request1.getTarget(), tmpRead.getTarget());
    assertEquals(request1.getSequence(), tmpRead.getSequence());
    assertEquals(request1.getPath(), tmpRead.getPath());
    assertEquals(successor.localActor(), tmpRead.getReplyTo());
    final ExistsTransactionRequest tmpExist = successor.expectTransactionRequest(ExistsTransactionRequest.class);
    assertNotNull(tmpExist);
    assertEquals(request2.getTarget(), tmpExist.getTarget());
    assertEquals(request2.getSequence(), tmpExist.getSequence());
    assertEquals(request2.getPath(), tmpExist.getPath());
    assertEquals(successor.localActor(), tmpExist.getReplyTo());
}