@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); }
public ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account) { List<Address> replyToAddresses = Arrays.asList(getRecipientsToReplyTo(message, account).to); HashSet<Address> alreadyAddedAddresses = new HashSet<>(replyToAddresses); ArrayList<Address> toAddresses = new ArrayList<>(replyToAddresses); ArrayList<Address> ccAddresses = new ArrayList<>(); for (Address address : message.getFrom()) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.TO)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.CC)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { ccAddresses.add(address); alreadyAddedAddresses.add(address); } } return new ReplyToAddresses(toAddresses, ccAddresses); }
ReplyToParser { public ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account) { List<Address> replyToAddresses = Arrays.asList(getRecipientsToReplyTo(message, account).to); HashSet<Address> alreadyAddedAddresses = new HashSet<>(replyToAddresses); ArrayList<Address> toAddresses = new ArrayList<>(replyToAddresses); ArrayList<Address> ccAddresses = new ArrayList<>(); for (Address address : message.getFrom()) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.TO)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.CC)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { ccAddresses.add(address); alreadyAddedAddresses.add(address); } } return new ReplyToAddresses(toAddresses, ccAddresses); } }
ReplyToParser { public ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account) { List<Address> replyToAddresses = Arrays.asList(getRecipientsToReplyTo(message, account).to); HashSet<Address> alreadyAddedAddresses = new HashSet<>(replyToAddresses); ArrayList<Address> toAddresses = new ArrayList<>(replyToAddresses); ArrayList<Address> ccAddresses = new ArrayList<>(); for (Address address : message.getFrom()) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.TO)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.CC)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { ccAddresses.add(address); alreadyAddedAddresses.add(address); } } return new ReplyToAddresses(toAddresses, ccAddresses); }  }
ReplyToParser { public ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account) { List<Address> replyToAddresses = Arrays.asList(getRecipientsToReplyTo(message, account).to); HashSet<Address> alreadyAddedAddresses = new HashSet<>(replyToAddresses); ArrayList<Address> toAddresses = new ArrayList<>(replyToAddresses); ArrayList<Address> ccAddresses = new ArrayList<>(); for (Address address : message.getFrom()) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.TO)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.CC)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { ccAddresses.add(address); alreadyAddedAddresses.add(address); } } return new ReplyToAddresses(toAddresses, ccAddresses); }  ReplyToAddresses getRecipientsToReplyTo(Message message, Account account); ReplyToAddresses getRecipientsToReplyListTo(Message message, Account account); ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account); }
ReplyToParser { public ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account) { List<Address> replyToAddresses = Arrays.asList(getRecipientsToReplyTo(message, account).to); HashSet<Address> alreadyAddedAddresses = new HashSet<>(replyToAddresses); ArrayList<Address> toAddresses = new ArrayList<>(replyToAddresses); ArrayList<Address> ccAddresses = new ArrayList<>(); for (Address address : message.getFrom()) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.TO)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { toAddresses.add(address); alreadyAddedAddresses.add(address); } } for (Address address : message.getRecipients(RecipientType.CC)) { if (!alreadyAddedAddresses.contains(address) && !account.isAnIdentity(address)) { ccAddresses.add(address); alreadyAddedAddresses.add(address); } } return new ReplyToAddresses(toAddresses, ccAddresses); }  ReplyToAddresses getRecipientsToReplyTo(Message message, Account account); ReplyToAddresses getRecipientsToReplyListTo(Message message, Account account); ReplyToAddresses getRecipientsToReplyAllTo(Message message, Account account);  }