RecipientServiceImpl implements RecipientService { @Override public List<Recipient> findReadyToNotify(NotificationType type) { switch (type) { case BACKUP: return repository.findReadyForBackup(); case REMIND: return repository.findReadyForRemind(); default: throw new IllegalArgumentException(); } }  @Override Recipient findByAccountName(String accountName); @Override Recipient save(String accountName, Recipient recipient); @Override List<Recipient> findReadyToNotify(NotificationType type); @Override void markNotified(NotificationType type, Recipient recipient);  }
@Test public void shouldFindReadyToNotifyWhenNotificationTypeIsBackup() { final List<Recipient> recipients = ImmutableList.of(new Recipient()); when(repository.findReadyForBackup()).thenReturn(recipients); List<Recipient> found = recipientService.findReadyToNotify(NotificationType.BACKUP); assertEquals(recipients, found); }
@Test public void shouldFindReadyToNotifyWhenNotificationTypeIsRemind() { final List<Recipient> recipients = ImmutableList.of(new Recipient()); when(repository.findReadyForRemind()).thenReturn(recipients); List<Recipient> found = recipientService.findReadyToNotify(NotificationType.REMIND); assertEquals(recipients, found); }