ProcessorLogger implements Logger { @Override public String getFileContent() { return logContent.toString(); } ProcessorLogger(Messager messager, Options options); @Override void note(LogLocation location, String message); @Override void warning(LogLocation location, String message); @Override String getFileContent(); static String exceptionToString(Exception exception);  }
@Test public void testProcessLoggerOptionsNoWarnings() { ProcessorLogger logger = new ProcessorLogger(messager, options); Assert.assertEquals("", logger.getFileContent()); List<Message> messages = messager.messages(); Assert.assertEquals(1, messages.size()); Assert.assertEquals(options.report(), messages.get(0).msg); }
@Test public void testProcessLoggerOptionsWithWarnings() { Map<String, String> map = new HashMap<String, String>(); map.put(Options.SPI_LOG_OPTION, "true"); map.put(Options.SPI_VERBOSE_OPTION, "true"); map.put(Options.SPI_DISABLED_OPTION, "yes"); Options o = new Options(map); ProcessorLogger logger = new ProcessorLogger(messager, o); List<Message> messages = messager.messages(); List<String> warnings = new ArrayList<String>(o.getWarnings()); Assert.assertEquals(o.report(), messages.get(0).msg); Assert.assertEquals(warnings.size() + 1, messages.size()); StringBuilder expectedFileContent = new StringBuilder(); for (int i = 0; i < warnings.size(); i++) { String warning = warnings.get(i); Assert.assertEquals(warning, messages.get(i + 1).msg); expectedFileContent.append("warning: ").append(warning).append("\n"); } Assert.assertEquals(expectedFileContent.toString(), logger.getFileContent()); }