### Question:
SettingsWarner { public void logWarningsForMisconfigurations() { if (!settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)) { ConsoleLogger.warning("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!"); } if (!settings.getProperty(EmailSettings.PORT25_USE_TLS) && settings.getProperty(EmailSettings.SMTP_PORT) != 25) { ConsoleLogger.warning("Note: You have set Email.useTls to false but this only affects mail over port 25"); } if (settings.getProperty(PluginSettings.SESSIONS_ENABLED) && settings.getProperty(PluginSettings.SESSIONS_TIMEOUT) <= 0) { ConsoleLogger.warning("Warning: Session timeout needs to be positive in order to work!"); } if (isTrue(bukkitService.isBungeeCordConfiguredForSpigot()) && !settings.getProperty(HooksSettings.BUNGEECORD)) { ConsoleLogger.warning("Note: Hooks.bungeecord is set to false but your server appears to be running in" + " bungeecord mode (see your spigot.yml). In order to allow the datasource caching and the" + " AuthMeBungee add-on to work properly you have to enable this option!"); } if (settings.getProperty(SecuritySettings.PASSWORD_HASH).equals(HashAlgorithm.ARGON2) && !Argon2.isLibraryLoaded()) { ConsoleLogger.warning("WARNING!!! You use Argon2 Hash Algorithm method but we can't find the Argon2 " + "library on your system! See https: authMe.stopOrUnload(); } } SettingsWarner(); void logWarningsForMisconfigurations();  }### Answer:
@Test public void shouldLogWarnings() { Logger logger = TestHelper.setupLogger(); given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(false); given(settings.getProperty(EmailSettings.SMTP_PORT)).willReturn(44); given(settings.getProperty(EmailSettings.PORT25_USE_TLS)).willReturn(false); given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(true); given(settings.getProperty(PluginSettings.SESSIONS_TIMEOUT)).willReturn(-5); given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.BCRYPT); given(settings.getProperty(HooksSettings.BUNGEECORD)).willReturn(false); given(bukkitService.isBungeeCordConfiguredForSpigot()).willReturn(Optional.of(true)); settingsWarner.logWarningsForMisconfigurations(); verify(logger, times(4)).warning(anyString()); }
@Test public void shouldNotLogAnyWarning() { Logger logger = TestHelper.setupLogger(); given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(true); given(settings.getProperty(EmailSettings.SMTP_PORT)).willReturn(25); given(settings.getProperty(EmailSettings.PORT25_USE_TLS)).willReturn(false); given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(false); given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.MD5); given(bukkitService.isBungeeCordConfiguredForSpigot()).willReturn(Optional.empty()); settingsWarner.logWarningsForMisconfigurations(); verifyZeroInteractions(logger); }