### Question:
CustomerService { public void savePreferredNotificationChannels(Customer customer, List<NotificationChannel> notificationChannels) { notificationChannels.forEach(notificationChannel -> customerRepository.savePreferredChannel(customer, notificationChannel)); } CustomerService(CustomerRepository customerRepository); void savePreferredNotificationChannels(Customer customer, List<NotificationChannel> notificationChannels);  }### Answer:
@Test public void theNotificationChannelsAreSavedByTheDataRepository() throws Exception { NotificationChannel channelOne = Mockito.mock(NotificationChannel.class); NotificationChannel channelTwo = Mockito.mock(NotificationChannel.class); CustomerRepository customerRepository = Mockito.mock(CustomerRepository.class); CustomerService customerService = new CustomerService(customerRepository); List<NotificationChannel> notificationChannels = new ArrayList(); notificationChannels.add(channelOne); notificationChannels.add(channelTwo); Customer customer = Mockito.mock(Customer.class); customerService.savePreferredNotificationChannels(customer, notificationChannels); Mockito.verify(customerRepository, Mockito.times(1)).savePreferredChannel(customer, channelOne); Mockito.verify(customerRepository, Mockito.times(1)).savePreferredChannel(customer, channelTwo); }