@Test public void test_should_send_sms_otp_for_password_reset() { final OtpRequest otpRequest = OtpRequest.builder().tenantId("tenant").mobileNumber("1234567890") .type(OtpRequestType.PASSWORD_RESET).userType("CITIZEN").build(); final String otpNumber = "otpNumber"; when(otpRepository.fetchOtp(otpRequest)).thenReturn(otpNumber); when(userRepository.fetchUser("1234567890", "tenant", "CITIZEN")).thenReturn(new User(1L, "foo@bar.com", "1234")); otpService.sendOtp(otpRequest); verify(otpSMSRepository).send(otpRequest, otpNumber); }
public void sendOtp(OtpRequest otpRequest) { otpRequest.validate(); if (otpRequest.isRegistrationRequestType() || otpRequest.isLoginRequestType()) { sendOtpForUserRegistration(otpRequest); } else { sendOtpForPasswordReset(otpRequest); } }
OtpService { public void sendOtp(OtpRequest otpRequest) { otpRequest.validate(); if (otpRequest.isRegistrationRequestType() || otpRequest.isLoginRequestType()) { sendOtpForUserRegistration(otpRequest); } else { sendOtpForPasswordReset(otpRequest); } } }
OtpService { public void sendOtp(OtpRequest otpRequest) { otpRequest.validate(); if (otpRequest.isRegistrationRequestType() || otpRequest.isLoginRequestType()) { sendOtpForUserRegistration(otpRequest); } else { sendOtpForPasswordReset(otpRequest); } } @Autowired  OtpService(OtpRepository otpRepository, OtpSMSRepository otpSMSSender, OtpEmailRepository otpEmailRepository,
			UserRepository userRepository); }
OtpService { public void sendOtp(OtpRequest otpRequest) { otpRequest.validate(); if (otpRequest.isRegistrationRequestType() || otpRequest.isLoginRequestType()) { sendOtpForUserRegistration(otpRequest); } else { sendOtpForPasswordReset(otpRequest); } } @Autowired  OtpService(OtpRepository otpRepository, OtpSMSRepository otpSMSSender, OtpEmailRepository otpEmailRepository,
			UserRepository userRepository); void sendOtp(OtpRequest otpRequest); }
OtpService { public void sendOtp(OtpRequest otpRequest) { otpRequest.validate(); if (otpRequest.isRegistrationRequestType() || otpRequest.isLoginRequestType()) { sendOtpForUserRegistration(otpRequest); } else { sendOtpForPasswordReset(otpRequest); } } @Autowired  OtpService(OtpRepository otpRepository, OtpSMSRepository otpSMSSender, OtpEmailRepository otpEmailRepository,
			UserRepository userRepository); void sendOtp(OtpRequest otpRequest);  }