### Question:
NotificationServiceImpl implements NotificationService { @Override @Scheduled(cron = "${backup.cron}") @CatAnnotation public void sendBackupNotifications() { final NotificationType type = NotificationType.BACKUP; List<Recipient> recipients = recipientService.findReadyToNotify(type); log.info("found {} recipients for backup notification", recipients.size()); recipients.forEach(recipient -> CompletableFuture.runAsync(() -> { try { String attachment = client.getAccount(recipient.getAccountName()); emailService.send(type, recipient, attachment); recipientService.markNotified(type, recipient); } catch (Throwable t) { log.error("an error during backup notification for {}", recipient, t); } })); }  @Override @Scheduled(cron = "${backup.cron}") @CatAnnotation void sendBackupNotifications(); @Override @Scheduled(cron = "${remind.cron}") @CatAnnotation void sendRemindNotifications();  }### Answer:
@Test public void shouldSendBackupNotificationsEvenWhenErrorsOccursForSomeRecipients() throws IOException, MessagingException, InterruptedException { final String attachment = "json"; Recipient withError = new Recipient(); withError.setAccountName("with-error"); Recipient withNoError = new Recipient(); withNoError.setAccountName("with-no-error"); when(client.getAccount(withError.getAccountName())).thenThrow(new RuntimeException()); when(client.getAccount(withNoError.getAccountName())).thenReturn(attachment); when(recipientService.findReadyToNotify(NotificationType.BACKUP)).thenReturn(ImmutableList.of(withNoError, withError)); notificationService.sendBackupNotifications(); verify(emailService, timeout(100)).send(NotificationType.BACKUP, withNoError, attachment); verify(recipientService, timeout(100)).markNotified(NotificationType.BACKUP, withNoError); verify(recipientService, never()).markNotified(NotificationType.BACKUP, withError); }