use of org.pentaho.di.core.RowSet in project pentaho-kettle by pentaho.
the class JsonInputTest method createJsonInput.
protected JsonInput createJsonInput(final String inCol, JsonInputMeta meta, VariableSpace variables, Object[]... inputRows) {
JsonInputData data = new JsonInputData();
JsonInput jsonInput = new JsonInput(helper.stepMeta, helper.stepDataInterface, 0, helper.transMeta, helper.trans);
RowSet input = helper.getMockInputRowSet(inputRows);
RowMetaInterface rowMeta = createRowMeta(new ValueMetaString(inCol));
input.setRowMeta(rowMeta);
jsonInput.addRowSetToInputRowSets(input);
jsonInput.setInputRowMeta(rowMeta);
jsonInput.initializeVariablesFrom(variables);
jsonInput.init(meta, data);
return jsonInput;
}
use of org.pentaho.di.core.RowSet in project pentaho-kettle by pentaho.
the class ScriptTest method testOutputDoneIfInputEmpty.
@Test
public void testOutputDoneIfInputEmpty() throws Exception {
Script step = new Script(helper.stepMeta, helper.stepDataInterface, 1, helper.transMeta, helper.trans);
step.init(helper.initStepMetaInterface, helper.initStepDataInterface);
RowSet rs = helper.getMockInputRowSet(new Object[0][0]);
List<RowSet> in = new ArrayList<RowSet>();
in.add(rs);
step.setInputRowSets(in);
TransTestingUtil.execute(step, helper.processRowsStepMetaInterface, helper.processRowsStepDataInterface, 0, true);
rs.getRow();
}
use of org.pentaho.di.core.RowSet 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.RowSet 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.RowSet in project pentaho-kettle by pentaho.
the class StringOperationsTest method mockInputRowSet.
private RowSet mockInputRowSet() {
ValueMetaString valueMeta = new ValueMetaString("Value");
valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
valueMeta.setStorageMetadata(new ValueMetaString("Value"));
RowMeta inputRowMeta = new RowMeta();
inputRowMeta.addValueMeta(valueMeta);
RowSet inputRowSet = smh.getMockInputRowSet(new Object[][] { { " Value ".getBytes() } });
doReturn(inputRowMeta).when(inputRowSet).getRowMeta();
return inputRowSet;
}
Aggregations