public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step )
    throws KettleException {
    try {
      rep.saveDatabaseMetaStepAttribute( id_transformation, id_step, "id_connection", databaseMeta );
      rep.saveStepAttribute( id_transformation, id_step, "schema", schemaName );
      rep.saveStepAttribute( id_transformation, id_step, "table", tableName );
      rep.saveStepAttribute( id_transformation, id_step, "commit", commitSize );
      rep.saveStepAttribute( id_transformation, id_step, "truncate", truncateTable );
      rep.saveStepAttribute( id_transformation, id_step, "ignore_errors", ignoreErrors );
      rep.saveStepAttribute( id_transformation, id_step, "use_batch", useBatchUpdate );
      rep.saveStepAttribute( id_transformation, id_step, "specify_fields", specifyFields );

      rep.saveStepAttribute( id_transformation, id_step, "partitioning_enabled", partitioningEnabled );
      rep.saveStepAttribute( id_transformation, id_step, "partitioning_field", partitioningField );
      rep.saveStepAttribute( id_transformation, id_step, "partitioning_daily", partitioningDaily );
      rep.saveStepAttribute( id_transformation, id_step, "partitioning_monthly", partitioningMonthly );

      rep.saveStepAttribute( id_transformation, id_step, "tablename_in_field", tableNameInField );
      rep.saveStepAttribute( id_transformation, id_step, "tablename_field", tableNameField );
      rep.saveStepAttribute( id_transformation, id_step, "tablename_in_table", tableNameInTable );

      rep.saveStepAttribute( id_transformation, id_step, "return_keys", returningGeneratedKeys );
      rep.saveStepAttribute( id_transformation, id_step, "return_field", generatedKeyField );

      int nrRows = ( fieldDatabase.length < fieldStream.length ? fieldStream.length : fieldDatabase.length );
      for ( int idx = 0; idx < nrRows; idx++ ) {
        String columnName = ( idx < fieldDatabase.length ? fieldDatabase[ idx ] : "" );
        String streamName = ( idx < fieldStream.length ? fieldStream[ idx ] : "" );
        rep.saveStepAttribute( id_transformation, id_step, idx, "column_name", columnName );
        rep.saveStepAttribute( id_transformation, id_step, idx, "stream_name", streamName );
      }

      // Also, save the step-database relationship!
      if ( databaseMeta != null ) {
        rep.insertStepDatabase( id_transformation, id_step, databaseMeta.getObjectId() );
      }
    } catch ( Exception e ) {
      throw new KettleException( "Unable to save step information to the repository for id_step=" + id_step, e );
    }
  }
@Test
  public void testSaveRep() throws Exception {
    TableOutputMeta tableOutputMeta = new TableOutputMeta();
    tableOutputMeta.loadXML( getTestNode(), databases, metaStore );
    StringObjectId id_step = new StringObjectId( "stepid" );
    StringObjectId id_transformation = new StringObjectId( "transid" );
    Repository rep = mock( Repository.class );
    tableOutputMeta.saveRep( rep, metaStore, id_transformation, id_step );
    verify( rep ).saveDatabaseMetaStepAttribute( id_transformation, id_step, "id_connection", null );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "schema", "public" );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "table", "sales_csv" );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "commit", "1000" );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "truncate", true );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "ignore_errors", false );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "use_batch", true );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "specify_fields", true );

    verify( rep ).saveStepAttribute( id_transformation, id_step, "partitioning_enabled", false );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "partitioning_field", null );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "partitioning_daily", false );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "partitioning_monthly", true );

    verify( rep ).saveStepAttribute( id_transformation, id_step, "tablename_in_field", false );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "tablename_field", null );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "tablename_in_table", true );

    verify( rep ).saveStepAttribute( id_transformation, id_step, "return_keys", false );
    verify( rep ).saveStepAttribute( id_transformation, id_step, "return_field", null );

    verify( rep ).saveStepAttribute( id_transformation, id_step, 0, "column_name", "ORDERNUMBER" );
    verify( rep ).saveStepAttribute( id_transformation, id_step, 0, "stream_name", "ORDERNUMBER" );

    verify( rep ).saveStepAttribute( id_transformation, id_step, 1, "column_name", "QUANTITYORDERED" );
    verify( rep ).saveStepAttribute( id_transformation, id_step, 1, "stream_name", "QUANTITYORDERED" );

    verify( rep ).saveStepAttribute( id_transformation, id_step, 2, "column_name", "PRICEEACH" );
    verify( rep ).saveStepAttribute( id_transformation, id_step, 2, "stream_name", "PRICEEACH" );

    verifyNoMoreInteractions( rep );
  }