use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class StreamLookupTest method doTest.
private void doTest(boolean memoryPreservationActive, boolean binaryLookupStream, boolean binaryDataStream) throws KettleException {
StreamLookup step = new StreamLookup(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
step.init(smh.initStepMetaInterface, smh.initStepDataInterface);
step.addRowSetToInputRowSets(mockLookupRowSet(binaryLookupStream));
step.addRowSetToInputRowSets(mockDataRowSet(binaryDataStream));
step.addRowSetToOutputRowSets(new QueueRowSet());
StreamLookupMeta meta = mockProcessRowMeta(memoryPreservationActive);
StreamLookupData data = new StreamLookupData();
data.readLookupValues = true;
RowSet outputRowSet = step.getOutputRowSets().get(0);
// Process rows and collect output
int rowNumber = 0;
String[] expectedOutput = { "Name", "", "Value" };
while (step.processRow(meta, data)) {
Object[] rowData = outputRowSet.getRow();
if (rowData != null) {
RowMetaInterface rowMeta = outputRowSet.getRowMeta();
Assert.assertEquals("Output row is of wrong size", 3, rowMeta.size());
rowNumber++;
// Verify output
for (int valueIndex = 0; valueIndex < rowMeta.size(); valueIndex++) {
String expectedValue = expectedOutput[valueIndex] + rowNumber;
Object actualValue = rowMeta.getValueMeta(valueIndex).convertToNormalStorageType(rowData[valueIndex]);
Assert.assertEquals("Unexpected value at row " + rowNumber + " position " + valueIndex, expectedValue, actualValue);
}
}
}
Assert.assertEquals("Incorrect output row number", 2, rowNumber);
}
use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class StringOperationsTest method testProcessBinaryInput.
@Test
public void testProcessBinaryInput() throws KettleException {
StringOperations step = new StringOperations(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
step.addRowSetToInputRowSets(mockInputRowSet());
RowSet outputRowSet = new QueueRowSet();
step.addRowSetToOutputRowSets(outputRowSet);
StringOperationsMeta meta = mockStepMeta();
StringOperationsData data = mockStepData();
step.init(meta, data);
boolean processResult;
do {
processResult = step.processRow(meta, data);
} while (processResult);
Assert.assertTrue(outputRowSet.isDone());
Assert.assertTrue("Unexpected output", verifyOutput(new Object[][] { { "Value" } }, outputRowSet));
}
use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class SwitchCaseTest method processRow_NullsArePutIntoDefaultWhenNotSpecified.
@Test
public void processRow_NullsArePutIntoDefaultWhenNotSpecified() throws Exception {
SwitchCaseCustom step = new SwitchCaseCustom(mockHelper);
step.meta.loadXML(loadStepXmlMetadata("SwitchCaseTest_PDI-12671.xml"), Collections.<DatabaseMeta>emptyList(), mock(IMetaStore.class));
List<RowSet> outputRowSets = new LinkedList<RowSet>();
for (SwitchCaseTarget item : step.meta.getCaseTargets()) {
StepMetaInterface smInt = new DummyTransMeta();
item.caseTargetStep = new StepMeta(item.caseTargetStepname, smInt);
RowSet rw = new QueueRowSet();
step.map.put(item.caseTargetStepname, rw);
outputRowSets.add(rw);
}
// create a default step
StepMetaInterface smInt = new DummyTransMeta();
StepMeta stepMeta = new StepMeta(step.meta.getDefaultTargetStepname(), smInt);
step.meta.setDefaultTargetStep(stepMeta);
RowSet defaultRowSet = new QueueRowSet();
step.map.put(step.meta.getDefaultTargetStepname(), defaultRowSet);
step.input.add(new Object[] { null });
step.processRow();
assertEquals(1, defaultRowSet.size());
for (RowSet rowSet : outputRowSets) {
assertEquals(0, rowSet.size());
}
assertNull(defaultRowSet.getRow()[0]);
}
use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class PDI_15270_Test method doTest.
public void doTest(String content, String[] expected) throws Exception {
RowSet output = new QueueRowSet();
File tmp = createTestFile(encoding, content);
try {
CsvInputMeta meta = createMeta(tmp, createInputFileFields("f1", "f2", "f3"));
CsvInputData data = new CsvInputData();
csvInput.init(meta, data);
csvInput.addRowSetToOutputRowSets(output);
try {
csvInput.processRow(meta, data);
} finally {
csvInput.dispose(meta, data);
}
} finally {
tmp.delete();
}
Object[] row = output.getRowImmediate();
assertNotNull(row);
assertEquals(expected[0], row[0]);
assertEquals(expected[1], row[1]);
assertEquals(expected[2], row[2]);
assertNull(output.getRowImmediate());
}
use of org.pentaho.di.core.QueueRowSet 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]);
}
Aggregations