### Question:
TitleForAcronymTagRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlAcronym acronym : page.findAllAcronymTags()) { if (!hasNonEmptyAttribute(acronym, "title")) { violations.add(createViolation(acronym, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void acronymElementWithTitleAttribute() throws Exception { String content = "<html><body><acronym title=\"as soon as possible\">ASAP</acronym></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations); }
@Test public void acronymElementWithEmptyTitleAttribute() throws Exception { String content = "<html><body><acronym title=\"\">ASAP</acronym></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }
@Test public void acronymElementWithMissingTitleAttribute() { String content = "<html><body><acronym>ASAP</acronym></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }