Search in sources :

Example 6 with JobExecutionDto

use of org.folio.rest.jaxrs.model.JobExecutionDto in project mod-source-record-manager by folio-org.

the class JobExecutionDaoImplTest method shouldSubstituteJobExecutionProgressToJobExecutions.

@Test
public void shouldSubstituteJobExecutionProgressToJobExecutions(TestContext context) {
    Async async = context.async();
    Future<List<JobExecutionDto>> future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).map(InitJobExecutionsRsDto::getJobExecutions).compose(this::createProgressForJobExecutions).compose(ar -> jobExecutionDao.getJobExecutionsWithoutParentMultiple(new JobExecutionFilter(), null, 0, 10, params.getTenantId())).map(JobExecutionDtoCollection::getJobExecutions);
    future.onComplete(ar -> {
        context.assertTrue(ar.succeeded());
        Async async2 = context.async(ar.result().size());
        for (JobExecutionDto jobExecution : ar.result()) {
            jobExecutionProgressDao.getByJobExecutionId(jobExecution.getId(), params.getTenantId()).onComplete(progressAr -> {
                context.assertTrue(progressAr.succeeded());
                context.assertTrue(progressAr.result().isPresent());
                JobExecutionProgress progress = progressAr.result().get();
                context.assertEquals(progress.getTotal(), jobExecution.getProgress().getTotal());
                context.assertEquals(progress.getCurrentlySucceeded() + progress.getCurrentlyFailed(), jobExecution.getProgress().getCurrent());
                async2.countDown();
            });
        }
        async.complete();
    });
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Arrays(java.util.Arrays) Date(java.util.Date) PostgresClient.convertToPsqlStandard(org.folio.rest.persist.PostgresClient.convertToPsqlStandard) Random(java.util.Random) CHILD(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.CHILD) MockitoAnnotations(org.mockito.MockitoAnnotations) JobExecution(org.folio.rest.jaxrs.model.JobExecution) Spy(org.mockito.Spy) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) ZoneOffset(java.time.ZoneOffset) JobExecutionDto(org.folio.rest.jaxrs.model.JobExecutionDto) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) JobExecutionSourceChunk(org.folio.rest.jaxrs.model.JobExecutionSourceChunk) UUID(java.util.UUID) Instant(java.time.Instant) Future(io.vertx.core.Future) OkapiConnectionParams(org.folio.dataimport.util.OkapiConnectionParams) String.format(java.lang.String.format) JobExecutionService(org.folio.services.JobExecutionService) List(java.util.List) JobExecutionDtoCollection(org.folio.rest.jaxrs.model.JobExecutionDtoCollection) Strings(org.apache.logging.log4j.util.Strings) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) RunTestOnContext(io.vertx.ext.unit.junit.RunTestOnContext) Async(io.vertx.ext.unit.Async) OKAPI_TENANT_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TENANT_HEADER) RunWith(org.junit.runner.RunWith) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) OKAPI_URL_HEADER(org.folio.dataimport.util.RestUtil.OKAPI_URL_HEADER) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) CompositeFuture(io.vertx.core.CompositeFuture) RowSet(io.vertx.sqlclient.RowSet) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) InitJobExecutionsRqDto(org.folio.rest.jaxrs.model.InitJobExecutionsRqDto) JobExecutionServiceImpl(org.folio.services.JobExecutionServiceImpl) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) Promise(io.vertx.core.Promise) Vertx(io.vertx.core.Vertx) Matchers(org.hamcrest.Matchers) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) COMPLETED(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED) JobExecutionProgress(org.folio.rest.jaxrs.model.JobExecutionProgress) Rule(org.junit.Rule) ChronoUnit(java.time.temporal.ChronoUnit) File(org.folio.rest.jaxrs.model.File) Row(io.vertx.sqlclient.Row) Log4j2(lombok.extern.log4j.Log4j2) JobExecutionDetail(org.folio.rest.jaxrs.model.JobExecutionDetail) OKAPI_TOKEN_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TOKEN_HEADER) CREATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE) Assert.assertEquals(org.junit.Assert.assertEquals) JobExecutionDtoCollection(org.folio.rest.jaxrs.model.JobExecutionDtoCollection) JobExecutionProgress(org.folio.rest.jaxrs.model.JobExecutionProgress) Async(io.vertx.ext.unit.Async) JobExecutionDto(org.folio.rest.jaxrs.model.JobExecutionDto) List(java.util.List) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Aggregations

Date (java.util.Date)6 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)6 JobExecution (org.folio.rest.jaxrs.model.JobExecution)6 JobExecutionDto (org.folio.rest.jaxrs.model.JobExecutionDto)6 JobExecutionDtoCollection (org.folio.rest.jaxrs.model.JobExecutionDtoCollection)6 Future (io.vertx.core.Future)5 Async (io.vertx.ext.unit.Async)5 TestContext (io.vertx.ext.unit.TestContext)5 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)5 Instant (java.time.Instant)5 ZoneOffset (java.time.ZoneOffset)5 ChronoUnit (java.time.temporal.ChronoUnit)5 List (java.util.List)5 UUID (java.util.UUID)5 PostgresClientFactory (org.folio.dao.util.PostgresClientFactory)5 ChangeManagerAPITest (org.folio.rest.impl.changeManager.ChangeManagerAPITest)5 InitJobExecutionsRsDto (org.folio.rest.jaxrs.model.InitJobExecutionsRsDto)5 CHILD (org.folio.rest.jaxrs.model.JobExecution.SubordinationType.CHILD)5 JournalRecord (org.folio.rest.jaxrs.model.JournalRecord)5 COMPLETED (org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED)5