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));
}
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);
}
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);
}
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);
}
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);
}