EmailUtils { public static List<String> filterEmails(final List<String> emailsToSend, EmailsFilter includeFilter, EmailsFilter excludeFilter) { List<String> filteredEmailsToSend = new LinkedList<>(emailsToSend); for (Iterator<String> i = filteredEmailsToSend.iterator(); i.hasNext(); ) { String email = i.next(); if ((includeFilter != null) && (!includeFilter.isMatching(email))) { i.remove(); continue; } if ((excludeFilter != null) && excludeFilter.isMatching(email)) { i.remove(); } } return new ArrayList<>(filteredEmailsToSend); }  static void sendMessageRequest(EmailConfig config); static void sendMessage(EmailConfig config); static void prepareMessage(User user, EmailConfig config, Interaction interaction, VariableProvider variableProvider); static List<String> getEmails(Executor executor); static String concatenateEmails(Collection<String> emails); static boolean isProcessNameMatching(String processName, ProcessNameFilter includeFilter, ProcessNameFilter excludeFilter); static List<String> filterEmails(final List<String> emailsToSend, EmailsFilter includeFilter, EmailsFilter excludeFilter); static EmailsFilter validateAndCreateEmailsFilter(final List<String> filters); static ProcessNameFilter validateAndCreateProcessNameFilter(final List<String> filters); static SwimlaneNameFilter validateAndCreateSwimlaneNameFilter(final List<String> filters); static boolean isSwimlaneNameMatching(String swimlaneName, SwimlaneNameFilter includeSwimlaneNameFiler, SwimlaneNameFilter excludeSwimlaneNameFiler);  }
@Test(dataProvider = "getFilterEmailsData") public void testFilterEmails(List<String> emails, List<String> includeFilters, List<String> excludeFilters, int filteredCount) { EmailsFilter includeFilter = EmailUtils.validateAndCreateEmailsFilter(includeFilters); EmailsFilter excludeFilter = EmailUtils.validateAndCreateEmailsFilter(excludeFilters); List<String> filteredEmails; filteredEmails = EmailUtils.filterEmails(emails, includeFilter, excludeFilter); LOG.info(filteredEmails.toString()); assertEquals(filteredEmails.size(), filteredCount); }