### Question:
BankStatementService { public void sendBankStatement(Customer customer) { List<NotificationType> preferredChannels = customerRepository.getPreferredNotificationChannels(customer); BankStatement bankStatement = bankStatementRepository.getCustomerBankStatement(customer); preferredChannels.forEach( channel -> notificationChannelFactory.getNotificationChannel(channel).send(bankStatement) ); } BankStatementService(NotificationChannelFactory notificationChannelFactory, CustomerRepository customerRepository, BankStatementRepository bankStatementRepository); void sendBankStatement(Customer customer);  }### Answer:
@Test public void theBankStatementIsSendUsingThePreferredNotificationChannels() throws Exception { BankStatement bankStatement = mock(BankStatement.class); Customer customer = mock(Customer.class); CustomerRepository customerRepository = mock(CustomerRepository.class); BankStatementRepository bankStatementRepository = mock(BankStatementRepository.class); when(customerRepository.getPreferredNotificationChannels(customer)).thenReturn(buildListOfNotificationTypes()); when(bankStatementRepository.getCustomerBankStatement(customer)).thenReturn(bankStatement); BankStatementService bankStatementService = new BankStatementService(notificationChannelsFactory, customerRepository, bankStatementRepository); bankStatementService.sendBankStatement(customer); verify(customerRepository, times(1)).getPreferredNotificationChannels(customer); verify(emailChannel, times(1)).send(bankStatement); verify(faxChannel, times(1)).send(bankStatement); }