### Question:
AlternativeTextForAreaOfImageMapRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlArea area : page.findAllAreaTags()) { if (area.getAltAttribute() == null || area.getAltAttribute().isEmpty()) { violations.add(createViolation(area, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void alternativeTextMissing() throws Exception { String content = "<html><body><img src=\"map.gif\" usemap=\"#mymap\"><map name=\"mymap\"><area shape=\"rect\" coords=\"0,0,10,10\" href=\"page2.htm\" /></map></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }
@Test public void alternativeTextPresent() throws Exception { String content = "<html><body><img src=\"map.gif\" usemap=\"#mymap\"><map name=\"mymap\"><area shape=\"rect\" coords=\"0,0,10,10\" href=\"page2.htm\" alt=\"Proceed to checkout\" /></map></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations, rule); }