### Question:
TableHeaderForTableColumnRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlTable table : page.findAllTableTags()) { applyTo(table, page, violations); } }  @Override String getName();  }### Answer:
@Test public void tableWithTableHeadersPresent() throws Exception { String content = "<html>" + "<body>" + " <table>" + " <tr>" + " <th>First row</th>" + " <th>Second row</th>" + " </tr>" + " <tr>" + " <td>Some value</td>" + " <td>Another value</td>" + " </tr>" + " </table>" + "</body>" + "</html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations, rule); }
@Test public void tableWithTableHeadersMissing() throws Exception { String content = "<html>" + "<body>" + " <table>" + " <tr>" + " <td>Some value</td>" + " <td>Another value</td>" + " </tr>" + " <tr>" + " <td>More values</td>" + " <td>More values</td>" + " </tr>" + " </table>" + "</body>" + "</html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 2); }
@Test public void tableWithOnlyOneRow() throws Exception { String content = "<html>" + "<body>" + " <table>" + " <tr>" + " <td>Some value</td>" + " <td>Another value</td>" + " </tr>" + " </table>" + "</body>" + "</html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }