TSK-1457: Fix timing issue in initializeSchedule tests for cleanupjobs

This commit is contained in:
Joerg Heffner 2020-11-19 13:24:03 +01:00 committed by Mustapha Zorgati
parent 2fbc6ad95c
commit 8830cfa629
3 changed files with 21 additions and 15 deletions

View File

@ -6,6 +6,7 @@ import acceptance.AbstractAccTest;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -382,14 +383,15 @@ class HistoryCleanupJobAccTest extends AbstractAccTest {
assertThat(jobsToRun).hasSize(30);
List<ScheduledJob> historyCleanupJobs =
jobsToRun.stream()
.filter(scheduledJob -> scheduledJob.getType().equals(Type.HISTORYCLEANUPJOB))
.collect(Collectors.toList());
HistoryCleanupJob.initializeSchedule(taskanaEngine);
jobsToRun = getJobMapper().findJobsToRun();
assertThat(jobsToRun).hasSize(20);
assertThat(jobsToRun)
.extracting(ScheduledJob::getType)
.containsOnly(Type.CLASSIFICATIONCHANGEDJOB, Type.UPDATETASKSJOB);
assertThat(jobsToRun).doesNotContainAnyElementsOf(historyCleanupJobs);
}
}

View File

@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import acceptance.AbstractAccTest;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -105,15 +106,16 @@ class TaskCleanupJobAccTest extends AbstractAccTest {
assertThat(jobsToRun).hasSize(30);
List<ScheduledJob> taskCleanupJobs =
jobsToRun.stream()
.filter(scheduledJob -> scheduledJob.getType().equals(Type.TASKCLEANUPJOB))
.collect(Collectors.toList());
TaskCleanupJob.initializeSchedule(taskanaEngine);
jobsToRun = getJobMapper().findJobsToRun();
assertThat(jobsToRun).hasSize(20);
assertThat(jobsToRun)
.extracting(ScheduledJob::getType)
.containsOnly(Type.CLASSIFICATIONCHANGEDJOB, Type.UPDATETASKSJOB);
assertThat(jobsToRun).doesNotContainAnyElementsOf(taskCleanupJobs);
}
private Task createAndCompleteTask() throws Exception {

View File

@ -4,6 +4,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import acceptance.AbstractAccTest;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ -105,15 +106,16 @@ class WorkbasketCleanupJobAccTest extends AbstractAccTest {
assertThat(jobsToRun).hasSize(30);
List<ScheduledJob> workbasketCleanupJobs =
jobsToRun.stream()
.filter(scheduledJob -> scheduledJob.getType().equals(Type.WORKBASKETCLEANUPJOB))
.collect(Collectors.toList());
WorkbasketCleanupJob.initializeSchedule(taskanaEngine);
jobsToRun = getJobMapper().findJobsToRun();
assertThat(jobsToRun).hasSize(20);
assertThat(jobsToRun)
.extracting(ScheduledJob::getType)
.containsOnly(Type.CLASSIFICATIONCHANGEDJOB, Type.UPDATETASKSJOB);
assertThat(jobsToRun).doesNotContainAnyElementsOf(workbasketCleanupJobs);
}
private long getNumberTaskNotCompleted(String workbasketId) {