use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method deleteVersionsBeforeDate.
@Test
public void deleteVersionsBeforeDate() throws KettleException {
IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService(mockRepo);
String fileId = "1";
Date beforeDate = getDate("01/02/2006");
purgeService.deleteVersionsBeforeDate(element1, beforeDate);
verifyDateBeforeDeletion(versionListMap, mockRepo, fileId, beforeDate);
verify(mockRepo, never()).deleteFileAtVersion(eq("2"), anyString());
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method keepNumberOfVersions0Test.
@Test
public void keepNumberOfVersions0Test() throws KettleException {
IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService(mockRepo);
String fileId = "1";
int versionCount = 0;
purgeService.keepNumberOfVersions(element1, versionCount);
verifyVersionCountDeletion(versionListMap, mockRepo, fileId, versionCount);
verify(mockRepo, never()).deleteFileAtVersion(eq("2"), anyString());
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method doPurgeUtilSharedObjectsTest.
@Test
public void doPurgeUtilSharedObjectsTest() throws PurgeDeletionException {
IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
UnifiedRepositoryPurgeService purgeService = getPurgeService(mockRepo);
PurgeUtilitySpecification spec = new PurgeUtilitySpecification();
spec.purgeFiles = true;
spec.setSharedObjects(true);
purgeService.doDeleteRevisions(spec);
// Since each tree call delivers the same mock tree, we expect the files to get deleted once per folder.
String fileId = "1";
String fileLastRevision = "105";
List<VersionSummary> list = versionListMap.get(fileId);
for (VersionSummary sum : list) {
final int expectedTimes;
if (!fileLastRevision.equals(sum.getId())) {
expectedTimes = 4;
} else {
expectedTimes = 0;
}
verify(mockRepo, times(expectedTimes)).deleteFileAtVersion(fileId, sum.getId());
verify(UnifiedRepositoryPurgeService.getRepoWs(), times(4)).deleteFileWithPermanentFlag(eq(fileId), eq(true), anyString());
}
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method verifyDateBeforeDeletion.
private static void verifyDateBeforeDeletion(HashMap<String, List<VersionSummary>> versionListMap, IUnifiedRepository mockRepo, String fileId, Date beforeDate) {
int i = 0;
List<VersionSummary> list = versionListMap.get(fileId);
for (VersionSummary sum : list) {
if (beforeDate.after(sum.getDate()) && !sum.getId().equals(list.get(list.size() - 1).getId())) {
verify(mockRepo, times(1)).deleteFileAtVersion(fileId, sum.getId());
} else {
verify(mockRepo, never()).deleteFileAtVersion(fileId, sum.getId());
}
}
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method doPurgeUtilPurgeFileTest.
@Test
public void doPurgeUtilPurgeFileTest() throws PurgeDeletionException {
IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
UnifiedRepositoryPurgeService purgeService = getPurgeService(mockRepo);
PurgeUtilitySpecification spec = new PurgeUtilitySpecification();
spec.purgeFiles = true;
spec.setPath("/");
purgeService.doDeleteRevisions(spec);
verifyAllVersionsDeleted(versionListMap, mockRepo, "1");
verifyAllVersionsDeleted(versionListMap, mockRepo, "2");
verify(UnifiedRepositoryPurgeService.getRepoWs(), times(1)).deleteFileWithPermanentFlag(eq("1"), eq(true), anyString());
verify(UnifiedRepositoryPurgeService.getRepoWs(), times(1)).deleteFileWithPermanentFlag(eq("2"), eq(true), anyString());
}
Aggregations