Search in sources :

Example 1 with PROCESS_ID

use of org.folio.util.HoldingsStatusUtil.PROCESS_ID in project mod-kb-ebsco-java by folio-org.

the class DefaultLoadHoldingsImplTest method shouldStartLoadingWhenStatusInProgressAndProcessTimedOut.

@Test
public void shouldStartLoadingWhenStatusInProgressAndProcessTimedOut() {
    setupDefaultLoadKBConfiguration();
    HoldingsLoadingStatus status = getStatusLoadingHoldings(1000, 500, 10, 5);
    status.getData().getAttributes().setUpdated(POSTGRES_TIMESTAMP_FORMATTER.format(OffsetDateTime.now().minus(10, ChronoUnit.DAYS)));
    saveStatus(STUB_CREDENTIALS_ID, status, PROCESS_ID, vertx);
    interceptor = interceptAndStop(LOAD_FACADE_ADDRESS, CREATE_SNAPSHOT_ACTION, message -> {
    });
    vertx.eventBus().addOutboundInterceptor(interceptor);
    postWithStatus(HOLDINGS_LOAD_BY_ID_URL, "", SC_NO_CONTENT, STUB_TOKEN_HEADER);
}
Also used : HoldingsLoadingStatusFactory.getStatusLoadingHoldings(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusLoadingHoldings) RMAPI_POST_HOLDINGS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_POST_HOLDINGS_URL) TestContext(io.vertx.ext.unit.TestContext) STUB_TOKEN_HEADER(org.folio.util.KbCredentialsTestUtil.STUB_TOKEN_HEADER) KbCredentialsTestUtil.saveKbCredentials(org.folio.util.KbCredentialsTestUtil.saveKbCredentials) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) HoldingsMessage(org.folio.service.holdings.message.HoldingsMessage) URISyntaxException(java.net.URISyntaxException) KBTestUtil.interceptAndContinue(org.folio.util.KBTestUtil.interceptAndContinue) Autowired(org.springframework.beans.factory.annotation.Autowired) RMAPI_HOLDINGS_STATUS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_HOLDINGS_STATUS_URL) LoadStatusNameEnum(org.folio.rest.jaxrs.model.LoadStatusNameEnum) LoadHoldingsMessage(org.folio.service.holdings.message.LoadHoldingsMessage) HoldingsLoadingStatusFactory.getStatusCompleted(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusCompleted) MockitoAnnotations(org.mockito.MockitoAnnotations) Mockito.doAnswer(org.mockito.Mockito.doAnswer) After(org.junit.After) Spy(org.mockito.Spy) HoldingsStatusUtil.saveStatusNotStarted(org.folio.util.HoldingsStatusUtil.saveStatusNotStarted) JsonObject(io.vertx.core.json.JsonObject) KBTestUtil.clearDataFromTable(org.folio.util.KBTestUtil.clearDataFromTable) KBTestUtil.interceptAndStop(org.folio.util.KBTestUtil.interceptAndStop) HoldingsStatusAuditTestUtil(org.folio.util.HoldingsStatusAuditTestUtil) WireMock.post(com.github.tomakehurst.wiremock.client.WireMock.post) SC_INTERNAL_SERVER_ERROR(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR) LoadServiceFacade(org.folio.service.holdings.LoadServiceFacade) SNAPSHOT_FAILED_ACTION(org.folio.service.holdings.HoldingConstants.SNAPSHOT_FAILED_ACTION) ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) Matchers.allOf(org.hamcrest.Matchers.allOf) CREATE_SNAPSHOT_ACTION(org.folio.service.holdings.HoldingConstants.CREATE_SNAPSHOT_ACTION) SNAPSHOT_CREATED_ACTION(org.folio.service.holdings.HoldingConstants.SNAPSHOT_CREATED_ACTION) STUB_TENANT(org.folio.test.util.TestUtil.STUB_TENANT) UUID(java.util.UUID) HoldingsService(org.folio.service.holdings.HoldingsService) Collectors(java.util.stream.Collectors) HOLDINGS_SERVICE_ADDRESS(org.folio.service.holdings.HoldingConstants.HOLDINGS_SERVICE_ADDRESS) RequestPatternBuilder(com.github.tomakehurst.wiremock.matching.RequestPatternBuilder) KB_CREDENTIALS_TABLE_NAME(org.folio.repository.kbcredentials.KbCredentialsTableConstants.KB_CREDENTIALS_TABLE_NAME) List(java.util.List) StringValuePattern(com.github.tomakehurst.wiremock.matching.StringValuePattern) OffsetDateTime(java.time.OffsetDateTime) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) LoadStatusAttributes(org.folio.rest.jaxrs.model.LoadStatusAttributes) Configuration(org.folio.holdingsiq.model.Configuration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) SC_NO_CONTENT(org.apache.http.HttpStatus.SC_NO_CONTENT) Async(io.vertx.ext.unit.Async) WireMockTestBase(org.folio.rest.impl.WireMockTestBase) HoldingsTestUtil(org.folio.util.HoldingsTestUtil) BeforeClass(org.junit.BeforeClass) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) POSTGRES_TIMESTAMP_FORMATTER(org.folio.service.holdings.HoldingsServiceImpl.POSTGRES_TIMESTAMP_FORMATTER) TestUtil.mockResponseList(org.folio.test.util.TestUtil.mockResponseList) ArrayList(java.util.ArrayList) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) DbHoldingInfo(org.folio.repository.holdings.DbHoldingInfo) COMPLETED(org.folio.rest.jaxrs.model.LoadStatusNameEnum.COMPLETED) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) HoldingsRetryStatusTestUtil.insertRetryStatus(org.folio.util.HoldingsRetryStatusTestUtil.insertRetryStatus) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) DeliveryContext(io.vertx.core.eventbus.DeliveryContext) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) TestUtil.mockGet(org.folio.test.util.TestUtil.mockGet) PROCESS_ID(org.folio.util.HoldingsStatusUtil.PROCESS_ID) Assert.assertTrue(org.junit.Assert.assertTrue) Matchers(org.hamcrest.Matchers) HoldingsLoadingStatus(org.folio.rest.jaxrs.model.HoldingsLoadingStatus) IOException(java.io.IOException) Test(org.junit.Test) LoadStatusNameDetailEnum(org.folio.rest.jaxrs.model.LoadStatusNameDetailEnum) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) WireMock.verify(com.github.tomakehurst.wiremock.client.WireMock.verify) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) STUB_CREDENTIALS_NAME(org.folio.util.KbCredentialsTestUtil.STUB_CREDENTIALS_NAME) Consumer(java.util.function.Consumer) LOAD_FACADE_ADDRESS(org.folio.service.holdings.HoldingConstants.LOAD_FACADE_ADDRESS) HoldingsStatusRepositoryImpl(org.folio.repository.holdings.status.HoldingsStatusRepositoryImpl) ChronoUnit(java.time.temporal.ChronoUnit) HoldingsStatusUtil.saveStatus(org.folio.util.HoldingsStatusUtil.saveStatus) RetryStatusRepository(org.folio.repository.holdings.status.retry.RetryStatusRepository) HoldingsStatusAuditTestUtil.saveStatusAudit(org.folio.util.HoldingsStatusAuditTestUtil.saveStatusAudit) DateTimeFormatter(java.time.format.DateTimeFormatter) Matcher(org.hamcrest.Matcher) WireMock.stubFor(com.github.tomakehurst.wiremock.client.WireMock.stubFor) SC_CONFLICT(org.apache.http.HttpStatus.SC_CONFLICT) TestUtil.readFile(org.folio.test.util.TestUtil.readFile) RequestMethod(com.github.tomakehurst.wiremock.http.RequestMethod) Handler(io.vertx.core.Handler) SAVE_HOLDINGS_ACTION(org.folio.service.holdings.HoldingConstants.SAVE_HOLDINGS_ACTION) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) HoldingsLoadingStatus(org.folio.rest.jaxrs.model.HoldingsLoadingStatus) Test(org.junit.Test)

Aggregations

ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)1 WireMock.post (com.github.tomakehurst.wiremock.client.WireMock.post)1 WireMock.stubFor (com.github.tomakehurst.wiremock.client.WireMock.stubFor)1 WireMock.verify (com.github.tomakehurst.wiremock.client.WireMock.verify)1 RequestMethod (com.github.tomakehurst.wiremock.http.RequestMethod)1 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)1 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)1 RequestPatternBuilder (com.github.tomakehurst.wiremock.matching.RequestPatternBuilder)1 StringValuePattern (com.github.tomakehurst.wiremock.matching.StringValuePattern)1 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)1 Handler (io.vertx.core.Handler)1 DeliveryContext (io.vertx.core.eventbus.DeliveryContext)1 JsonObject (io.vertx.core.json.JsonObject)1 Async (io.vertx.ext.unit.Async)1 TestContext (io.vertx.ext.unit.TestContext)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 OffsetDateTime (java.time.OffsetDateTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1