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]);
}
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);
}
Aggregations