documentListPresenter.onTransUnitUpdated(mockEvent);
verify(mockEventBus, times(2)).fireEvent(
capturedEventBusEvent.capture());
DocumentStatsUpdatedEvent docStatsEvent = null;
for (GwtEvent event : capturedEventBusEvent.getAllValues()) {
if (event.getAssociatedType().equals(
DocumentStatsUpdatedEvent.getType())) {
docStatsEvent = (DocumentStatsUpdatedEvent) event;
}
}
assertThat(
"a document stats event should be fired when a TU update event occurs, not found",
docStatsEvent, notNullValue());
// document stats
assertThat(
"document id in document stats event shoudl match updated TU document id",
docStatsEvent.getDocId(), equalTo(new DocumentId(2222L, "")));
// check actual counts (approved/fuzzy/untranslated)
// default TUs: 1/2/3
// approving 1 fuzzy, expect 2/1/3
assertThat(
"document Approved TU count should increase by 1 when a TU is updated from NeedsReview to Approved",
docStatsEvent.getNewStats()
.getStats(LocaleId.ES.toString(), StatUnit.MESSAGE)
.getApproved(), is(new Long(2)));
assertThat(
"document NeedsReview TU count should decrease by 1 when a TU is updated from NeedsReview to Approved",
docStatsEvent.getNewStats()
.getStats(LocaleId.ES.toString(), StatUnit.MESSAGE)
.getDraft(), is(new Long(1)));
assertThat(
"document Untranslated TU count should remain the same when a TU is updated from NeedsReview to Approved",
docStatsEvent.getNewStats()
.getStats(LocaleId.ES.toString(), StatUnit.MESSAGE)
.getUntranslated(), is(new Long(3)));
// default words: 4/5/6
// approving 3 fuzzy so expect 7/2/6
assertThat(
"document Approved words should increase when TU changes to Approved",
docStatsEvent.getNewStats()
.getStats(LocaleId.ES.toString(), StatUnit.WORD)
.getApproved(), is(new Long(7)));
assertThat(
"document NeedsReview words should decrease when a TU changes from NeedsReview",
docStatsEvent.getNewStats()
.getStats(LocaleId.ES.toString(), StatUnit.WORD)
.getDraft(), is(new Long(2)));
assertThat(
"document Untranslated words should not change when TU changes between NeedsReview and Approved",
docStatsEvent.getNewStats()
.getStats(LocaleId.ES.toString(), StatUnit.WORD)
.getDraft(), is(new Long(2)));
}