use of org.folio.rest.jaxrs.model.JobMonitoring in project mod-source-record-manager by folio-org.
the class JobExecutionDaoImplTest method prepareDataForDeletion.
private Future<JobExecution> prepareDataForDeletion(Instant completedDate) {
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), Matchers.is(1));
JobExecution jobExec = createdJobExecutions.get(0);
jobExec.withCompletedDate(Date.from(completedDate));
JobExecutionProgress jobExecutionProgress = new JobExecutionProgress().withJobExecutionId(jobExec.getId()).withTotal(1).withCurrentlySucceeded(1).withCurrentlyFailed(0);
JobMonitoring jobMonitoring = new JobMonitoring().withId(UUID.randomUUID().toString()).withJobExecutionId(jobExec.getId()).withNotificationSent(true).withLastEventTimestamp(new Date());
JournalRecord journalRecord = new JournalRecord().withJobExecutionId(jobExec.getId()).withSourceRecordOrder(0).withSourceId(UUID.randomUUID().toString()).withEntityType(JournalRecord.EntityType.MARC_BIBLIOGRAPHIC).withEntityId(UUID.randomUUID().toString()).withActionType(CREATE).withActionDate(new Date()).withActionStatus(COMPLETED);
JobExecutionSourceChunk jobExecutionSourceChunk = new JobExecutionSourceChunk().withId("67dfac11-1caf-4470-9ad1-d533f6360bdd").withJobExecutionId(jobExec.getId()).withLast(false).withState(JobExecutionSourceChunk.State.COMPLETED).withChunkSize(10).withProcessedAmount(42);
return jobExecutionDao.updateJobExecution(jobExec, TENANT_ID).compose(jobExecution -> {
Future<RowSet<Row>> saveProgressFuture = jobExecutionProgressDao.save(jobExecutionProgress, TENANT_ID);
Future<String> saveMonitoringFuture = jobMonitoringDao.save(jobMonitoring, TENANT_ID);
Future<String> saveJournalFuture = journalRecordDao.save(journalRecord, TENANT_ID);
Future<String> saveSourceChunkFuture = jobExecutionSourceChunkDao.save(jobExecutionSourceChunk, TENANT_ID);
return CompositeFuture.all(saveProgressFuture, saveMonitoringFuture, saveJournalFuture, saveSourceChunkFuture).compose(ar -> Future.succeededFuture(jobExecution));
});
}
use of org.folio.rest.jaxrs.model.JobMonitoring in project mod-source-record-manager by folio-org.
the class JobExecutionProgressServiceImplTest method shouldUpdateProgress.
@Test
public void shouldUpdateProgress(TestContext context) {
Async async = context.async();
int expectedTotalRecords = 42;
int expectedSucceededRecords = 40;
int expectedFailedRecords = 2;
Future<JobExecutionProgress> future = jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params).compose(initJobExecutionsRsDto -> jobExecutionService.initializeJobExecutions(initJobExecutionsRqDto, params)).compose(initJobExecutionsRsDto -> jobExecutionProgressService.initializeJobExecutionProgress(initJobExecutionsRsDto.getParentJobExecutionId(), expectedTotalRecords, TENANT_ID)).compose(progress -> jobExecutionProgressService.updateJobExecutionProgress(progress.getJobExecutionId(), progressToUpdate -> progressToUpdate.withCurrentlySucceeded(expectedSucceededRecords).withCurrentlyFailed(expectedFailedRecords), TENANT_ID));
future.onComplete(ar -> {
context.assertTrue(ar.succeeded());
JobExecutionProgress progress = ar.result();
context.assertEquals(expectedTotalRecords, progress.getTotal());
context.assertEquals(expectedSucceededRecords, progress.getCurrentlySucceeded());
context.assertEquals(expectedFailedRecords, progress.getCurrentlyFailed());
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();
});
});
}
use of org.folio.rest.jaxrs.model.JobMonitoring in project mod-source-record-manager by folio-org.
the class JobMonitoringServiceImplTest method shouldUpdateJobMonitoring.
@Test
public void shouldUpdateJobMonitoring(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.updateByJobExecutionId(jobMonitoring.getJobExecutionId(), Timestamp.valueOf(LocalDateTime.now()), true, TENANT_ID)).compose(updated -> jobMonitoringService.getByJobExecutionId(initJobExecutionsRsDto.getParentJobExecutionId(), 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.assertTrue(savedJobMonitoring.getNotificationSent());
async.complete();
});
}
use of org.folio.rest.jaxrs.model.JobMonitoring in project mod-source-record-manager by folio-org.
the class JobMonitoringServiceImplTest method shouldFindAllJobMonitoring.
@Test
public void shouldFindAllJobMonitoring(TestContext context) {
Async async = context.async();
Future<List<JobMonitoring>> 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)).compose(list -> jobMonitoringService.getAll(TENANT_ID));
future.onComplete(ar -> {
context.assertTrue(ar.succeeded());
List<JobMonitoring> jobMonitors = ar.result();
context.assertTrue(!jobMonitors.isEmpty());
context.assertTrue(jobMonitors.size() == 2);
async.complete();
});
}
use of org.folio.rest.jaxrs.model.JobMonitoring in project mod-source-record-manager by folio-org.
the class JobMonitoringServiceImpl method saveNew.
@Override
public Future<JobMonitoring> saveNew(String jobExecutionId, String tenantId) {
JobMonitoring jobMonitoring = new JobMonitoring();
jobMonitoring.setId(UUID.randomUUID().toString());
jobMonitoring.setJobExecutionId(jobExecutionId);
jobMonitoring.setLastEventTimestamp(new Date());
jobMonitoring.setNotificationSent(false);
return jobMonitoringDao.save(jobMonitoring, tenantId).map(jobMonitoring);
}
Aggregations