use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository in project pentaho-kettle by pentaho.
the class PurRepository_GetObjectInformation_IT method getObjectInformation_InvalidRepositoryId_ExceptionIsHandled.
@Test
public void getObjectInformation_InvalidRepositoryId_ExceptionIsHandled() throws Exception {
IUnifiedRepository unifiedRepository = mock(IUnifiedRepository.class);
when(unifiedRepository.getFileById(any(Serializable.class))).thenThrow(new RuntimeException("unknown id"));
purRepository.setTest(unifiedRepository);
RepositoryObject information = purRepository.getObjectInformation(new StringObjectId("invalid id"), RepositoryObjectType.JOB);
assertNull("Should return null if file was not found", information);
}
use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository 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.IUnifiedRepository 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.IUnifiedRepository 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());
}
use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository 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());
}
Aggregations