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());
}
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());
}
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;
}
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);
}
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));
}
Aggregations