Search in sources :

Example 41 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class MigrationTest method migratePgpInlineEncryptedMessage.

@Test
public void migratePgpInlineEncryptedMessage() throws Exception {
    SQLiteDatabase db = createV50Database();
    insertPgpInlineEncryptedMessage(db);
    db.close();
    LocalStore localStore = LocalStore.getInstance(account, RuntimeEnvironment.application);
    LocalMessage msg = localStore.getFolder("dev").getMessage("7");
    FetchProfile fp = new FetchProfile();
    fp.add(FetchProfile.Item.BODY);
    localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null);
    Assert.assertEquals(6, 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_MESSAGE, OpenPgpUtils.parseMessage(msgTextContent));
}
Also used : FetchProfile(com.fsck.k9.mail.FetchProfile) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Test(org.junit.Test)

Example 42 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class StoreSchemaDefinitionTest method createAccount.

private Account createAccount() {
    Account account = mock(Account.class);
    when(account.getInboxFolderName()).thenReturn("Inbox");
    when(account.getLocalStorageProviderId()).thenReturn(StorageManager.InternalStorageProvider.ID);
    return account;
}
Also used : Account(com.fsck.k9.Account)

Example 43 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class ReplyToParserTest method getRecipientsToReplyAllTo_should_excludeDuplicates.

@Test
public void getRecipientsToReplyAllTo_should_excludeDuplicates() throws Exception {
    when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
    when(message.getFrom()).thenReturn(arrayConcatenate(FROM_ADDRESSES, REPLY_TO_ADDRESSES, Address.class));
    when(message.getRecipients(RecipientType.TO)).thenReturn(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class));
    when(message.getRecipients(RecipientType.CC)).thenReturn(arrayConcatenate(CC_ADDRESSES, TO_ADDRESSES, Address.class));
    when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
    ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
    assertArrayContainsAll(REPLY_TO_ADDRESSES, recipientsToReplyAllTo.to);
    assertArrayContainsAll(FROM_ADDRESSES, recipientsToReplyAllTo.to);
    assertArrayContainsAll(TO_ADDRESSES, recipientsToReplyAllTo.to);
    int totalExpectedAddresses = REPLY_TO_ADDRESSES.length + FROM_ADDRESSES.length + TO_ADDRESSES.length;
    assertEquals(totalExpectedAddresses, recipientsToReplyAllTo.to.length);
    assertArrayEquals(CC_ADDRESSES, recipientsToReplyAllTo.cc);
}
Also used : Address(com.fsck.k9.mail.Address) ReplyToAddresses(com.fsck.k9.helper.ReplyToParser.ReplyToAddresses) Test(org.junit.Test)

Example 44 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class ReplyToParserTest method getRecipientsToReplyTo_should_prefer_replyTo_over_any_other_field.

@Test
public void getRecipientsToReplyTo_should_prefer_replyTo_over_any_other_field() throws Exception {
    when(message.getReplyTo()).thenReturn(REPLY_TO_ADDRESSES);
    when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
    when(message.getFrom()).thenReturn(FROM_ADDRESSES);
    ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
    assertArrayEquals(REPLY_TO_ADDRESSES, result.to);
    assertArrayEquals(EMPTY_ADDRESSES, result.cc);
    verify(account).isAnIdentity(result.to);
}
Also used : ReplyToAddresses(com.fsck.k9.helper.ReplyToParser.ReplyToAddresses) Test(org.junit.Test)

Example 45 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class ReplyToParserTest method getRecipientsToReplyTo_should_prefer_listPost_over_from_field.

@Test
public void getRecipientsToReplyTo_should_prefer_listPost_over_from_field() throws Exception {
    when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
    when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(LIST_POST_HEADER_VALUES);
    when(message.getFrom()).thenReturn(FROM_ADDRESSES);
    ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
    assertArrayEquals(LIST_POST_ADDRESSES, result.to);
    assertArrayEquals(EMPTY_ADDRESSES, result.cc);
    verify(account).isAnIdentity(result.to);
}
Also used : ReplyToAddresses(com.fsck.k9.helper.ReplyToParser.ReplyToAddresses) Test(org.junit.Test)

Aggregations

Account (com.fsck.k9.Account)122 Test (org.junit.Test)81 MessagingException (com.fsck.k9.mail.MessagingException)53 LocalFolder (com.fsck.k9.mailstore.LocalFolder)44 LocalMessage (com.fsck.k9.mailstore.LocalMessage)43 LocalStore (com.fsck.k9.mailstore.LocalStore)42 ArrayList (java.util.ArrayList)34 MessageReference (com.fsck.k9.activity.MessageReference)32 Message (com.fsck.k9.mail.Message)29 Folder (com.fsck.k9.mail.Folder)27 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)25 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)22 IOException (java.io.IOException)22 Cursor (android.database.Cursor)21 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)20 Store (com.fsck.k9.mail.Store)20 SearchAccount (com.fsck.k9.search.SearchAccount)20 PendingIntent (android.app.PendingIntent)19 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)19 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)18