use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method doPurgeUtilDateBeforeTest.
@Test
public void doPurgeUtilDateBeforeTest() throws PurgeDeletionException {
IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
UnifiedRepositoryPurgeService purgeService = getPurgeService(mockRepo);
PurgeUtilitySpecification spec = new PurgeUtilitySpecification();
spec.setBeforeDate(getDate("01/02/2006"));
spec.setPath("/");
purgeService.doDeleteRevisions(spec);
verifyDateBeforeDeletion(versionListMap, mockRepo, "1", spec.getBeforeDate());
verifyDateBeforeDeletion(versionListMap, mockRepo, "2", spec.getBeforeDate());
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method deleteVersionTest.
@Test
public void deleteVersionTest() throws KettleException {
IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService(mockRepo);
String fileId = "1";
String versionId = "103";
purgeService.deleteVersion(element1, versionId);
verify(mockRepo, times(1)).deleteFileAtVersion(fileId, versionId);
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 keepNumberOfVersionsTest.
@Test
public void keepNumberOfVersionsTest() 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 = 2;
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 RevisionResourceTest method getMockVersionSummaries.
/**
* Return mock list of version summaries
*
* @return
*/
private List<VersionSummary> getMockVersionSummaries() {
List<VersionSummary> versionSummaries = new ArrayList<VersionSummary>();
VersionSummary versionSummary1 = new VersionSummary(MOCK_VERSION_ID_1, MOCK_FILE_ID, false, new Date(), MOCK_VERSION_AUTHOR_1, MOCK_VERSION_MESSAGE_1, new ArrayList<String>());
versionSummaries.add(versionSummary1);
return versionSummaries;
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeService method keepNumberOfVersions.
@Override
public void keepNumberOfVersions(Serializable fileId, int versionCount) {
List<VersionSummary> versionList = unifiedRepository.getVersionSummaries(fileId);
int i = 0;
int listSize = versionList.size();
if (listSize > versionCount) {
getLogger().info("version count: removing versions");
}
for (VersionSummary versionSummary : versionList) {
if (i < listSize - versionCount) {
Serializable versionId = versionSummary.getId();
getLogger().debug("removing version " + versionId.toString());
unifiedRepository.deleteFileAtVersion(fileId, versionId);
i++;
} else {
break;
}
}
}
Aggregations