Search in sources :

Example 31 with RowSet

use of org.pentaho.di.core.RowSet in project pentaho-kettle by pentaho.

the class TransPartitioningTest method testManyToManyCopies.

/**
 * This checks transformation initialization when using many to many copies.
 *
 * @throws KettleException
 */
@Test
public void testManyToManyCopies() throws KettleException {
    prepareStepMetas_x2_x2();
    trans.prepareExecution(new String[] {});
    List<RowSet> rowsets = trans.getRowsets();
    assertTrue(!rowsets.isEmpty());
    assertEquals("We have 2 rowsets finally", 2, rowsets.size());
    assertEquals("We have 4 steps: 2 copies of producer and 2 copies of consumer", 4, trans.getSteps().size());
    // Ok, examine initialized steps now.
    StepInterface stepOne0 = getStepByName(S10);
    assertTrue("1 step have no input row sets", stepOne0.getInputRowSets().isEmpty());
    assertEquals("1 step have 1 output rowsets", 1, stepOne0.getOutputRowSets().size());
    StepInterface stepOne1 = getStepByName(S11);
    assertTrue("1 step have no input row sets", stepOne1.getInputRowSets().isEmpty());
    assertEquals("1 step have 1 output rowsets", 1, stepOne1.getOutputRowSets().size());
    StepInterface stepTwo0 = getStepByName(S20);
    Assert.assertEquals("2.0 step have 1 input row sets", 1, stepTwo0.getInputRowSets().size());
    Assert.assertTrue("2.0 step have no output row sets", stepTwo0.getOutputRowSets().isEmpty());
    StepInterface stepTwo1 = getStepByName(S21);
    Assert.assertEquals("2.1 step have 1 input row sets", 1, stepTwo1.getInputRowSets().size());
    Assert.assertTrue("2.1 step have no output row sets", stepTwo1.getOutputRowSets().isEmpty());
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) RowSet(org.pentaho.di.core.RowSet) Test(org.junit.Test)

Example 32 with RowSet

use of org.pentaho.di.core.RowSet in project pentaho-kettle by pentaho.

the class TransPartitioningTest method testOneToManyCopies.

/**
 * This checks transformation initialization when using one to many copies
 *
 * @throws KettleException
 */
@Test
public void testOneToManyCopies() throws KettleException {
    prepareStepMetas_1_x2();
    trans.prepareExecution(new String[] {});
    List<RowSet> rowsets = trans.getRowsets();
    assertTrue(!rowsets.isEmpty());
    assertEquals("We have 2 rowsets finally", 2, rowsets.size());
    assertEquals("We have 3 steps: one producer and 2 copies of consumer", 3, trans.getSteps().size());
    // Ok, examine initialized steps now.
    StepInterface stepOne = getStepByName(S10);
    assertTrue("1 step have no input row sets", stepOne.getInputRowSets().isEmpty());
    assertEquals("1 step have 2 output rowsets", 2, stepOne.getOutputRowSets().size());
    StepInterface stepTwo0 = getStepByName(S20);
    Assert.assertEquals("2.0 step have 12 input row sets", 1, stepTwo0.getInputRowSets().size());
    Assert.assertTrue("2.0 step have no output row sets", stepTwo0.getOutputRowSets().isEmpty());
    StepInterface stepTwo1 = getStepByName(S21);
    Assert.assertEquals("2.1 step have 1 input row sets", 1, stepTwo1.getInputRowSets().size());
    Assert.assertTrue("2.1 step have no output row sets", stepTwo1.getOutputRowSets().isEmpty());
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) RowSet(org.pentaho.di.core.RowSet) Test(org.junit.Test)

Example 33 with RowSet

use of org.pentaho.di.core.RowSet in project pentaho-kettle by pentaho.

the class TransTestingUtil method execute.

public static List<Object[]> execute(BaseStep step, StepMetaInterface meta, StepDataInterface data, int expectedRowsAmount, boolean checkIsDone) throws Exception {
    RowSet output = new BlockingRowSet(Math.max(1, expectedRowsAmount));
    step.setOutputRowSets(Collections.singletonList(output));
    int i = 0;
    List<Object[]> result = new ArrayList<>(expectedRowsAmount);
    while (step.processRow(meta, data) && i < expectedRowsAmount) {
        Object[] row = output.getRowImmediate();
        assertNotNull(Integer.toString(i), row);
        result.add(row);
        i++;
    }
    assertEquals("The amount of executions should be equal to expected", expectedRowsAmount, i);
    if (checkIsDone) {
        assertTrue(output.isDone());
    }
    return result;
}
Also used : RowSet(org.pentaho.di.core.RowSet) BlockingRowSet(org.pentaho.di.core.BlockingRowSet) ArrayList(java.util.ArrayList) BlockingRowSet(org.pentaho.di.core.BlockingRowSet)

Example 34 with RowSet

use of org.pentaho.di.core.RowSet in project pentaho-kettle by pentaho.

the class DummyTransTest method testDummyTransWritesOutputWithInputRow.

@Test
public void testDummyTransWritesOutputWithInputRow() throws KettleException {
    DummyTrans dummy = new DummyTrans(stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans);
    dummy.init(stepMockHelper.initStepMetaInterface, stepMockHelper.initStepDataInterface);
    Object[] row = new Object[] { "abcd" };
    RowSet rowSet = stepMockHelper.getMockInputRowSet(row);
    RowMetaInterface inputRowMeta = mock(RowMetaInterface.class);
    when(inputRowMeta.clone()).thenReturn(inputRowMeta);
    when(rowSet.getRowMeta()).thenReturn(inputRowMeta);
    dummy.addRowSetToInputRowSets(rowSet);
    RowSet outputRowSet = mock(RowSet.class);
    dummy.addRowSetToOutputRowSets(outputRowSet);
    when(outputRowSet.putRow(inputRowMeta, row)).thenReturn(true);
    dummy.processRow(stepMockHelper.processRowsStepMetaInterface, stepMockHelper.processRowsStepDataInterface);
    verify(outputRowSet, times(1)).putRow(inputRowMeta, row);
}
Also used : RowSet(org.pentaho.di.core.RowSet) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Test(org.junit.Test)

Example 35 with RowSet

use of org.pentaho.di.core.RowSet in project pentaho-kettle by pentaho.

the class DummyTransTest method testDummyTransDoesntWriteOutputWithoutInputRow.

@Test
public void testDummyTransDoesntWriteOutputWithoutInputRow() throws KettleException {
    DummyTrans dummy = new DummyTrans(stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans);
    dummy.init(stepMockHelper.initStepMetaInterface, stepMockHelper.initStepDataInterface);
    RowSet rowSet = stepMockHelper.getMockInputRowSet();
    RowMetaInterface inputRowMeta = mock(RowMetaInterface.class);
    when(rowSet.getRowMeta()).thenReturn(inputRowMeta);
    dummy.addRowSetToInputRowSets(rowSet);
    RowSet outputRowSet = mock(RowSet.class);
    dummy.addRowSetToOutputRowSets(outputRowSet);
    dummy.processRow(stepMockHelper.processRowsStepMetaInterface, stepMockHelper.processRowsStepDataInterface);
    verify(inputRowMeta, never()).cloneRow(any(Object[].class));
    verify(outputRowSet, never()).putRow(any(RowMetaInterface.class), any(Object[].class));
}
Also used : RowSet(org.pentaho.di.core.RowSet) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Test(org.junit.Test)

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