@Override
  public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep,
                         VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
    if ( nextStep != null ) {
      if ( nextStep.equals( executionResultTargetStepMeta ) ) {
        inputRowMeta.clear();
        prepareExecutionResultsFields( inputRowMeta, nextStep );
      } else if ( nextStep.equals( resultFilesTargetStepMeta ) ) {
        inputRowMeta.clear();
        prepareExecutionResultsFileFields( inputRowMeta, nextStep );
      } else if ( nextStep.equals( outputRowsSourceStepMeta ) ) {
        inputRowMeta.clear();
        prepareResultsRowsFields( inputRowMeta );
      }
      // else don't call clear on inputRowMeta, it's the main output and should mimic the input
    }
  }
@Test
  public void testGetFields() throws Exception {
    TransExecutorMeta meta = new TransExecutorMeta();
    meta = spy( meta );

    StepMeta nextStep = mock( StepMeta.class );

    // Test null
    meta.getFields( null, null, null, nextStep, null, null, null );
    verify( meta, never() ).addFieldToRow( any( RowMetaInterface.class ), anyString(), anyInt() );

    RowMetaInterface rowMeta = mock( RowMetaInterface.class );
    meta.getFields( rowMeta, null, null, nextStep, null, null, null );
    verify( rowMeta, never() ).clear();

    StepMeta executionResultTargetStepMeta = mock( StepMeta.class );
    meta.setExecutionResultTargetStepMeta( executionResultTargetStepMeta );
    meta.getFields( rowMeta, null, null, nextStep, null, null, null );
    verify( rowMeta, atMost( 1 ) ).clear();
    meta.setExecutionResultTargetStepMeta( null );

    StepMeta resultFilesTargetStepMeta = mock( StepMeta.class );
    meta.setResultFilesTargetStepMeta( resultFilesTargetStepMeta );
    meta.getFields( rowMeta, null, null, nextStep, null, null, null );
    verify( rowMeta, atMost( 1 ) ).clear();
    meta.setResultFilesTargetStepMeta( null );

    StepMeta outputRowsSourceStepMeta = mock( StepMeta.class );
    meta.setOutputRowsSourceStepMeta( outputRowsSourceStepMeta );
    meta.getFields( rowMeta, null, null, nextStep, null, null, null );
    verify( rowMeta, atMost( 1 ) ).clear();
    meta.setOutputRowsSourceStepMeta( null );
  }