public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {
    // Close the running transformation
    if ( getData().wasStarted ) {
      if ( !getData().mappingTrans.isFinished() ) {
        // Wait until the child transformation has finished.
        getData().mappingTrans.waitUntilFinished();
      }
      // Remove it from the list of active sub-transformations...
      //
      getTrans().removeActiveSubTransformation( getStepname() );

      // See if there was an error in the sub-transformation, in that case, flag error etc.
      if ( getData().mappingTrans.getErrors() > 0 ) {
        logError( BaseMessages.getString( PKG, "SimpleMapping.Log.ErrorOccurredInSubTransformation" ) );
        setErrors( 1 );
      }
    }
    super.dispose( smi, sdi );
  }
@Test
  public void testDispose() throws KettleException {

    // Set Up TransMock to return the error
    when( stepMockHelper.trans.getErrors() ).thenReturn( 0 );

    // The step has been already finished
    when( stepMockHelper.trans.isFinished() ).thenReturn( Boolean.FALSE );
    // The step was started
    simpleMpData.wasStarted = true;

    smp =
            new SimpleMapping( stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta,
                    stepMockHelper.trans );
    smp.init( stepMockHelper.initStepMetaInterface, simpleMpData );

    smp.dispose( stepMockHelper.processRowsStepMetaInterface, simpleMpData );
    verify( stepMockHelper.trans, times( 1 ) ).isFinished();
    verify( stepMockHelper.trans, times( 1 ) ).waitUntilFinished();
    verify( stepMockHelper.trans, times( 1 ) ).removeActiveSubTransformation( anyString() );

  }