Search in sources :

Example 21 with IExternalResourceInfo

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());
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Example 22 with IExternalResourceInfo

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());
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Example 23 with IExternalResourceInfo

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());
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) Matchers.anyString(org.mockito.Matchers.anyString) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 24 with IExternalResourceInfo

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());
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Test(org.junit.Test)

Example 25 with IExternalResourceInfo

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());
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) Test(org.junit.Test)

Aggregations

IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)64 Test (org.junit.Test)38 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)16 StepMeta (org.pentaho.di.trans.step.StepMeta)16 LinkedList (java.util.LinkedList)12 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)12 HashSet (java.util.HashSet)10 KettleException (org.pentaho.di.core.exception.KettleException)10 ArrayList (java.util.ArrayList)8 VariableSpace (org.pentaho.di.core.variables.VariableSpace)8 FileObject (org.apache.commons.vfs2.FileObject)7 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)5 IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)5 List (java.util.List)4 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)4 IStepExternalResourceConsumer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer)3 WebServiceResourceInfo (org.pentaho.metaverse.api.model.WebServiceResourceInfo)3 Before (org.junit.Before)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2