ProcessorLogger implements Logger { @Override public void warning(LogLocation location, String message) { if (location == null) { throw new NullPointerException("location"); } if (message == null) { throw new NullPointerException("message"); } if (location.toMessager()) { messager.printMessage(Kind.WARNING, message); } if (options.logging() && location.toLogFile()) { logContent.append("warning: ").append(message).append("\n"); } } 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(expected=NullPointerException.class) public void testWarningLocationNull() { ProcessorLogger logger = new ProcessorLogger(messager, options); logger.warning(null, ""); }
@Test(expected=NullPointerException.class) public void testWarningMessageNull() { ProcessorLogger logger = new ProcessorLogger(messager, options); logger.warning(LogLocation.BOTH, null); }
@Test public void testWarningToMessagerNotVerbose() { ProcessorLogger logger = new ProcessorLogger(messager, optionsLog); messager.reset(); logger.warning(LogLocation.MESSAGER, "message"); List<Message> messages = messager.messages(); Assert.assertEquals(1, messages.size()); Assert.assertEquals("message", messages.get(0).msg); Assert.assertEquals(Kind.WARNING, messages.get(0).kind); }
@Test public void testWarningToMessagerVerbose() { ProcessorLogger logger = new ProcessorLogger(messager, optionsVerbose); messager.reset(); logger.warning(LogLocation.MESSAGER, "message"); List<Message> messages = messager.messages(); Assert.assertEquals(1, messages.size()); Assert.assertEquals("message", messages.get(0).msg); Assert.assertEquals(Kind.WARNING, messages.get(0).kind); }