use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class PurRepository_MoveAndRename_IT method rename_CreatesNewRevision.
private void rename_CreatesNewRevision(Assistant assistant) throws Exception {
final String initial = "rename_CreatesNewRevision";
final String renamed = initial + "_renamed";
AbstractMeta meta = assistant.createNew();
assistant.save(meta, initial, getPublicDir());
List<VersionSummary> historyBefore = unifiedRepository.getVersionSummaries(meta.getObjectId().getId());
long before = System.currentTimeMillis();
assistant.rename(meta, renamed);
long after = System.currentTimeMillis();
List<VersionSummary> historyAfter = unifiedRepository.getVersionSummaries(meta.getObjectId().getId());
assertEquals(historyBefore.size() + 1, historyAfter.size());
long newRevisionTs = historyAfter.get(historyAfter.size() - 1).getDate().getTime();
assertTrue(String.format("%d <= %d <= %d", before, newRevisionTs, after), (before <= newRevisionTs) && (newRevisionTs <= after));
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class PurRepository_Revisions_IT method testOnlyRevision_DateAndCommentAreSaved.
private void testOnlyRevision_DateAndCommentAreSaved(RepositoryElementInterface transOrJob) throws Exception {
final String elementName = "onlyRevision_" + transOrJob.getRepositoryElementType();
final String comment = "onlyRevision";
final Calendar date = Calendar.getInstance();
date.setTimeInMillis(0);
transOrJob.setName(elementName);
transOrJob.setRepositoryDirectory(purRepository.getDefaultSaveDirectory(transOrJob));
purRepository.save(transOrJob, comment, date, null, false);
assertCommentAndDate(transOrJob.getObjectRevision(), date, comment);
List<VersionSummary> versions = assertExistsAndGetRevisions(transOrJob);
assertEquals(1, versions.size());
assertCommentAndDate(versions.get(0), date, comment);
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method processVersionMap.
private HashMap<String, List<VersionSummary>> processVersionMap(IUnifiedRepository mockRepo) {
// Build versionListMap
final HashMap<String, List<VersionSummary>> versionListMap = new HashMap<String, List<VersionSummary>>();
List<VersionSummary> mockVersionList = new ArrayList<VersionSummary>();
Date d = null;
String fileId = null;
for (String[] values : versionData) {
d = getDate(values[2]);
if (!values[1].equals(fileId)) {
if (fileId != null) {
versionListMap.put(fileId, mockVersionList);
}
mockVersionList = new ArrayList<VersionSummary>();
}
fileId = values[1];
VersionSummary versionSummary = new VersionSummary(values[0], fileId, false, d, values[3], values[4], Arrays.asList(new String[] { values[5] }));
mockVersionList.add(versionSummary);
}
versionListMap.put(fileId, mockVersionList);
final ArgumentCaptor<String> fileIdArgument = ArgumentCaptor.forClass(String.class);
when(mockRepo.getVersionSummaries(fileIdArgument.capture())).thenAnswer(new Answer<List<VersionSummary>>() {
public List<VersionSummary> answer(InvocationOnMock invocation) throws Throwable {
return versionListMap.get(fileIdArgument.getValue());
}
});
return versionListMap;
}
use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method deleteAllVersionsTest.
@Test
public void deleteAllVersionsTest() throws KettleException {
IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService(mockRepo);
String fileId = "1";
purgeService.deleteAllVersions(element1);
verifyAllVersionsDeleted(versionListMap, mockRepo, "1");
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 doPurgeUtilVersionCountTest.
@Test
public void doPurgeUtilVersionCountTest() throws PurgeDeletionException {
IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
UnifiedRepositoryPurgeService purgeService = getPurgeService(mockRepo);
PurgeUtilitySpecification spec = new PurgeUtilitySpecification();
spec.setVersionCount(3);
spec.setPath("/");
purgeService.doDeleteRevisions(spec);
verifyVersionCountDeletion(versionListMap, mockRepo, "1", spec.getVersionCount());
verifyVersionCountDeletion(versionListMap, mockRepo, "2", spec.getVersionCount());
}
Aggregations