use of org.pentaho.metaverse.api.analyzer.kettle.IExternalResourceConsumer in project pentaho-metaverse by pentaho.
the class BaseStepExternalResourceConsumerTest method testGetResourcesFromMeta.
@Test
public void testGetResourcesFromMeta() throws Exception {
Collection<IExternalResourceConsumer> resources = null;
BaseStepMeta meta = null;
// null meta
resources = consumer.getResourcesFromMeta(meta);
assertNotNull(resources);
assertTrue(resources.isEmpty());
// non-file meta
meta = Mockito.mock(BaseStepMeta.class);
resources = consumer.getResourcesFromMeta(meta);
assertNotNull(resources);
assertTrue(resources.isEmpty());
Mockito.verify(meta, Mockito.times(0)).getParentStepMeta();
// file meta
meta = Mockito.mock(BaseFileMeta.class);
TransMeta transMeta = Mockito.mock(TransMeta.class);
StepMeta stepMeta = Mockito.mock(StepMeta.class);
Mockito.when(((BaseFileMeta) meta).writesToFile()).thenReturn(true);
Mockito.when(meta.getParentStepMeta()).thenReturn(stepMeta);
Mockito.when(stepMeta.getParentTransMeta()).thenReturn(transMeta);
consumer.getResourcesFromMeta(meta);
Mockito.verify(meta, Mockito.times(2)).getParentStepMeta();
Mockito.verify((BaseFileMeta) meta, Mockito.times(1)).getFilePaths(false);
}
Aggregations