Emailer { public boolean sendEmailCC(String cc, String subject, String body, List<File> attachments) throws AddressException, MessagingException { if (webappAndMailHelper.isEmailFunctionalityDisabled()) return false; InternetAddress mailFromAddress = new InternetAddress(mailfrom); InternetAddress[] recipientsCC = InternetAddress.parse(cc); File[] attachmentsArray = attachmentListToArry(attachments); MailerResult result = new MailerResult(); MimeMessage msg = webappAndMailHelper.createMessage(mailFromAddress, null, recipientsCC, null, body + footer, subject, attachmentsArray, result); webappAndMailHelper.send(msg, result); return true; } Emailer(MailTemplate mailTemplate);   Emailer(MailTemplate mailTemplate, MailPackageStaticDependenciesWrapper facadeToWebappAndMailhelper);  Emailer(OLATPrincipal senderPrincipal, boolean tryInstitutionalEmail, MailTemplate mailTemplate);   Emailer(OLATPrincipal senderPrincipal, boolean tryInstitutionalEmail, MailTemplate mailTemplate, MailPackageStaticDependenciesWrapper facadeToWebappAndMailhelper); boolean sendEmail(List<ContactList> listOfContactLists, String subject, String body); boolean sendEmail(List<ContactList> listOfContactLists, String subject, String body, List<File> attachments); boolean sendEmailCC(String cc, String subject, String body, List<File> attachments); boolean sendEmail(String mailto, String subject, String body);  }
@Test public void testShouldSendCCMail() throws AddressException, MessagingException{ OLATPrincipal helene = ObjectMother.createHeleneMeyerPrincipial(); OLATPrincipal mia = ObjectMother.createMiaBrennerPrincipal(); OLATPrincipal nicolas = ObjectMother.createNicolas33Principal(); String cc = ObjectMother.getPrivateEmailsAsCSVFor(helene, mia, nicolas); InternetAddress[] privateEmailAsInternetAddressesFor = ObjectMother.getPrivateEmailAsInternetAddressesFor( nicolas, mia,helene); peterBichselEmailer.sendEmailCC(cc, ObjectMother.AN_EXAMPLE_SUBJECT, ObjectMother.HELLOY_KITTY_THIS_IS_AN_EXAMPLE_BODY, null); assertEquals("peter bichsel is the email sender with its private mail.", ObjectMother.PETER_BICHSEL_INSTITUTIONAL_EMAIL, peterBichselEmailer.mailfrom); InternetAddress[] nullAddresses = null; File[] nullFiles = null; verify(webappAndMailhelperMockPrincipalMailer, times(1)).createMessage(any(InternetAddress.class), aryEq(nullAddresses), aryEq(privateEmailAsInternetAddressesFor), aryEq(nullAddresses), eq(ObjectMother.HELLOY_KITTY_THIS_IS_AN_EXAMPLE_BODY + ObjectMother.MAIL_TEMPLATE_FOOTER), eq(ObjectMother.AN_EXAMPLE_SUBJECT), aryEq(nullFiles), any(MailerResult.class)); }