@Test
public void should_throw_TrainingException_if_training_was_not_found() {

    // given
    TrainingId trainingId = TrainingId.next();
    Ticket ticket = new Ticket(TicketId.next(), trainingId, Available);
    Nominator nominator = new Nominator("200901010007", "admin", "admin@eas.com", TrainingRole.Coordinator);
    Nominee nominee = new Nominee("200910100111", "bruce", "bruce@email.com");
    CourseId courseId = CourseId.next();
    LocalDateTime beginTime = LocalDateTime.of(2020, 1, 8, 9, 0);
    LocalDateTime endTime = LocalDateTime.of(2020, 1, 9, 17, 0);
    String place = "London Room";
    Training training = new Training(trainingId, "DDD", "DDD Course", beginTime, endTime, place, courseId);
    MailTemplate mailTemplate = new MailTemplate(buildTemplate(), TemplateType.Nomination);
    MailTemplateRepository mockTemplateRepo = mock(MailTemplateRepository.class);
    when(mockTemplateRepo.templateOf(TemplateType.Nomination)).thenReturn(Optional.of(mailTemplate));
    NotificationClient mockNotificationClient = mock(NotificationClient.class);
    TrainingRepository mockTrainingRepo = mock(TrainingRepository.class);
    when(mockTrainingRepo.trainingOf(trainingId)).thenReturn(Optional.empty());
    ValidDateRepository mockValidDateRepo = mock(ValidDateRepository.class);
    NotificationService notificationService = createNotificationService(
            mockTemplateRepo,
            mockNotificationClient,
            mockTrainingRepo,
            mockValidDateRepo);
    // then
    assertThatThrownBy(() -> notificationService.notifyNominee(ticket, nominator, nominee))
            .isInstanceOf(TrainingException.class)
            .hasMessageContaining(String.format("training by id {%s} was not found", trainingId));
    verify(mockTemplateRepo).templateOf(TemplateType.Nomination);
    verify(mockTrainingRepo).trainingOf(trainingId);
    verify(mockValidDateRepo, never()).validDateOf(trainingId, ValidDateType.PODeadline);
    verify(mockNotificationClient, never()).send(isA(Notification.class));
}