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()));
}
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());
}
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;
}
};
}
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);
}
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);
}
Aggregations