Java Code Examples for org.pentaho.di.trans.step.StepMeta#setName()

The following examples show how to use org.pentaho.di.trans.step.StepMeta#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterRowsMetaTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void modifiedTarget() throws Exception {
  FilterRowsMeta filterRowsMeta = new FilterRowsMeta();
  StepMeta trueOutput = new StepMeta( "true", new DummyTransMeta() );
  StepMeta falseOutput = new StepMeta( "false", new DummyTransMeta() );

  filterRowsMeta.setCondition( new Condition() );
  filterRowsMeta.setTrueStepname( trueOutput.getName() );
  filterRowsMeta.setFalseStepname( falseOutput.getName() );
  filterRowsMeta.searchInfoAndTargetSteps( ImmutableList.of( trueOutput, falseOutput ) );

  trueOutput.setName( "true renamed" );
  falseOutput.setName( "false renamed" );

  assertEquals( "true renamed", filterRowsMeta.getTrueStepname() );
  assertEquals( "false renamed", filterRowsMeta.getFalseStepname() );
}
 
Example 2
Source File: BaseParsingTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize step info. Method is final against redefine in descendants.
 */
@Before
public final void beforeCommon() throws Exception {
  KettleEnvironment.init();
  PluginRegistry.addPluginType( CompressionPluginType.getInstance() );
  PluginRegistry.init( false );

  stepMeta = new StepMeta();
  stepMeta.setName( "test" );

  trans = new Trans();
  trans.setLog( log );
  trans.setRunning( true );
  transMeta = new TransMeta() {
    @Override
    public StepMeta findStep( String name ) {
      return stepMeta;
    }
  };

  fs = VFS.getManager();
  inPrefix = '/' + this.getClass().getPackage().getName().replace( '.', '/' ) + "/files/";
}
 
Example 3
Source File: SpoonStepsDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void dupeStep( TransMeta transMeta, StepMeta stepMeta ) {
  spoon.getLog().logDebug(
    toString(), BaseMessages.getString( PKG, "Spoon.Log.DuplicateStep" ) + stepMeta.getName() ); // Duplicate
  // step:

  StepMeta stMeta = (StepMeta) stepMeta.clone();
  if ( stMeta != null ) {
    String newname = transMeta.getAlternativeStepname( stepMeta.getName() );
    int nr = 2;
    while ( transMeta.findStep( newname ) != null ) {
      newname = stepMeta.getName() + " (copy " + nr + ")";
      nr++;
    }
    stMeta.setName( newname );
    // Don't select this new step!
    stMeta.setSelected( false );
    Point loc = stMeta.getLocation();
    stMeta.setLocation( loc.x + 20, loc.y + 20 );
    transMeta.addStep( stMeta );
    spoon.addUndoNew( transMeta, new StepMeta[] { (StepMeta) stMeta.clone() }, new int[] { transMeta
      .indexOfStep( stMeta ) } );
    spoon.refreshTree();
    spoon.refreshGraph();
  }
}
 
Example 4
Source File: TransGraph.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void renameStep( StepMeta stepMeta, String stepname ) {
  String newname = stepname;

  StepMeta smeta = transMeta.findStep( newname, stepMeta );
  int nr = 2;
  while ( smeta != null ) {
    newname = stepname + " " + nr;
    smeta = transMeta.findStep( newname );
    nr++;
  }
  if ( nr > 2 ) {
    stepname = newname;
    modalMessageDialog( getString( "Spoon.Dialog.StepnameExists.Title" ),
      getString( "Spoon.Dialog.StepnameExists.Message", stepname ), SWT.OK | SWT.ICON_INFORMATION );
  }
  stepMeta.setName( stepname );
  stepMeta.setChanged();
  spoon.refreshTree(); // to reflect the new name
  spoon.refreshGraph();
}
 
Example 5
Source File: TransGraphTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void testEnableHopGetsSelected() {
  TransGraph transGraph = mock( TransGraph.class );
  doCallRealMethod().when( transGraph ).setTransMeta( any( TransMeta.class ) );
  doCallRealMethod().when( transGraph ).setSpoon( any( Spoon.class ) );
  transGraph.setTransMeta( new TransMeta() );
  transGraph.setSpoon( mock( Spoon.class ) );
  StepMeta stepMeta = mock( StepMeta.class );
  StepErrorMeta errorMeta = new StepErrorMeta( null, null );
  TransHopMeta selectedHop = new TransHopMeta();
  selectedHop.setErrorHop( true );
  selectedHop.setEnabled( false );
  selectedHop.setFromStep( stepMeta );

  when( stepMeta.getStepErrorMeta() ).thenReturn( errorMeta );
  StepMeta toStep = new StepMeta();
  toStep.setName( "toStep" );
  selectedHop.setToStep( toStep );
  when( transGraph.getCurrentHop() ).thenReturn( selectedHop );

  doCallRealMethod().when( transGraph ).enableHop();
  transGraph.enableHop();

  Assert.assertTrue( errorMeta.isEnabled() );
}
 
Example 6
Source File: TransMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testIsAnySelectedStepUsedInTransHopsAnySelectedCase() {
  StepMeta stepMeta = new StepMeta();
  stepMeta.setName( STEP_NAME );
  TransHopMeta transHopMeta = new TransHopMeta();
  stepMeta.setSelected( true );
  List<StepMeta> selectedSteps = asList( new StepMeta(), stepMeta, new StepMeta() );

  transHopMeta.setToStep( stepMeta );
  transHopMeta.setFromStep( stepMeta );
  transMeta.getSteps().addAll( selectedSteps );
  transMeta.addTransHop( transHopMeta );

  assertTrue( transMeta.isAnySelectedStepUsedInTransHops() );
}
 
Example 7
Source File: RestTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateMultivalueMap() {
  StepMeta stepMeta = new StepMeta();
  stepMeta.setName( "TestRest" );
  TransMeta transMeta = new TransMeta();
  transMeta.setName( "TestRest" );
  transMeta.addStep( stepMeta );
  Rest rest = new Rest( stepMeta, mock( StepDataInterface.class ),
    1, transMeta, mock( Trans.class ) );
  MultivaluedMapImpl map = rest.createMultivalueMap( "param1", "{a:{[val1]}}" );
  String val1 = map.getFirst( "param1" );
  assertTrue( val1.contains( "%7D" ) );
}
 
Example 8
Source File: JoinRowsTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private JoinRows getJoinRows() throws Exception {
  StepMeta stepMeta = new StepMeta();
  TransMeta transMeta = new TransMeta();
  Trans trans = new Trans( transMeta );

  transMeta.clear();
  transMeta.addStep( stepMeta );
  transMeta.setStep( 0, stepMeta );
  stepMeta.setName( "test" );
  trans.setLog( mock( LogChannelInterface.class ) );
  trans.prepareExecution( null );
  trans.startThreads();

  return new JoinRows( stepMeta, null, 0, transMeta, trans );
}
 
Example 9
Source File: RowGeneratorUnitTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws KettleException {
  // add variable to row generator step
  StepMetaInterface stepMetaInterface = spy( new RowGeneratorMeta() );
  ( (RowGeneratorMeta) stepMetaInterface ).setRowLimit( "${ROW_LIMIT}" );
  String[] strings = {};
  when( ( (RowGeneratorMeta) stepMetaInterface ).getFieldName() ).thenReturn( strings );

  StepMeta stepMeta = new StepMeta();
  stepMeta.setStepMetaInterface( stepMetaInterface );
  stepMeta.setName( "ROW_STEP_META" );
  StepDataInterface stepDataInterface = stepMeta.getStepMetaInterface().getStepData();

  // add variable to transformation variable space
  Map<String, String> map = new HashMap<String, String>();
  map.put( "ROW_LIMIT", "1440" );
  TransMeta transMeta = spy( new TransMeta() );
  transMeta.injectVariables( map );
  when( transMeta.findStep( anyString() ) ).thenReturn( stepMeta );

  Trans trans = spy( new Trans( transMeta, null ) );
  when( trans.getSocketRepository() ).thenReturn( null );
  when( trans.getLogChannelId() ).thenReturn( "ROW_LIMIT" );

  //prepare row generator, substitutes variable by value from transformation variable space
  rowGenerator = spy( new RowGenerator( stepMeta, stepDataInterface, 0, transMeta, trans ) );
  rowGenerator.initializeVariablesFrom( trans );
  rowGenerator.init( stepMetaInterface, stepDataInterface );
}
 
Example 10
Source File: SharedObjectSyncUtilTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private static StepMeta createStepMeta( String name, boolean shared ) {
  StepMeta stepMeta = new StepMeta();
  stepMeta.setName( name );
  stepMeta.setDescription( BEFORE_SYNC_VALUE );
  stepMeta.setShared( shared );
  return stepMeta;
}
 
Example 11
Source File: XmlJoinMetaGetFieldsTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetFieldsReturnTargetStepFieldsPlusResultXmlField() throws Exception {
  String sourceXmlStep = "source xml step name";
  String sourceStepField = "source field test name";
  String targetStepField = "target field test name";
  String resultXmlFieldName = "result xml field name";
  RowMeta rowMetaPreviousSteps = new RowMeta();
  rowMetaPreviousSteps.addValueMeta( new ValueMeta( sourceStepField, ValueMetaInterface.TYPE_STRING ) );
  xmlJoinMeta.setSourceXMLstep( sourceXmlStep );
  xmlJoinMeta.setValueXMLfield( "result xml field name" );
  StepMeta sourceStepMeta = new StepMeta();
  sourceStepMeta.setName( sourceXmlStep );

  doReturn( sourceStepMeta ).when( transMeta ).findStep( sourceXmlStep );
  doReturn( rowMetaPreviousSteps ).when( transMeta ).getStepFields( sourceStepMeta, null, null );


  RowMeta rowMeta = new RowMeta();
  ValueMetaString keepValueMeta = new ValueMetaString( targetStepField );
  ValueMetaString removeValueMeta = new ValueMetaString( sourceStepField );
  rowMeta.addValueMeta( keepValueMeta );
  rowMeta.addValueMeta( removeValueMeta );

  xmlJoinMeta.getFields( rowMeta, "testStepName", null, null, transMeta, null, null );
  assertEquals( 2, rowMeta.size() );
  String[] strings = rowMeta.getFieldNames();
  assertEquals( targetStepField, strings[0] );
  assertEquals( resultXmlFieldName, strings[1] );
}
 
Example 12
Source File: SalesforceInputTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@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 ] );
}
 
Example 13
Source File: KettleDatabaseRepositoryStepDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Create a new step by loading the metadata from the specified repository.
 *
 * @param rep
 * @param stepId
 * @param databases
 * @param counters
 * @param partitionSchemas
 * @throws KettleException
 */
public StepMeta loadStepMeta( ObjectId stepId, List<DatabaseMeta> databases,
  List<PartitionSchema> partitionSchemas ) throws KettleException {
  StepMeta stepMeta = new StepMeta();
  PluginRegistry registry = PluginRegistry.getInstance();

  try {
    RowMetaAndData r = getStep( stepId );
    if ( r != null ) {
      stepMeta.setObjectId( stepId );

      stepMeta.setName( r.getString( KettleDatabaseRepository.FIELD_STEP_NAME, null ) );
      stepMeta.setDescription( r.getString( KettleDatabaseRepository.FIELD_STEP_DESCRIPTION, null ) );

      long id_step_type = r.getInteger( KettleDatabaseRepository.FIELD_STEP_ID_STEP_TYPE, -1L );
      RowMetaAndData steptyperow = getStepType( new LongObjectId( id_step_type ) );

      stepMeta.setStepID( steptyperow.getString( KettleDatabaseRepository.FIELD_STEP_TYPE_CODE, null ) );
      stepMeta.setDistributes( r.getBoolean( KettleDatabaseRepository.FIELD_STEP_DISTRIBUTE, true ) );
      int copies = (int) r.getInteger( KettleDatabaseRepository.FIELD_STEP_COPIES, 1 );
      String copiesString = r.getString( KettleDatabaseRepository.FIELD_STEP_COPIES_STRING, null );
      if ( !Utils.isEmpty( copiesString ) ) {
        stepMeta.setCopiesString( copiesString );
      } else {
        stepMeta.setCopies( copies );
      }

      int x = (int) r.getInteger( KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_X, 0 );
      int y = (int) r.getInteger( KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_Y, 0 );
      stepMeta.setLocation( new Point( x, y ) );
      stepMeta.setDraw( r.getBoolean( KettleDatabaseRepository.FIELD_STEP_GUI_DRAW, false ) );

      // Generate the appropriate class...
      PluginInterface sp = registry.findPluginWithId( StepPluginType.class, stepMeta.getStepID() );
      if ( sp == null ) {
        stepMeta.setStepMetaInterface( new MissingTrans( stepMeta.getName(), stepMeta.getStepID() ) );
      } else {
        stepMeta.setStepMetaInterface( (StepMetaInterface) registry.loadClass( sp ) );
      }
      if ( stepMeta.getStepMetaInterface() != null ) {
        // Read the step info from the repository!
        readRepCompatibleStepMeta(
          stepMeta.getStepMetaInterface(), repository, stepMeta.getObjectId(), databases );
        stepMeta.getStepMetaInterface().readRep(
          repository, repository.metaStore, stepMeta.getObjectId(), databases );
      }

      // Get the partitioning as well...
      //
      stepMeta.setStepPartitioningMeta( loadStepPartitioningMeta( stepMeta.getObjectId() ) );
      stepMeta.getStepPartitioningMeta().setPartitionSchemaAfterLoading( partitionSchemas );

      // Get the cluster schema name
      //
      stepMeta.setClusterSchemaName( repository.getStepAttributeString( stepId, "cluster_schema" ) );

      // Are we using a custom row distribution plugin?
      //
      String rowDistributionCode = repository.getStepAttributeString( stepId, 0, "row_distribution_code" );
      RowDistributionInterface rowDistribution =
        PluginRegistry.getInstance().loadClass(
          RowDistributionPluginType.class, rowDistributionCode, RowDistributionInterface.class );
      stepMeta.setRowDistribution( rowDistribution );

      // Load the attribute groups map
      //
      stepMeta.setAttributesMap( loadStepAttributesMap( stepId ) );

      // Done!
      //
      return stepMeta;
    } else {
      throw new KettleException( BaseMessages.getString(
        PKG, "StepMeta.Exception.StepInfoCouldNotBeFound", String.valueOf( stepId ) ) );
    }
  } catch ( KettleDatabaseException dbe ) {
    throw new KettleException( BaseMessages.getString( PKG, "StepMeta.Exception.StepCouldNotBeLoaded", String
      .valueOf( stepMeta.getObjectId() ) ), dbe );
  }
}
 
Example 14
Source File: SpoonStepsDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public String editStep( TransMeta transMeta, StepMeta stepMeta ) {
  boolean refresh = false;
  String stepname = null;
  try {
    String name = stepMeta.getName();

    // Before we do anything, let's store the situation the way it
    // was...
    //
    StepMeta before = (StepMeta) stepMeta.clone();
    StepDialogInterface dialog = spoon.getStepEntryDialog( stepMeta.getStepMetaInterface(), transMeta, name );
    if ( dialog != null ) {
      dialog.setRepository( spoon.getRepository() );
      dialog.setMetaStore( spoon.getMetaStore() );
      stepname = dialog.open();
    }

    if ( !Utils.isEmpty( stepname ) ) {
      // Force the recreation of the step IO metadata object. (cached by default)
      //
      stepMeta.getStepMetaInterface().resetStepIoMeta();

      //
      // See if the new name the user enter, doesn't collide with
      // another step.
      // If so, change the stepname and warn the user!
      //
      String newname = stepname;
      StepMeta smeta = transMeta.findStep( newname, stepMeta );
      int nr = 2;
      while ( smeta != null ) {
        newname = stepname + " " + nr;
        smeta = transMeta.findStep( newname );
        nr++;
      }
      if ( nr > 2 ) {
        stepname = newname;
        MessageBox mb = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION );
        mb.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.StepnameExists.Message", stepname ) );
        mb.setText( BaseMessages.getString( PKG, "Spoon.Dialog.StepnameExists.Title" ) );
        mb.open();
      }

      if ( !stepname.equals( name ) ) {
        refresh = true;
      }

      StepMeta newStepMeta = (StepMeta) stepMeta.clone();
      newStepMeta.setName( stepname );
      transMeta.clearCaches();
      transMeta.notifyAllListeners( stepMeta, newStepMeta );
      stepMeta.setName( stepname );

      //
      // OK, so the step has changed...
      // Backup the situation for undo/redo
      //
      StepMeta after = (StepMeta) stepMeta.clone();
      spoon.addUndoChange( transMeta, new StepMeta[] { before }, new StepMeta[] { after }, new int[] { transMeta
        .indexOfStep( stepMeta ) } );
    } else {
      // Scenario: change connections and click cancel...
      // Perhaps new connections were created in the step dialog?
      if ( transMeta.haveConnectionsChanged() ) {
        refresh = true;
      }
    }
    spoon.refreshGraph(); // name is displayed on the graph too.

    // TODO: verify "double pathway" steps for bug #4365
    // After the step was edited we can complain about the possible
    // deadlock here.
    //
  } catch ( Throwable e ) {
    if ( spoon.getShell().isDisposed() ) {
      return null;
    }
    new ErrorDialog(
      spoon.getShell(), BaseMessages.getString( PKG, "Spoon.Dialog.UnableOpenDialog.Title" ), BaseMessages
        .getString( PKG, "Spoon.Dialog.UnableOpenDialog.Message" ), e );
  }

  if ( refresh ) {
    spoon.refreshTree(); // Perhaps new connections were created in
    // the step
    // dialog or the step name changed.
  }

  return stepname;
}
 
Example 15
Source File: XmlJoinMetaGetFieldsTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetFieldsReturnTargetStepFieldsWithDuplicates() throws Exception {
  // Source Step
  String sourceXmlStep = "source xml step name";
  String sourceStepField1 = "a";
  String sourceStepField2 = "b";

  // Target Step
  String targetXmlStep = "target xml step name";
  String targetStepField1 = "b";
  String targetStepField2 = "c";

  // XML Join Result
  String resultXmlFieldName = "result xml field name";

  // Source Row Meta
  RowMeta rowMetaPreviousSourceStep = new RowMeta();
  rowMetaPreviousSourceStep.addValueMeta( new ValueMeta( sourceStepField1, ValueMetaInterface.TYPE_STRING ) );
  rowMetaPreviousSourceStep.addValueMeta( new ValueMeta( sourceStepField2, ValueMetaInterface.TYPE_STRING ) );

  // Set source step in XML Join step.
  xmlJoinMeta.setSourceXMLstep( sourceXmlStep );
  StepMeta sourceStepMeta = new StepMeta();
  sourceStepMeta.setName( sourceXmlStep );

  doReturn( sourceStepMeta ).when( transMeta ).findStep( sourceXmlStep );
  doReturn( rowMetaPreviousSourceStep ).when( transMeta ).getStepFields( sourceStepMeta, null, null );

  // Target Row Meta
  RowMeta rowMetaPreviousTargetStep = new RowMeta();
  rowMetaPreviousTargetStep.addValueMeta( new ValueMeta( targetStepField1, ValueMetaInterface.TYPE_STRING ) );
  rowMetaPreviousTargetStep.addValueMeta( new ValueMeta( targetStepField2, ValueMetaInterface.TYPE_STRING ) );

  // Set target step in XML Join step.
  xmlJoinMeta.setTargetXMLstep( targetXmlStep );
  StepMeta targetStepMeta = new StepMeta();
  targetStepMeta.setName( targetXmlStep );

  doReturn( targetStepMeta ).when( transMeta ).findStep( targetXmlStep );
  doReturn( rowMetaPreviousTargetStep ).when( transMeta ).getStepFields( targetStepMeta, null, null );

  // Set result field name
  xmlJoinMeta.setValueXMLfield( resultXmlFieldName );

  RowMeta rowMeta = new RowMeta();
  ValueMetaString removeValueMeta1 = new ValueMetaString( "a" );
  rowMeta.addValueMeta( removeValueMeta1 );
  ValueMetaString keepValueMeta1 = new ValueMetaString( "b" );
  rowMeta.addValueMeta( keepValueMeta1 );
  ValueMetaString keepValueMeta2 = new ValueMetaString( "c" );
  rowMeta.addValueMeta( keepValueMeta2 );

  // Get output fields
  xmlJoinMeta.getFields( rowMeta, "testStepName", null, null, transMeta, null, null );
  assertEquals( 3, rowMeta.size() );
  String[] strings = rowMeta.getFieldNames();
  assertEquals( "b", strings[0] );
  assertEquals( "c", strings[1] );
  assertEquals( "result xml field name", strings[2] );
}
 
Example 16
Source File: TransMetaTest.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Test
public void testTransListeners() {
  TransMeta TransMeta = new TransMeta();

  StepMeta oldFormStep = new StepMeta();
  oldFormStep.setName( "Generate_1" );

  StepMeta newFormStep = new StepMeta();
  newFormStep.setName( "Generate_2" );

  StepMeta toStep = new StepMeta();
  toStep.setStepMetaInterface( new MetaInjectMeta() );
  toStep.setName( "ETL Inject Metadata" );

  StepMeta deletedStep = new StepMeta();
  deletedStep.setStepMetaInterface( new MetaInjectMeta() );
  deletedStep.setName( "ETL Inject Metadata for delete" );

  // Verify add & remove listeners

  TransMeta.addStep( oldFormStep );
  TransMeta.addStep( toStep );
  TransMeta.addStep( deletedStep );

  assertEquals( TransMeta.nrStepChangeListeners(), 2 );
  TransMeta.removeStepChangeListener( (StepMetaChangeListenerInterface) deletedStep.getStepMetaInterface() );
  assertEquals( TransMeta.nrStepChangeListeners(), 1 );
  TransMeta.removeStep( 2 );

  TransHopMeta hi = new TransHopMeta( oldFormStep, toStep );
  TransMeta.addTransHop( hi );

  // Verify MetaInjectMeta.onStepChange()

  // add new TargetStepAttribute
  MetaInjectMeta toMeta = (MetaInjectMeta) toStep.getStepMetaInterface();

  Map<TargetStepAttribute, SourceStepField> sourceMapping = new HashMap<TargetStepAttribute, SourceStepField>();
  TargetStepAttribute keyTest = new TargetStepAttribute( "File", "key", true );
  SourceStepField valueTest = new SourceStepField( oldFormStep.getName(), oldFormStep.getName() );
  sourceMapping.put( keyTest, valueTest );

  toMeta.setTargetSourceMapping( sourceMapping );

  // Run all listeners
  TransMeta.notifyAllListeners( oldFormStep, newFormStep );

  // Verify changes, which listeners makes
  sourceMapping = toMeta.getTargetSourceMapping();
  for ( Entry<TargetStepAttribute, SourceStepField> entry : sourceMapping.entrySet() ) {
    SourceStepField value = entry.getValue();
    if ( !value.getStepname().equals( newFormStep.getName() ) ) {
      fail();
    }
  }

  // verify another functions
  TransMeta.addStep( deletedStep );
  assertEquals( TransMeta.nrSteps(), 3 );
  assertEquals( TransMeta.nrStepChangeListeners(), 2 );

  TransMeta.removeStep( 0 );
  assertEquals( TransMeta.nrSteps(), 2 );

}