use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class TransExecutorUnitTest method collectsResultsFromInternalTransformation.
@Test
public void collectsResultsFromInternalTransformation() throws Exception {
prepareOneRowForExecutor();
RowMetaAndData expectedResult = new RowMetaAndData(new RowMeta(), "fake result");
internalResult.getRows().add(expectedResult);
RowSet rowSet = new QueueRowSet();
// any value except null
StepMeta stepMeta = mockStepAndMapItToRowSet("stepMetaMock", rowSet);
meta.setOutputRowsSourceStepMeta(stepMeta);
executor.init(meta, data);
executor.setInputRowMeta(new RowMeta());
assertTrue("Passing one line at first time", executor.processRow(meta, data));
assertFalse("Executing the internal trans during the second round", executor.processRow(meta, data));
Object[] resultsRow = rowSet.getRowImmediate();
assertNotNull(resultsRow);
assertArrayEquals(expectedResult.getData(), resultsRow);
assertNull("Only one row is expected", rowSet.getRowImmediate());
}
use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class CsvInputEnclosureTest method doTest.
public void doTest(String content, String enclosure) throws Exception {
RowSet output = new QueueRowSet();
File tmp = createTestFile("utf-8", content);
try {
CsvInputMeta meta = createMeta(tmp, createInputFileFields("f1", "f2"), enclosure);
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("value1", row[0]);
assertEquals("value2", row[1]);
assertNull(output.getRowImmediate());
}
use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class CsvInputMultiCharDelimiterTest method doTest.
private void doTest(String content) throws Exception {
RowSet output = new QueueRowSet();
File tmp = createTestFile("utf-8", 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("value1", row[0]);
assertEquals("value2", row[1]);
assertEquals("value3", row[2]);
assertNull(output.getRowImmediate());
}
use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class BaseStepTest method putGetFromPutToDefaultRowHandlerMethods.
@Test
public void putGetFromPutToDefaultRowHandlerMethods() throws KettleException {
BaseStep baseStep = new BaseStep(mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans);
baseStep.setRowHandler(rowHandlerWithDefaultMethods());
RowMetaInterface rowMetaInterface = mock(RowMetaInterface.class);
Object[] objects = new Object[] { "foo", "bar" };
try {
baseStep.putRowTo(rowMetaInterface, objects, new QueueRowSet());
fail("Expected default exception for putRowTo");
} catch (UnsupportedOperationException uoe) {
assertThat(uoe.getMessage(), containsString(this.getClass().getName()));
}
try {
baseStep.getRowFrom(new QueueRowSet());
fail("Expected default exception for getRowFrom");
} catch (UnsupportedOperationException uoe) {
assertThat(uoe.getMessage(), containsString(this.getClass().getName()));
}
}
use of org.pentaho.di.core.QueueRowSet in project pentaho-kettle by pentaho.
the class FieldSplitterTest method testSplitFields.
@Test
public void testSplitFields() throws KettleException {
FieldSplitter step = new FieldSplitter(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
step.init(smh.initStepMetaInterface, smh.stepDataInterface);
step.setInputRowMeta(getInputRowMeta());
step.addRowSetToInputRowSets(mockInputRowSet());
step.addRowSetToOutputRowSets(new QueueRowSet());
boolean hasMoreRows;
do {
hasMoreRows = step.processRow(mockProcessRowMeta(), smh.processRowsStepDataInterface);
} while (hasMoreRows);
RowSet outputRowSet = step.getOutputRowSets().get(0);
Object[] actualRow = outputRowSet.getRow();
Object[] expectedRow = new Object[] { "before", null, "b=b", "after" };
assertEquals("Output row is of an unexpected length", expectedRow.length, outputRowSet.getRowMeta().size());
for (int i = 0; i < expectedRow.length; i++) {
assertEquals("Unexpected output value at index " + i, expectedRow[i], actualRow[i]);
}
}
Aggregations