Search in sources :

Example 1 with ConfigurationMessage

use of org.folio.service.holdings.message.ConfigurationMessage in project mod-kb-ebsco-java by folio-org.

the class TransactionLoadServiceFacadeTest method shouldCreateSnapshotUsingExistingTransactionIfItIsInProgress.

@Test
public void shouldCreateSnapshotUsingExistingTransactionIfItIsInProgress(TestContext context) throws IOException, URISyntaxException {
    Async async = context.async();
    mockGetWithBody(new EqualToPattern(RMAPI_TRANSACTIONS_URL), readFile("responses/rmapi/holdings/status/get-transaction-list-in-progress.json"));
    mockResponseList(new UrlPathPattern(new EqualToPattern(getStatusEndpoint(TRANSACTION_ID)), false), new ResponseDefinitionBuilder().withBody(readFile("responses/rmapi/holdings/status/get-transaction-status-completed.json")));
    mockPostHoldings();
    interceptor = interceptAndStop(HOLDINGS_SERVICE_ADDRESS, SNAPSHOT_CREATED_ACTION, message -> async.complete());
    vertx.eventBus().addOutboundInterceptor(interceptor);
    loadServiceFacade.createSnapshot(new ConfigurationMessage(stubConfiguration, STUB_CREDENTIALS_ID, STUB_TENANT));
    async.await(TIMEOUT);
    assertTrue(async.isSucceeded());
}
Also used : ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) TestContext(io.vertx.ext.unit.TestContext) KbCredentialsTestUtil.saveKbCredentials(org.folio.util.KbCredentialsTestUtil.saveKbCredentials) URISyntaxException(java.net.URISyntaxException) Autowired(org.springframework.beans.factory.annotation.Autowired) LoadHoldingsMessage(org.folio.service.holdings.message.LoadHoldingsMessage) After(org.junit.After) HoldingsStatusUtil.saveStatusNotStarted(org.folio.util.HoldingsStatusUtil.saveStatusNotStarted) TransactionId(org.folio.holdingsiq.model.TransactionId) KBTestUtil.clearDataFromTable(org.folio.util.KBTestUtil.clearDataFromTable) KBTestUtil.interceptAndStop(org.folio.util.KBTestUtil.interceptAndStop) ZoneOffset(java.time.ZoneOffset) WireMock.post(com.github.tomakehurst.wiremock.client.WireMock.post) HoldingsTransactionIdsList(org.folio.holdingsiq.model.HoldingsTransactionIdsList) ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) HOLDINGS_STATUS_TIME_FORMATTER(org.folio.service.holdings.AbstractLoadServiceFacade.HOLDINGS_STATUS_TIME_FORMATTER) SNAPSHOT_CREATED_ACTION(org.folio.service.holdings.HoldingConstants.SNAPSHOT_CREATED_ACTION) STUB_TENANT(org.folio.test.util.TestUtil.STUB_TENANT) RMAPI_TRANSACTIONS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_TRANSACTIONS_URL) HOLDINGS_SERVICE_ADDRESS(org.folio.service.holdings.HoldingConstants.HOLDINGS_SERVICE_ADDRESS) KB_CREDENTIALS_TABLE_NAME(org.folio.repository.kbcredentials.KbCredentialsTableConstants.KB_CREDENTIALS_TABLE_NAME) Configuration(org.folio.holdingsiq.model.Configuration) TransactionLoadServiceFacade(org.folio.service.holdings.TransactionLoadServiceFacade) Async(io.vertx.ext.unit.Async) WireMockTestBase(org.folio.rest.impl.WireMockTestBase) Json(io.vertx.core.json.Json) LocalDateTime(java.time.LocalDateTime) RunWith(org.junit.runner.RunWith) WireMock.postRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor) TestUtil.mockResponseList(org.folio.test.util.TestUtil.mockResponseList) WireMock(com.github.tomakehurst.wiremock.client.WireMock) HoldingsRetryStatusTestUtil.insertRetryStatus(org.folio.util.HoldingsRetryStatusTestUtil.insertRetryStatus) Before(org.junit.Before) TestUtil.mockGetWithBody(org.folio.test.util.TestUtil.mockGetWithBody) DeliveryContext(io.vertx.core.eventbus.DeliveryContext) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RMAPI_TRANSACTION_STATUS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_TRANSACTION_STATUS_URL) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) HoldingsLoadTransactionStatus(org.folio.holdingsiq.model.HoldingsLoadTransactionStatus) TestUtil.readJsonFile(org.folio.test.util.TestUtil.readJsonFile) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) HoldingsDownloadTransaction(org.folio.holdingsiq.model.HoldingsDownloadTransaction) STUB_CREDENTIALS_NAME(org.folio.util.KbCredentialsTestUtil.STUB_CREDENTIALS_NAME) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) WireMock.stubFor(com.github.tomakehurst.wiremock.client.WireMock.stubFor) TestUtil.readFile(org.folio.test.util.TestUtil.readFile) RMAPI_POST_TRANSACTIONS_HOLDINGS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_POST_TRANSACTIONS_HOLDINGS_URL) Handler(io.vertx.core.Handler) Collections(java.util.Collections) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) Async(io.vertx.ext.unit.Async) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) Test(org.junit.Test)

Example 2 with ConfigurationMessage

use of org.folio.service.holdings.message.ConfigurationMessage in project mod-kb-ebsco-java by folio-org.

the class TransactionLoadServiceFacadeTest method shouldNotCreateSnapshotIfItWasRecentlyCreated.

@Test
public void shouldNotCreateSnapshotIfItWasRecentlyCreated(TestContext context) throws IOException, URISyntaxException {
    Async async = context.async();
    String now = HOLDINGS_STATUS_TIME_FORMATTER.format(LocalDateTime.now(ZoneOffset.UTC));
    HoldingsTransactionIdsList idList = readJsonFile("responses/rmapi/holdings/status/get-transaction-list.json", HoldingsTransactionIdsList.class);
    HoldingsDownloadTransaction firstTransaction = idList.getHoldingsDownloadTransactionIds().get(0);
    idList.getHoldingsDownloadTransactionIds().set(0, firstTransaction.toBuilder().creationDate(now).build());
    HoldingsLoadTransactionStatus status = readJsonFile("responses/rmapi/holdings/status/get-transaction-status-completed.json", HoldingsLoadTransactionStatus.class).toBuilder().creationDate(now).build();
    mockGetWithBody(new EqualToPattern(RMAPI_TRANSACTIONS_URL), Json.encode(idList));
    mockGetWithBody(new EqualToPattern(getStatusEndpoint(TRANSACTION_ID)), Json.encode(status));
    mockPostHoldings();
    interceptor = interceptAndStop(HOLDINGS_SERVICE_ADDRESS, SNAPSHOT_CREATED_ACTION, message -> async.complete());
    vertx.eventBus().addOutboundInterceptor(interceptor);
    loadServiceFacade.createSnapshot(new ConfigurationMessage(stubConfiguration, STUB_CREDENTIALS_ID, STUB_TENANT));
    async.await(TIMEOUT);
    WireMock.verify(0, postRequestedFor(new UrlPathPattern(new EqualToPattern(RMAPI_POST_TRANSACTIONS_HOLDINGS_URL), false)));
}
Also used : HoldingsDownloadTransaction(org.folio.holdingsiq.model.HoldingsDownloadTransaction) TestContext(io.vertx.ext.unit.TestContext) KbCredentialsTestUtil.saveKbCredentials(org.folio.util.KbCredentialsTestUtil.saveKbCredentials) URISyntaxException(java.net.URISyntaxException) Autowired(org.springframework.beans.factory.annotation.Autowired) LoadHoldingsMessage(org.folio.service.holdings.message.LoadHoldingsMessage) After(org.junit.After) HoldingsStatusUtil.saveStatusNotStarted(org.folio.util.HoldingsStatusUtil.saveStatusNotStarted) TransactionId(org.folio.holdingsiq.model.TransactionId) KBTestUtil.clearDataFromTable(org.folio.util.KBTestUtil.clearDataFromTable) KBTestUtil.interceptAndStop(org.folio.util.KBTestUtil.interceptAndStop) ZoneOffset(java.time.ZoneOffset) WireMock.post(com.github.tomakehurst.wiremock.client.WireMock.post) HoldingsTransactionIdsList(org.folio.holdingsiq.model.HoldingsTransactionIdsList) ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) HOLDINGS_STATUS_TIME_FORMATTER(org.folio.service.holdings.AbstractLoadServiceFacade.HOLDINGS_STATUS_TIME_FORMATTER) SNAPSHOT_CREATED_ACTION(org.folio.service.holdings.HoldingConstants.SNAPSHOT_CREATED_ACTION) STUB_TENANT(org.folio.test.util.TestUtil.STUB_TENANT) RMAPI_TRANSACTIONS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_TRANSACTIONS_URL) HOLDINGS_SERVICE_ADDRESS(org.folio.service.holdings.HoldingConstants.HOLDINGS_SERVICE_ADDRESS) KB_CREDENTIALS_TABLE_NAME(org.folio.repository.kbcredentials.KbCredentialsTableConstants.KB_CREDENTIALS_TABLE_NAME) Configuration(org.folio.holdingsiq.model.Configuration) TransactionLoadServiceFacade(org.folio.service.holdings.TransactionLoadServiceFacade) Async(io.vertx.ext.unit.Async) WireMockTestBase(org.folio.rest.impl.WireMockTestBase) Json(io.vertx.core.json.Json) LocalDateTime(java.time.LocalDateTime) RunWith(org.junit.runner.RunWith) WireMock.postRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor) TestUtil.mockResponseList(org.folio.test.util.TestUtil.mockResponseList) WireMock(com.github.tomakehurst.wiremock.client.WireMock) HoldingsRetryStatusTestUtil.insertRetryStatus(org.folio.util.HoldingsRetryStatusTestUtil.insertRetryStatus) Before(org.junit.Before) TestUtil.mockGetWithBody(org.folio.test.util.TestUtil.mockGetWithBody) DeliveryContext(io.vertx.core.eventbus.DeliveryContext) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RMAPI_TRANSACTION_STATUS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_TRANSACTION_STATUS_URL) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) HoldingsLoadTransactionStatus(org.folio.holdingsiq.model.HoldingsLoadTransactionStatus) TestUtil.readJsonFile(org.folio.test.util.TestUtil.readJsonFile) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) HoldingsDownloadTransaction(org.folio.holdingsiq.model.HoldingsDownloadTransaction) STUB_CREDENTIALS_NAME(org.folio.util.KbCredentialsTestUtil.STUB_CREDENTIALS_NAME) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) WireMock.stubFor(com.github.tomakehurst.wiremock.client.WireMock.stubFor) TestUtil.readFile(org.folio.test.util.TestUtil.readFile) RMAPI_POST_TRANSACTIONS_HOLDINGS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_POST_TRANSACTIONS_HOLDINGS_URL) Handler(io.vertx.core.Handler) Collections(java.util.Collections) HoldingsLoadTransactionStatus(org.folio.holdingsiq.model.HoldingsLoadTransactionStatus) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) Async(io.vertx.ext.unit.Async) HoldingsTransactionIdsList(org.folio.holdingsiq.model.HoldingsTransactionIdsList) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) Test(org.junit.Test)

Example 3 with ConfigurationMessage

use of org.folio.service.holdings.message.ConfigurationMessage in project mod-kb-ebsco-java by folio-org.

the class DefaultLoadServiceFacadeTest method shouldNotCreateSnapshotIfItWasRecentlyCreated.

@Test
public void shouldNotCreateSnapshotIfItWasRecentlyCreated(TestContext context) throws IOException, URISyntaxException {
    Async async = context.async();
    String now = HOLDINGS_STATUS_TIME_FORMATTER.format(LocalDateTime.now(ZoneOffset.UTC));
    HoldingsLoadStatus status = readJsonFile("responses/rmapi/holdings/status/get-status-completed.json", HoldingsLoadStatus.class).toBuilder().created(now).build();
    mockGetWithBody(new EqualToPattern(RMAPI_HOLDINGS_STATUS_URL), Json.encode(status));
    mockPostHoldings();
    interceptor = interceptAndStop(HOLDINGS_SERVICE_ADDRESS, SNAPSHOT_CREATED_ACTION, message -> async.complete());
    vertx.eventBus().addOutboundInterceptor(interceptor);
    loadServiceFacade.createSnapshot(new ConfigurationMessage(configuration, STUB_CREDENTIALS_ID, STUB_TENANT));
    async.await(TIMEOUT);
    WireMock.verify(0, postRequestedFor(new UrlPathPattern(new EqualToPattern(RMAPI_POST_HOLDINGS_URL), false)));
}
Also used : RMAPI_POST_HOLDINGS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_POST_HOLDINGS_URL) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) WireMockTestBase(org.folio.rest.impl.WireMockTestBase) Json(io.vertx.core.json.Json) KbCredentialsTestUtil.saveKbCredentials(org.folio.util.KbCredentialsTestUtil.saveKbCredentials) URISyntaxException(java.net.URISyntaxException) LocalDateTime(java.time.LocalDateTime) RunWith(org.junit.runner.RunWith) Autowired(org.springframework.beans.factory.annotation.Autowired) RMAPI_HOLDINGS_STATUS_URL(org.folio.rest.impl.RmApiConstants.RMAPI_HOLDINGS_STATUS_URL) LoadHoldingsMessage(org.folio.service.holdings.message.LoadHoldingsMessage) WireMock.postRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor) DefaultLoadServiceFacade(org.folio.service.holdings.DefaultLoadServiceFacade) TestUtil.mockResponseList(org.folio.test.util.TestUtil.mockResponseList) WireMock(com.github.tomakehurst.wiremock.client.WireMock) After(org.junit.After) HoldingsStatusUtil.saveStatusNotStarted(org.folio.util.HoldingsStatusUtil.saveStatusNotStarted) HoldingsRetryStatusTestUtil.insertRetryStatus(org.folio.util.HoldingsRetryStatusTestUtil.insertRetryStatus) KBTestUtil.clearDataFromTable(org.folio.util.KBTestUtil.clearDataFromTable) KBTestUtil.interceptAndStop(org.folio.util.KBTestUtil.interceptAndStop) ZoneOffset(java.time.ZoneOffset) WireMock.post(com.github.tomakehurst.wiremock.client.WireMock.post) Before(org.junit.Before) TestUtil.mockGetWithBody(org.folio.test.util.TestUtil.mockGetWithBody) DeliveryContext(io.vertx.core.eventbus.DeliveryContext) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) HOLDINGS_STATUS_TIME_FORMATTER(org.folio.service.holdings.AbstractLoadServiceFacade.HOLDINGS_STATUS_TIME_FORMATTER) HoldingsLoadStatus(org.folio.holdingsiq.model.HoldingsLoadStatus) SNAPSHOT_CREATED_ACTION(org.folio.service.holdings.HoldingConstants.SNAPSHOT_CREATED_ACTION) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) STUB_TENANT(org.folio.test.util.TestUtil.STUB_TENANT) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) TestUtil.readJsonFile(org.folio.test.util.TestUtil.readJsonFile) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) HOLDINGS_SERVICE_ADDRESS(org.folio.service.holdings.HoldingConstants.HOLDINGS_SERVICE_ADDRESS) STUB_CREDENTIALS_NAME(org.folio.util.KbCredentialsTestUtil.STUB_CREDENTIALS_NAME) KB_CREDENTIALS_TABLE_NAME(org.folio.repository.kbcredentials.KbCredentialsTableConstants.KB_CREDENTIALS_TABLE_NAME) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) WireMock.stubFor(com.github.tomakehurst.wiremock.client.WireMock.stubFor) TestUtil.readFile(org.folio.test.util.TestUtil.readFile) Configuration(org.folio.holdingsiq.model.Configuration) Handler(io.vertx.core.Handler) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) Async(io.vertx.ext.unit.Async) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) HoldingsLoadStatus(org.folio.holdingsiq.model.HoldingsLoadStatus) Test(org.junit.Test)

Example 4 with ConfigurationMessage

use of org.folio.service.holdings.message.ConfigurationMessage in project mod-kb-ebsco-java by folio-org.

the class HoldingsServiceImpl method loadSingleHoldings.

@Override
public CompletableFuture<Void> loadSingleHoldings(RMAPITemplateContext context) {
    final String tenantId = context.getOkapiData().getTenant();
    final String credentialsId = context.getCredentialsId();
    Future<Void> executeFuture = executeWithLock(START_LOADING_LOCK, () -> tryChangingStatusToInProgress(getStatusPopulatingStagingArea(), toUUID(credentialsId), tenantId).thenCompose(o -> resetRetries(snapshotRetryCount - 1, toUUID(credentialsId), tenantId)).thenAccept(o -> {
        ConfigurationMessage configuration = new ConfigurationMessage(context.getConfiguration(), credentialsId, tenantId);
        loadServiceFacade.createSnapshot(configuration);
    }));
    return mapVertxFuture(executeFuture);
}
Also used : HoldingsLoadingStatusFactory.getStatusLoadingHoldings(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusLoadingHoldings) Arrays(java.util.Arrays) HoldingsMessage(org.folio.service.holdings.message.HoldingsMessage) DeltaReportCreatedMessage(org.folio.service.holdings.message.DeltaReportCreatedMessage) Autowired(org.springframework.beans.factory.annotation.Autowired) HoldingChangeType(org.folio.holdingsiq.model.HoldingChangeType) LoadStatusNameEnum(org.folio.rest.jaxrs.model.LoadStatusNameEnum) HOLDING_UPDATED_ADDED_COVERAGE(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_UPDATED_ADDED_COVERAGE) HoldingsStatusRepository(org.folio.repository.holdings.status.HoldingsStatusRepository) RetryStatus(org.folio.repository.holdings.status.retry.RetryStatus) HoldingsLoadingStatusFactory.getLoadStatusFailed(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getLoadStatusFailed) HoldingsLoadingStatusFactory.getStatusPopulatingStagingArea(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusPopulatingStagingArea) StringUtils(org.apache.commons.lang3.StringUtils) SnapshotCreatedMessage(org.folio.service.holdings.message.SnapshotCreatedMessage) HoldingsLoadingStatusFactory.getStatusCompleted(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusCompleted) Holding(org.folio.holdingsiq.model.Holding) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) RowSetUtils.toUUID(org.folio.db.RowSetUtils.toUUID) UUID(java.util.UUID) HOLDING_ADDED(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_ADDED) Collectors(java.util.stream.Collectors) Future(io.vertx.core.Future) List(java.util.List) OffsetDateTime(java.time.OffsetDateTime) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) LoadStatusAttributes(org.folio.rest.jaxrs.model.LoadStatusAttributes) RMAPITemplateContext(org.folio.rest.util.template.RMAPITemplateContext) HOLDING_UPDATED(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_UPDATED) HoldingsServiceMessagesFactory.getLoadHoldingsMessage(org.folio.repository.holdings.HoldingsServiceMessagesFactory.getLoadHoldingsMessage) Producer(org.glassfish.jersey.internal.util.Producer) CompletableFuture(java.util.concurrent.CompletableFuture) HoldingsLoadingStatusFactory.getStatusNotStarted(org.folio.repository.holdings.status.HoldingsLoadingStatusFactory.getStatusNotStarted) Function(java.util.function.Function) ProcessInProgressException(org.folio.service.holdings.exception.ProcessInProgressException) ErrorUtil.createError(org.folio.rest.util.ErrorUtil.createError) Value(org.springframework.beans.factory.annotation.Value) HoldingInReport(org.folio.holdingsiq.model.HoldingInReport) HoldingsRepository(org.folio.repository.holdings.HoldingsRepository) DbHoldingInfo(org.folio.repository.holdings.DbHoldingInfo) SnapshotFailedMessage(org.folio.service.holdings.message.SnapshotFailedMessage) AsyncResult(io.vertx.core.AsyncResult) HOLDING_UPDATED_DELETED_COVERAGE(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_UPDATED_DELETED_COVERAGE) FutureUtils.mapVertxFuture(org.folio.util.FutureUtils.mapVertxFuture) FutureUtils.failedFuture(org.folio.util.FutureUtils.failedFuture) LoadFailedMessage(org.folio.service.holdings.message.LoadFailedMessage) Promise(io.vertx.core.Promise) DeltaReportMessage(org.folio.service.holdings.message.DeltaReportMessage) Vertx(io.vertx.core.Vertx) HoldingsLoadingStatus(org.folio.rest.jaxrs.model.HoldingsLoadingStatus) Integer.parseInt(java.lang.Integer.parseInt) Component(org.springframework.stereotype.Component) HoldingsId(org.folio.repository.holdings.HoldingsId) ChronoUnit(java.time.temporal.ChronoUnit) Lock(io.vertx.core.shareddata.Lock) LoadStatusInformation(org.folio.rest.jaxrs.model.LoadStatusInformation) RetryStatusRepository(org.folio.repository.holdings.status.retry.RetryStatusRepository) DateTimeFormatter(java.time.format.DateTimeFormatter) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) TransactionIdRepository(org.folio.repository.holdings.transaction.TransactionIdRepository) HOLDING_DELETED(org.folio.holdingsiq.model.HoldingChangeType.HOLDING_DELETED) Handler(io.vertx.core.Handler) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage)

Example 5 with ConfigurationMessage

use of org.folio.service.holdings.message.ConfigurationMessage in project mod-kb-ebsco-java by folio-org.

the class AbstractLoadServiceFacade method createSnapshot.

@Override
public void createSnapshot(ConfigurationMessage message) {
    LoadServiceImpl loadingService = new LoadServiceImpl(message.getConfiguration(), vertx);
    populateHoldingsIfNecessary(loadingService).thenAccept(status -> holdingsService.snapshotCreated(getSnapshotCreatedMessage(message, status, getRequestCount(status.getTotalCount(), getMaxPageSize())))).whenComplete((o, throwable) -> {
        if (throwable != null) {
            logger.error("Failed to create snapshot", throwable);
            holdingsService.snapshotFailed(getSnapshotFailedMessage(message, throwable));
        }
    });
}
Also used : HoldingsServiceMessagesFactory.getSnapshotCreatedMessage(org.folio.repository.holdings.HoldingsServiceMessagesFactory.getSnapshotCreatedMessage) IntStream(java.util.stream.IntStream) DateTimeFormatterBuilder(java.time.format.DateTimeFormatterBuilder) COMPLETED(org.folio.repository.holdings.LoadStatus.COMPLETED) Producer(org.glassfish.jersey.internal.util.Producer) ZonedDateTime(java.time.ZonedDateTime) LocalDateTime(java.time.LocalDateTime) CompletableFuture(java.util.concurrent.CompletableFuture) LoadHoldingsMessage(org.folio.service.holdings.message.LoadHoldingsMessage) StringUtils(org.apache.commons.lang3.StringUtils) HoldingsServiceMessagesFactory.getLoadFailedMessage(org.folio.repository.holdings.HoldingsServiceMessagesFactory.getLoadFailedMessage) Value(org.springframework.beans.factory.annotation.Value) BiPredicate(java.util.function.BiPredicate) IN_PROGRESS(org.folio.repository.holdings.LoadStatus.IN_PROGRESS) Nullable(org.springframework.lang.Nullable) ZoneOffset(java.time.ZoneOffset) INTEGER_ZERO(org.apache.commons.lang3.math.NumberUtils.INTEGER_ZERO) IntFunction(java.util.function.IntFunction) LoadStatus(org.folio.repository.holdings.LoadStatus) Vertx(io.vertx.core.Vertx) Collectors(java.util.stream.Collectors) HOLDINGS_SERVICE_ADDRESS(org.folio.service.holdings.HoldingConstants.HOLDINGS_SERVICE_ADDRESS) List(java.util.List) Component(org.springframework.stereotype.Component) ChronoUnit(java.time.temporal.ChronoUnit) Logger(org.apache.logging.log4j.Logger) DateTimeFormatter(java.time.format.DateTimeFormatter) ConfigurationMessage(org.folio.service.holdings.message.ConfigurationMessage) LoadService(org.folio.holdingsiq.service.LoadService) LoadServiceImpl(org.folio.holdingsiq.service.impl.LoadServiceImpl) LogManager(org.apache.logging.log4j.LogManager) HoldingsServiceMessagesFactory.getSnapshotFailedMessage(org.folio.repository.holdings.HoldingsServiceMessagesFactory.getSnapshotFailedMessage) LoadServiceImpl(org.folio.holdingsiq.service.impl.LoadServiceImpl)

Aggregations

ConfigurationMessage (org.folio.service.holdings.message.ConfigurationMessage)7 Handler (io.vertx.core.Handler)6 LocalDateTime (java.time.LocalDateTime)6 ZoneOffset (java.time.ZoneOffset)6 HOLDINGS_SERVICE_ADDRESS (org.folio.service.holdings.HoldingConstants.HOLDINGS_SERVICE_ADDRESS)6 LoadHoldingsMessage (org.folio.service.holdings.message.LoadHoldingsMessage)6 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)5 WireMock (com.github.tomakehurst.wiremock.client.WireMock)5 WireMock.post (com.github.tomakehurst.wiremock.client.WireMock.post)5 WireMock.postRequestedFor (com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor)5 WireMock.stubFor (com.github.tomakehurst.wiremock.client.WireMock.stubFor)5 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)5 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)5 DeliveryContext (io.vertx.core.eventbus.DeliveryContext)5 Json (io.vertx.core.json.Json)5 Async (io.vertx.ext.unit.Async)5 TestContext (io.vertx.ext.unit.TestContext)5 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)5 IOException (java.io.IOException)5 URISyntaxException (java.net.URISyntaxException)5