use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class FixedFileInputStepAnalyzerTest method testFixedFileInputExternalResourceConsumer_nullFileName.
@Test
public void testFixedFileInputExternalResourceConsumer_nullFileName() throws Exception {
FixedFileInputExternalResourceConsumer consumer = new FixedFileInputExternalResourceConsumer();
StepMeta spyMeta = spy(new StepMeta("test", meta));
when(meta.getParentStepMeta()).thenReturn(spyMeta);
when(spyMeta.getParentTransMeta()).thenReturn(transMeta);
when(meta.getFilename()).thenReturn(null);
assertFalse(consumer.isDataDriven(meta));
assertTrue(consumer.getResourcesFromMeta(meta).isEmpty());
when(rmi.getString(Mockito.any(Object[].class), Mockito.anyString(), Mockito.anyString())).thenThrow(KettleException.class);
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromRow(input, rmi, new String[] { "id", "name" });
assertTrue(resources.isEmpty());
assertEquals(FixedInputMeta.class, consumer.getMetaClass());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class FixedFileInputStepAnalyzerTest method testFixedFileInputExternalResourceConsumer.
@Test
public void testFixedFileInputExternalResourceConsumer() throws Exception {
FixedFileInputExternalResourceConsumer consumer = new FixedFileInputExternalResourceConsumer();
StepMeta spyMeta = spy(new StepMeta("test", meta));
when(meta.getParentStepMeta()).thenReturn(spyMeta);
when(spyMeta.getParentTransMeta()).thenReturn(transMeta);
when(meta.getFilename()).thenReturn("path/to/file.txt");
assertFalse(consumer.isDataDriven(meta));
assertFalse(consumer.getResourcesFromMeta(meta).isEmpty());
when(rmi.getString(Mockito.any(Object[].class), Mockito.anyString(), Mockito.anyString())).thenThrow(KettleException.class);
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromRow(input, rmi, new String[] { "id", "name" });
assertTrue(resources.isEmpty());
assertEquals(FixedInputMeta.class, consumer.getMetaClass());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class RestClientStepAnalyzerTest method testCreateResourceNode.
@Test
public void testCreateResourceNode() throws Exception {
IExternalResourceInfo res = mock(IExternalResourceInfo.class);
when(res.getName()).thenReturn("http://my.rest.url");
IMetaverseNode resourceNode = analyzer.createResourceNode(res);
assertNotNull(resourceNode);
assertEquals(DictionaryConst.NODE_TYPE_WEBSERVICE, resourceNode.getType());
assertEquals("http://my.rest.url", resourceNode.getName());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class TableInputExternalResourceConsumerTest method testGetResourcesFromMeta.
@Test
public void testGetResourcesFromMeta() throws Exception {
when(meta.getSQL()).thenReturn("select * from table");
when(meta.getDatabaseMeta()).thenReturn(dbMeta);
Collection<IExternalResourceInfo> resourceInfos = consumer.getResourcesFromMeta(meta, context);
assertNotNull(resourceInfos);
assertEquals(1, resourceInfos.size());
IExternalResourceInfo info = resourceInfos.iterator().next();
assertEquals("select * from table", info.getAttributes().get(DictionaryConst.PROPERTY_QUERY));
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class TableOutputExternalResourceConsumerTest method testGetResourcesFromMeta_runtime.
@Test
public void testGetResourcesFromMeta_runtime() throws Exception {
TableOutputMeta meta = mock(TableOutputMeta.class);
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
DatabaseInterface dbi = mock(DatabaseInterface.class);
when(meta.getDatabaseMeta()).thenReturn(dbMeta);
when(meta.getTableName()).thenReturn("tableName");
when(meta.getSchemaName()).thenReturn("schemaName");
when(meta.getParentStepMeta()).thenReturn(parentStepMeta);
when(parentStepMeta.getParentTransMeta()).thenReturn(parentTransMeta);
when(parentTransMeta.environmentSubstitute("tableName")).thenReturn("tableName");
when(parentTransMeta.environmentSubstitute("schemaName")).thenReturn("schemaName");
when(dbMeta.getAccessTypeDesc()).thenReturn("JNDI");
when(dbMeta.getName()).thenReturn("TestConnection");
when(dbMeta.getDescription()).thenReturn("my conn description");
when(dbMeta.getDatabaseInterface()).thenReturn(dbi);
when(dbi.getPluginId()).thenReturn("POSTGRESQL");
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromMeta(meta, new AnalysisContext(DictionaryConst.CONTEXT_RUNTIME));
assertEquals(1, resources.size());
IExternalResourceInfo res = resources.iterator().next();
assertEquals("TestConnection", res.getName());
assertEquals("tableName", res.getAttributes().get(DictionaryConst.PROPERTY_TABLE));
assertEquals("schemaName", res.getAttributes().get(DictionaryConst.PROPERTY_SCHEMA));
}
Aggregations