use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository 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.IUnifiedRepository 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.IUnifiedRepository in project pentaho-kettle by pentaho.
the class StreamToNodeConvertersPrivateDatabasesTest method getData.
@Parameterized.Parameters
public static List<Object[]> getData() throws Exception {
RepositoryFile repositoryFile = new RepositoryFile.Builder("test file").build();
IUnifiedRepository pur = mock(IUnifiedRepository.class);
when(pur.getFileById(FILE_ID)).thenReturn(repositoryFile);
TransMeta transMeta = new TransMeta();
JobMeta jobMeta = new JobMeta();
Repository repository = mock(Repository.class);
when(repository.loadTransformation(any(StringObjectId.class), anyString())).thenReturn(transMeta);
when(repository.loadJob(any(StringObjectId.class), anyString())).thenReturn(jobMeta);
StreamToTransNodeConverter transNodeConverter = new StreamToTransNodeConverter(pur);
transNodeConverter = spy(transNodeConverter);
doReturn(repository).when(transNodeConverter).connectToRepository();
StreamToJobNodeConverter jobNodeConverter = new StreamToJobNodeConverter(pur);
jobNodeConverter = spy(jobNodeConverter);
doReturn(repository).when(jobNodeConverter).connectToRepository();
Object[] trans = { transNodeConverter, TransMeta.XML_TAG, transMeta };
Object[] job = { jobNodeConverter, JobMeta.XML_TAG, jobMeta };
return asList(trans, job);
}
use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository in project pentaho-kettle by pentaho.
the class DatabaseDelegateTest method testExtraOptionEscapeWithInvalidCharInDatabaseType.
@Test
public void testExtraOptionEscapeWithInvalidCharInDatabaseType() throws KettleException {
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
when(dbMeta.getPluginId()).thenReturn("pluginId");
when(dbMeta.getAccessTypeDesc()).thenReturn("Native");
when(dbMeta.getHostname()).thenReturn("AS/400Host");
when(dbMeta.getDatabaseName()).thenReturn("mainframeTable");
when(dbMeta.getDatabasePortNumberString()).thenReturn("1234");
when(dbMeta.getUsername()).thenReturn("testUser");
when(dbMeta.getPassword()).thenReturn("123");
when(dbMeta.getServername()).thenReturn("as400.dot.com");
when(dbMeta.getDataTablespace()).thenReturn("tableSpace");
when(dbMeta.getIndexTablespace()).thenReturn("123");
// Create an extra options that has an unsupported character like '/'
Properties extraOptions = new Properties();
extraOptions.setProperty("EXTRA_OPTION_AS/400.optionExtraOption", "true");
when(dbMeta.getAttributes()).thenReturn(extraOptions);
IUnifiedRepository purRepo = mock(IUnifiedRepository.class);
when(purRepo.getReservedChars()).thenReturn(Arrays.asList(new Character[] { '/' }));
when(mockPurRepository.getUnderlyingRepository()).thenReturn(purRepo);
DataNode escapedAttributes = dbDelegate.elementToDataNode(dbMeta);
// Should only be one option in list
for (Iterator<DataNode> iter = escapedAttributes.getNodes().iterator(); iter.hasNext(); ) {
DataNode options = iter.next();
assertTrue("Invalid escaped extra options", options.hasProperty("EXTRA_OPTION_AS%2F400.optionExtraOption"));
assertFalse("Should not contain un-escaped option", options.hasProperty("EXTRA_OPTION_AS/400.optionExtraOption"));
}
}
use of org.pentaho.platform.api.repository2.unified.IUnifiedRepository in project pentaho-kettle by pentaho.
the class DelegatesPrivateDatabasesTest method getData.
@Parameterized.Parameters
public static List<Object[]> getData() {
Repository repository = mock(Repository.class);
IUnifiedRepository pur = mock(IUnifiedRepository.class);
Object[] trans = { new TransDelegate(repository, pur), new TransMeta(), TransDelegate.NODE_TRANS_PRIVATE_DATABASES, TransDelegate.PROP_TRANS_PRIVATE_DATABASE_NAMES };
Object[] job = { new JobDelegate(repository, pur), new JobMeta(), JobDelegate.NODE_JOB_PRIVATE_DATABASES, JobDelegate.PROP_JOB_PRIVATE_DATABASE_NAMES };
return Arrays.asList(trans, job);
}
Aggregations