Search in sources :

Example 71 with Repository

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

the class JobJobEntryAnalyzerTest method testAnalyzeWithRepoByRefThrowsException.

@Test(expected = MetaverseAnalyzerException.class)
public void testAnalyzeWithRepoByRefThrowsException() throws Exception {
    Repository repo = mock(Repository.class);
    when(mockParentJobMeta.getRepository()).thenReturn(repo);
    when(jobEntryJob.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE);
    // Test exception
    when(repo.loadJob(any(ObjectId.class), anyString())).thenThrow(new KettleException());
    spyAnalyzer.analyze(descriptor, jobEntryJob);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) ObjectId(org.pentaho.di.repository.ObjectId) Test(org.junit.Test)

Example 72 with Repository

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

the class TransJobEntryAnalyzerTest method testAnalyzeWithRepoByNameThrowsException.

@Test(expected = MetaverseAnalyzerException.class)
public void testAnalyzeWithRepoByNameThrowsException() throws Exception {
    Repository repo = mock(Repository.class);
    when(mockParentJobMeta.getRepository()).thenReturn(repo);
    when(jobEntryTrans.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
    // Test exception
    when(repo.findDirectory(anyString())).thenThrow(new KettleException());
    spyAnalyzer.analyze(descriptor, jobEntryTrans);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) Test(org.junit.Test)

Example 73 with Repository

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

the class TransJobEntryAnalyzerTest method testAnalyzeWithRepoByRefThrowsException.

@Test(expected = MetaverseAnalyzerException.class)
public void testAnalyzeWithRepoByRefThrowsException() throws Exception {
    Repository repo = mock(Repository.class);
    when(mockParentJobMeta.getRepository()).thenReturn(repo);
    when(jobEntryTrans.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE);
    // Test exception
    when(repo.loadTransformation(any(ObjectId.class), anyString())).thenThrow(new KettleException());
    spyAnalyzer.analyze(descriptor, jobEntryTrans);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) ObjectId(org.pentaho.di.repository.ObjectId) Test(org.junit.Test)

Example 74 with Repository

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

the class TransExecutorStepAnalyzerTest method testCustomAnalyze_repoFile_ErrorFindingRepoDir.

@Test(expected = MetaverseAnalyzerException.class)
public void testCustomAnalyze_repoFile_ErrorFindingRepoDir() throws Exception {
    // we should get an exception if the sub transformation isn't found on the filesystem
    when(meta.getDirectoryPath()).thenReturn("/home/admin");
    when(meta.getTransName()).thenReturn("my.ktr");
    Repository repo = mock(Repository.class);
    when(parentTransMeta.getRepository()).thenReturn(repo);
    when(repo.findDirectory(anyString())).thenThrow(new KettleException());
    when(meta.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
    spyAnalyzer.customAnalyze(meta, node);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) Test(org.junit.Test)

Example 75 with Repository

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

the class TransExecutorStepAnalyzerTest method testCustomAnalyze_repoRef.

@Test
public void testCustomAnalyze_repoRef() throws Exception {
    when(meta.getTransObjectId()).thenReturn(mock(ObjectId.class));
    Repository repo = mock(Repository.class);
    RepositoryDirectoryInterface repoDir = mock(RepositoryDirectoryInterface.class);
    when(repo.findDirectory(anyString())).thenReturn(repoDir);
    when(repo.loadTransformation(any(ObjectId.class), anyString())).thenReturn(childTransMeta);
    when(parentTransMeta.getRepository()).thenReturn(repo);
    doReturn(childTransMeta).when(spyAnalyzer).getSubTransMeta(anyString());
    when(childTransMeta.getPathAndName()).thenReturn("/home/admin/my");
    when(childTransMeta.getDefaultExtension()).thenReturn("ktr");
    when(meta.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_REFERENCE);
    // don't bother running the connectX methods, we'll test those later
    doNothing().when(spyAnalyzer).connectToSubTransInputFields(eq(meta), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
    doNothing().when(spyAnalyzer).connectToSubTransOutputFields(eq(meta), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
    spyAnalyzer.customAnalyze(meta, node);
    verify(node).setProperty(eq(TransExecutorStepAnalyzer.TRANSFORMATION_TO_EXECUTE), Mockito.contains("/home/admin/my.ktr"));
    // we should have one link created that "executes" the sub transformation
    verify(builder, times(1)).addLink(eq(node), eq(DictionaryConst.LINK_EXECUTES), any(IMetaverseNode.class));
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) ObjectId(org.pentaho.di.repository.ObjectId) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Test(org.junit.Test)

Aggregations

Repository (org.pentaho.di.repository.Repository)143 Test (org.junit.Test)69 KettleException (org.pentaho.di.core.exception.KettleException)54 TransMeta (org.pentaho.di.trans.TransMeta)39 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)21 IMetaStore (org.pentaho.metastore.api.IMetaStore)20 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)19 JobMeta (org.pentaho.di.job.JobMeta)18 ObjectId (org.pentaho.di.repository.ObjectId)14 StepMeta (org.pentaho.di.trans.step.StepMeta)14 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)14 StringObjectId (org.pentaho.di.repository.StringObjectId)13 Variables (org.pentaho.di.core.variables.Variables)12 ArrayList (java.util.ArrayList)11 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)11 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)11 VariableSpace (org.pentaho.di.core.variables.VariableSpace)11 RepositoriesMeta (org.pentaho.di.repository.RepositoriesMeta)11 RepositoryPluginType (org.pentaho.di.core.plugins.RepositoryPluginType)10 IOException (java.io.IOException)9