assertEquals(1, waveViewService.opens.size());
WaveViewService.OpenCallback openCallback = waveViewService.lastOpen().callback;
// Pretend we got the initial snapshot at version 1 signature1.
muxListener.verifyNoMoreInteractions();
openCallback.onUpdate(new FakeWaveViewServiceUpdate().setChannelId(CHANNEL_ID));
FakeWaveViewServiceUpdate update = new FakeWaveViewServiceUpdate()
.setWaveletId(WAVELET_ID_1)
.setWaveletSnapshot(WAVE_ID, USER_NAME, 0L, HashedVersion.of(1L, SIGNATURE1))
.setLastCommittedVersion(HashedVersion.unsigned(0));
openCallback.onUpdate(update);
OperationChannel channel = muxListener.verifyOperationChannelCreated(
update.getWaveletSnapshot(), Accessibility.READ_WRITE);
openCallback.onUpdate(new FakeWaveViewServiceUpdate().setMarker(false));
muxListener.verifyOpenFinished();
// Send Op, get ack.
channel.send(createAddParticipantOp());
assertEquals(1, waveViewService.submits.size());
WaveViewService.SubmitCallback submitCallback1 = waveViewService.lastSubmit().callback;
HashedVersion v2 = HashedVersion.of(2, SIGNATURE2);
submitCallback1.onSuccess(v2, 1, null, ResponseCode.OK);
assertUnsavedDataInfo(0, 1, 0, 2, 0);
// Send another Op, get ack.
channel.send(createAddParticipantOp());
assertEquals(2, waveViewService.submits.size());
WaveViewService.SubmitCallback submitCallback2 = waveViewService.lastSubmit().callback;
HashedVersion v3 = HashedVersion.of(3, SIGNATURE3);
submitCallback2.onSuccess(v3, 1, null, ResponseCode.OK);
assertUnsavedDataInfo(0, 2, 0, 3, 0);
// Server sends commit for the first addParticipant op.
openCallback.onUpdate(
new FakeWaveViewServiceUpdate().setWaveletId(WAVELET_ID_1).setLastCommittedVersion(v2));
// Now we expect to be told that NOT everything is committed.
assertUnsavedDataInfo(0, 1, 0, 3, 2);
// Server sends commit for the second addParticipant op.
openCallback.onUpdate(
new FakeWaveViewServiceUpdate().setWaveletId(WAVELET_ID_1).setLastCommittedVersion(v3));
// Now we expect to be told that everything is committed.
assertUnsavedDataInfo(0, 0, 0, 3, 3);
mux.close();
assertEquals(1, waveViewService.closes.size());