@Test
@DisplayName("retryFraudDispostion will throw RetryableFailureException on ServiceConnectionTimeoutException")
void testRetryFraudDispositionRetryExhausted() throws IOException, ApiException {
var fraudDisposition = this.mapper.readValue(
new File("src/test/resources/test-data/valid_ficoRequestVBW.json"),
FraudDisposition.class
);
when(ficoTokenManager.getFicoAuthToken())
.thenReturn(FicoAuthToken.builder().build());
when(ficoService.getFraudTransactionResponse(any()))
.thenThrow(new ServiceConnectionTimeoutException());
assertThrows(RetryableFailureException.class,
() -> ficoRetryServiceInvoker.retryFraudDispostion(fraudDisposition));
verify(ficoService, times(2))
.getFraudTransactionResponse(any());
}
@Test
@DisplayName("retryFraudDispostion will throw RetryableFailureException on TokenGenerationException")
void testRetryFraudDispositionTokenGenerationException() throws IOException, ApiException {
var fraudDisposition = this.mapper.readValue(
new File("src/test/resources/test-data/valid_ficoRequestVBW.json"),
FraudDisposition.class
);
when(ficoTokenManager.getFicoAuthToken())
.thenThrow(new TokenGenerationException());
assertThrows(RetryableFailureException.class,
() -> ficoRetryServiceInvoker.retryFraudDispostion(fraudDisposition));
}
@Test
@DisplayName("retryFraudDispostion will throw ApiException on BadRequestException")
void testRetryFraudDispositionBadRequestException() throws IOException, ApiException {
var fraudDisposition = this.mapper.readValue(
new File("src/test/resources/test-data/valid_ficoRequestVBW.json"),
FraudDisposition.class
);
when(ficoTokenManager.getFicoAuthToken())
.thenReturn(FicoAuthToken.builder().build());
when(ficoService.getFraudTransactionResponse(any()))
.thenThrow(new BadRequestException());
assertThrows(ApiException.class,
() -> ficoRetryServiceInvoker.retryFraudDispostion(fraudDisposition));
}
@Test
@DisplayName("retryFraudDispostion will throw ApiException on RequestReadTimeoutException")
void testRetryFraudDispositionRequestReadTimeoutException() throws IOException, ApiException {
var fraudDisposition = this.mapper.readValue(
new File("src/test/resources/test-data/valid_ficoRequestVBW.json"),
FraudDisposition.class
);
when(ficoTokenManager.getFicoAuthToken())
.thenReturn(FicoAuthToken.builder().build());
when(ficoService.getFraudTransactionResponse(any()))
.thenThrow(new RequestReadTimeoutException());
assertThrows(ApiException.class,
() -> ficoRetryServiceInvoker.retryFraudDispostion(fraudDisposition));
}
@Test
@DisplayName("retryFraudDispostion will throw ApiException on ServiceGeneralException")
void testRetryFraudDispositionServiceGeneralException() throws IOException, ApiException {
var fraudDisposition = this.mapper.readValue(
new File("src/test/resources/test-data/valid_ficoRequestVBW.json"),
FraudDisposition.class
);
when(ficoTokenManager.getFicoAuthToken())
.thenReturn(FicoAuthToken.builder().build());
when(ficoService.getFraudTransactionResponse(any()))
.thenThrow(new ServiceGeneralException());
assertThrows(ApiException.class,
() -> ficoRetryServiceInvoker.retryFraudDispostion(fraudDisposition));
}
@Test
@DisplayName("retryFraudDispostion will throw ApiException on generic Exception")
void testRetryFraudDispositionGenericException() throws IOException, ApiException {
var fraudDisposition = this.mapper.readValue(
new File("src/test/resources/test-data/valid_ficoRequestVBW.json"),
FraudDisposition.class
);
when(ficoTokenManager.getFicoAuthToken())
.thenReturn(FicoAuthToken.builder().build());
when(ficoService.getFraudTransactionResponse(any()))
.thenThrow(new RuntimeException("unexpected error"));
assertThrows(ApiException.class,
() -> ficoRetryServiceInvoker.retryFraudDispostion(fraudDisposition));
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)