@Test public void testPrepareOutputRow() throws Exception { ConcatFieldsHandler concatFields = new ConcatFieldsHandler( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans ); Object[] row = new Object[] { "one", "two" }; String[] fieldNames = new String[] { "one", "two" }; concatFields.setRow( row ); RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); when( inputRowMeta.clone() ).thenReturn( inputRowMeta ); when( inputRowMeta.size() ).thenReturn( 2 ); when( inputRowMeta.getFieldNames() ).thenReturn( fieldNames ); when( stepMockHelper.processRowsStepMetaInterface.getOutputFields() ).thenReturn( textFileFields ); when( stepMockHelper.processRowsStepMetaInterface.isFastDump() ).thenReturn( Boolean.TRUE ); when( stepMockHelper.processRowsStepMetaInterface.isFileAppended() ).thenReturn( Boolean.FALSE ); when( stepMockHelper.processRowsStepMetaInterface.isFileNameInField() ).thenReturn( Boolean.FALSE ); when( stepMockHelper.processRowsStepMetaInterface.isHeaderEnabled() ).thenReturn( Boolean.TRUE ); when( stepMockHelper.processRowsStepMetaInterface.isRemoveSelectedFields() ).thenReturn( Boolean.TRUE ); concatFields.setInputRowMeta( inputRowMeta ); try { concatFields.processRow( stepMockHelper.processRowsStepMetaInterface, stepMockHelper.processRowsStepDataInterface ); concatFields.prepareOutputRow( row ); } catch ( NullPointerException npe ) { fail( "NullPointerException issue PDI-8870 still reproduced " ); } }
Object[] prepareOutputRow( Object[] r ) { Object[] outputRowData = null; if ( !meta.isRemoveSelectedFields() ) { outputRowData = RowDataUtil.resizeArray( r, data.outputRowMeta.size() ); } else { outputRowData = new Object[data.outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE]; if ( r != null ) { for ( int i = 0; i < data.remainingFieldsInputOutputMapping.length; i++ ) { outputRowData[i] = r[data.remainingFieldsInputOutputMapping[i]]; } } } return outputRowData; }
ConcatFields extends TextFileOutput implements StepInterface { Object[] prepareOutputRow( Object[] r ) { Object[] outputRowData = null; if ( !meta.isRemoveSelectedFields() ) { outputRowData = RowDataUtil.resizeArray( r, data.outputRowMeta.size() ); } else { outputRowData = new Object[data.outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE]; if ( r != null ) { for ( int i = 0; i < data.remainingFieldsInputOutputMapping.length; i++ ) { outputRowData[i] = r[data.remainingFieldsInputOutputMapping[i]]; } } } return outputRowData; } }
ConcatFields extends TextFileOutput implements StepInterface { Object[] prepareOutputRow( Object[] r ) { Object[] outputRowData = null; if ( !meta.isRemoveSelectedFields() ) { outputRowData = RowDataUtil.resizeArray( r, data.outputRowMeta.size() ); } else { outputRowData = new Object[data.outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE]; if ( r != null ) { for ( int i = 0; i < data.remainingFieldsInputOutputMapping.length; i++ ) { outputRowData[i] = r[data.remainingFieldsInputOutputMapping[i]]; } } } return outputRowData; } ConcatFields( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); }
ConcatFields extends TextFileOutput implements StepInterface { Object[] prepareOutputRow( Object[] r ) { Object[] outputRowData = null; if ( !meta.isRemoveSelectedFields() ) { outputRowData = RowDataUtil.resizeArray( r, data.outputRowMeta.size() ); } else { outputRowData = new Object[data.outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE]; if ( r != null ) { for ( int i = 0; i < data.remainingFieldsInputOutputMapping.length; i++ ) { outputRowData[i] = r[data.remainingFieldsInputOutputMapping[i]]; } } } return outputRowData; } ConcatFields( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); @Override synchronized boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
ConcatFields extends TextFileOutput implements StepInterface { Object[] prepareOutputRow( Object[] r ) { Object[] outputRowData = null; if ( !meta.isRemoveSelectedFields() ) { outputRowData = RowDataUtil.resizeArray( r, data.outputRowMeta.size() ); } else { outputRowData = new Object[data.outputRowMeta.size() + RowDataUtil.OVER_ALLOCATE_SIZE]; if ( r != null ) { for ( int i = 0; i < data.remainingFieldsInputOutputMapping.length; i++ ) { outputRowData[i] = r[data.remainingFieldsInputOutputMapping[i]]; } } } return outputRowData; } ConcatFields( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); @Override synchronized boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); public ConcatFieldsMeta meta; public ConcatFieldsData data; }