@Test public void testNewShiftsAlert() { ShiftDto shiftDto1 = ShiftDto.builder() .id(UUID.randomUUID().toString()) .companyId(companyId) .teamId(teamId) .jobId(jobId) .published(true) .userId(userId) .start(Instant.now().plus(2, ChronoUnit.DAYS)) .stop(Instant.now().plus(3, ChronoUnit.DAYS)) .build(); ShiftDto shiftDto2 = ShiftDto.builder() .id(UUID.randomUUID().toString()) .companyId(companyId) .teamId(teamId) .jobId(jobId) .published(true) .userId(userId) .start(Instant.now().plus(4, ChronoUnit.DAYS)) .stop(Instant.now().plus(5, ChronoUnit.DAYS)) .build(); AlertNewShiftsRequest alertNewShiftsRequest = AlertNewShiftsRequest.builder() .userId(userId) .build(); alertNewShiftsRequest.getNewShifts().add(shiftDto1); alertNewShiftsRequest.getNewShifts().add(shiftDto2); BaseResponse baseResponse = botClient.alertNewShifts(alertNewShiftsRequest); log.info(baseResponse.toString()); assertThat(baseResponse.isSuccess()).isTrue(); ArgumentCaptor<EmailRequest> argument = ArgumentCaptor.forClass(EmailRequest.class); verify(mailClient, times(1)).send(argument.capture()); EmailRequest emailRequest = argument.getValue(); log.info(emailRequest.toString()); assertThat(emailRequest.getTo()).isEqualTo(accountDto.getEmail()); assertThat(emailRequest.getName()).isEqualTo(accountDto.getName()); assertThat(emailRequest.getSubject()).isEqualTo("New Shifts Alert"); assertThat(emailRequest.getHtmlBody()).contains(accountDto.getName(), companyDto.getName(), jobDto.getName()); }
@PostMapping(value = "alert_new_shifts") public BaseResponse alertNewShifts(@RequestBody @Validated AlertNewShiftsRequest request) { alertService.alertNewShifts(request); return BaseResponse.builder().message("new shifts alerted").build(); }
AlertController { @PostMapping(value = "alert_new_shifts") public BaseResponse alertNewShifts(@RequestBody @Validated AlertNewShiftsRequest request) { alertService.alertNewShifts(request); return BaseResponse.builder().message("new shifts alerted").build(); } }
AlertController { @PostMapping(value = "alert_new_shifts") public BaseResponse alertNewShifts(@RequestBody @Validated AlertNewShiftsRequest request) { alertService.alertNewShifts(request); return BaseResponse.builder().message("new shifts alerted").build(); }  }
AlertController { @PostMapping(value = "alert_new_shifts") public BaseResponse alertNewShifts(@RequestBody @Validated AlertNewShiftsRequest request) { alertService.alertNewShifts(request); return BaseResponse.builder().message("new shifts alerted").build(); }  @PostMapping(value = "alert_new_shift") BaseResponse alertNewShift(@RequestBody @Validated AlertNewShiftRequest request); @PostMapping(value = "alert_new_shifts") BaseResponse alertNewShifts(@RequestBody @Validated AlertNewShiftsRequest request); @PostMapping(value = "alert_removed_shift") BaseResponse alertRemovedShift(@RequestBody @Validated AlertRemovedShiftRequest request); @PostMapping(value = "alert_removed_shifts") BaseResponse alertRemovedShifts(@RequestBody @Validated AlertRemovedShiftsRequest request); @PostMapping(value = "alert_changed_shifts") BaseResponse alertChangedShifts(@RequestBody @Validated AlertChangedShiftRequest request); }
AlertController { @PostMapping(value = "alert_new_shifts") public BaseResponse alertNewShifts(@RequestBody @Validated AlertNewShiftsRequest request) { alertService.alertNewShifts(request); return BaseResponse.builder().message("new shifts alerted").build(); }  @PostMapping(value = "alert_new_shift") BaseResponse alertNewShift(@RequestBody @Validated AlertNewShiftRequest request); @PostMapping(value = "alert_new_shifts") BaseResponse alertNewShifts(@RequestBody @Validated AlertNewShiftsRequest request); @PostMapping(value = "alert_removed_shift") BaseResponse alertRemovedShift(@RequestBody @Validated AlertRemovedShiftRequest request); @PostMapping(value = "alert_removed_shifts") BaseResponse alertRemovedShifts(@RequestBody @Validated AlertRemovedShiftsRequest request); @PostMapping(value = "alert_changed_shifts") BaseResponse alertChangedShifts(@RequestBody @Validated AlertChangedShiftRequest request);  }