UnifiedHTMLDiffManager implements XMLDiffManager, Initializable { @Override public String diff(String previousHTML, String nextHTML, XMLDiffConfiguration config) throws DiffException { List<XMLDiffFilter> filters = config.getFilters(); Document previousDocument = filterBeforeDiff(parseHTML(previousHTML), filters); Document nextDocument = filterBeforeDiff(parseHTML(nextHTML), filters); if (!this.htmlDiffMarker.markDiff(previousDocument, nextDocument, config)) { return ""; } return unwrap(HTMLUtils.toString(filterAfterDiff(previousDocument, filters), false, false).trim()); }  @Override void initialize(); @Override String diff(String previousHTML, String nextHTML, XMLDiffConfiguration config);  }
@Test void verifyXMLDiffFiltersThrowingExceptions() throws Exception { XMLDiffFilter alice = mock(XMLDiffFilter.class, "alice"); doThrow(new RuntimeException("before alice failed!")).when(alice).before(any(Document.class)); doThrow(new RuntimeException("after alice failed!")).when(alice).after(any(Document.class)); XMLDiffFilter bob = mock(XMLDiffFilter.class, "bob"); this.config.getFilters().add(0, alice); this.config.getFilters().add(bob); this.unifiedHTMLDiffManager.diff("<p>one</p>", "<p>two</p>", this.config); assertEquals("Failed to apply filter before diff.", this.logCapture.getMessage(0)); assertEquals("Failed to apply filter before diff.", this.logCapture.getMessage(1)); assertEquals("Failed to apply filter after diff.", this.logCapture.getMessage(2)); verify(bob, times(2)).before(any(Document.class)); verify(bob).after(any(Document.class)); }