@Test
  public void retrieveSomeChat_ShouldSaveIndexAfterClose() {
    FolderIndexMock folderIndex = new FolderIndexMock();
    IndexedSkypeMailFolder indexedGmailFolder_SUBJECT = createIndexedSkypeMailFolder(folderIndex);

    SkypeChat nonIndexedSkypeChat =
        SkypeApiMock.produceChatMock("#is-not-indexed", "not", "indexed");
    indexedGmailFolder_SUBJECT.retrieveMessageEntryFor(nonIndexedSkypeChat);

    Assert.assertEquals(false, folderIndex.wasSaved());
    indexedGmailFolder_SUBJECT.close();
    Assert.assertEquals(true, folderIndex.wasSaved());
  }
  @Test
  public void retrieveNonIndexedChat_ShouldAddNewIndexEntryAfterRetrievalAttempt() {
    FolderIndexMock folderIndex = new FolderIndexMock();
    IndexedSkypeMailFolder indexedGmailFolder_SUBJECT = createIndexedSkypeMailFolder(folderIndex);

    SkypeChat nonIndexedSkypeChat =
        SkypeApiMock.produceChatMock("#is-not-indexed", "not", "indexed");

    Assert.assertNull(folderIndex.getSignatureFor("#is-not-indexed"));

    indexedGmailFolder_SUBJECT.retrieveMessageEntryFor(nonIndexedSkypeChat);

    String sig = folderIndex.getSignatureFor("#is-not-indexed");
    Assert.assertEquals(nonIndexedSkypeChat.getBodySignature(), sig);
  }
  private IndexedSkypeMailFolder createIndexedSkypeMailFolder(FolderIndexMock folderIndex) {
    final FolderMock nonIndexedFolder = new FolderMock();
    folderIndex.addSignatureForId("#42$foo", "previous-signature");

    NonIndexGmailFolderProvider nonIndexedFolderMock =
        new NonIndexGmailFolderProvider() {
          @Override
          public SkypeMailFolder get() {
            return nonIndexedFolder;
          }
        };
    IndexedSkypeMailFolder indexedGmailFolder =
        new IndexedSkypeMailFolder(nonIndexedFolderMock, folderIndex);
    addPreviousMessages(indexedGmailFolder);
    return indexedGmailFolder;
  }