use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class MigrationTest method migratePgpInlineClearsignedMessage.
@Test
public void migratePgpInlineClearsignedMessage() throws Exception {
SQLiteDatabase db = createV50Database();
insertPgpInlineClearsignedMessage(db);
db.close();
LocalStore localStore = LocalStore.getInstance(account, RuntimeEnvironment.application);
LocalMessage msg = localStore.getFolder("dev").getMessage("8");
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.BODY);
localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
Assert.assertEquals(7, msg.getId());
Assert.assertEquals(12, msg.getHeaderNames().size());
Assert.assertEquals("text/plain", msg.getMimeType());
Assert.assertEquals(0, msg.getAttachmentCount());
Assert.assertTrue(msg.getBody() instanceof BinaryMemoryBody);
String msgTextContent = MessageExtractor.getTextFromPart(msg);
Assert.assertEquals(OpenPgpUtils.PARSE_RESULT_SIGNED_MESSAGE, OpenPgpUtils.parseMessage(msgTextContent));
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class MessagingControllerTest method synchronizeMailboxSynchronous_withAccountSetToSyncRemoteDeletions_shouldDeleteLocalCopiesOfExistingMessagesBeforeEarliestPollDate.
@Test
public void synchronizeMailboxSynchronous_withAccountSetToSyncRemoteDeletions_shouldDeleteLocalCopiesOfExistingMessagesBeforeEarliestPollDate() throws Exception {
messageCountInRemoteFolder(1);
LocalMessage localMessage = localMessageWithCopyOnServer();
Date dateOfEarliestPoll = new Date();
when(account.syncRemoteDeletions()).thenReturn(true);
when(account.getEarliestPollDate()).thenReturn(dateOfEarliestPoll);
when(localMessage.olderThan(dateOfEarliestPoll)).thenReturn(true);
when(localFolder.getAllMessagesAndEffectiveDates()).thenReturn(Collections.singletonMap(MESSAGE_UID1, 0L));
when(localFolder.getMessagesByUids(any(List.class))).thenReturn(Collections.singletonList(localMessage));
controller.synchronizeMailboxSynchronous(account, FOLDER_NAME, listener, remoteFolder);
verify(localFolder).destroyMessages(messageListCaptor.capture());
assertEquals(localMessage, messageListCaptor.getValue().get(0));
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class MessagingControllerTest method synchronizeMailboxSynchronous_withAccountSetNotToSyncRemoteDeletions_shouldNotDeleteLocalCopiesOfMessages.
@Test
public void synchronizeMailboxSynchronous_withAccountSetNotToSyncRemoteDeletions_shouldNotDeleteLocalCopiesOfMessages() throws Exception {
messageCountInRemoteFolder(0);
LocalMessage remoteDeletedMessage = mock(LocalMessage.class);
when(account.syncRemoteDeletions()).thenReturn(false);
when(localFolder.getMessages(null)).thenReturn(Collections.singletonList(remoteDeletedMessage));
controller.synchronizeMailboxSynchronous(account, FOLDER_NAME, listener, remoteFolder);
verify(localFolder, never()).destroyMessages(messageListCaptor.capture());
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NewMailNotificationsTest method testClearNewMailNotifications.
@Test
public void testClearNewMailNotifications() throws Exception {
int notificationIndex = 0;
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
LocalMessage message = createLocalMessage();
NotificationContent content = createNotificationContent();
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
addToNotificationContentCreator(message, content);
setActiveNotificationIds(notificationId);
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
newMailNotifications.addNewMailNotification(account, message, 3);
newMailNotifications.clearNewMailNotifications(account);
verify(notificationManager).cancel(notificationId);
verify(notificationManager).cancel(NotificationIds.getNewMailSummaryNotificationId(account));
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotificationClearingAllNotifications.
@Test
public void testRemoveNewMailNotificationClearingAllNotifications() throws Exception {
MessageReference messageReference = createMessageReference(1);
int notificationIndex = 0;
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
LocalMessage message = createLocalMessage();
NotificationContent content = createNotificationContent();
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
addToNotificationContentCreator(message, content);
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
Notification summaryNotification = createNotification();
addToDeviceNotifications(summaryNotification);
newMailNotifications.addNewMailNotification(account, message, 23);
whenRemovingContentReturn(messageReference, RemoveNotificationResult.cancelNotification(notificationId));
when(newMailNotifications.notificationData.getNewMessagesCount()).thenReturn(0);
setActiveNotificationIds();
newMailNotifications.removeNewMailNotification(account, messageReference);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager).cancel(notificationId);
verify(notificationManager).cancel(summaryNotificationId);
}
Aggregations