@Test public void testMarkLog_EnsureLogLevel() { for (LoggerLevel level : EnumSet.complementOf(EnumSet.of(LoggerLevel.DEFAULT))) { reset(logManager); when(logManager.getLoggerEffectiveLevel(LOG_NAME)).thenReturn(level); logMarker.markLog("test"); try { if (EnumSet.of(LoggerLevel.OFF, LoggerLevel.ERROR, LoggerLevel.WARN).contains(level)) { verify(logManager).setLoggerLevel(LOG_NAME, LoggerLevel.INFO); } else { verify(logManager, never()).setLoggerLevel(anyObject(), anyObject()); } } catch (AssertionError e) { throw new AssertionError("Mishandled log level " + level, e); } } }
@Before public void setUp() { logMarker = new LogMarkerImpl(logManager, eventManager); when(logManager.getLoggerEffectiveLevel(LOG_NAME)).thenReturn(LoggerLevel.INFO); }