Search in sources :

Example 6 with ReplyToAddresses

use of com.fsck.k9.helper.ReplyToParser.ReplyToAddresses in project k-9 by k9mail.

the class RecipientPresenterTest method testInitFromReplyToAllMessage.

@Test
public void testInitFromReplyToAllMessage() throws Exception {
    Message message = mock(Message.class);
    when(replyToParser.getRecipientsToReplyTo(message, account)).thenReturn(TO_ADDRESSES);
    ReplyToAddresses replyToAddresses = new ReplyToAddresses(ALL_TO_ADDRESSES, ALL_CC_ADDRESSES);
    when(replyToParser.getRecipientsToReplyAllTo(message, account)).thenReturn(replyToAddresses);
    recipientPresenter.initFromReplyToMessage(message, true);
    verify(recipientMvpView).addRecipients(eq(RecipientType.TO), any(Recipient.class));
    verify(recipientMvpView).addRecipients(eq(RecipientType.CC), any(Recipient.class));
}
Also used : Message(com.fsck.k9.mail.Message) ReplyToAddresses(com.fsck.k9.helper.ReplyToParser.ReplyToAddresses) Recipient(com.fsck.k9.view.RecipientSelectView.Recipient) Test(org.junit.Test)

Example 7 with ReplyToAddresses

use of com.fsck.k9.helper.ReplyToParser.ReplyToAddresses in project k-9 by k9mail.

the class ReplyToParserTest method getRecipientsToReplyTo_should_prefer_from_ifOtherIsIdentity.

@Test
public void getRecipientsToReplyTo_should_prefer_from_ifOtherIsIdentity() 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);
    when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
    when(account.isAnIdentity(any(Address[].class))).thenReturn(true);
    ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
    assertArrayEquals(TO_ADDRESSES, result.to);
    assertArrayEquals(EMPTY_ADDRESSES, result.cc);
}
Also used : ReplyToAddresses(com.fsck.k9.helper.ReplyToParser.ReplyToAddresses) Test(org.junit.Test)

Example 8 with ReplyToAddresses

use of com.fsck.k9.helper.ReplyToParser.ReplyToAddresses in project k-9 by k9mail.

the class ReplyToParserTest method getRecipientsToReplyAllTo_should_excludeIdentityAddresses.

@Test
public void getRecipientsToReplyAllTo_should_excludeIdentityAddresses() throws Exception {
    when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
    when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
    when(message.getFrom()).thenReturn(EMPTY_ADDRESSES);
    when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
    when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
    Address excludedCcAddress = CC_ADDRESSES[1];
    Address excludedToAddress = TO_ADDRESSES[0];
    when(account.isAnIdentity(eq(excludedToAddress))).thenReturn(true);
    when(account.isAnIdentity(eq(excludedCcAddress))).thenReturn(true);
    ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
    assertArrayEquals(arrayExcept(TO_ADDRESSES, excludedToAddress), recipientsToReplyAllTo.to);
    assertArrayEquals(arrayExcept(CC_ADDRESSES, excludedCcAddress), recipientsToReplyAllTo.cc);
}
Also used : Address(com.fsck.k9.mail.Address) ReplyToAddresses(com.fsck.k9.helper.ReplyToParser.ReplyToAddresses) Test(org.junit.Test)

Example 9 with ReplyToAddresses

use of com.fsck.k9.helper.ReplyToParser.ReplyToAddresses in project k-9 by k9mail.

the class ReplyToParserTest method getRecipientsToReplyAllTo_should_returnFromAndToAndCcRecipients.

@Test
public void getRecipientsToReplyAllTo_should_returnFromAndToAndCcRecipients() throws Exception {
    when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
    when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
    when(message.getFrom()).thenReturn(FROM_ADDRESSES);
    when(message.getRecipients(RecipientType.TO)).thenReturn(TO_ADDRESSES);
    when(message.getRecipients(RecipientType.CC)).thenReturn(CC_ADDRESSES);
    ReplyToAddresses recipientsToReplyAllTo = replyToParser.getRecipientsToReplyAllTo(message, account);
    assertArrayEquals(arrayConcatenate(FROM_ADDRESSES, TO_ADDRESSES, Address.class), recipientsToReplyAllTo.to);
    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 10 with ReplyToAddresses

use of com.fsck.k9.helper.ReplyToParser.ReplyToAddresses in project k-9 by k9mail.

the class ReplyToParserTest method getRecipientsToReplyTo_should_return_from_otherwise.

@Test
public void getRecipientsToReplyTo_should_return_from_otherwise() throws Exception {
    when(message.getReplyTo()).thenReturn(EMPTY_ADDRESSES);
    when(message.getHeader(ListHeaders.LIST_POST_HEADER)).thenReturn(new String[0]);
    when(message.getFrom()).thenReturn(FROM_ADDRESSES);
    ReplyToAddresses result = replyToParser.getRecipientsToReplyTo(message, account);
    assertArrayEquals(FROM_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

ReplyToAddresses (com.fsck.k9.helper.ReplyToParser.ReplyToAddresses)9 Test (org.junit.Test)8 Address (com.fsck.k9.mail.Address)4 Message (com.fsck.k9.mail.Message)1 Recipient (com.fsck.k9.view.RecipientSelectView.Recipient)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1