use of org.pentaho.di.trans.steps.mappingoutput.MappingOutput in project pentaho-kettle by pentaho.
the class SimpleMappingTest method setup.
@Before
public void setup() throws Exception {
stepMockHelper = new StepMockHelper<SimpleMappingMeta, SimpleMappingData>("SIMPLE_MAPPING_TEST", SimpleMappingMeta.class, SimpleMappingData.class);
when(stepMockHelper.logChannelInterfaceFactory.create(any(), any(LoggingObjectInterface.class))).thenReturn(stepMockHelper.logChannelInterface);
when(stepMockHelper.trans.isRunning()).thenReturn(true);
// Mock for MappingInput
MappingInput mpInputMock = mock(MappingInput.class);
when(mpInputMock.getStepname()).thenReturn(MAPPING_INPUT_STEP_NAME);
// Mock for MappingOutput
MappingOutput mpOutputMock = mock(MappingOutput.class);
when(mpOutputMock.getStepname()).thenReturn(MAPPING_OUTPUT_STEP_NAME);
// Mock for RowDataInputMapper
RowDataInputMapper rdInputMpMock = mock(RowDataInputMapper.class);
RowMetaInterface rwMetaInMock = mock(RowMeta.class);
doReturn(Boolean.TRUE).when(rdInputMpMock).putRow(rwMetaInMock, new Object[] {});
// Mock for RowProducer
RowProducer rProducerMock = mock(RowProducer.class);
when(rProducerMock.putRow(any(RowMetaInterface.class), any(Object[].class), anyBoolean())).thenReturn(true);
// Mock for MappingIODefinition
MappingIODefinition mpIODefMock = mock(MappingIODefinition.class);
// Set up real SimpleMappingData with some mocked elements
simpleMpData.mappingInput = mpInputMock;
simpleMpData.mappingOutput = mpOutputMock;
simpleMpData.rowDataInputMapper = rdInputMpMock;
simpleMpData.mappingTrans = stepMockHelper.trans;
when(stepMockHelper.trans.findStepInterface(MAPPING_OUTPUT_STEP_NAME, 0)).thenReturn(mpOutputMock);
when(stepMockHelper.trans.addRowProducer(MAPPING_INPUT_STEP_NAME, 0)).thenReturn(rProducerMock);
when(stepMockHelper.processRowsStepMetaInterface.getInputMapping()).thenReturn(mpIODefMock);
}
use of org.pentaho.di.trans.steps.mappingoutput.MappingOutput in project pentaho-kettle by pentaho.
the class SimpleMappingTest method testStepShouldStopProcessingInput_IfUnderlyingTransitionIsStopped.
@Test
public void testStepShouldStopProcessingInput_IfUnderlyingTransitionIsStopped() throws Exception {
MappingInput mappingInput = mock(MappingInput.class);
when(mappingInput.getStepname()).thenReturn(MAPPING_INPUT_STEP_NAME);
stepMockHelper.processRowsStepDataInterface.mappingInput = mappingInput;
RowProducer rowProducer = mock(RowProducer.class);
when(rowProducer.putRow(any(RowMetaInterface.class), any(Object[].class), anyBoolean())).thenReturn(true);
StepInterface stepInterface = mock(StepInterface.class);
Trans mappingTrans = mock(Trans.class);
when(mappingTrans.addRowProducer(anyString(), anyInt())).thenReturn(rowProducer);
when(mappingTrans.findStepInterface(anyString(), anyInt())).thenReturn(stepInterface);
when(mappingTrans.isFinishedOrStopped()).thenReturn(Boolean.FALSE).thenReturn(Boolean.TRUE);
stepMockHelper.processRowsStepDataInterface.mappingTrans = mappingTrans;
MappingOutput mappingOutput = mock(MappingOutput.class);
when(mappingOutput.getStepname()).thenReturn(MAPPING_OUTPUT_STEP_NAME);
stepMockHelper.processRowsStepDataInterface.mappingOutput = mappingOutput;
smp = new SimpleMapping(stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans);
smp.init(stepMockHelper.initStepMetaInterface, simpleMpData);
smp.addRowSetToInputRowSets(stepMockHelper.getMockInputRowSet(new Object[] {}));
smp.addRowSetToInputRowSets(stepMockHelper.getMockInputRowSet(new Object[] {}));
assertTrue(smp.processRow(stepMockHelper.processRowsStepMetaInterface, stepMockHelper.processRowsStepDataInterface));
assertFalse(smp.processRow(stepMockHelper.processRowsStepMetaInterface, stepMockHelper.processRowsStepDataInterface));
}
Aggregations