### Question:
AlternativeTextForObjectRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlObject object : page.findAllObjectTags()) { if (object.getTextContent() == null || object.getTextContent().isEmpty()) { violations.add(createViolation(object, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void objectWithoutAlternativeTextPresent() throws Exception { String content = "<html><body><object data=\"movie.mp4\" type=\"video/mp4\"></object></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }
@Test public void objectWithAlternativeTextPresent() throws Exception { String content = "<html><body><object data=\"movie.mp4\" type=\"video/mp4\">Movie about usage of BitvUnit</object></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations, rule); }
@Test public void objectWithAlternativeTextInInnerElementPresent() throws Exception { String content = "<html><body><object data=\"movie.mp4\" type=\"video/mp4\"><p>Movie about usage of BitvUnit</p></object></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations, rule); }