use of org.folio.rest.jaxrs.model.HoldingsLoadingStatus in project mod-kb-ebsco-java by folio-org.
the class LoadHoldingsStatusImplTest method shouldReturnStatusNotStarted.
@Test
public void shouldReturnStatusNotStarted() {
setupDefaultLoadKBConfiguration();
final HoldingsLoadingStatus status = getWithOk(STUB_HOLDINGS_LOAD_STATUS_BY_ID_URL, STUB_TOKEN_HEADER).body().as(HoldingsLoadingStatus.class);
assertThat(status.getData().getAttributes().getStatus().getName(), equalTo(LoadStatusNameEnum.NOT_STARTED));
}
use of org.folio.rest.jaxrs.model.HoldingsLoadingStatus in project mod-kb-ebsco-java by folio-org.
the class LoadHoldingsStatusImplTest method shouldReturnErrorWhenRMAPIReturnsError.
@Test
public void shouldReturnErrorWhenRMAPIReturnsError(TestContext context) {
setupDefaultLoadKBConfiguration();
mockGet(new EqualToPattern(RMAPI_HOLDINGS_STATUS_URL), SC_INTERNAL_SERVER_ERROR);
Async finishedAsync = context.async(SNAPSHOT_RETRIES);
handleStatusChange(FAILED, holdingsStatusRepository, o -> finishedAsync.countDown());
postWithStatus(HOLDINGS_LOAD_BY_ID_URL, "", SC_NO_CONTENT, STUB_TOKEN_HEADER);
finishedAsync.await(TIMEOUT);
final HoldingsLoadingStatus status = getWithOk(STUB_HOLDINGS_LOAD_STATUS_BY_ID_URL, STUB_TOKEN_HEADER).body().as(HoldingsLoadingStatus.class);
assertThat(status.getData().getAttributes().getStatus().getName(), equalTo(FAILED));
}
use of org.folio.rest.jaxrs.model.HoldingsLoadingStatus in project mod-kb-ebsco-java by folio-org.
the class LoadHoldingsStatusImplTest method shouldReturnStatusPopulatingStagingArea.
@Test
public void shouldReturnStatusPopulatingStagingArea(TestContext context) throws IOException, URISyntaxException {
setupDefaultLoadKBConfiguration();
mockResponseList(new UrlPathPattern(new EqualToPattern(RMAPI_HOLDINGS_STATUS_URL), false), new ResponseDefinitionBuilder().withBody(readFile("responses/rmapi/holdings/status/get-status-in-progress.json")).withStatus(200), new ResponseDefinitionBuilder().withBody(readFile("responses/rmapi/holdings/status/get-status-completed.json")).withStatus(200));
Async startedAsync = context.async();
Handler<DeliveryContext<LoadHoldingsMessage>> interceptor = interceptAndContinue(LOAD_FACADE_ADDRESS, CREATE_SNAPSHOT_ACTION, message -> startedAsync.complete());
vertx.eventBus().addOutboundInterceptor(interceptor);
interceptors.add(interceptor);
Async finishedAsync = context.async();
interceptor = interceptAndStop(HOLDINGS_SERVICE_ADDRESS, SNAPSHOT_CREATED_ACTION, message -> finishedAsync.complete());
vertx.eventBus().addOutboundInterceptor(interceptor);
interceptors.add(interceptor);
postWithStatus(HOLDINGS_LOAD_BY_ID_URL, "", SC_NO_CONTENT, STUB_TOKEN_HEADER);
startedAsync.await(TIMEOUT);
final HoldingsLoadingStatus status = getWithOk(STUB_HOLDINGS_LOAD_STATUS_BY_ID_URL, STUB_TOKEN_HEADER).body().as(HoldingsLoadingStatus.class);
assertThat(status.getData().getAttributes().getStatus().getDetail(), equalTo(LoadStatusNameDetailEnum.POPULATING_STAGING_AREA));
finishedAsync.await(TIMEOUT);
}
use of org.folio.rest.jaxrs.model.HoldingsLoadingStatus in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturnStatusNotStartedOnKbCredentialsCreation.
@Test
public void shouldReturnStatusNotStartedOnKbCredentialsCreation() {
KbCredentialsPostRequest kbCredentialsPostRequest = new KbCredentialsPostRequest().withData(stubbedCredentials());
String postBody = Json.encode(kbCredentialsPostRequest);
mockVerifyValidCredentialsRequest();
KbCredentials actual = postWithStatus(KB_CREDENTIALS_ENDPOINT, postBody, SC_CREATED, STUB_TOKEN_HEADER).as(KbCredentials.class);
final HoldingsLoadingStatus status = getStatus(actual.getId(), vertx);
assertEquals(LoadStatusNameEnum.NOT_STARTED, status.getData().getAttributes().getStatus().getName());
final RetryStatus retryStatus = getRetryStatus(actual.getId(), vertx);
assertThat(retryStatus, notNullValue());
}
use of org.folio.rest.jaxrs.model.HoldingsLoadingStatus in project mod-kb-ebsco-java by folio-org.
the class DefaultLoadHoldingsImplTest method shouldStartLoadingWhenStatusInProgressAndStartedMoreThen5DaysBefore.
@Test
public void shouldStartLoadingWhenStatusInProgressAndStartedMoreThen5DaysBefore(TestContext context) throws IOException, URISyntaxException {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
OffsetDateTime dateTime = OffsetDateTime.now().minus(6, ChronoUnit.DAYS);
HoldingsLoadingStatus statusLoadingHoldings = getStatusLoadingHoldings(1000, 500, 10, 5);
statusLoadingHoldings.getData().getAttributes().setUpdated(dateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
saveStatus(STUB_CREDENTIALS_ID, statusLoadingHoldings, PROCESS_ID, dateTime, vertx);
insertRetryStatus(STUB_CREDENTIALS_ID, vertx);
runPostHoldingsWithMocks(context);
final List<DbHoldingInfo> holdingsList = HoldingsTestUtil.getHoldings(vertx);
assertThat(holdingsList.size(), Matchers.notNullValue());
}
Aggregations