Search in sources :

Example 1 with VacuumTaskParams

use of com.enonic.xp.repo.impl.vacuum.VacuumTaskParams in project xp by enonic.

the class SegmentVacuumTaskTest method test.

@Test
public void test() {
    final BlobRecord record = blobStore.addRecord(segment, ByteSource.wrap("hello".getBytes()));
    final BlobRecord record2 = blobStore.addRecord(segment2, ByteSource.wrap("hello".getBytes()));
    assertEquals(2, blobStore.listSegments().count());
    blobStore.removeRecord(segment, record2.getKey());
    assertEquals(2, blobStore.listSegments().count());
    final SegmentVacuumTask task = new SegmentVacuumTask();
    task.setBlobStore(blobStore);
    task.setRepositoryService(repositoryService);
    task.setNodeService(nodeService);
    final VacuumTaskParams vacuumParameters = VacuumTaskParams.create().build();
    final VacuumTaskResult result = task.execute(vacuumParameters);
    assertEquals(2, result.getProcessed());
    assertEquals(1, result.getDeleted());
    assertEquals(1, result.getInUse());
    assertEquals(1, blobStore.listSegments().count());
    assertEquals(segment, blobStore.listSegments().findFirst().get());
}
Also used : BlobRecord(com.enonic.xp.blob.BlobRecord) VacuumTaskResult(com.enonic.xp.vacuum.VacuumTaskResult) VacuumTaskParams(com.enonic.xp.repo.impl.vacuum.VacuumTaskParams) Test(org.junit.jupiter.api.Test)

Aggregations

BlobRecord (com.enonic.xp.blob.BlobRecord)1 VacuumTaskParams (com.enonic.xp.repo.impl.vacuum.VacuumTaskParams)1 VacuumTaskResult (com.enonic.xp.vacuum.VacuumTaskResult)1 Test (org.junit.jupiter.api.Test)1