@Test public void doConversions() throws Exception { StepMeta stepMeta = new StepMeta(); String name = "test"; stepMeta.setName( name ); StepDataInterface stepDataInterface = Mockito.mock( StepDataInterface.class ); int copyNr = 0; TransMeta transMeta = Mockito.mock( TransMeta.class ); Trans trans = Mockito.mock( Trans.class ); Mockito.when( transMeta.findStep( Mockito.eq( name ) ) ).thenReturn( stepMeta ); SalesforceInput salesforceInput = new SalesforceInput( stepMeta, stepDataInterface, copyNr, transMeta, trans ); SalesforceInputMeta meta = new SalesforceInputMeta(); SalesforceInputData data = new SalesforceInputData(); data.outputRowMeta = Mockito.mock( RowMeta.class ); Mockito.when( data.outputRowMeta.getValueMeta( Mockito.eq( 0 ) ) ).thenReturn( new ValueMetaBinary() ); data.convertRowMeta = Mockito.mock( RowMeta.class ); Mockito.when( data.convertRowMeta.getValueMeta( Mockito.eq( 0 ) ) ).thenReturn( new ValueMetaString() ); Field metaField = salesforceInput.getClass().getDeclaredField( "meta" ); metaField.setAccessible( true ); metaField.set( salesforceInput, meta ); Field dataField = salesforceInput.getClass().getDeclaredField( "data" ); dataField.setAccessible( true ); dataField.set( salesforceInput, data ); Object[] outputRowData = new Object[ 1 ]; byte[] binary = { 0, 1, 0, 1, 1, 1 }; salesforceInput.doConversions( outputRowData, 0, new String( Base64.encode( binary ) ) ); Assert.assertArrayEquals( binary, (byte[]) outputRowData[ 0 ] ); binary = new byte[ 0 ]; salesforceInput.doConversions( outputRowData, 0, new String( Base64.encode( binary ) ) ); Assert.assertArrayEquals( binary, (byte[]) outputRowData[ 0 ] ); }
void doConversions( Object[] outputRowData, int i, String value ) throws KettleValueException { ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( i ); ValueMetaInterface sourceValueMeta = data.convertRowMeta.getValueMeta( i ); if ( ValueMetaInterface.TYPE_BINARY != targetValueMeta.getType() ) { outputRowData[i] = targetValueMeta.convertData( sourceValueMeta, value ); } else { if ( value != null ) { outputRowData[ i ] = Base64.decode( value ); } else { outputRowData[ i ] = null; } } }
SalesforceInput extends SalesforceStep { void doConversions( Object[] outputRowData, int i, String value ) throws KettleValueException { ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( i ); ValueMetaInterface sourceValueMeta = data.convertRowMeta.getValueMeta( i ); if ( ValueMetaInterface.TYPE_BINARY != targetValueMeta.getType() ) { outputRowData[i] = targetValueMeta.convertData( sourceValueMeta, value ); } else { if ( value != null ) { outputRowData[ i ] = Base64.decode( value ); } else { outputRowData[ i ] = null; } } } }
SalesforceInput extends SalesforceStep { void doConversions( Object[] outputRowData, int i, String value ) throws KettleValueException { ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( i ); ValueMetaInterface sourceValueMeta = data.convertRowMeta.getValueMeta( i ); if ( ValueMetaInterface.TYPE_BINARY != targetValueMeta.getType() ) { outputRowData[i] = targetValueMeta.convertData( sourceValueMeta, value ); } else { if ( value != null ) { outputRowData[ i ] = Base64.decode( value ); } else { outputRowData[ i ] = null; } } } SalesforceInput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); }
SalesforceInput extends SalesforceStep { void doConversions( Object[] outputRowData, int i, String value ) throws KettleValueException { ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( i ); ValueMetaInterface sourceValueMeta = data.convertRowMeta.getValueMeta( i ); if ( ValueMetaInterface.TYPE_BINARY != targetValueMeta.getType() ) { outputRowData[i] = targetValueMeta.convertData( sourceValueMeta, value ); } else { if ( value != null ) { outputRowData[ i ] = Base64.decode( value ); } else { outputRowData[ i ] = null; } } } SalesforceInput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi ); }
SalesforceInput extends SalesforceStep { void doConversions( Object[] outputRowData, int i, String value ) throws KettleValueException { ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta( i ); ValueMetaInterface sourceValueMeta = data.convertRowMeta.getValueMeta( i ); if ( ValueMetaInterface.TYPE_BINARY != targetValueMeta.getType() ) { outputRowData[i] = targetValueMeta.convertData( sourceValueMeta, value ); } else { if ( value != null ) { outputRowData[ i ] = Base64.decode( value ); } else { outputRowData[ i ] = null; } } } SalesforceInput( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); @Override boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); @Override boolean init( StepMetaInterface smi, StepDataInterface sdi ); @Override void dispose( StepMetaInterface smi, StepDataInterface sdi );  }