private static void verifyMarkdownContainsFieldsInTables(File doc,Map<String,Set<String>> fieldsByTable) throws IOException {
  final List<String> lines=Files.readAllLines(doc.toPath(),Charset.defaultCharset());
  final Map<String,Set<String>> fieldsLeftByTable=Maps.newHashMap();
  for (  Map.Entry<String,Set<String>> entry : fieldsByTable.entrySet()) {
    fieldsLeftByTable.put(entry.getKey(),Sets.newHashSet(entry.getValue()));
  }
  String inTable=null;
  for (  String line : lines) {
    if (fieldsLeftByTable.isEmpty()) {
      return;
    }
    final String currentHeader=getTableHeader(line);
    if (inTable == null || currentHeader != null) {
      inTable=currentHeader;
    }
    if (inTable != null && fieldsLeftByTable.containsKey(inTable)) {
      String[] parts=line.split("\\|");
      if (parts.length > 1) {
        final String fieldName=parts[1];
        final Set<String> fieldsLeft=fieldsLeftByTable.get(inTable);
        Iterator<String> fieldIt=fieldsLeft.iterator();
        while (fieldIt.hasNext()) {
          String fieldLeft=fieldIt.next();
          if (fieldName.contains(fieldLeft))           fieldIt.remove();
        }
        if (fieldsLeft.isEmpty()) {
          fieldsLeftByTable.remove(inTable);
        }
      }
    }
  }
  if (!fieldsLeftByTable.isEmpty()) {
    fail(String.format("Markdown file '%s' did not contain expected fields (by table): %s",doc,fieldsLeftByTable));
  }
}

private static void verifyMarkdownContainsFieldsInTables ( File doc , Map < String , Set < String > > fieldsByTable ) throws IOException { final List < String > lines = Files . readAllLines ( doc . toPath ( ) , Charset . defaultCharset ( ) ) ; final Map < String , Set < String > > fieldsLeftByTable = Maps . newHashMap ( ) ; for ( Map . Entry < String , Set < String > > entry : fieldsByTable . entrySet ( ) ) { fieldsLeftByTable . put ( entry . getKey ( ) , Sets . newHashSet ( entry . getValue ( ) ) ) ; } String inTable = null ; for ( String line : lines ) { if ( fieldsLeftByTable . isEmpty ( ) ) { return ; } final String currentHeader = getTableHeader ( line ) ; if ( inTable == null || currentHeader != null ) { inTable = currentHeader ; } if ( inTable != null && fieldsLeftByTable . containsKey ( inTable ) ) { String [ ] parts = line . split ( "\\|" ) ; if ( parts . length > 1 ) { final String fieldName = parts [ 1 ] ; final Set < String > fieldsLeft = fieldsLeftByTable . get ( inTable ) ; Iterator < String > fieldIt = fieldsLeft . iterator ( ) ; while ( fieldIt . hasNext ( ) ) { String fieldLeft = fieldIt . next ( ) ; if ( fieldName . contains ( fieldLeft ) ) fieldIt . remove ( ) ; } if ( fieldsLeft . isEmpty ( ) ) { fieldsLeftByTable . remove ( inTable ) ; } } } } if ( ! fieldsLeftByTable . isEmpty ( ) ) { fail ( String . format ( "Markdown file '%s' did not contain expected fields (by table): %s" , doc , fieldsLeftByTable ) ) ; } }
given a markdown document to search , this checks to see if the specified tables have all of the expected fields listed . match is a " search " , and not an " equals " match .
