use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class CsvFileInputExternalResourceConsumerTest method testCsvInputExternalResourceConsumer.
@Test
public void testCsvInputExternalResourceConsumer() throws Exception {
CsvFileInputExternalResourceConsumer consumer = new CsvFileInputExternalResourceConsumer();
StepMeta stepMeta = spy(new StepMeta("test", meta));
when(meta.getParentStepMeta()).thenReturn(stepMeta);
when(stepMeta.getParentTransMeta()).thenReturn(transMeta);
String[] filePaths = { "/path/to/file1", "/another/path/to/file2" };
when(meta.getFilePaths(Mockito.any(VariableSpace.class))).thenReturn(filePaths);
assertFalse(consumer.isDataDriven(meta));
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromMeta(meta);
assertFalse(resources.isEmpty());
assertEquals(2, resources.size());
when(rmi.getString(Mockito.any(Object[].class), Mockito.anyString(), Mockito.anyString())).thenThrow(KettleException.class);
resources = consumer.getResourcesFromRow(input, rmi, new String[] { "id", "name" });
assertTrue(resources.isEmpty());
assertEquals(CsvInputMeta.class, consumer.getMetaClass());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class CsvFileInputStepAnalyzerTest method testCreateResourceNode.
@Test
public void testCreateResourceNode() throws Exception {
IExternalResourceInfo res = mock(IExternalResourceInfo.class);
when(res.getName()).thenReturn("file:///Users/home/tmp/xyz.ktr");
IMetaverseNode resourceNode = analyzer.createResourceNode(res);
assertNotNull(resourceNode);
assertEquals(DictionaryConst.NODE_TYPE_FILE, resourceNode.getType());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class ExcelInputStepAnalyzerTest method resourcesFromMetaGotSuccessfully.
@Test
public void resourcesFromMetaGotSuccessfully() throws Exception {
StepMeta spyMeta = spy(new StepMeta("test", meta));
when(meta.getParentStepMeta()).thenReturn(spyMeta);
when(spyMeta.getParentTransMeta()).thenReturn(transMeta);
when(meta.getFileName()).thenReturn(null);
when(meta.isAcceptingFilenames()).thenReturn(false);
String[] filePaths = { "/path/to/file1", "/another/path/to/file2" };
when(meta.getFilePaths(Mockito.any(VariableSpace.class))).thenReturn(filePaths);
assertFalse(consumer.isDataDriven(meta));
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromMeta(meta);
assertEquals(2, resources.size());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class ExcelOutputStepAnalyzerTest method testCreateResourceNode.
@Test
public void testCreateResourceNode() throws Exception {
IExternalResourceInfo res = mock(IExternalResourceInfo.class);
when(res.getName()).thenReturn("file:///Users/home/tmp/xyz.ktr");
IMetaverseNode resourceNode = analyzer.createResourceNode(res);
assertNotNull(resourceNode);
assertEquals(DictionaryConst.NODE_TYPE_FILE, resourceNode.getType());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class HTTPClientStepAnalyzerTest method testHTTPClientExternalResourceConsumer.
@Test
public void testHTTPClientExternalResourceConsumer() throws Exception {
HTTPClientExternalResourceConsumer consumer = new HTTPClientExternalResourceConsumer();
StepMeta spyMeta = spy(new StepMeta("test", meta));
when(meta.getParentStepMeta()).thenReturn(spyMeta);
when(spyMeta.getParentTransMeta()).thenReturn(mockTransMeta);
when(meta.getUrl()).thenReturn("http://seylermartialarts.com");
when(meta.isUrlInField()).thenReturn(false);
assertTrue(consumer.isDataDriven(meta));
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromMeta(meta);
assertFalse(resources.isEmpty());
assertEquals(1, resources.size());
when(meta.isUrlInField()).thenReturn(true);
assertTrue(consumer.isDataDriven(meta));
assertTrue(consumer.getResourcesFromMeta(meta).isEmpty());
when(mockRowMetaInterface.getString(Mockito.any(Object[].class), Mockito.anyString(), Mockito.anyString())).thenReturn("/path/to/row/file");
resources = consumer.getResourcesFromRow(mockHTTP, mockRowMetaInterface, new String[] { "id", "name" });
assertFalse(resources.isEmpty());
assertEquals(1, resources.size());
when(mockRowMetaInterface.getString(Mockito.any(Object[].class), Mockito.anyString(), Mockito.anyString())).thenThrow(KettleException.class);
resources = consumer.getResourcesFromRow(mockHTTP, mockRowMetaInterface, new String[] { "id", "name" });
assertTrue(resources.isEmpty());
assertEquals(HTTPMeta.class, consumer.getMetaClass());
}
Aggregations