Search in sources :

Example 21 with StepDataInterface

use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.

the class PDI5436Test method testCacheAllTable.

@Test
public void testCacheAllTable() throws KettleException {
    DatabaseLookup stepSpy = spy(new DatabaseLookup(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans));
    Database database = mockDatabase();
    doReturn(database).when(stepSpy).getDatabase(any(DatabaseMeta.class));
    stepSpy.addRowSetToInputRowSets(mockInputRowSet());
    stepSpy.setInputRowMeta(mockInputRowMeta());
    RowSet outputRowSet = new QueueRowSet();
    stepSpy.addRowSetToOutputRowSets(outputRowSet);
    StepMetaInterface meta = mockStepMeta();
    StepDataInterface data = smh.initStepDataInterface;
    Assert.assertTrue("Step init failed", stepSpy.init(meta, data));
    Assert.assertTrue("Error processing row", stepSpy.processRow(meta, data));
    Assert.assertEquals("Cache lookup failed", "value", outputRowSet.getRow()[2]);
}
Also used : QueueRowSet(org.pentaho.di.core.QueueRowSet) Database(org.pentaho.di.core.database.Database) RowSet(org.pentaho.di.core.RowSet) QueueRowSet(org.pentaho.di.core.QueueRowSet) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Test(org.junit.Test)

Example 22 with StepDataInterface

use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.

the class RowGeneratorUnitTest method setUp.

@Before
public void setUp() throws KettleException {
    // add variable to row generator step
    StepMetaInterface stepMetaInterface = spy(new RowGeneratorMeta());
    ((RowGeneratorMeta) stepMetaInterface).setRowLimit("${ROW_LIMIT}");
    String[] strings = {};
    when(((RowGeneratorMeta) stepMetaInterface).getFieldName()).thenReturn(strings);
    StepMeta stepMeta = new StepMeta();
    stepMeta.setStepMetaInterface(stepMetaInterface);
    stepMeta.setName("ROW_STEP_META");
    StepDataInterface stepDataInterface = stepMeta.getStepMetaInterface().getStepData();
    // add variable to transformation variable space
    Map<String, String> map = new HashMap<String, String>();
    map.put("ROW_LIMIT", "1440");
    TransMeta transMeta = spy(new TransMeta());
    transMeta.injectVariables(map);
    when(transMeta.findStep(anyString())).thenReturn(stepMeta);
    Trans trans = spy(new Trans(transMeta, null));
    when(trans.getSocketRepository()).thenReturn(null);
    when(trans.getLogChannelId()).thenReturn("ROW_LIMIT");
    // prepare row generator, substitutes variable by value from transformation variable space
    rowGenerator = spy(new RowGenerator(stepMeta, stepDataInterface, 0, transMeta, trans));
    rowGenerator.initializeVariablesFrom(trans);
    rowGenerator.init(stepMetaInterface, stepDataInterface);
}
Also used : HashMap(java.util.HashMap) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) TransMeta(org.pentaho.di.trans.TransMeta) Mockito.anyString(org.mockito.Mockito.anyString) StepMeta(org.pentaho.di.trans.step.StepMeta) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Trans(org.pentaho.di.trans.Trans) Before(org.junit.Before)

Aggregations

StepDataInterface (org.pentaho.di.trans.step.StepDataInterface)22 StepMeta (org.pentaho.di.trans.step.StepMeta)19 Test (org.junit.Test)15 StepInterface (org.pentaho.di.trans.step.StepInterface)13 Trans (org.pentaho.di.trans.Trans)9 TransMeta (org.pentaho.di.trans.TransMeta)9 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 KettleException (org.pentaho.di.core.exception.KettleException)5 StepMetaDataCombi (org.pentaho.di.trans.step.StepMetaDataCombi)5 ArrayList (java.util.ArrayList)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)3 List (java.util.List)2 FileObject (org.apache.commons.vfs2.FileObject)2 Mockito.anyString (org.mockito.Mockito.anyString)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 BaseStep (org.pentaho.di.trans.step.BaseStep)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1