use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
analyzer = spy(new ExternalResourceStepAnalyzer<BaseStepMeta>() {
@Override
public Set<Class<? extends BaseStepMeta>> getSupportedSteps() {
return null;
}
@Override
protected Set<StepField> getUsedFields(BaseStepMeta meta) {
Set<StepField> stepFields = new HashSet<>();
stepFields.add(new StepField("prevStep", "filename"));
return stepFields;
}
@Override
public IMetaverseNode createResourceNode(IExternalResourceInfo resource) throws MetaverseException {
return resourceNode;
}
@Override
public String getResourceInputNodeType() {
return "INPUT_TYPE";
}
@Override
public String getResourceOutputNodeType() {
return "OUTPUT_TYPE";
}
@Override
public boolean isOutput() {
return false;
}
@Override
public boolean isInput() {
return true;
}
});
when(analyzer.getMetaverseBuilder()).thenReturn(builder);
analyzer.descriptor = descriptor;
analyzer.parentTransMeta = parentTransMeta;
analyzer.parentStepMeta = parentStepMeta;
analyzer.setMetaverseObjectFactory(new MetaverseObjectFactory());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-kettle by pentaho.
the class GetXMLDataStepAnalyzerTest method testCreateResourceNode.
@Test
public void testCreateResourceNode() throws Exception {
IExternalResourceInfo res = mock(IExternalResourceInfo.class);
when(res.getName()).thenReturn("file:///Users/home/tmp/xyz.xml");
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-kettle by pentaho.
the class GetXMLDataStepAnalyzerTest method testGetXMLDataExternalResourceConsumer.
@Test
public void testGetXMLDataExternalResourceConsumer() throws Exception {
GetXMLDataExternalResourceConsumer consumer = new GetXMLDataExternalResourceConsumer();
StepMeta spyMeta = spy(new StepMeta("test", meta));
when(meta.getParentStepMeta()).thenReturn(spyMeta);
when(spyMeta.getParentTransMeta()).thenReturn(parentTransMeta);
when(data.getStepMetaInterface()).thenReturn(meta);
when(meta.isInFields()).thenReturn(false);
String[] filePaths = { "/path/to/file1", "/another/path/to/file2" };
when(meta.getFileName()).thenReturn(filePaths);
when(parentTransMeta.environmentSubstitute(any(String[].class))).thenReturn(filePaths);
assertFalse(consumer.isDataDriven(meta));
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromMeta(meta);
assertFalse(resources.isEmpty());
assertEquals(2, resources.size());
when(meta.isInFields()).thenReturn(true);
when(meta.getIsAFile()).thenReturn(true);
assertTrue(consumer.isDataDriven(meta));
assertTrue(consumer.getResourcesFromMeta(meta).isEmpty());
when(rmi.getString(Mockito.any(Object[].class), anyString(), anyString())).thenReturn("/path/to/row/file");
resources = consumer.getResourcesFromRow(data, rmi, new String[] { "id", "name" });
assertFalse(resources.isEmpty());
assertEquals(1, resources.size());
when(rmi.getString(Mockito.any(Object[].class), anyString(), anyString())).thenThrow(new KettleValueException());
resources = consumer.getResourcesFromRow(data, rmi, new String[] { "id", "name" });
assertTrue(resources.isEmpty());
assertEquals(GetXMLDataMeta.class, consumer.getMetaClass());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-kettle by pentaho.
the class XMLOutputStepAnalyzerTest method testCreateResourceNode.
@Test
public void testCreateResourceNode() throws Exception {
IExternalResourceInfo res = mock(IExternalResourceInfo.class);
when(res.getName()).thenReturn("file:///Users/home/tmp/xyz.xml");
IMetaverseNode resourceNode = analyzer.createResourceNode(res);
assertNotNull(resourceNode);
assertEquals(DictionaryConst.NODE_TYPE_FILE, resourceNode.getType());
}
Aggregations