presenter.setStatesForTest(projectStats, selectedDocumentStats, null,
null);
DocumentId docId = new DocumentId(1L, "");
// newly selected document has new stats
ContainerTranslationStatistics newSelectedStats =
new ContainerTranslationStatistics();
newSelectedStats.addStats(new TranslationStatistics(new TransUnitCount(
1, 2, 3), LocaleId.EN_US.toString()));
newSelectedStats.addStats(new TranslationStatistics(new TransUnitWords(
4, 5, 6), LocaleId.EN_US.toString()));
DocumentInfo documentInfo =
new DocumentInfo(docId, "a.po", "pot/", new LocaleId("en-US"),
newSelectedStats, new AuditInfo(new Date(),
"Translator"), new HashMap<String, String>(),
new AuditInfo(new Date(), "last translator"));
when(documentListPresenter.getDocumentInfo(docId)).thenReturn(
documentInfo);
// current view is editor
presenter.showView(MainView.Editor);
verify(display).setStats(statsCaptor.capture(), eq(true));
assertThat(statsCaptor.getValue(),
Matchers.sameInstance(selectedDocumentStats));
// When:
presenter.selectDocument(docId);
// Then:
display.setDocumentLabel("pot/", "a.po");
verify(display, atLeastOnce()).setStats(selectedDocumentStats, true);
assertThat(selectedDocumentStats.getStats(),
Matchers.equalTo(newSelectedStats.getStats()));
assertThat(presenter.getSelectedDocIdOrNull(), Matchers.is(docId));
}