}
@Test
public void onRPCSuccessAndThereIsPendingSave() {
// Given:
TransUnit old =
TestFixture.makeTransUnit(TRANS_UNIT_ID.getId(),
ContentState.NeedReview, "old content");
when(navigationService.getByIdOrNull(TRANS_UNIT_ID)).thenReturn(old);
// When: save twice and one will be pending
service.onTransUnitSave(event("new content", ContentState.NeedReview,
TRANS_UNIT_ID, VER_NUM, "old content"));
service.onTransUnitSave(event("newer content", ContentState.NeedReview,
TRANS_UNIT_ID, VER_NUM, "new content"));
// Then: dispatcher will be call twice
verify(dispatcher).execute(actionCaptor.capture(),
resultCaptor.capture());
// on save success
// Given: result comes back with saving successful
int rowIndex = 1;
when(messages.notifyUpdateSaved(rowIndex, TRANS_UNIT_ID.toString()))
.thenReturn("saved row 1, id 1");
when(navigationService.findRowIndexById(TRANS_UNIT_ID)).thenReturn(
rowIndex);
when(undoProvider.get()).thenReturn(undoLink);
AsyncCallback<UpdateTransUnitResult> callback = resultCaptor.getValue();
TransUnit updatedTU =
TestFixture.makeTransUnit(TRANS_UNIT_ID.getId(),
ContentState.NeedReview, "new content");
UpdateTransUnitResult result =
result(true, updatedTU, ContentState.NeedReview, null);