Search in sources :

Example 81 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceMetaFactoryTest method testCreateDataServiceName.

@Test
public void testCreateDataServiceName() throws Exception {
    when(transMeta.getObjectId()).thenReturn(null);
    when(transMeta.getFilename()).thenReturn("C:\\windows\\path\\file.ktr");
    DataServiceMeta ds1 = factory.createDataService(stepMeta);
    assertTrue(TransientResolver.isTransient(ds1.getName()));
    when(transMeta.getFilename()).thenReturn("/unix/path/file.ktr");
    DataServiceMeta ds2 = factory.createDataService(stepMeta);
    assertTrue(TransientResolver.isTransient(ds2.getName()));
    RepositoryDirectoryInterface repositoryDirectoryInterface = mock(RepositoryDirectoryInterface.class);
    when(repositoryDirectoryInterface.getPath()).thenReturn("/repository/path");
    when(transMeta.getObjectId()).thenReturn(mock(ObjectId.class));
    when(transMeta.getFilename()).thenReturn("/unix/path/file.ktr");
    when(transMeta.getRepositoryDirectory()).thenReturn(repositoryDirectoryInterface);
    DataServiceMeta ds3 = factory.createDataService(stepMeta);
    assertTrue(TransientResolver.isTransient(ds3.getName()));
    repositoryDirectoryInterface = mock(RepositoryDirectoryInterface.class);
    when(repositoryDirectoryInterface.getPath()).thenReturn("/repository/path");
    when(transMeta.getFilename()).thenReturn("");
    when(transMeta.getRepositoryDirectory()).thenReturn(repositoryDirectoryInterface);
    DataServiceMeta ds6 = factory.createDataService(stepMeta);
    assertTrue(TransientResolver.isTransient(ds6.getName()));
    when(repositoryDirectoryInterface.getPath()).thenReturn("/repository/path/");
    when(transMeta.getFilename()).thenReturn("");
    when(transMeta.getRepositoryDirectory()).thenReturn(repositoryDirectoryInterface);
    DataServiceMeta ds4 = factory.createDataService(stepMeta);
    assertTrue(TransientResolver.isTransient(ds4.getName()));
    when(transMeta.getRepositoryDirectory()).thenReturn(null);
    DataServiceMeta ds5 = factory.createDataService(stepMeta);
    assertTrue(TransientResolver.isTransient(ds5.getName()));
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ObjectId(org.pentaho.di.repository.ObjectId) Test(org.junit.Test)

Example 82 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pdi-dataservice-server-plugin by pentaho.

the class TransientResolverTest method testGetDataService.

private void testGetDataService(String fileSeparator) throws Exception {
    RepositoryDirectoryInterface directory = mock(RepositoryDirectoryInterface.class);
    when(root.findDirectory(fileSeparator + "path" + fileSeparator + "to")).thenReturn(directory);
    when(repository.getTransformationID("name", directory)).thenReturn(objectId);
    when(repository.loadTransformation(objectId, null)).thenReturn(transMeta);
    String transientId = TransientResolver.buildTransient(fileSeparator + "path" + fileSeparator + "to" + fileSeparator + "name", "data_service");
    DataServiceMeta dataServiceMeta = transientResolver.getDataService(transientId);
    assertNotNull(dataServiceMeta);
    assertThat(dataServiceMeta.getStepname(), is("data_service"));
    assertFalse(dataServiceMeta.isUserDefined());
    assertThat(dataServiceMeta, hasServiceCacheOptimization());
    int rowLimit = 1000;
    transientId = TransientResolver.buildTransient(fileSeparator + "path" + fileSeparator + "to" + fileSeparator + "name", "data_service", rowLimit);
    dataServiceMeta = transientResolver.getDataService(transientId);
    assertEquals(rowLimit, dataServiceMeta.getRowLimit());
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta)

Example 83 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceReferenceSynchronizerTest method before.

@Before
public void before() {
    ObjectId transId = new StringObjectId("transId");
    when(transMeta.getMetaStore()).thenReturn(externalMetastore);
    when(transMeta.getEmbeddedMetaStore()).thenReturn(embeddedMetastore);
    when(transMeta.getObjectId()).thenReturn(transId);
    when(transMeta.getRepository()).thenReturn(repository);
    when(repository.getRepositoryMeta()).thenReturn(repositoryMeta);
    when(repositoryMeta.getRepositoryCapabilities()).thenReturn(mock(RepositoryCapabilities.class));
    RepositoryDirectoryInterface root = mock(RepositoryDirectoryInterface.class);
    RepositoryDirectoryInterface dir = new RepositoryDirectory(root, "location");
    when(root.findDirectory(eq("/"))).thenReturn(dir);
    try {
        when(repository.getTransformationID(eq("location"), eq(dir))).thenReturn(transId);
        when(repository.loadRepositoryDirectoryTree()).thenReturn(root);
    } catch (KettleException ke) {
    // Noop
    }
    when(context.getPushDownFactories()).thenReturn(Collections.emptyList());
    synchronizer = new DataServiceReferenceSynchronizer(context) {

        protected <T> MetaStoreFactory<T> getMetastoreFactory(IMetaStore metaStore, Class<T> clazz) {
            return externalMetaStoreFactory;
        }

        protected MetaStoreFactory<DataServiceMeta> getEmbeddedMetaStoreFactory(TransMeta meta) {
            return embeddedMetaStoreFactory;
        }
    };
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) MetaStoreFactory(org.pentaho.metastore.persist.MetaStoreFactory) TransMeta(org.pentaho.di.trans.TransMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) IMetaStore(org.pentaho.metastore.api.IMetaStore) RepositoryCapabilities(org.pentaho.di.repository.RepositoryCapabilities) Before(org.junit.Before)

Example 84 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-metaverse by pentaho.

the class JobJobEntryAnalyzerTest method testAnalyzeWithRepoByName.

@Test
public void testAnalyzeWithRepoByName() throws Exception {
    Repository repo = mock(Repository.class);
    RepositoryDirectoryInterface repoDir = mock(RepositoryDirectoryInterface.class);
    when(mockParentJobMeta.getRepository()).thenReturn(repo);
    when(jobEntryJob.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
    // Test exception
    when(repo.findDirectory(anyString())).thenReturn(repoDir);
    when(repo.loadJob(anyString(), eq(repoDir), any(ProgressMonitorListener.class), anyString())).thenReturn(childJobMeta);
    spyAnalyzer.analyze(descriptor, jobEntryJob);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) ProgressMonitorListener(org.pentaho.di.core.ProgressMonitorListener) Test(org.junit.Test)

Example 85 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-metaverse by pentaho.

the class TransJobEntryAnalyzerTest method testAnalyzeWithRepoByName.

@Test
public void testAnalyzeWithRepoByName() throws Exception {
    Repository repo = mock(Repository.class);
    RepositoryDirectoryInterface repoDir = mock(RepositoryDirectoryInterface.class);
    when(mockParentJobMeta.getRepository()).thenReturn(repo);
    when(jobEntryTrans.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
    when(repo.findDirectory(anyString())).thenReturn(repoDir);
    when(repo.loadTransformation(anyString(), eq(repoDir), any(ProgressMonitorListener.class), anyBoolean(), anyString())).thenReturn(childTransMeta);
    spyAnalyzer.analyze(descriptor, jobEntryTrans);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) ProgressMonitorListener(org.pentaho.di.core.ProgressMonitorListener) Test(org.junit.Test)

Aggregations

RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)163 KettleException (org.pentaho.di.core.exception.KettleException)68 Test (org.junit.Test)32 TransMeta (org.pentaho.di.trans.TransMeta)30 ObjectId (org.pentaho.di.repository.ObjectId)27 JobMeta (org.pentaho.di.job.JobMeta)23 Repository (org.pentaho.di.repository.Repository)22 ArrayList (java.util.ArrayList)17 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)17 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)15 IOException (java.io.IOException)14 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)13 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)11 RepositoryObject (org.pentaho.di.repository.RepositoryObject)11 FileObject (org.apache.commons.vfs2.FileObject)10 List (java.util.List)8 TreeItem (org.eclipse.swt.widgets.TreeItem)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)8 Date (java.util.Date)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)7