Search in sources :

Example 6 with IUnifiedRepository

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());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 7 with IUnifiedRepository

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());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 8 with IUnifiedRepository

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);
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) Repository(org.pentaho.di.repository.Repository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) TransMeta(org.pentaho.di.trans.TransMeta) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) StringObjectId(org.pentaho.di.repository.StringObjectId) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 9 with IUnifiedRepository

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"));
    }
}
Also used : DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) Properties(java.util.Properties) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 10 with IUnifiedRepository

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);
}
Also used : Repository(org.pentaho.di.repository.Repository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Aggregations

IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)88 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)61 Test (org.junit.Test)51 Matchers.anyString (org.mockito.Matchers.anyString)37 ArrayList (java.util.ArrayList)18 List (java.util.List)10 StringObjectId (org.pentaho.di.repository.StringObjectId)10 Serializable (java.io.Serializable)9 DatabaseDialectService (org.pentaho.database.service.DatabaseDialectService)7 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)7 DataNode (org.pentaho.platform.api.repository2.unified.data.node.DataNode)7 InputStream (java.io.InputStream)6 JobMeta (org.pentaho.di.job.JobMeta)6 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)6 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)6 HashMap (java.util.HashMap)5 ObjectId (org.pentaho.di.repository.ObjectId)5 IDatasourceMgmtService (org.pentaho.platform.api.repository.datasource.IDatasourceMgmtService)5 Properties (java.util.Properties)4 Log (org.apache.commons.logging.Log)4