AlertLevelConverter { public static AlertLevel fromLevel(final Level level) { if (level == Level.FATAL) { return SEVERE; } else if (level == Level.ERROR) { return ERROR; } else if (level == Level.WARN) { return WARNING; } else if (level == Level.OFF) { return NONE; } throw new IllegalArgumentException("No matching AlertLevel for Log4J2 Level " + level + "."); }  static boolean hasAlertLevel(final Level level); static Level toLevel(final AlertLevel alert); static AlertLevel fromLevel(final Level level);  }
@Test public void toAlertLevel_LevelFatal_returnsAlertSevere() { assertThat(fromLevel(Level.FATAL)).isEqualTo(AlertLevel.SEVERE); }
@Test public void toAlertLevel_LevelError_returnsAlertError() { assertThat(fromLevel(Level.ERROR)).isEqualTo(AlertLevel.ERROR); }
@Test public void toAlertLevel_LevelWarn_returnsAlertWarning() { assertThat(fromLevel(Level.WARN)).isEqualTo(AlertLevel.WARNING); }
@Test public void toAlertLevel_LevelOff_returnsAlertNone() { assertThat(fromLevel(Level.OFF)).isEqualTo(AlertLevel.NONE); }
@Test public void toAlertLevel_LevelAll_throwsIllegalArgumentException() { assertThatThrownBy(() -> fromLevel(Level.ALL)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("No matching AlertLevel for Log4J2 Level " + Level.ALL + "."); }
@Test public void toAlertLevel_LevelTrace_throwsIllegalArgumentException() { assertThatThrownBy(() -> fromLevel(Level.TRACE)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("No matching AlertLevel for Log4J2 Level " + Level.TRACE + "."); }
@Test public void toAlertLevel_LevelDebug_throwsIllegalArgumentException() { assertThatThrownBy(() -> fromLevel(Level.DEBUG)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("No matching AlertLevel for Log4J2 Level " + Level.DEBUG + "."); }
@Test public void toAlertLevel_LevelInfo_throwsIllegalArgumentException() { assertThatThrownBy(() -> fromLevel(Level.INFO)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("No matching AlertLevel for Log4J2 Level " + Level.INFO + "."); }