use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingControllerTest method refreshRemoteSynchronous_shouldCreateFoldersFromRemote.
@Test
public void refreshRemoteSynchronous_shouldCreateFoldersFromRemote() throws MessagingException {
configureRemoteStoreWithFolder();
LocalFolder newLocalFolder = mock(LocalFolder.class);
List<Folder> folders = Collections.singletonList(remoteFolder);
when(remoteStore.getPersonalNamespaces(false)).thenAnswer(createAnswer(folders));
when(remoteFolder.getName()).thenReturn("NewFolder");
when(localStore.getFolder("NewFolder")).thenReturn(newLocalFolder);
controller.refreshRemoteSynchronous(account, listener);
verify(localStore).createFolders(eq(Collections.singletonList(newLocalFolder)), anyInt());
}
use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingControllerTest method synchronizeMailboxSynchronous_withAccountSetToSyncRemoteDeletions_shouldDeleteLocalCopiesOfDeletedMessages.
@Test
public void synchronizeMailboxSynchronous_withAccountSetToSyncRemoteDeletions_shouldDeleteLocalCopiesOfDeletedMessages() throws Exception {
messageCountInRemoteFolder(0);
LocalMessage localCopyOfRemoteDeletedMessage = mock(LocalMessage.class);
when(account.syncRemoteDeletions()).thenReturn(true);
when(localFolder.getAllMessagesAndEffectiveDates()).thenReturn(Collections.singletonMap(MESSAGE_UID1, 0L));
when(localFolder.getMessagesByUids(any(List.class))).thenReturn(Collections.singletonList(localCopyOfRemoteDeletedMessage));
controller.synchronizeMailboxSynchronous(account, FOLDER_NAME, listener, remoteFolder);
verify(localFolder).destroyMessages(messageListCaptor.capture());
assertEquals(localCopyOfRemoteDeletedMessage, messageListCaptor.getValue().get(0));
}
use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingControllerTest method refreshRemoteSynchronous_shouldDeleteFoldersNotOnRemote.
@Test
public void refreshRemoteSynchronous_shouldDeleteFoldersNotOnRemote() throws MessagingException {
configureRemoteStoreWithFolder();
LocalFolder oldLocalFolder = mock(LocalFolder.class);
when(oldLocalFolder.getName()).thenReturn("OldLocalFolder");
when(localStore.getPersonalNamespaces(false)).thenReturn(Collections.singletonList(oldLocalFolder));
List<Folder> folders = Collections.emptyList();
when(remoteStore.getPersonalNamespaces(false)).thenAnswer(createAnswer(folders));
controller.refreshRemoteSynchronous(account, listener);
verify(oldLocalFolder).delete(false);
}
use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingControllerTest method refreshRemoteSynchronous_shouldNotDeleteSpecialFoldersNotOnRemote.
@Test
public void refreshRemoteSynchronous_shouldNotDeleteSpecialFoldersNotOnRemote() throws MessagingException {
configureRemoteStoreWithFolder();
LocalFolder missingSpecialFolder = mock(LocalFolder.class);
when(account.isSpecialFolder("Outbox")).thenReturn(true);
when(missingSpecialFolder.getName()).thenReturn("Outbox");
when(localStore.getPersonalNamespaces(false)).thenReturn(Collections.singletonList(missingSpecialFolder));
List<Folder> folders = Collections.emptyList();
when(remoteStore.getPersonalNamespaces(false)).thenAnswer(createAnswer(folders));
controller.refreshRemoteSynchronous(account, listener);
verify(missingSpecialFolder, never()).delete(false);
}
use of com.fsck.k9.mailstore.LocalFolder in project k-9 by k9mail.
the class MessagingControllerTest method searchLocalMessagesSynchronous_shouldNotifyWhenStoreFinishesRetrievingAMessage.
@Test
public void searchLocalMessagesSynchronous_shouldNotifyWhenStoreFinishesRetrievingAMessage() throws Exception {
setAccountsInPreferences(Collections.singletonMap("1", account));
LocalMessage localMessage = mock(LocalMessage.class);
when(localMessage.getFolder()).thenReturn(localFolder);
when(search.getAccountUuids()).thenReturn(new String[] { "allAccounts" });
when(localStore.searchForMessages(any(MessageRetrievalListener.class), eq(search))).thenThrow(new MessagingException("Test"));
controller.searchLocalMessagesSynchronous(search, listener);
verify(localStore).searchForMessages(messageRetrievalListenerCaptor.capture(), eq(search));
messageRetrievalListenerCaptor.getValue().messageFinished(localMessage, 1, 1);
verify(listener).listLocalMessagesAddMessages(eq(account), eq((String) null), eq(Collections.singletonList(localMessage)));
}
Aggregations