diff --git a/src/main/java/fr/xephi/authme/util/MigrationService.java b/src/main/java/fr/xephi/authme/util/MigrationService.java index d4ab15339..86f98e4c1 100644 --- a/src/main/java/fr/xephi/authme/util/MigrationService.java +++ b/src/main/java/fr/xephi/authme/util/MigrationService.java @@ -31,6 +31,7 @@ public final class MigrationService { * @param dataSource The data source * @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation */ + @SuppressWarnings("deprecation") public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource, SHA256 authmeSha256) { if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) { @@ -56,6 +57,7 @@ public final class MigrationService { * @param dataSource The data source * @return The converted datasource (SQLite), or null if no migration was necessary */ + @SuppressWarnings("deprecation") public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) { if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) { ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated; it will be changed " diff --git a/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java b/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java index 0f4dff18d..e3970fa6b 100644 --- a/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java @@ -30,7 +30,7 @@ public class CommandUtilsTest { @Test public void shouldPrintEmptyStringForNoArguments() { // given - List parts = Collections.EMPTY_LIST; + List parts = Collections.emptyList(); // when String str = CommandUtils.labelsToString(parts); diff --git a/src/test/java/fr/xephi/authme/command/PlayerCommandTest.java b/src/test/java/fr/xephi/authme/command/PlayerCommandTest.java index 3fcc05ca6..4afee564c 100644 --- a/src/test/java/fr/xephi/authme/command/PlayerCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/PlayerCommandTest.java @@ -28,7 +28,7 @@ public class PlayerCommandTest { PlayerCommandImpl command = new PlayerCommandImpl(); // when - command.executeCommand(sender, Collections.EMPTY_LIST, mock(CommandService.class)); + command.executeCommand(sender, Collections. emptyList(), mock(CommandService.class)); // then ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); @@ -58,7 +58,7 @@ public class PlayerCommandTest { PlayerCommandWithAlt command = new PlayerCommandWithAlt(); // when - command.executeCommand(sender, Collections.EMPTY_LIST, mock(CommandService.class)); + command.executeCommand(sender, Collections. emptyList(), mock(CommandService.class)); // then ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java index abf422c46..824696354 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java @@ -47,7 +47,7 @@ public class AccountsCommandTest { public void shouldGetAccountsOfCurrentUser() { // given given(sender.getName()).willReturn("Tester"); - List arguments = Collections.EMPTY_LIST; + List arguments = Collections.emptyList(); given(dataSource.getAuth("tester")).willReturn(authWithIp("123.45.67.89")); given(dataSource.getAllAuthsByIp("123.45.67.89")).willReturn(Arrays.asList("Toaster", "Pester")); @@ -81,7 +81,7 @@ public class AccountsCommandTest { // given List arguments = Collections.singletonList("SomeUser"); given(dataSource.getAuth("someuser")).willReturn(mock(PlayerAuth.class)); - given(dataSource.getAllAuthsByIp(anyString())).willReturn(Collections.EMPTY_LIST); + given(dataSource.getAllAuthsByIp(anyString())).willReturn(Collections. emptyList()); // when command.executeCommand(sender, arguments, service); @@ -115,7 +115,7 @@ public class AccountsCommandTest { public void shouldReturnIpUnknown() { // given List arguments = Collections.singletonList("123.45.67.89"); - given(dataSource.getAllAuthsByIp("123.45.67.89")).willReturn(Collections.EMPTY_LIST); + given(dataSource.getAllAuthsByIp("123.45.67.89")).willReturn(Collections. emptyList()); // when command.executeCommand(sender, arguments, service); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/AuthMeCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/AuthMeCommandTest.java index c7038ac6c..8be1185ab 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/AuthMeCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/AuthMeCommandTest.java @@ -27,7 +27,7 @@ public class AuthMeCommandTest { CommandService service = mock(CommandService.class); // when - command.executeCommand(sender, Collections.EMPTY_LIST, service); + command.executeCommand(sender, Collections. emptyList(), service); // then ArgumentCaptor messagesCaptor = ArgumentCaptor.forClass(String.class); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommandTest.java index d6cc0af32..aa4f7b74b 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommandTest.java @@ -36,7 +36,7 @@ public class FirstSpawnCommandTest { ExecutableCommand command = new FirstSpawnCommand(); // when - command.executeCommand(player, Collections.EMPTY_LIST, service); + command.executeCommand(player, Collections. emptyList(), service); // then verify(player).teleport(firstSpawn); @@ -54,7 +54,7 @@ public class FirstSpawnCommandTest { ExecutableCommand command = new FirstSpawnCommand(); // when - command.executeCommand(player, Collections.EMPTY_LIST, service); + command.executeCommand(player, Collections. emptyList(), service); // then ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/LastLoginCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/LastLoginCommandTest.java index 2df4a610e..96cf8844a 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/LastLoginCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/LastLoginCommandTest.java @@ -103,7 +103,7 @@ public class LastLoginCommandTest { ExecutableCommand command = new LastLoginCommand(); // when - command.executeCommand(sender, Collections.EMPTY_LIST, service); + command.executeCommand(sender, Collections. emptyList(), service); // then verify(dataSource).getAuth(name); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommandTest.java index d24d57b47..9f2078667 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommandTest.java @@ -61,7 +61,7 @@ public class PurgeLastPositionCommandTest { ExecutableCommand command = new PurgeLastPositionCommand(); // when - command.executeCommand(sender, Collections.EMPTY_LIST, service); + command.executeCommand(sender, Collections. emptyList(), service); // then verify(dataSource).getAuth(player); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ReloadCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ReloadCommandTest.java index deb6c50f3..873108ee0 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ReloadCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ReloadCommandTest.java @@ -37,7 +37,7 @@ public class ReloadCommandTest { ExecutableCommand command = new ReloadCommand(); // when - command.executeCommand(sender, Collections.EMPTY_LIST, service); + command.executeCommand(sender, Collections. emptyList(), service); // then verify(authMe).reload(); @@ -55,7 +55,7 @@ public class ReloadCommandTest { ExecutableCommand command = new ReloadCommand(); // when - command.executeCommand(sender, Collections.EMPTY_LIST, service); + command.executeCommand(sender, Collections. emptyList(), service); // then verify(authMe).reload(); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/SetFirstSpawnCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/SetFirstSpawnCommandTest.java index e56e297b5..307831ce7 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/SetFirstSpawnCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/SetFirstSpawnCommandTest.java @@ -35,7 +35,7 @@ public class SetFirstSpawnCommandTest { ExecutableCommand command = new SetFirstSpawnCommand(); // when - command.executeCommand(player, Collections.EMPTY_LIST, service); + command.executeCommand(player, Collections. emptyList(), service); // then verify(spawnLoader).setFirstSpawn(location); @@ -57,7 +57,7 @@ public class SetFirstSpawnCommandTest { ExecutableCommand command = new SetFirstSpawnCommand(); // when - command.executeCommand(player, Collections.EMPTY_LIST, service); + command.executeCommand(player, Collections. emptyList(), service); // then verify(spawnLoader).setFirstSpawn(location); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/SetSpawnCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/SetSpawnCommandTest.java index 11c2f42c4..11c28d32b 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/SetSpawnCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/SetSpawnCommandTest.java @@ -35,7 +35,7 @@ public class SetSpawnCommandTest { ExecutableCommand command = new SetSpawnCommand(); // when - command.executeCommand(player, Collections.EMPTY_LIST, service); + command.executeCommand(player, Collections. emptyList(), service); // then verify(spawnLoader).setSpawn(location); @@ -57,7 +57,7 @@ public class SetSpawnCommandTest { ExecutableCommand command = new SetSpawnCommand(); // when - command.executeCommand(player, Collections.EMPTY_LIST, service); + command.executeCommand(player, Collections. emptyList(), service); // then verify(spawnLoader).setSpawn(location); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/SpawnCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/SpawnCommandTest.java index eebfd5af4..7b76ad02b 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/SpawnCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/SpawnCommandTest.java @@ -35,7 +35,7 @@ public class SpawnCommandTest { ExecutableCommand command = new SpawnCommand(); // when - command.executeCommand(player, Collections.EMPTY_LIST, service); + command.executeCommand(player, Collections. emptyList(), service); // then verify(player).teleport(spawn); @@ -53,7 +53,7 @@ public class SpawnCommandTest { ExecutableCommand command = new SpawnCommand(); // when - command.executeCommand(player, Collections.EMPTY_LIST, service); + command.executeCommand(player, Collections. emptyList(), service); // then verify(player).sendMessage(argThat(containsString("Spawn has failed"))); diff --git a/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java index 31fb30f15..213dba4c3 100644 --- a/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java @@ -44,7 +44,7 @@ public class ChangePasswordCommandTest { when(commandService.getProperty(SecuritySettings.MAX_PASSWORD_LENGTH)).thenReturn(50); // Only allow passwords with alphanumerical characters for the test when(commandService.getProperty(RestrictionSettings.ALLOWED_PASSWORD_REGEX)).thenReturn("[a-zA-Z0-9]+"); - when(commandService.getProperty(SecuritySettings.UNSAFE_PASSWORDS)).thenReturn(Collections.EMPTY_LIST); + when(commandService.getProperty(SecuritySettings.UNSAFE_PASSWORDS)).thenReturn(Collections. emptyList()); } @Test diff --git a/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java b/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java index 45e4d4240..6568a773b 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java @@ -253,7 +253,7 @@ public class HelpProviderTest { public void shouldHandleUnboundFoundCommandResult() { // given FoundCommandResult result = new FoundCommandResult(null, Arrays.asList("authme", "test"), - Collections.EMPTY_LIST, 0.0, FoundResultStatus.UNKNOWN_LABEL); + Collections. emptyList(), 0.0, FoundResultStatus.UNKNOWN_LABEL); // when List lines = helpProvider.printHelp(sender, result, ALL_OPTIONS); @@ -317,7 +317,7 @@ public class HelpProviderTest { * @return The generated FoundCommandResult object */ private static FoundCommandResult newFoundResult(CommandDescription command, List labels) { - return new FoundCommandResult(command, labels, Collections.EMPTY_LIST, 0.0, FoundResultStatus.SUCCESS); + return new FoundCommandResult(command, labels, Collections. emptyList(), 0.0, FoundResultStatus.SUCCESS); } private static String removeColors(String str) { diff --git a/src/test/java/fr/xephi/authme/datasource/AbstractResourceClosingTest.java b/src/test/java/fr/xephi/authme/datasource/AbstractResourceClosingTest.java index f5ba58e85..69bb0512f 100644 --- a/src/test/java/fr/xephi/authme/datasource/AbstractResourceClosingTest.java +++ b/src/test/java/fr/xephi/authme/datasource/AbstractResourceClosingTest.java @@ -97,6 +97,7 @@ public abstract class AbstractResourceClosingTest { } /** Initialize the settings mock and makes it return the default of any given property by default. */ + @SuppressWarnings({ "unchecked", "rawtypes" }) @BeforeClass public static void initializeSettings() throws IOException, ClassNotFoundException { settings = mock(NewSetting.class); diff --git a/src/test/java/fr/xephi/authme/datasource/MySqlIntegrationTest.java b/src/test/java/fr/xephi/authme/datasource/MySqlIntegrationTest.java index 586ca0ad1..81e2e122b 100644 --- a/src/test/java/fr/xephi/authme/datasource/MySqlIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/datasource/MySqlIntegrationTest.java @@ -38,6 +38,7 @@ public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest { /** * Set up the settings mock to return specific values for database settings and load {@link #sqlInitialize}. */ + @SuppressWarnings({ "unchecked", "rawtypes" }) @BeforeClass public static void initializeSettings() throws IOException, ClassNotFoundException { // Check that we have an H2 driver diff --git a/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java b/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java index 715d2ce9b..2ef4e15a5 100644 --- a/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java @@ -37,6 +37,7 @@ public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest { /** * Set up the settings mock to return specific values for database settings and load {@link #sqlInitialize}. */ + @SuppressWarnings({ "unchecked", "rawtypes" }) @BeforeClass public static void initializeSettings() throws IOException, ClassNotFoundException { // Check that we have an implementation for SQLite diff --git a/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java b/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java index c98dd7d0e..c6b003837 100644 --- a/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java @@ -112,6 +112,7 @@ public class SettingsClassConsistencyTest { return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers); } + @SuppressWarnings("unchecked") private static Class getSettingsClassFromFile(File file) { String fileName = file.getPath(); String className = fileName diff --git a/src/test/java/fr/xephi/authme/util/UtilsTest.java b/src/test/java/fr/xephi/authme/util/UtilsTest.java index 3ed7ee626..639946f65 100644 --- a/src/test/java/fr/xephi/authme/util/UtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/UtilsTest.java @@ -110,8 +110,8 @@ public class UtilsTest { public void shouldAcceptEmailWithEmptyLists() { // given NewSetting settings = mock(NewSetting.class); - given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.EMPTY_LIST); - given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)).willReturn(Collections.EMPTY_LIST); + given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections. emptyList()); + given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)).willReturn(Collections. emptyList()); // when boolean result = Utils.isEmailCorrect("test@example.org", settings); @@ -126,7 +126,7 @@ public class UtilsTest { NewSetting settings = mock(NewSetting.class); given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)) .willReturn(Arrays.asList("domain.tld", "example.com")); - given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)).willReturn(Collections.EMPTY_LIST); + given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)).willReturn(Collections. emptyList()); // when boolean result = Utils.isEmailCorrect("TesT@Example.com", settings); @@ -141,7 +141,7 @@ public class UtilsTest { NewSetting settings = mock(NewSetting.class); given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)) .willReturn(Arrays.asList("domain.tld", "example.com")); - given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)).willReturn(Collections.EMPTY_LIST); + given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)).willReturn(Collections. emptyList()); // when boolean result = Utils.isEmailCorrect("email@other-domain.abc", settings); @@ -154,7 +154,7 @@ public class UtilsTest { public void shouldAcceptEmailNotInBlacklist() { // given NewSetting settings = mock(NewSetting.class); - given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.EMPTY_LIST); + given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections. emptyList()); given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)) .willReturn(Arrays.asList("Example.org", "a-test-name.tld")); @@ -169,7 +169,7 @@ public class UtilsTest { public void shouldRejectEmailInBlacklist() { // given NewSetting settings = mock(NewSetting.class); - given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.EMPTY_LIST); + given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections. emptyList()); given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)) .willReturn(Arrays.asList("Example.org", "a-test-name.tld"));