@Test public void testComment() { FileDefinition file = new FileDefinition( new File( "some-file" )); BlockComment block = new BlockComment( file, "# some comment" ); Assert.assertEquals( 0, ParsingModelValidator.validate((AbstractBlock) block ).size()); block = new BlockComment( file, "##### some comment" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block = new BlockComment( file, "# comment 1\n#comment 2\n# Comment number blabla" ); Assert.assertEquals( 0, ParsingModelValidator.validate( block ).size()); block = new BlockComment( file, "# Comment 1\nOops, I forgot the sharp symbol\n# Another comment" ); Collection<ParsingError> errors = ParsingModelValidator.validate( block ); Assert.assertEquals( 1, errors.size()); Assert.assertEquals( ErrorCode.PM_MALFORMED_COMMENT, errors.iterator().next().getErrorCode()); }
public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; }
ParsingModelValidator { public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; } }
ParsingModelValidator { public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; } private  ParsingModelValidator(); }
ParsingModelValidator { public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; } private  ParsingModelValidator(); static Collection<ParsingError> validate( FileDefinition definitionFile ); static Collection<ParsingError> validate( AbstractBlock block ); static Collection<ParsingError> validate( BlockImport block ); static Collection<ParsingError> validate( BlockComponent block ); static Collection<ParsingError> validate( BlockInstanceOf block ); static Collection<ParsingError> validate( BlockFacet block ); static Collection<ParsingError> validate( BlockProperty block ); static Collection<ParsingError> validate( BlockComment block ); static Collection<ParsingError> validate( BlockBlank block ); }
ParsingModelValidator { public static Collection<ParsingError> validate( FileDefinition definitionFile ) { Collection<ParsingError> result = new ArrayList<> (); result.addAll( definitionFile.getParsingErrors()); for( AbstractBlock block : definitionFile.getBlocks()) result.addAll( validate( block )); return result; } private  ParsingModelValidator(); static Collection<ParsingError> validate( FileDefinition definitionFile ); static Collection<ParsingError> validate( AbstractBlock block ); static Collection<ParsingError> validate( BlockImport block ); static Collection<ParsingError> validate( BlockComponent block ); static Collection<ParsingError> validate( BlockInstanceOf block ); static Collection<ParsingError> validate( BlockFacet block ); static Collection<ParsingError> validate( BlockProperty block ); static Collection<ParsingError> validate( BlockComment block ); static Collection<ParsingError> validate( BlockBlank block );  }