@Test
  public void testOnDocumentListBoxChanged() throws Exception {
    Date lastModifiedDate = new Date();
    // Given: two details
    TransMemoryDetails details1 =
        new TransMemoryDetails(
            "source comment1",
            "target comment1",
            "project",
            "1",
            "docId1",
            "resId",
            "msgContext",
            ContentState.Approved,
            "admin",
            lastModifiedDate);
    TransMemoryDetails details2 =
        new TransMemoryDetails(
            "source comment2",
            "target comment2",
            "project",
            "2",
            "docId2",
            "resId",
            "msgContext",
            ContentState.Approved,
            null,
            lastModifiedDate);
    presenter.setStatForTesting(new TransMemoryDetailsList(Lists.newArrayList(details1, details2)));

    // When: selecting second one
    when(display.getSelectedDocumentIndex()).thenReturn(1);
    presenter.onDocumentListBoxChanged();

    // Then:
    verify(display).setSourceComment("source comment2");
    verify(display).setTargetComment("target comment2");
    verify(display).setProjectName("project");
    verify(display).setVersionName("2");
    verify(display).setDocumentName("docId2");
    verify(display).setLastModified(null, lastModifiedDate);
  }
  @Test
  public void testShow() throws Exception {
    TransMemoryResultItem transMemoryResultItem = Mockito.mock(TransMemoryResultItem.class);
    ArrayList<Long> sourceIds = Lists.newArrayList(1L, 2L);
    when(transMemoryResultItem.getSourceIdList()).thenReturn(sourceIds);
    when(transMemoryResultItem.getSourceContents()).thenReturn(Lists.newArrayList("a", "b"));
    when(transMemoryResultItem.getTargetContents()).thenReturn(Lists.newArrayList("c", "d"));

    presenter.show(transMemoryResultItem);

    verify(dispatcher).execute(actionCaptor.capture(), resultCaptor.capture());
    assertThat(actionCaptor.getValue().getTransUnitIdList(), Matchers.equalTo(sourceIds));
    AbstractAsyncCallback<TransMemoryDetailsList> callback = resultCaptor.getValue();

    Date lastModifiedDate = new Date();
    // testing on callback success
    TransMemoryDetails details =
        new TransMemoryDetails(
            "source comment",
            "target comment",
            "project",
            "iteration",
            "docId",
            "resId",
            "msgContext",
            ContentState.Approved,
            "admin",
            lastModifiedDate);
    callback.onSuccess(new TransMemoryDetailsList(Lists.newArrayList(details)));

    InOrder inOrder = Mockito.inOrder(display);
    inOrder.verify(display).clearSourceAndTarget();
    inOrder.verify(display).setSource(transMemoryResultItem.getSourceContents());
    inOrder.verify(display).setTarget(transMemoryResultItem.getTargetContents());
    inOrder.verify(display).clearDocs();
    inOrder.verify(display).addDoc("project/iteration/docId");

    verify(display).setSourceComment("source comment");
    verify(display).setTargetComment("target comment");
    verify(display).setProjectName("project");
    verify(display).setVersionName("iteration");
    verify(display).setDocumentName("docId");
    verify(display).setLastModified("admin", lastModifiedDate);

    inOrder.verify(display).center();
  }
  @Test
  public void testDismissTransMemoryDetails() throws Exception {
    presenter.dismissTransMemoryDetails();

    verify(display).hide();
  }