Search in sources :

Example 6 with JobMonitoring

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

the class DataImportInitConsumerVerticleTest method assertProgressAndMonitoringAndJobExecutionStatus.

private void assertProgressAndMonitoringAndJobExecutionStatus(JobExecution.Status statusToCheck, Async async) {
    jobExecutionProgressService.getByJobExecutionId(jobExecutionId, TENANT_ID).onSuccess(progress -> {
        assertEquals(jobExecutionId, progress.getJobExecutionId());
        assertEquals(TOTAL_RECORDS, progress.getTotal());
        jobExecutionService.getJobExecutionById(jobExecutionId, TENANT_ID).onSuccess(jobExecutionOptional -> {
            JobExecution jobExecution = jobExecutionOptional.get();
            assertEquals(statusToCheck, jobExecution.getStatus());
            jobMonitoringService.getByJobExecutionId(jobExecution.getId(), TENANT_ID).onSuccess(jobMonitoringOptional -> {
                JobMonitoring jobMonitoring = jobMonitoringOptional.get();
                assertEquals(jobExecutionId, jobMonitoring.getJobExecutionId());
                async.complete();
            });
        });
    });
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring)

Example 7 with JobMonitoring

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

the class JobExecutionProgressServiceImplTest method shouldInitProgress.

@Test
public void shouldInitProgress(TestContext context) {
    Async async = context.async();
    int expectedTotalRecords = 62;
    Future<JobExecutionProgress> future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobExecutionProgressService.initializeJobExecutionProgress(initJobExecutionsRsDto.getParentJobExecutionId(), expectedTotalRecords, TENANT_ID)).compose(progress -> jobExecutionProgressService.getByJobExecutionId(progress.getJobExecutionId(), TENANT_ID));
    future.onComplete(ar -> {
        context.assertTrue(ar.succeeded());
        JobExecutionProgress progress = ar.result();
        context.assertEquals(expectedTotalRecords, progress.getTotal());
        jobMonitoringService.getByJobExecutionId(progress.getJobExecutionId(), params.getTenantId()).onSuccess(optionalJobMonitoring -> {
            context.assertTrue(optionalJobMonitoring.isPresent());
            JobMonitoring jobMonitoring = optionalJobMonitoring.get();
            context.assertNotNull(jobMonitoring.getId());
            context.assertEquals(progress.getJobExecutionId(), jobMonitoring.getJobExecutionId());
            context.assertNotNull(jobMonitoring.getLastEventTimestamp());
            context.assertFalse(jobMonitoring.getNotificationSent());
            async.complete();
        });
    });
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) Arrays(java.util.Arrays) OKAPI_TENANT_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TENANT_HEADER) JobMonitoringDaoImpl(org.folio.dao.JobMonitoringDaoImpl) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) JobExecutionProgressServiceImpl(org.folio.services.progress.JobExecutionProgressServiceImpl) OKAPI_URL_HEADER(org.folio.dataimport.util.RestUtil.OKAPI_URL_HEADER) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) CompositeFuture(io.vertx.core.CompositeFuture) MockitoAnnotations(org.mockito.MockitoAnnotations) JobExecutionProgressService(org.folio.services.progress.JobExecutionProgressService) Spy(org.mockito.Spy) InitJobExecutionsRqDto(org.folio.rest.jaxrs.model.InitJobExecutionsRqDto) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) GenericCompositeFuture(org.folio.okapi.common.GenericCompositeFuture) JobExecutionProgressDaoImpl(org.folio.dao.JobExecutionProgressDaoImpl) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) UUID(java.util.UUID) Future(io.vertx.core.Future) OkapiConnectionParams(org.folio.dataimport.util.OkapiConnectionParams) JobExecutionProgress(org.folio.rest.jaxrs.model.JobExecutionProgress) Rule(org.junit.Rule) File(org.folio.rest.jaxrs.model.File) JobExecutionDaoImpl(org.folio.dao.JobExecutionDaoImpl) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) OKAPI_TOKEN_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TOKEN_HEADER) RunTestOnContext(io.vertx.ext.unit.junit.RunTestOnContext) Collections(java.util.Collections) JobExecutionProgress(org.folio.rest.jaxrs.model.JobExecutionProgress) Async(io.vertx.ext.unit.Async) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring) Test(org.junit.Test) AbstractRestTest(org.folio.rest.impl.AbstractRestTest)

Example 8 with JobMonitoring

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

the class JobMonitoringServiceImplTest method shouldDeleteJobMonitoring.

@Test
public void shouldDeleteJobMonitoring(TestContext context) {
    Async async = context.async();
    Future<Optional<JobMonitoring>> future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobMonitoringService.saveNew(initJobExecutionsRsDto.getParentJobExecutionId(), TENANT_ID).compose(jobMonitoring -> jobMonitoringService.deleteByJobExecutionId(jobMonitoring.getJobExecutionId(), TENANT_ID)).compose(deleted -> jobMonitoringService.getByJobExecutionId(initJobExecutionsRsDto.getParentJobExecutionId(), TENANT_ID)));
    future.onComplete(ar -> {
        context.assertTrue(ar.succeeded());
        Optional<JobMonitoring> optionalJobMonitoring = ar.result();
        context.assertTrue(optionalJobMonitoring.isEmpty());
        async.complete();
    });
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) OKAPI_TENANT_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TENANT_HEADER) JobMonitoringDaoImpl(org.folio.dao.JobMonitoringDaoImpl) PostgresClient.convertToPsqlStandard(org.folio.rest.persist.PostgresClient.convertToPsqlStandard) LocalDateTime(java.time.LocalDateTime) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) OKAPI_URL_HEADER(org.folio.dataimport.util.RestUtil.OKAPI_URL_HEADER) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) MockitoAnnotations(org.mockito.MockitoAnnotations) After(org.junit.After) Spy(org.mockito.Spy) InitJobExecutionsRqDto(org.folio.rest.jaxrs.model.InitJobExecutionsRqDto) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring) Timestamp(java.sql.Timestamp) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) UUID(java.util.UUID) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) Future(io.vertx.core.Future) String.format(java.lang.String.format) OkapiConnectionParams(org.folio.dataimport.util.OkapiConnectionParams) List(java.util.List) Rule(org.junit.Rule) File(org.folio.rest.jaxrs.model.File) JobExecutionDaoImpl(org.folio.dao.JobExecutionDaoImpl) Optional(java.util.Optional) OKAPI_TOKEN_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TOKEN_HEADER) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Collections(java.util.Collections) RunTestOnContext(io.vertx.ext.unit.junit.RunTestOnContext) Optional(java.util.Optional) Async(io.vertx.ext.unit.Async) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring) Test(org.junit.Test) AbstractRestTest(org.folio.rest.impl.AbstractRestTest)

Example 9 with JobMonitoring

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

the class JobMonitoringServiceImplTest method shouldSaveJobMonitoring.

@Test
public void shouldSaveJobMonitoring(TestContext context) {
    Async async = context.async();
    Future<Optional<JobMonitoring>> future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobMonitoringService.saveNew(initJobExecutionsRsDto.getParentJobExecutionId(), TENANT_ID)).compose(jobMonitoring -> jobMonitoringService.getByJobExecutionId(jobMonitoring.getJobExecutionId(), TENANT_ID));
    future.onComplete(ar -> {
        context.assertTrue(ar.succeeded());
        Optional<JobMonitoring> optionalJobMonitoring = ar.result();
        context.assertTrue(optionalJobMonitoring.isPresent());
        JobMonitoring savedJobMonitoring = optionalJobMonitoring.get();
        context.assertNotNull(savedJobMonitoring.getId());
        context.assertNotNull(savedJobMonitoring.getJobExecutionId());
        context.assertNotNull(savedJobMonitoring.getLastEventTimestamp());
        context.assertFalse(savedJobMonitoring.getNotificationSent());
        async.complete();
    });
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) OKAPI_TENANT_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TENANT_HEADER) JobMonitoringDaoImpl(org.folio.dao.JobMonitoringDaoImpl) PostgresClient.convertToPsqlStandard(org.folio.rest.persist.PostgresClient.convertToPsqlStandard) LocalDateTime(java.time.LocalDateTime) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) OKAPI_URL_HEADER(org.folio.dataimport.util.RestUtil.OKAPI_URL_HEADER) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) MockitoAnnotations(org.mockito.MockitoAnnotations) After(org.junit.After) Spy(org.mockito.Spy) InitJobExecutionsRqDto(org.folio.rest.jaxrs.model.InitJobExecutionsRqDto) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring) Timestamp(java.sql.Timestamp) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) UUID(java.util.UUID) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) Future(io.vertx.core.Future) String.format(java.lang.String.format) OkapiConnectionParams(org.folio.dataimport.util.OkapiConnectionParams) List(java.util.List) Rule(org.junit.Rule) File(org.folio.rest.jaxrs.model.File) JobExecutionDaoImpl(org.folio.dao.JobExecutionDaoImpl) Optional(java.util.Optional) OKAPI_TOKEN_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TOKEN_HEADER) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Collections(java.util.Collections) RunTestOnContext(io.vertx.ext.unit.junit.RunTestOnContext) Optional(java.util.Optional) Async(io.vertx.ext.unit.Async) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring) Test(org.junit.Test) AbstractRestTest(org.folio.rest.impl.AbstractRestTest)

Example 10 with JobMonitoring

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

the class JobMonitoringServiceImplTest method shouldFindAllInactiveJobMonitors.

@Test
public void shouldFindAllInactiveJobMonitors(TestContext context) {
    Async async = context.async();
    var future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobMonitoringService.saveNew(initJobExecutionsRsDto.getParentJobExecutionId(), TENANT_ID)).compose(initJobExecutionsRsDto2 -> jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params)).compose(initJobExecutionsRsDto2 -> jobMonitoringService.saveNew(initJobExecutionsRsDto2.getParentJobExecutionId(), TENANT_ID));
    vertx.setTimer(10L, timerId -> future.compose(list -> jobMonitoringService.getInactiveJobMonitors(1L, TENANT_ID)).onComplete(ar -> {
        context.assertTrue(ar.succeeded());
        List<JobMonitoring> jobMonitors = ar.result();
        context.assertTrue(!jobMonitors.isEmpty());
        System.out.println(jobMonitors.size());
        context.assertTrue(jobMonitors.size() == 2);
        async.complete();
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) OKAPI_TENANT_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TENANT_HEADER) JobMonitoringDaoImpl(org.folio.dao.JobMonitoringDaoImpl) PostgresClient.convertToPsqlStandard(org.folio.rest.persist.PostgresClient.convertToPsqlStandard) LocalDateTime(java.time.LocalDateTime) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) OKAPI_URL_HEADER(org.folio.dataimport.util.RestUtil.OKAPI_URL_HEADER) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) MockitoAnnotations(org.mockito.MockitoAnnotations) After(org.junit.After) Spy(org.mockito.Spy) InitJobExecutionsRqDto(org.folio.rest.jaxrs.model.InitJobExecutionsRqDto) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) JobMonitoring(org.folio.rest.jaxrs.model.JobMonitoring) Timestamp(java.sql.Timestamp) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) UUID(java.util.UUID) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) Future(io.vertx.core.Future) String.format(java.lang.String.format) OkapiConnectionParams(org.folio.dataimport.util.OkapiConnectionParams) List(java.util.List) Rule(org.junit.Rule) File(org.folio.rest.jaxrs.model.File) JobExecutionDaoImpl(org.folio.dao.JobExecutionDaoImpl) Optional(java.util.Optional) OKAPI_TOKEN_HEADER(org.folio.rest.util.OkapiConnectionParams.OKAPI_TOKEN_HEADER) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Collections(java.util.Collections) RunTestOnContext(io.vertx.ext.unit.junit.RunTestOnContext) Async(io.vertx.ext.unit.Async) List(java.util.List) Test(org.junit.Test) AbstractRestTest(org.folio.rest.impl.AbstractRestTest)

Aggregations

JobMonitoring (org.folio.rest.jaxrs.model.JobMonitoring)11 Async (io.vertx.ext.unit.Async)8 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)8 Test (org.junit.Test)8 Future (io.vertx.core.Future)7 Vertx (io.vertx.core.Vertx)7 TestContext (io.vertx.ext.unit.TestContext)7 RunTestOnContext (io.vertx.ext.unit.junit.RunTestOnContext)7 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)7 Collections (java.util.Collections)7 HashMap (java.util.HashMap)7 UUID (java.util.UUID)7 JobExecutionDaoImpl (org.folio.dao.JobExecutionDaoImpl)7 JobMonitoringDaoImpl (org.folio.dao.JobMonitoringDaoImpl)7 PostgresClientFactory (org.folio.dao.util.PostgresClientFactory)7 OkapiConnectionParams (org.folio.dataimport.util.OkapiConnectionParams)7 OKAPI_URL_HEADER (org.folio.dataimport.util.RestUtil.OKAPI_URL_HEADER)7 File (org.folio.rest.jaxrs.model.File)7 InitJobExecutionsRqDto (org.folio.rest.jaxrs.model.InitJobExecutionsRqDto)7 OKAPI_TENANT_HEADER (org.folio.rest.util.OkapiConnectionParams.OKAPI_TENANT_HEADER)7