use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class HTTPClientStepAnalyzerTest 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 HTTPPostStepAnalyzerTest 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 HTTPPostStepAnalyzerTest method testHTTPPostExternalResourceConsumer.
@Test
public void testHTTPPostExternalResourceConsumer() throws Exception {
HTTPPostExternalResourceConsumer consumer = new HTTPPostExternalResourceConsumer();
StepMeta meta = new StepMeta("test", this.meta);
StepMeta spyMeta = spy(meta);
when(this.meta.getParentStepMeta()).thenReturn(spyMeta);
when(spyMeta.getParentTransMeta()).thenReturn(mockTransMeta);
when(this.meta.getUrl()).thenReturn("http://seylermartialarts.com");
when(this.meta.isUrlInField()).thenReturn(false);
assertTrue(consumer.isDataDriven(this.meta));
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromMeta(this.meta);
assertFalse(resources.isEmpty());
assertEquals(1, resources.size());
when(this.meta.isUrlInField()).thenReturn(true);
assertTrue(consumer.isDataDriven(this.meta));
assertTrue(consumer.getResourcesFromMeta(this.meta).isEmpty());
when(mockRowMetaInterface.getString(Mockito.any(Object[].class), Mockito.anyString(), Mockito.anyString())).thenReturn("/path/to/row/file");
resources = consumer.getResourcesFromRow(mockHTTPPost, 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(mockHTTPPost, mockRowMetaInterface, new String[] { "id", "name" });
assertTrue(resources.isEmpty());
assertEquals(HTTPPOSTMeta.class, consumer.getMetaClass());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzerTest method testMongoDbInputExternalResourceConsumer.
@Test
public void testMongoDbInputExternalResourceConsumer() throws Exception {
MongoDbInputExternalResourceConsumer consumer = new MongoDbInputExternalResourceConsumer();
StepMeta meta = new StepMeta("test", this.meta);
StepMeta spyMeta = spy(meta);
when(this.meta.getParentStepMeta()).thenReturn(spyMeta);
when(spyMeta.getParentTransMeta()).thenReturn(mockTransMeta);
assertFalse(consumer.isDataDriven(this.meta));
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromMeta(this.meta);
assertNotNull(resources);
assertEquals(1, resources.size());
assertEquals(MongoDbInputMeta.class, consumer.getMetaClass());
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class RestClientExternalResourceConsumerTest method testGetResourcesFromRow.
@Test
public void testGetResourcesFromRow() throws Exception {
when(meta.isUrlInField()).thenReturn(true);
when(meta.getUrlField()).thenReturn("url");
when(meta.getHeaderField()).thenReturn(headerFields);
when(meta.getParameterField()).thenReturn(paramFields);
when(meta.getHeaderName()).thenReturn(headerNames);
when(meta.getParameterName()).thenReturn(paramNames);
when(rmi.getString(row, "header", null)).thenReturn(row[2].toString());
when(rmi.getString(row, "param", null)).thenReturn(row[2].toString());
Collection<IExternalResourceInfo> resourcesFromMeta = consumer.getResourcesFromRow(step, rmi, row);
assertEquals(1, resourcesFromMeta.size());
IExternalResourceInfo resourceInfo = resourcesFromMeta.toArray(new IExternalResourceInfo[1])[0];
assertEquals(row[0], resourceInfo.getName());
assertNotNull(resourceInfo.getAttributes());
}
Aggregations