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