@Test public void testShouldReturnFalseWhenOtpIdentityDoesNotMatch() throws Exception { server.expect(once(), requestTo("http: .andExpect(content().string(new Resources().getFileContents("otpSearchSuccessRequest.json"))) .andRespond(withSuccess(new Resources().getFileContents("otpSearchIdentityDifferentResponse.json"), MediaType.APPLICATION_JSON_UTF8)); final OtpValidationRequest request = buildRequest(); boolean isOtpValidated = otpRepository.isOtpValidationComplete(request); server.verify(); assertFalse(isOtpValidated); }
public boolean isOtpValidationComplete(OtpValidationRequest request) { Otp otp = Otp.builder().tenantId(request.getTenantId()).uuid(request.getOtpReference()).build(); OtpRequest otpRequest = new OtpRequest(otp); OtpResponse otpResponse = restTemplate.postForObject(otpSearchEndpoint, otpRequest, OtpResponse.class); return otpResponse.isValidationComplete(request.getMobileNumber()); }
OtpRepository { public boolean isOtpValidationComplete(OtpValidationRequest request) { Otp otp = Otp.builder().tenantId(request.getTenantId()).uuid(request.getOtpReference()).build(); OtpRequest otpRequest = new OtpRequest(otp); OtpResponse otpResponse = restTemplate.postForObject(otpSearchEndpoint, otpRequest, OtpResponse.class); return otpResponse.isValidationComplete(request.getMobileNumber()); } }
OtpRepository { public boolean isOtpValidationComplete(OtpValidationRequest request) { Otp otp = Otp.builder().tenantId(request.getTenantId()).uuid(request.getOtpReference()).build(); OtpRequest otpRequest = new OtpRequest(otp); OtpResponse otpResponse = restTemplate.postForObject(otpSearchEndpoint, otpRequest, OtpResponse.class); return otpResponse.isValidationComplete(request.getMobileNumber()); } @Autowired  OtpRepository(@Value("${egov.otp.host}") String otpServiceHost,
                         @Value("${egov.services.otp.search_otp}") String otpSearchContextEndpoint,
                         @Value("${egov.services.otp.validate_otp}") String otpValidateEndpoint,
                         RestTemplate restTemplate); }
OtpRepository { public boolean isOtpValidationComplete(OtpValidationRequest request) { Otp otp = Otp.builder().tenantId(request.getTenantId()).uuid(request.getOtpReference()).build(); OtpRequest otpRequest = new OtpRequest(otp); OtpResponse otpResponse = restTemplate.postForObject(otpSearchEndpoint, otpRequest, OtpResponse.class); return otpResponse.isValidationComplete(request.getMobileNumber()); } @Autowired  OtpRepository(@Value("${egov.otp.host}") String otpServiceHost,
                         @Value("${egov.services.otp.search_otp}") String otpSearchContextEndpoint,
                         @Value("${egov.services.otp.validate_otp}") String otpValidateEndpoint,
                         RestTemplate restTemplate); boolean isOtpValidationComplete(OtpValidationRequest request); boolean validateOtp(OtpValidateRequest request); }
OtpRepository { public boolean isOtpValidationComplete(OtpValidationRequest request) { Otp otp = Otp.builder().tenantId(request.getTenantId()).uuid(request.getOtpReference()).build(); OtpRequest otpRequest = new OtpRequest(otp); OtpResponse otpResponse = restTemplate.postForObject(otpSearchEndpoint, otpRequest, OtpResponse.class); return otpResponse.isValidationComplete(request.getMobileNumber()); } @Autowired  OtpRepository(@Value("${egov.otp.host}") String otpServiceHost,
                         @Value("${egov.services.otp.search_otp}") String otpSearchContextEndpoint,
                         @Value("${egov.services.otp.validate_otp}") String otpValidateEndpoint,
                         RestTemplate restTemplate); boolean isOtpValidationComplete(OtpValidationRequest request); boolean validateOtp(OtpValidateRequest request);  }