@Test public void testOnboardingWorker() { String userId = UUID.randomUUID().toString(); AccountDto accountDto = AccountDto.builder() .name("test_user001") .phoneNumber("11111111111") .email("test_user001@staffjoy.xyz") .id(userId) .memberSince(Instant.now().minus(30, ChronoUnit.DAYS)) .confirmedAndActive(true) .photoUrl("https: .build(); when(accountClient.getAccount(AuthConstant.AUTHORIZATION_BOT_SERVICE, userId)) .thenReturn(new GenericAccountResponse(accountDto)); String companyId = UUID.randomUUID().toString(); CompanyDto companyDto = CompanyDto.builder() .name("test_company001") .defaultTimezone(TimeZone.getDefault().getID()) .defaultDayWeekStarts("Monday") .id(companyId) .build(); when(companyClient.getCompany(AuthConstant.AUTHORIZATION_BOT_SERVICE, companyId)) .thenReturn(new GenericCompanyResponse(companyDto)); when(mailClient.send(any(EmailRequest.class))).thenReturn(BaseResponse.builder().message("mail sent").build()); BaseResponse baseResponse = botClient.onboardWorker(OnboardWorkerRequest.builder().companyId(companyId).userId(userId).build()); 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("Onboarding Message"); assertThat(emailRequest.getHtmlBody()).contains(userId, accountDto.getName(), companyDto.getName()); }
@PostMapping(value = "/onboard_worker") public BaseResponse onboardWorker(@RequestBody @Validated OnboardWorkerRequest request) { onBoardingService.onboardWorker(request); return BaseResponse.builder().message("onboarded worker").build(); }
OnBoardingController { @PostMapping(value = "/onboard_worker") public BaseResponse onboardWorker(@RequestBody @Validated OnboardWorkerRequest request) { onBoardingService.onboardWorker(request); return BaseResponse.builder().message("onboarded worker").build(); } }
OnBoardingController { @PostMapping(value = "/onboard_worker") public BaseResponse onboardWorker(@RequestBody @Validated OnboardWorkerRequest request) { onBoardingService.onboardWorker(request); return BaseResponse.builder().message("onboarded worker").build(); }  }
OnBoardingController { @PostMapping(value = "/onboard_worker") public BaseResponse onboardWorker(@RequestBody @Validated OnboardWorkerRequest request) { onBoardingService.onboardWorker(request); return BaseResponse.builder().message("onboarded worker").build(); }  @PostMapping(value = "/onboard_worker") BaseResponse onboardWorker(@RequestBody @Validated OnboardWorkerRequest request); }
OnBoardingController { @PostMapping(value = "/onboard_worker") public BaseResponse onboardWorker(@RequestBody @Validated OnboardWorkerRequest request) { onBoardingService.onboardWorker(request); return BaseResponse.builder().message("onboarded worker").build(); }  @PostMapping(value = "/onboard_worker") BaseResponse onboardWorker(@RequestBody @Validated OnboardWorkerRequest request);  }