### Question:
SetValueConstant extends BaseStep implements StepInterface { private void updateField( Object[] r ) throws Exception { for ( int i = 0; i < data.getFieldnr(); i++ ) { ValueMetaInterface targetValueMeta = data.getOutputRowMeta().getValueMeta( data.getFieldnrs()[i] ); ValueMetaInterface sourceValueMeta = data.getConvertRowMeta().getValueMeta( data.getFieldnrs()[i] ); if ( !Utils.isEmpty( meta.getReplaceMask()[i] ) ) { sourceValueMeta.setConversionMask( meta.getReplaceMask()[i] ); } sourceValueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); r[data.getFieldnrs()[i]] = targetValueMeta.convertData( sourceValueMeta, data.getRealReplaceByValues()[i] ); targetValueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_NORMAL ); } } SetValueConstant( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi );  }### Answer:
@Test public void testUpdateField() throws Exception { SetValueConstant step = new SetValueConstant( smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans ); ValueMetaInterface valueMeta = new ValueMetaString( "Field1" ); valueMeta.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING ); RowMeta rowMeta = new RowMeta(); rowMeta.addValueMeta( valueMeta ); doReturn( new String[] { null } ).when( smh.initStepMetaInterface ).getReplaceMask(); doReturn( rowMeta ).when( smh.initStepDataInterface ).getConvertRowMeta(); doReturn( rowMeta ).when( smh.initStepDataInterface ).getOutputRowMeta(); doReturn( 1 ).when( smh.initStepDataInterface ).getFieldnr(); doReturn( new int[] { 0 } ).when( smh.initStepDataInterface ).getFieldnrs(); doReturn( new String[] { "foo" } ).when( smh.initStepDataInterface ).getRealReplaceByValues(); step.init( smh.initStepMetaInterface, smh.initStepDataInterface ); Method m = SetValueConstant.class.getDeclaredMethod( "updateField", Object[].class ); m.setAccessible( true ); Object[] row = new Object[] { null }; m.invoke( step, new Object[] { row } ); Assert.assertEquals( "foo", valueMeta.getString( row[0] ) ); }