public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases )
    throws KettleException {
    try {
      encoding = rep.getStepAttributeString( id_step, "encoding" );
      nameSpace = rep.getStepAttributeString( id_step, "name_space" );
      mainElement = rep.getStepAttributeString( id_step, "xml_main_element" );
      repeatElement = rep.getStepAttributeString( id_step, "xml_repeat_element" );

      fileName = rep.getStepAttributeString( id_step, "file_name" );
      extension = rep.getStepAttributeString( id_step, "file_extention" );
      servletOutput = rep.getStepAttributeBoolean( id_step, "file_servlet_output" );

      doNotOpenNewFileInit = rep.getStepAttributeBoolean( id_step, "do_not_open_newfile_init" );
      splitEvery = (int) rep.getStepAttributeInteger( id_step, "file_split" );
      stepNrInFilename = rep.getStepAttributeBoolean( id_step, "file_add_stepnr" );
      dateInFilename = rep.getStepAttributeBoolean( id_step, "file_add_date" );
      timeInFilename = rep.getStepAttributeBoolean( id_step, "file_add_time" );
      SpecifyFormat = rep.getStepAttributeBoolean( id_step, "SpecifyFormat" );
      omitNullValues = rep.getStepAttributeBoolean( id_step, "omit_null_values" );
      date_time_format = rep.getStepAttributeString( id_step, "date_time_format" );

      addToResultFilenames = rep.getStepAttributeBoolean( id_step, "add_to_result_filenames" );
      zipped = rep.getStepAttributeBoolean( id_step, "file_zipped" );

      int nrfields = rep.countNrStepAttributes( id_step, "field_name" );

      allocate( nrfields );

      for ( int i = 0; i < nrfields; i++ ) {
        outputFields[i] = new XMLField();

        outputFields[i].setContentType( ContentType.valueOf( Const.NVL( rep.getStepAttributeString( id_step, i,
            "field_content_type" ), ContentType.Element.name() ) ) );
        outputFields[i].setFieldName( rep.getStepAttributeString( id_step, i, "field_name" ) );
        outputFields[i].setElementName( rep.getStepAttributeString( id_step, i, "field_element" ) );
        outputFields[i].setType( rep.getStepAttributeString( id_step, i, "field_type" ) );
        outputFields[i].setFormat( rep.getStepAttributeString( id_step, i, "field_format" ) );
        outputFields[i].setCurrencySymbol( rep.getStepAttributeString( id_step, i, "field_currency" ) );
        outputFields[i].setDecimalSymbol( rep.getStepAttributeString( id_step, i, "field_decimal" ) );
        outputFields[i].setGroupingSymbol( rep.getStepAttributeString( id_step, i, "field_group" ) );
        outputFields[i].setNullString( rep.getStepAttributeString( id_step, i, "field_nullif" ) );
        outputFields[i].setLength( (int) rep.getStepAttributeInteger( id_step, i, "field_length" ) );
        outputFields[i].setPrecision( (int) rep.getStepAttributeInteger( id_step, i, "field_precision" ) );
      }
    } catch ( Exception e ) {
      throw new KettleException( "Unexpected error reading step information from the repository", e );
    }
  }
@SuppressWarnings( "ConstantConditions" )
  @Test
  public void testReadRep() throws Exception {
    XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
    Repository rep = mock( Repository.class );
    IMetaStore metastore = mock( IMetaStore.class );
    DatabaseMeta dbMeta = mock( DatabaseMeta.class );

    String encoding = "UTF-8";
    String namespace = "";
    String mainElement = "rows";
    String repeatElement = "row";
    String fileName = "repFileName";
    StringObjectId oid = new StringObjectId( "oid" );
    String fileExtension = "repxml";
    boolean servletOutput = true;
    boolean newFile = true;
    long split = 100L;
    boolean addStepNbr = false;
    boolean addDate = false;
    boolean addTime = true;
    boolean specifyFormat = true;
    boolean omitNull = false;
    String dateTimeFormat = "yyyyMMdd";
    boolean addToResult = true;
    boolean zipped = true;
    String contentType = "Element";
    String fieldName = "aField";
    String fieldElement = "field";
    String fieldType = "String";
    long fieldLength = 20L;
    long fieldPrecision = 0L;

    when( rep.getStepAttributeString( oid, "encoding" ) ).thenReturn( encoding );
    when( rep.getStepAttributeString( oid, "name_space" ) ).thenReturn( namespace );
    when( rep.getStepAttributeString( oid, "xml_main_element" ) ).thenReturn( mainElement );
    when( rep.getStepAttributeString( oid, "xml_repeat_element" ) ).thenReturn( repeatElement );
    when( rep.getStepAttributeString( oid, "file_name" ) ).thenReturn( fileName );
    when( rep.getStepAttributeString( oid, "file_extention" ) ).thenReturn( fileExtension );
    when( rep.getStepAttributeBoolean( oid, "file_servlet_output" ) ).thenReturn( servletOutput );
    when( rep.getStepAttributeBoolean( oid, "do_not_open_newfile_init" ) ).thenReturn( newFile );
    when( rep.getStepAttributeInteger( oid, "file_split" ) ).thenReturn( split );
    when( rep.getStepAttributeBoolean( oid, "file_add_stepnr" ) ).thenReturn( addStepNbr );
    when( rep.getStepAttributeBoolean( oid, "file_add_date" ) ).thenReturn( addDate );
    when( rep.getStepAttributeBoolean( oid, "file_add_time" ) ).thenReturn( addTime );
    when( rep.getStepAttributeBoolean( oid, "SpecifyFormat" ) ).thenReturn( specifyFormat );
    when( rep.getStepAttributeBoolean( oid, "omit_null_values" ) ).thenReturn( omitNull );
    when( rep.getStepAttributeString( oid, "date_time_format" ) ).thenReturn( dateTimeFormat );
    when( rep.getStepAttributeBoolean( oid, "add_to_result_filenames" ) ).thenReturn( addToResult );
    when( rep.getStepAttributeBoolean( oid, "file_zipped" ) ).thenReturn( zipped );
    when( rep.countNrStepAttributes( oid, "field_name" ) ).thenReturn( 1 );
    when( rep.getStepAttributeString( oid, 0, "field_content_type" ) ).thenReturn( contentType );
    when( rep.getStepAttributeString( oid, 0, "field_name" ) ).thenReturn( fieldName );
    when( rep.getStepAttributeString( oid, 0, "field_element" ) ).thenReturn( fieldElement );
    when( rep.getStepAttributeString( oid, 0, "field_type" ) ).thenReturn( fieldType );
    when( rep.getStepAttributeString( oid, 0, "field_format" ) ).thenReturn( null );
    when( rep.getStepAttributeString( oid, 0, "field_currency" ) ).thenReturn( null );
    when( rep.getStepAttributeString( oid, 0, "field_decimal" ) ).thenReturn( null );
    when( rep.getStepAttributeString( oid, 0, "field_group" ) ).thenReturn( null );
    when( rep.getStepAttributeString( oid, 0, "field_nullif" ) ).thenReturn( null );
    when( rep.getStepAttributeInteger( oid, 0, "field_length" ) ).thenReturn( fieldLength );
    when( rep.getStepAttributeInteger( oid, 0, "field_precision" ) ).thenReturn( fieldPrecision );

    xmlOutputMeta.readRep( rep, metastore, oid, Collections.singletonList( dbMeta ) );

    assertEquals( fileName, xmlOutputMeta.getFileName() );
    assertTrue( xmlOutputMeta.isDoNotOpenNewFileInit() );
    assertTrue( xmlOutputMeta.isServletOutput() );
    assertEquals( fileExtension, xmlOutputMeta.getExtension() );
    assertFalse( xmlOutputMeta.isStepNrInFilename() );
    assertFalse( xmlOutputMeta.isDateInFilename() );
    assertTrue( xmlOutputMeta.isTimeInFilename() );
    assertTrue( xmlOutputMeta.isSpecifyFormat() );
    assertEquals( dateTimeFormat, xmlOutputMeta.getDateTimeFormat() );
    assertTrue( xmlOutputMeta.isAddToResultFiles() );
    assertTrue( xmlOutputMeta.isZipped() );
    assertEquals( encoding, xmlOutputMeta.getEncoding() );
    assertTrue( StringUtil.isEmpty( xmlOutputMeta.getNameSpace() ) );
    assertEquals( mainElement, xmlOutputMeta.getMainElement() );
    assertEquals( repeatElement, xmlOutputMeta.getRepeatElement() );
    assertEquals( split, xmlOutputMeta.getSplitEvery() );
    assertFalse( xmlOutputMeta.isOmitNullValues() );
    XMLField[] outputFields = xmlOutputMeta.getOutputFields();
    assertEquals( 1, outputFields.length );

    assertEquals( fieldName, outputFields[0].getFieldName() );
    assertEquals( XMLField.ContentType.Element, outputFields[0].getContentType() );
    assertEquals( fieldElement, outputFields[0].getElementName() );
    assertEquals( fieldLength, outputFields[0].getLength() );
    assertEquals( fieldPrecision, outputFields[0].getPrecision() );

    Mockito.reset( rep, metastore );
    StringObjectId transid = new StringObjectId( "transid" );
    xmlOutputMeta.saveRep( rep, metastore, transid, oid );
    verify( rep ).saveStepAttribute( transid, oid, "encoding", encoding );
    verify( rep ).saveStepAttribute( transid, oid, "name_space", namespace );
    verify( rep ).saveStepAttribute( transid, oid, "xml_main_element", mainElement );
    verify( rep ).saveStepAttribute( transid, oid, "xml_repeat_element", repeatElement );
    verify( rep ).saveStepAttribute( transid, oid, "file_name", fileName );
    verify( rep ).saveStepAttribute( transid, oid, "file_extention", fileExtension );
    verify( rep ).saveStepAttribute( transid, oid, "file_servlet_output", servletOutput );
    verify( rep ).saveStepAttribute( transid, oid, "do_not_open_newfile_init", newFile );
    verify( rep ).saveStepAttribute( transid, oid, "file_split", split );
    verify( rep ).saveStepAttribute( transid, oid, "file_add_stepnr", addStepNbr );
    verify( rep ).saveStepAttribute( transid, oid, "file_add_date", addDate );
    verify( rep ).saveStepAttribute( transid, oid, "file_add_time", addTime );
    verify( rep ).saveStepAttribute( transid, oid, "SpecifyFormat", specifyFormat );
    verify( rep ).saveStepAttribute( transid, oid, "omit_null_values", omitNull );
    verify( rep ).saveStepAttribute( transid, oid, "date_time_format", dateTimeFormat );
    verify( rep ).saveStepAttribute( transid, oid, "add_to_result_filenames", addToResult );
    verify( rep ).saveStepAttribute( transid, oid, "file_zipped", zipped );

    verify( rep ).saveStepAttribute( transid, oid, 0, "field_content_type", contentType );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_name", fieldName );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_element", fieldElement );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_type", fieldType );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_format", null );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_currency", null );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_decimal", null );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_group", null );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_nullif", null );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_length", fieldLength );
    verify( rep ).saveStepAttribute( transid, oid, 0, "field_precision", fieldPrecision );

    Mockito.verifyNoMoreInteractions( rep, metastore );
  }