### Question:
UnorderedListContainsListItemsRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { List<HtmlUnorderedList> unorderedLists = page.findAllUnorderedLists(); for (HtmlUnorderedList unorderedList : unorderedLists) { if (!listHasOneOrMoreListItems(unorderedList)) { violations.add(createViolation(unorderedList, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void unorderedListWithoutItems() throws Exception { String content = "<html><body><ul></ul></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }
@Test public void unorderedListContainingToUnorderedListsWithoutItems() throws Exception { String content = "<html><body><ul><li><ul></ul></li><li><ul></ul></li></ul></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 2); }
@Test public void unorderedListWithItems() throws Exception { String content = "<html><body><ul><li>First item</li></ul></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations); }