public void test_performOperation_whenException() throws Exception {
   Logger oldLogger = AnalysisEngine.getInstance().getLogger();
   try {
     Error myException = new Error();
     when(unit.accept(isA(AngularHtmlIndexContributor.class))).thenThrow(myException);
     // set mock Logger
     Logger logger = mock(Logger.class);
     AnalysisEngine.getInstance().setLogger(logger);
     // run operation
     operation.performOperation();
     // verify that "myException" was logged
     verify(logger).logError(anyString(), same(myException));
   } finally {
     AnalysisEngine.getInstance().setLogger(oldLogger);
   }
 }
 /**
  * Build the HTML element for the given source.
  *
  * @param source the source describing the compilation unit
  * @param unit the AST structure representing the HTML
  * @throws AnalysisException if the analysis could not be performed
  */
 public HtmlElementImpl buildHtmlElement(Source source, HtmlUnit unit) throws AnalysisException {
   HtmlElementImpl result = new HtmlElementImpl(context, source.getShortName());
   result.setSource(source);
   htmlElement = result;
   unit.accept(this);
   htmlElement = null;
   unit.setElement(result);
   return result;
 }