use of org.folio.inventory.resources.ingest.IngestJob in project mod-inventory by folio-org.
the class InMemoryIngestJobCollectionExamples method jobStateCanBeUpdated.
@Test
public void jobStateCanBeUpdated() throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<IngestJob> addFuture = new CompletableFuture<>();
collection.add(new IngestJob(IngestJobState.REQUESTED), succeed(addFuture), fail(addFuture));
IngestJob added = getOnCompletion(addFuture);
IngestJob completed = added.complete();
CompletableFuture<Void> updateFuture = new CompletableFuture<>();
collection.update(completed, succeed(updateFuture), fail(updateFuture));
waitForCompletion(updateFuture);
CompletableFuture<IngestJob> findFuture = new CompletableFuture<>();
collection.findById(added.id, succeed(findFuture), fail(findFuture));
IngestJob found = getOnCompletion(findFuture);
assertThat(found.state, is(IngestJobState.COMPLETED));
}
use of org.folio.inventory.resources.ingest.IngestJob in project mod-inventory by folio-org.
the class InMemoryIngestJobCollectionExamples method jobsCanBeFoundById.
@Test
public void jobsCanBeFoundById() throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<IngestJob> addFuture = new CompletableFuture<>();
collection.add(new IngestJob(IngestJobState.REQUESTED), succeed(addFuture), fail(addFuture));
IngestJob added = getOnCompletion(addFuture);
CompletableFuture<IngestJob> findFuture = new CompletableFuture<>();
collection.findById(added.id, succeed(findFuture), fail(findFuture));
IngestJob found = getOnCompletion(findFuture);
assertThat(found.id, is(added.id));
assertThat(found.state, is(IngestJobState.REQUESTED));
}
use of org.folio.inventory.resources.ingest.IngestJob in project mod-inventory by folio-org.
the class IngestMessageProcessor method markIngestCompleted.
private void markIngestCompleted(Message<JsonObject> message) {
final MessagingContext context = new MessagingContext(message.headers());
storage.getIngestJobCollection(context).update(new IngestJob(context.getJobId(), IngestJobState.COMPLETED), v -> log.info(String.format("Ingest job %s completed", context.getJobId())), failure -> log.error(String.format("Updating ingest job failed: %s", failure.getReason())));
}
use of org.folio.inventory.resources.ingest.IngestJob in project mod-inventory by folio-org.
the class InMemoryIngestJobCollectionExamples method jobsCanBeAdded.
@Test
public void jobsCanBeAdded() throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<IngestJob> addFuture = new CompletableFuture<>();
collection.add(new IngestJob(IngestJobState.REQUESTED), succeed(addFuture), fail(addFuture));
waitForCompletion(addFuture);
CompletableFuture<MultipleRecords<IngestJob>> findFuture = new CompletableFuture<>();
collection.findAll(PagingParameters.defaults(), succeed(findFuture), fail(findFuture));
MultipleRecords<IngestJob> allJobsWrapped = getOnCompletion(findFuture);
List<IngestJob> allJobs = allJobsWrapped.records;
assertThat(allJobs.size(), is(1));
allJobs.stream().forEach(job -> assertThat(job.id, is(notNullValue())));
allJobs.stream().forEach(job -> assertThat(job.state, is(IngestJobState.REQUESTED)));
}
use of org.folio.inventory.resources.ingest.IngestJob in project mod-inventory by folio-org.
the class InMemoryIngestJobCollectionExamples method singleJobWithSameIdFollowingUpdate.
@Test
public void singleJobWithSameIdFollowingUpdate() throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<IngestJob> addFuture = new CompletableFuture<>();
collection.add(new IngestJob(IngestJobState.REQUESTED), succeed(addFuture), fail(addFuture));
IngestJob added = getOnCompletion(addFuture);
IngestJob completed = added.complete();
CompletableFuture<Void> updateFuture = new CompletableFuture<>();
collection.update(completed, succeed(updateFuture), fail(updateFuture));
waitForCompletion(updateFuture);
CompletableFuture<MultipleRecords<IngestJob>> findAllFuture = new CompletableFuture<>();
collection.findAll(PagingParameters.defaults(), succeed(findAllFuture), fail(findAllFuture));
MultipleRecords<IngestJob> allJobsWrapped = getOnCompletion(findAllFuture);
List<IngestJob> allJobs = allJobsWrapped.records;
assertThat(allJobs.size(), is(1));
assertThat(allJobs.stream().findFirst().get().id, is(added.id));
}
Aggregations