Search in sources :

Example 11 with QueueRowSet

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

Example 12 with QueueRowSet

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

Example 13 with QueueRowSet

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

Example 14 with QueueRowSet

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

Example 15 with QueueRowSet

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

Aggregations

QueueRowSet (org.pentaho.di.core.QueueRowSet)20 RowSet (org.pentaho.di.core.RowSet)18 Test (org.junit.Test)13 RowMeta (org.pentaho.di.core.row.RowMeta)5 StepMeta (org.pentaho.di.trans.step.StepMeta)5 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 File (java.io.File)3 SingleRowRowSet (org.pentaho.di.core.SingleRowRowSet)3 KettleException (org.pentaho.di.core.exception.KettleException)3 SimpleDateFormat (java.text.SimpleDateFormat)2 BlockingBatchingRowSet (org.pentaho.di.core.BlockingBatchingRowSet)2 BlockingRowSet (org.pentaho.di.core.BlockingRowSet)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 StepDataInterface (org.pentaho.di.trans.step.StepDataInterface)2 StepInterface (org.pentaho.di.trans.step.StepInterface)2 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)2 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1