use of org.folio.service.holdings.HoldingConstants.SNAPSHOT_FAILED_ACTION in project mod-kb-ebsco-java by folio-org.
the class DefaultLoadHoldingsImplTest method shouldStopRetryingAfterMultipleFailures.
@Test
public void shouldStopRetryingAfterMultipleFailures(TestContext context) throws IOException, URISyntaxException {
setupDefaultLoadKBConfiguration();
mockGet(new EqualToPattern(RMAPI_HOLDINGS_STATUS_URL), RMAPI_RESPONSE_HOLDINGS_STATUS_COMPLETED);
UrlPathPattern urlPattern = new UrlPathPattern(new EqualToPattern(RMAPI_POST_HOLDINGS_URL), false);
stubFor(post(urlPattern).willReturn(new ResponseDefinitionBuilder().withStatus(500)));
Async async = context.async(TEST_SNAPSHOT_RETRY_COUNT);
interceptor = interceptAndContinue(HOLDINGS_SERVICE_ADDRESS, SNAPSHOT_FAILED_ACTION, o -> async.countDown());
vertx.eventBus().addOutboundInterceptor(interceptor);
postWithStatus(HOLDINGS_LOAD_BY_ID_URL, "", SC_NO_CONTENT, STUB_TOKEN_HEADER);
async.await(TIMEOUT);
Async retryStatusAsync = context.async();
retryStatusRepository.findByCredentialsId(UUID.fromString(STUB_CREDENTIALS_ID), STUB_TENANT).thenAccept(status -> {
boolean timerExists = vertx.cancelTimer(status.getTimerId());
context.assertEquals(0, status.getRetryAttemptsLeft());
context.assertFalse(timerExists);
retryStatusAsync.complete();
});
retryStatusAsync.await(TIMEOUT);
verify(TEST_SNAPSHOT_RETRY_COUNT, RequestPatternBuilder.newRequestPattern(RequestMethod.POST, urlPattern));
}
use of org.folio.service.holdings.HoldingConstants.SNAPSHOT_FAILED_ACTION in project mod-kb-ebsco-java by folio-org.
the class TransactionLoadHoldingsImplTest method shouldStopRetryingAfterMultipleFailures.
@Test
public void shouldStopRetryingAfterMultipleFailures(TestContext context) throws IOException, URISyntaxException {
mockEmptyTransactionList();
mockGet(new EqualToPattern(getStatusEndpoint()), RMAPI_RESPONSE_TRANSACTION_STATUS_COMPLETED);
UrlPathPattern urlPattern = new UrlPathPattern(new EqualToPattern(RMAPI_POST_TRANSACTIONS_HOLDINGS_URL), false);
stubFor(post(urlPattern).willReturn(new ResponseDefinitionBuilder().withStatus(500)));
Async async = context.async(TEST_SNAPSHOT_RETRY_COUNT);
interceptor = interceptAndContinue(HOLDINGS_SERVICE_ADDRESS, SNAPSHOT_FAILED_ACTION, o -> async.countDown());
vertx.eventBus().addOutboundInterceptor(interceptor);
postWithStatus(HOLDINGS_LOAD_BY_ID_URL, "", SC_NO_CONTENT, STUB_TOKEN_HEADER);
async.await(TIMEOUT);
Async retryStatusAsync = context.async();
retryStatusRepository.findByCredentialsId(UUID.fromString(STUB_CREDENTIALS_ID), STUB_TENANT).thenAccept(status -> {
boolean timerExists = vertx.cancelTimer(status.getTimerId());
context.assertEquals(0, status.getRetryAttemptsLeft());
context.assertFalse(timerExists);
retryStatusAsync.complete();
});
retryStatusAsync.await(TIMEOUT);
verify(TEST_SNAPSHOT_RETRY_COUNT, RequestPatternBuilder.newRequestPattern(RequestMethod.POST, urlPattern));
}
Aggregations