@Test(expected = OtpNumberNotPresentException.class) public void test_should_throw_exception_when_otp_number_in_response_is_null() { final OtpRequest domainOtpRequest = OtpRequest.builder() .tenantId("tenantId") .mobileNumber("mobileNumber") .build(); final RestTemplate mockRestTemplate = mock(RestTemplate.class); otpRepository = new OtpRepository(mockRestTemplate, HOST, CREATE_OTP_URL); when(mockRestTemplate.postForObject(eq("http: any(), eq(org.egov.persistence.contract.OtpResponse.class))) .thenReturn(new org.egov.persistence.contract.OtpResponse(Otp.builder().otp(null).build())); otpRepository.fetchOtp(domainOtpRequest); }
public String fetchOtp(OtpRequest otpRequest) { final org.egov.persistence.contract.OtpRequest request = new org.egov.persistence.contract.OtpRequest(otpRequest); final OtpResponse otpResponse = restTemplate.postForObject(otpCreateUrl, request, OtpResponse.class); if(isOtpNumberAbsent(otpResponse)) { throw new OtpNumberNotPresentException(); } return otpResponse.getOtpNumber(); }
OtpRepository { public String fetchOtp(OtpRequest otpRequest) { final org.egov.persistence.contract.OtpRequest request = new org.egov.persistence.contract.OtpRequest(otpRequest); final OtpResponse otpResponse = restTemplate.postForObject(otpCreateUrl, request, OtpResponse.class); if(isOtpNumberAbsent(otpResponse)) { throw new OtpNumberNotPresentException(); } return otpResponse.getOtpNumber(); } }
OtpRepository { public String fetchOtp(OtpRequest otpRequest) { final org.egov.persistence.contract.OtpRequest request = new org.egov.persistence.contract.OtpRequest(otpRequest); final OtpResponse otpResponse = restTemplate.postForObject(otpCreateUrl, request, OtpResponse.class); if(isOtpNumberAbsent(otpResponse)) { throw new OtpNumberNotPresentException(); } return otpResponse.getOtpNumber(); } OtpRepository(RestTemplate restTemplate,
                         @Value("${otp.host}") String otpHost,
                         @Value("${otp.create.url}") String otpCreateUrl); }
OtpRepository { public String fetchOtp(OtpRequest otpRequest) { final org.egov.persistence.contract.OtpRequest request = new org.egov.persistence.contract.OtpRequest(otpRequest); final OtpResponse otpResponse = restTemplate.postForObject(otpCreateUrl, request, OtpResponse.class); if(isOtpNumberAbsent(otpResponse)) { throw new OtpNumberNotPresentException(); } return otpResponse.getOtpNumber(); } OtpRepository(RestTemplate restTemplate,
                         @Value("${otp.host}") String otpHost,
                         @Value("${otp.create.url}") String otpCreateUrl); String fetchOtp(OtpRequest otpRequest); }
OtpRepository { public String fetchOtp(OtpRequest otpRequest) { final org.egov.persistence.contract.OtpRequest request = new org.egov.persistence.contract.OtpRequest(otpRequest); final OtpResponse otpResponse = restTemplate.postForObject(otpCreateUrl, request, OtpResponse.class); if(isOtpNumberAbsent(otpResponse)) { throw new OtpNumberNotPresentException(); } return otpResponse.getOtpNumber(); } OtpRepository(RestTemplate restTemplate,
                         @Value("${otp.host}") String otpHost,
                         @Value("${otp.create.url}") String otpCreateUrl); String fetchOtp(OtpRequest otpRequest);  }