Search in sources :

Example 16 with IExternalResourceInfo

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

Example 17 with IExternalResourceInfo

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

Example 18 with IExternalResourceInfo

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

Example 19 with IExternalResourceInfo

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

Example 20 with IExternalResourceInfo

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());
}
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)

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