use of com.enonic.xp.vacuum.VacuumService in project xp by enonic.
the class VacuumTaskHandlerTest method vacuum.
@Test
public void vacuum() throws Exception {
final TaskId taskId = TaskId.from("task");
Mockito.when(vacuumService.vacuum(isA(VacuumParameters.class))).thenReturn(VacuumResult.create().build());
TaskProgressReporterContext.withContext((id, progressReporter) -> runFunction("/test/VacuumTaskHandlerTest.js", "vacuum")).run(taskId, progressReporter);
Mockito.verify(vacuumService, Mockito.times(1)).vacuum(paramsCaptor.capture());
assertEquals("PT2S", paramsCaptor.getValue().getAgeThreshold().toString());
assertEquals(2, paramsCaptor.getValue().getTaskNames().size());
assertTrue(paramsCaptor.getValue().getTaskNames().containsAll(Set.of("a", "b")));
assertNotNull(paramsCaptor.getValue().getVacuumListener());
}
use of com.enonic.xp.vacuum.VacuumService in project xp by enonic.
the class VacuumTaskHandlerTest method vacuumDefaultParams.
@Test
public void vacuumDefaultParams() throws Exception {
final TaskId taskId = TaskId.from("task");
Mockito.when(vacuumService.vacuum(isA(VacuumParameters.class))).thenReturn(VacuumResult.create().build());
TaskProgressReporterContext.withContext((id, progressReporter) -> runFunction("/test/VacuumTaskHandlerTest.js", "vacuumDefault")).run(taskId, progressReporter);
Mockito.verify(vacuumService, Mockito.times(1)).vacuum(paramsCaptor.capture());
assertNull(paramsCaptor.getValue().getAgeThreshold());
assertEquals(2, paramsCaptor.getValue().getTaskNames().size());
assertTrue(paramsCaptor.getValue().getTaskNames().containsAll(Set.of("SegmentVacuumTask", "VersionTableVacuumTask")));
assertNotNull(paramsCaptor.getValue().getVacuumListener());
}
Aggregations