### Question:
LanguageForHtmlTagRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlHtml html : page.findAllHtmlTags()) { if (!hasNonEmptyAttribute(html, LANG_ATTRIBUTE)) { violations.add(createViolation(html, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void languageAttributeMissing() throws Exception { String content = "<html><body><p>Hello World</p></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }
@Test public void languageAttributeExists() throws Exception { String content = "<html lang=\"en\"><body><p>Hello World</p></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations); }