Search in sources :

Example 1 with JobExecutionDetail

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

the class JobExecutionDaoImplTest method shouldNotDeleteIfCompletedDateNotExceeds.

@Test
public void shouldNotDeleteIfCompletedDateNotExceeds(TestContext context) {
    /*
      In this test we setup job execution that finishes 1 day ago, after this job execution has been soft deleted.
      Periodic job should not hard delete it, because 1 day does not meet condition: older than 2 days.
    */
    Async async = context.async();
    Instant minusOneDay = LocalDateTime.now().minus(1, ChronoUnit.DAYS).atOffset(ZoneOffset.UTC).toInstant();
    Future<JobExecution> preparationFuture = prepareDataForDeletion(minusOneDay);
    preparationFuture.onComplete(ar -> {
        JobExecution jobExecution = ar.result();
        List<String> jobExecutionIds = List.of(jobExecution.getId());
        jobExecutionDao.softDeleteJobExecutionsByIds(jobExecutionIds, TENANT_ID).onSuccess(reply -> {
            JobExecutionDetail jobExecutionDetail = reply.getJobExecutionDetails().get(0);
            assertEquals(jobExecutionDetail.getJobExecutionId(), jobExecution.getId());
            assertTrue(jobExecutionDetail.getIsDeleted());
            jobExecutionDao.hardDeleteJobExecutions(2, TENANT_ID).onSuccess(resp -> checkDataExistenceAfterHardDeleting(1, jobExecutionIds, async));
        });
    });
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) Async(io.vertx.ext.unit.Async) Instant(java.time.Instant) JobExecutionDetail(org.folio.rest.jaxrs.model.JobExecutionDetail) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 2 with JobExecutionDetail

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

the class JobExecutionDaoImpl method mapRowSetToDeleteChangeManagerJobExeResp.

private DeleteJobExecutionsResp mapRowSetToDeleteChangeManagerJobExeResp(RowSet<Row> rowSet) {
    DeleteJobExecutionsResp deleteJobExecutionsResp = new DeleteJobExecutionsResp();
    List<JobExecutionDetail> jobExecutionDetails = new ArrayList<>();
    rowSet.forEach(row -> {
        JobExecutionDetail executionLogDetail = new JobExecutionDetail();
        executionLogDetail.setJobExecutionId(row.getUUID(ID).toString());
        executionLogDetail.setIsDeleted(row.getBoolean(IS_DELETED));
        jobExecutionDetails.add(executionLogDetail);
    });
    deleteJobExecutionsResp.setJobExecutionDetails(jobExecutionDetails);
    return deleteJobExecutionsResp;
}
Also used : ArrayList(java.util.ArrayList) JobExecutionDetail(org.folio.rest.jaxrs.model.JobExecutionDetail) DeleteJobExecutionsResp(org.folio.rest.jaxrs.model.DeleteJobExecutionsResp)

Example 3 with JobExecutionDetail

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

the class JobExecutionDaoImplTest method shouldDeleteRecordsMarkedForJobExecutionsDeletion.

@Test
public void shouldDeleteRecordsMarkedForJobExecutionsDeletion(TestContext context) {
    /*
      In this test we setup job execution that finishes 3 days ago, after this job execution has been soft deleted.
      Periodic job should hard delete it, because it checks soft deleted jobs older than 2 days.
    */
    Async async = context.async();
    Instant minusThreeDays = LocalDateTime.now().minus(3, ChronoUnit.DAYS).atOffset(ZoneOffset.UTC).toInstant();
    Future<JobExecution> preparationFuture = prepareDataForDeletion(minusThreeDays);
    preparationFuture.onComplete(ar -> {
        JobExecution jobExecution = ar.result();
        List<String> jobExecutionIds = List.of(jobExecution.getId());
        jobExecutionDao.softDeleteJobExecutionsByIds(jobExecutionIds, TENANT_ID).onSuccess(reply -> {
            JobExecutionDetail jobExecutionDetail = reply.getJobExecutionDetails().get(0);
            assertEquals(jobExecutionDetail.getJobExecutionId(), jobExecution.getId());
            assertTrue(jobExecutionDetail.getIsDeleted());
            jobExecutionDao.hardDeleteJobExecutions(2, TENANT_ID).onSuccess(resp -> checkDataExistenceAfterHardDeleting(0, jobExecutionIds, async));
        });
    });
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) Async(io.vertx.ext.unit.Async) Instant(java.time.Instant) JobExecutionDetail(org.folio.rest.jaxrs.model.JobExecutionDetail) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Aggregations

JobExecutionDetail (org.folio.rest.jaxrs.model.JobExecutionDetail)3 Async (io.vertx.ext.unit.Async)2 Instant (java.time.Instant)2 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)2 JobExecution (org.folio.rest.jaxrs.model.JobExecution)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 DeleteJobExecutionsResp (org.folio.rest.jaxrs.model.DeleteJobExecutionsResp)1