FileDefinitionSerializer { public String write( FileDefinition definitionFile, boolean writeComments ) { StringBuilder sb = new StringBuilder(); for( Iterator<AbstractBlock> it = definitionFile.getBlocks().iterator(); it.hasNext(); ) { sb.append( write( it.next(), writeComments )); if( it.hasNext()) sb.append( this.lineSeparator ); } return sb.toString(); } FileDefinitionSerializer();  FileDefinitionSerializer( String lineSeparator ); String write( FileDefinition definitionFile, boolean writeComments ); String write( AbstractBlock block, boolean writeComments ); String write( BlockImport block, boolean writeComments ); String write( BlockComponent block, boolean writeComments ); String write( BlockFacet block, boolean writeComments ); String write( BlockInstanceOf block, boolean writeComments, int indentationLevel ); String write( BlockBlank block, boolean writeComments ); String write( BlockProperty block, boolean writeComments ); String write( BlockComment block, boolean writeComments );  }
@Test public void testRepairedBlank() { FileDefinition def = new FileDefinition( new File( "whatever" )); BlockBlank block = new BlockBlank( def, "invalid blank block" ); FileDefinitionSerializer serializer = new FileDefinitionSerializer(); String s = serializer.write( block, true ); Assert.assertEquals( System.getProperty( "line.separator" ), s ); }
@Test public void testRepairedComment() { FileDefinition def = new FileDefinition( new File( "whatever" )); BlockComment block = new BlockComment( def, "invalid comment \n\t # followed by a valid \n#comment" ); FileDefinitionSerializer serializer = new FileDefinitionSerializer(); String s = serializer.write( block, true ); String expected = "# invalid comment \n\t # followed by a valid \n#comment\n".replace( "\n", System.getProperty( "line.separator" )); Assert.assertEquals( expected, s ); }