Search in sources :

Example 91 with RowSet

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;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowSet(org.pentaho.di.core.RowSet) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface)

Example 92 with RowSet

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();
}
Also used : RowSet(org.pentaho.di.core.RowSet) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 93 with RowSet

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);
}
Also used : QueueRowSet(org.pentaho.di.core.QueueRowSet) RowSet(org.pentaho.di.core.RowSet) QueueRowSet(org.pentaho.di.core.QueueRowSet) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Matchers.anyString(org.mockito.Matchers.anyString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 94 with RowSet

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));
}
Also used : QueueRowSet(org.pentaho.di.core.QueueRowSet) RowSet(org.pentaho.di.core.RowSet) QueueRowSet(org.pentaho.di.core.QueueRowSet) Test(org.junit.Test)

Example 95 with RowSet

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;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) RowSet(org.pentaho.di.core.RowSet) QueueRowSet(org.pentaho.di.core.QueueRowSet)

Aggregations

RowSet (org.pentaho.di.core.RowSet)109 Test (org.junit.Test)43 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)40 RowMeta (org.pentaho.di.core.row.RowMeta)34 QueueRowSet (org.pentaho.di.core.QueueRowSet)26 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)25 KettleException (org.pentaho.di.core.exception.KettleException)23 BlockingRowSet (org.pentaho.di.core.BlockingRowSet)21 KettleStepException (org.pentaho.di.core.exception.KettleStepException)19 ArrayList (java.util.ArrayList)16 StepInterface (org.pentaho.di.trans.step.StepInterface)13 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)12 StepMeta (org.pentaho.di.trans.step.StepMeta)11 SingleRowRowSet (org.pentaho.di.core.SingleRowRowSet)10 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)9 RowAdapter (org.pentaho.di.trans.step.RowAdapter)9 Matchers.anyString (org.mockito.Matchers.anyString)7 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)7 IOException (java.io.IOException)6 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)6