use of org.hisp.dhis.scheduling.JobType.DATAVALUE_IMPORT in project dhis2-core by dhis2.
the class NotificationMapTest method testFirstSummaryToBeCreatedIsTheFirstOneToBeRemoved.
@Test
void testFirstSummaryToBeCreatedIsTheFirstOneToBeRemoved() {
// Fill the map with jobs
JobConfiguration jobConfiguration = new JobConfiguration(null, DATAVALUE_IMPORT, "userId", false);
for (int i = 0; i < MAX_POOL_TYPE_SIZE; i++) {
jobConfiguration.setUid(String.valueOf(i));
mapToTest.addSummary(jobConfiguration, i);
}
// Add one more
jobConfiguration.setUid(String.valueOf(MAX_POOL_TYPE_SIZE));
mapToTest.addSummary(jobConfiguration, MAX_POOL_TYPE_SIZE);
// Check that oldest job is not in the map anymore
Optional<String> notPresentSummary = mapToTest.getJobSummariesForJobType(DATAVALUE_IMPORT).keySet().stream().filter(object -> object.equals("0")).findAny();
Assertions.assertFalse(notPresentSummary.isPresent());
// Add one more
jobConfiguration.setUid(String.valueOf(MAX_POOL_TYPE_SIZE + 1));
mapToTest.addSummary(jobConfiguration, MAX_POOL_TYPE_SIZE + 1);
// Check that oldest job is not in the map anymore
notPresentSummary = mapToTest.getJobSummariesForJobType(DATAVALUE_IMPORT).keySet().stream().filter(object -> object.equals("1")).findAny();
Assertions.assertFalse(notPresentSummary.isPresent());
}
Aggregations