### Question:
NotificationService { @Scheduled(cron = "${backup.cron}") @SchedulerLock(name = "backupNotifications") public void sendBackupNotifications() { List<Recipient> recipients = recipientRepository.readyToNotify(NotificationType.BACKUP, LocalDate.now()); Flux.fromIterable(recipients) .flatMap(recipient -> accountServiceStub.getAccount( AccountServiceProto.GetAccountRequest.newBuilder() .setName(recipient.getUsername()) .build()) .publishOn(jdbcScheduler) .doOnNext(account -> { try { emailService.send(NotificationType.BACKUP, recipient, JsonFormat.printer().print(account)); recipient.markNotified(NotificationType.BACKUP); recipientRepository.update(recipient); } catch (Exception e) { throw Exceptions.propagate(e); } }).onErrorContinue((e, account) -> logger.error("Backup notification for user '" + recipient.getUsername() + "' failed", e) ) ).count() .subscribe(count -> logger.info("Backup notification sent to {} recipients", count)); }  @Scheduled(cron = "${backup.cron}") @SchedulerLock(name = "backupNotifications") void sendBackupNotifications(); @Scheduled(cron = "${remind.cron}") @SchedulerLock(name = "remindNotifications") void sendRemindNotifications();  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldSendBackupNotificationsEvenWhenErrorsOccurForSomeRecipients() throws Exception { doReturn(Mono.just(AccountServiceProto.Account.getDefaultInstance())).when(accountService) .getAccount(getAccountRequestCaptor.capture()); doThrow(RuntimeException.class).when(emailService).send(eq(NotificationType.BACKUP), eq(failed), anyString()); notificationService.sendBackupNotifications(); verify(emailService).send(eq(NotificationType.BACKUP), eq(successful), anyString()); verify(recipientRepository).update(argThat(arg -> { assertThat(arg.getUsername()).isEqualTo(SUCCESSFUL); assertThat(arg.getNotifications().get(NotificationType.BACKUP).getNotifyDate()).isAfter(date); assertThat(arg.getNotifications().get(NotificationType.REMIND).getNotifyDate()).isEqualTo(date); return true; })); verify(recipientRepository, never()).update(failed); StepVerifier.create(getAccountRequestCaptor.getAllValues().get(0)) .expectNextMatches(request -> { assertThat(request.getName()).isEqualTo(FAILED); return true; }).verifyComplete(); StepVerifier.create(getAccountRequestCaptor.getAllValues().get(1)) .expectNextMatches(request -> { assertThat(request.getName()).isEqualTo(SUCCESSFUL); return true; }).verifyComplete(); }