remote.requestHistory(REMOTE_WAVELET, REMOTE_DOMAIN, START_VERSION, VERSION_ONE, -1, listener);
verifyZeroInteractions(listener);
assertEquals(1, transport.packetsSent);
// Validate the outgoing request.
IQ outgoingRequest = (IQ) transport.packets.poll();
assertEquals(EXPECTED_HISTORY_REQUEST, outgoingRequest.toString());
// Send the outgoing request back to the manager, so it hooks up to the
// Federation Host.
manager.receivePacket(outgoingRequest);
ArgumentCaptor<HistoryResponseListener> remoteListener =
ArgumentCaptor.forClass(HistoryResponseListener.class);
// TODO(thorogood): Note that the caller's JID is not the domain we expect
// here - it is not actually the domain of the requester!
verify(mockProvider).requestHistory(eq(REMOTE_WAVELET), eq(LOCAL_JID), eq(START_VERSION),
eq(VERSION_ONE), anyInt(), remoteListener.capture());
remoteListener.getValue().onSuccess(ImmutableList.of(DELTA_BYTESTRING), VERSION_ONE, 0);
// Confirm that the packet has been sent back out over the transport.
assertEquals(2, transport.packetsSent);
IQ historyResponse = (IQ) transport.packets.poll();
manager.receivePacket(historyResponse);
// Confirm that the success is finally delivered to the listener.
ArgumentCaptor<ProtocolHashedVersion> commitVersion =
ArgumentCaptor.forClass(ProtocolHashedVersion.class);