use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotificationWithCreateNotification.
@Test
public void testRemoveNewMailNotificationWithCreateNotification() throws Exception {
MessageReference messageReference = createMessageReference(1);
int notificationIndex = 0;
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
LocalMessage message = createLocalMessage();
NotificationContent contentOne = createNotificationContent();
NotificationContent contentTwo = createNotificationContent();
NotificationHolder holderOne = createNotificationHolder(contentOne, notificationIndex);
NotificationHolder holderTwo = createNotificationHolder(contentTwo, notificationIndex);
addToNotificationContentCreator(message, contentOne);
whenAddingContentReturn(contentOne, AddNotificationResult.newNotification(holderOne));
Notification summaryNotification = createNotification();
addToDeviceNotifications(summaryNotification);
Notification wearNotificationOne = createNotification();
Notification wearNotificationTwo = createNotification();
addToWearNotifications(holderOne, wearNotificationOne);
addToWearNotifications(holderTwo, wearNotificationTwo);
newMailNotifications.addNewMailNotification(account, message, 23);
whenRemovingContentReturn(messageReference, RemoveNotificationResult.createNotification(holderTwo));
newMailNotifications.removeNewMailNotification(account, messageReference);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager).cancel(notificationId);
verify(notificationManager).notify(notificationId, wearNotificationTwo);
verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification);
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class ReconstructMessageFromDatabaseTest method readMessageFromDatabase.
protected LocalMessage readMessageFromDatabase(LocalFolder folder, MimeMessage message) throws MessagingException {
LocalMessage localMessage = folder.getMessage(message.getUid());
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.BODY);
folder.fetch(Collections.singletonList(localMessage), fp, null);
folder.close();
return localMessage;
}
use of com.fsck.k9.mailstore.LocalMessage in project k-9 by k9mail.
the class ReconstructMessageFromDatabaseTest method testAddMissingPart.
public void testAddMissingPart() throws MessagingException, IOException {
LocalFolder folder = createFolderInDatabase();
MimeMessage message = new MimeMessage();
message.addHeader("To", "to@example.com");
message.addHeader("MIME-Version", "1.0");
message.addHeader("Content-Type", "text/plain");
message.setServerExtra("text");
saveMessageToDatabase(folder, message);
LocalMessage localMessage = readMessageFromDatabase(folder, message);
assertEquals("to@example.com", localMessage.getHeader("To")[0]);
assertEquals("text/plain", localMessage.getHeader(MimeHeader.HEADER_CONTENT_TYPE)[0]);
assertEquals("text", localMessage.getServerExtra());
assertNull(localMessage.getBody());
Body body = new BinaryMemoryBody("Test message body".getBytes(), MimeUtil.ENC_7BIT);
localMessage.setBody(body);
folder.addPartToMessage(localMessage, localMessage);
LocalMessage completeLocalMessage = readMessageFromDatabase(folder, message);
String reconstructedMessage = writeMessageToString(completeLocalMessage);
assertEquals("To: to@example.com\r\n" + "MIME-Version: 1.0\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "Test message body", reconstructedMessage);
}
Aggregations