@Test
public void testValidToAndInvalidCCAndInvalidBCCForSendAsSeparateMails() {

    // setup
    OLATPrincipal invalidPrincipal = ObjectMother.createInvalidPrincipal();
    recipientsCC.add(invalidPrincipal);
    recipientsBCC.add(invalidPrincipal);
    int failedIdentities = 2;
    int numberOfSeparateMails = recipients.size();
    numberOfSeparateMails += recipientsCC.size();
    // BCC Senders are in reality sent as "TO" inside the mailer.
    // This means, that for invalid recipients on the BCC
    // no MIME Message is created. We have to subtract the invalid users
    // on the BCC from the expected numberOfSeparateMails.
    // DESIGNCRITIQUE: In the MailerWithTemplate there are BCC arrays of Principals
    // which are handed around. But the MailerWithTemplate.sendMailAsSeparateMails Method
    // transforms the EMailaddresses handed in as BCC into EMailaddresses which go
    // into the TO Field.
    numberOfSeparateMails += recipientsBCC.size() - 1;
    MailerResult result = new MailerResult();
    //
    result = mailerWithTemplate.sendMailAsSeparateMails(recipients, recipientsCC, recipientsBCC, template, ruedi);
    // verify
    assertEquals(MailerResult.OK, result.getReturnCode());
    assertNotNull("failed email must be reported, hence not null", result.getFailedIdentites());
    assertEquals(failedIdentities, result.getFailedIdentites().size());
    verifyTimesCallingCreateAndSendMessageInvocationsFor(numberOfSeparateMails, recipients, recipientsBCC, recipientsBCC);
}