@Test public void sync_withAccountSetToSyncRemoteDeletions_shouldDeleteLocalCopiesOfDeletedMessages() { messageCountInRemoteFolder(0); configureSyncConfigWithSyncRemoteDeletions(true); when(backendFolder.getAllMessagesAndEffectiveDates()).thenReturn(Collections.singletonMap(MESSAGE_UID1, 0L)); imapSync.sync(FOLDER_NAME, syncConfig, listener, remoteFolder); verify(backendFolder).destroyMessages(messageListCaptor.capture()); assertEquals(MESSAGE_UID1, messageListCaptor.getValue().get(0)); }
@Test public void sync_withAccountSetNotToSyncRemoteDeletions_shouldNotDeleteLocalCopiesOfMessages() { messageCountInRemoteFolder(0); configureSyncConfigWithSyncRemoteDeletions(false); imapSync.sync(FOLDER_NAME, syncConfig, listener, remoteFolder); verify(backendFolder, never()).destroyMessages(messageListCaptor.capture()); }
@Test public void sync_withAccountSetToSyncRemoteDeletions_shouldNotDeleteLocalCopiesOfExistingMessagesAfterEarliestPollDate() throws Exception { messageCountInRemoteFolder(1); Date dateOfEarliestPoll = new Date(); Message remoteMessage = messageOnServer(); configureSyncConfigWithSyncRemoteDeletionsAndEarliestPollDate(dateOfEarliestPoll); when(remoteMessage.olderThan(dateOfEarliestPoll)).thenReturn(false); imapSync.sync(FOLDER_NAME, syncConfig, listener, remoteFolder); verify(backendFolder, never()).destroyMessages(messageListCaptor.capture()); }
@Test public void sync_withAccountSetToSyncRemoteDeletions_shouldDeleteLocalCopiesOfExistingMessagesBeforeEarliestPollDate() throws Exception { messageCountInRemoteFolder(1); Message remoteMessage = messageOnServer(); Date dateOfEarliestPoll = new Date(); configureSyncConfigWithSyncRemoteDeletionsAndEarliestPollDate(dateOfEarliestPoll); when(remoteMessage.olderThan(dateOfEarliestPoll)).thenReturn(true); when(backendFolder.getAllMessagesAndEffectiveDates()).thenReturn(Collections.singletonMap(MESSAGE_UID1, 0L)); imapSync.sync(FOLDER_NAME, syncConfig, listener, remoteFolder); verify(backendFolder).destroyMessages(messageListCaptor.capture()); assertEquals(MESSAGE_UID1, messageListCaptor.getValue().get(0)); }
moreMessages = MoreMessages.UNKNOWN; backendFolder.destroyMessages(destroyMessageUids); for (String uid : destroyMessageUids) { listener.syncRemovedMessage(folder, uid);
moreMessages = MoreMessages.UNKNOWN; backendFolder.destroyMessages(destroyMessageUids); for (String uid : destroyMessageUids) { listener.syncRemovedMessage(folder, uid);
moreMessages = MoreMessages.UNKNOWN; backendFolder.destroyMessages(destroyMessageUids); for (String uid : destroyMessageUids) { listener.syncRemovedMessage(folder, uid);