Blame eclipse warnings

This commit is contained in:
Gabriele C 2016-03-17 21:16:13 +01:00
parent 1462d3c39e
commit 19070c220b
19 changed files with 34 additions and 28 deletions

View File

@ -31,6 +31,7 @@ public final class MigrationService {
* @param dataSource The data source * @param dataSource The data source
* @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation * @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation
*/ */
@SuppressWarnings("deprecation")
public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource, public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource,
SHA256 authmeSha256) { SHA256 authmeSha256) {
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) { if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
@ -56,6 +57,7 @@ public final class MigrationService {
* @param dataSource The data source * @param dataSource The data source
* @return The converted datasource (SQLite), or null if no migration was necessary * @return The converted datasource (SQLite), or null if no migration was necessary
*/ */
@SuppressWarnings("deprecation")
public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) { public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) {
if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) { if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) {
ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated; it will be changed " ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated; it will be changed "

View File

@ -30,7 +30,7 @@ public class CommandUtilsTest {
@Test @Test
public void shouldPrintEmptyStringForNoArguments() { public void shouldPrintEmptyStringForNoArguments() {
// given // given
List<String> parts = Collections.EMPTY_LIST; List<String> parts = Collections.emptyList();
// when // when
String str = CommandUtils.labelsToString(parts); String str = CommandUtils.labelsToString(parts);

View File

@ -28,7 +28,7 @@ public class PlayerCommandTest {
PlayerCommandImpl command = new PlayerCommandImpl(); PlayerCommandImpl command = new PlayerCommandImpl();
// when // when
command.executeCommand(sender, Collections.EMPTY_LIST, mock(CommandService.class)); command.executeCommand(sender, Collections.<String> emptyList(), mock(CommandService.class));
// then // then
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
@ -58,7 +58,7 @@ public class PlayerCommandTest {
PlayerCommandWithAlt command = new PlayerCommandWithAlt(); PlayerCommandWithAlt command = new PlayerCommandWithAlt();
// when // when
command.executeCommand(sender, Collections.EMPTY_LIST, mock(CommandService.class)); command.executeCommand(sender, Collections.<String> emptyList(), mock(CommandService.class));
// then // then
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);

View File

@ -47,7 +47,7 @@ public class AccountsCommandTest {
public void shouldGetAccountsOfCurrentUser() { public void shouldGetAccountsOfCurrentUser() {
// given // given
given(sender.getName()).willReturn("Tester"); given(sender.getName()).willReturn("Tester");
List<String> arguments = Collections.EMPTY_LIST; List<String> arguments = Collections.emptyList();
given(dataSource.getAuth("tester")).willReturn(authWithIp("123.45.67.89")); given(dataSource.getAuth("tester")).willReturn(authWithIp("123.45.67.89"));
given(dataSource.getAllAuthsByIp("123.45.67.89")).willReturn(Arrays.asList("Toaster", "Pester")); given(dataSource.getAllAuthsByIp("123.45.67.89")).willReturn(Arrays.asList("Toaster", "Pester"));
@ -81,7 +81,7 @@ public class AccountsCommandTest {
// given // given
List<String> arguments = Collections.singletonList("SomeUser"); List<String> arguments = Collections.singletonList("SomeUser");
given(dataSource.getAuth("someuser")).willReturn(mock(PlayerAuth.class)); given(dataSource.getAuth("someuser")).willReturn(mock(PlayerAuth.class));
given(dataSource.getAllAuthsByIp(anyString())).willReturn(Collections.EMPTY_LIST); given(dataSource.getAllAuthsByIp(anyString())).willReturn(Collections.<String> emptyList());
// when // when
command.executeCommand(sender, arguments, service); command.executeCommand(sender, arguments, service);
@ -115,7 +115,7 @@ public class AccountsCommandTest {
public void shouldReturnIpUnknown() { public void shouldReturnIpUnknown() {
// given // given
List<String> arguments = Collections.singletonList("123.45.67.89"); List<String> 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.<String> emptyList());
// when // when
command.executeCommand(sender, arguments, service); command.executeCommand(sender, arguments, service);

View File

@ -27,7 +27,7 @@ public class AuthMeCommandTest {
CommandService service = mock(CommandService.class); CommandService service = mock(CommandService.class);
// when // when
command.executeCommand(sender, Collections.EMPTY_LIST, service); command.executeCommand(sender, Collections.<String> emptyList(), service);
// then // then
ArgumentCaptor<String> messagesCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> messagesCaptor = ArgumentCaptor.forClass(String.class);

View File

@ -36,7 +36,7 @@ public class FirstSpawnCommandTest {
ExecutableCommand command = new FirstSpawnCommand(); ExecutableCommand command = new FirstSpawnCommand();
// when // when
command.executeCommand(player, Collections.EMPTY_LIST, service); command.executeCommand(player, Collections.<String> emptyList(), service);
// then // then
verify(player).teleport(firstSpawn); verify(player).teleport(firstSpawn);
@ -54,7 +54,7 @@ public class FirstSpawnCommandTest {
ExecutableCommand command = new FirstSpawnCommand(); ExecutableCommand command = new FirstSpawnCommand();
// when // when
command.executeCommand(player, Collections.EMPTY_LIST, service); command.executeCommand(player, Collections.<String> emptyList(), service);
// then // then
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);

View File

@ -103,7 +103,7 @@ public class LastLoginCommandTest {
ExecutableCommand command = new LastLoginCommand(); ExecutableCommand command = new LastLoginCommand();
// when // when
command.executeCommand(sender, Collections.EMPTY_LIST, service); command.executeCommand(sender, Collections.<String> emptyList(), service);
// then // then
verify(dataSource).getAuth(name); verify(dataSource).getAuth(name);

View File

@ -61,7 +61,7 @@ public class PurgeLastPositionCommandTest {
ExecutableCommand command = new PurgeLastPositionCommand(); ExecutableCommand command = new PurgeLastPositionCommand();
// when // when
command.executeCommand(sender, Collections.EMPTY_LIST, service); command.executeCommand(sender, Collections.<String> emptyList(), service);
// then // then
verify(dataSource).getAuth(player); verify(dataSource).getAuth(player);

View File

@ -37,7 +37,7 @@ public class ReloadCommandTest {
ExecutableCommand command = new ReloadCommand(); ExecutableCommand command = new ReloadCommand();
// when // when
command.executeCommand(sender, Collections.EMPTY_LIST, service); command.executeCommand(sender, Collections.<String> emptyList(), service);
// then // then
verify(authMe).reload(); verify(authMe).reload();
@ -55,7 +55,7 @@ public class ReloadCommandTest {
ExecutableCommand command = new ReloadCommand(); ExecutableCommand command = new ReloadCommand();
// when // when
command.executeCommand(sender, Collections.EMPTY_LIST, service); command.executeCommand(sender, Collections.<String> emptyList(), service);
// then // then
verify(authMe).reload(); verify(authMe).reload();

View File

@ -35,7 +35,7 @@ public class SetFirstSpawnCommandTest {
ExecutableCommand command = new SetFirstSpawnCommand(); ExecutableCommand command = new SetFirstSpawnCommand();
// when // when
command.executeCommand(player, Collections.EMPTY_LIST, service); command.executeCommand(player, Collections.<String> emptyList(), service);
// then // then
verify(spawnLoader).setFirstSpawn(location); verify(spawnLoader).setFirstSpawn(location);
@ -57,7 +57,7 @@ public class SetFirstSpawnCommandTest {
ExecutableCommand command = new SetFirstSpawnCommand(); ExecutableCommand command = new SetFirstSpawnCommand();
// when // when
command.executeCommand(player, Collections.EMPTY_LIST, service); command.executeCommand(player, Collections.<String> emptyList(), service);
// then // then
verify(spawnLoader).setFirstSpawn(location); verify(spawnLoader).setFirstSpawn(location);

View File

@ -35,7 +35,7 @@ public class SetSpawnCommandTest {
ExecutableCommand command = new SetSpawnCommand(); ExecutableCommand command = new SetSpawnCommand();
// when // when
command.executeCommand(player, Collections.EMPTY_LIST, service); command.executeCommand(player, Collections.<String> emptyList(), service);
// then // then
verify(spawnLoader).setSpawn(location); verify(spawnLoader).setSpawn(location);
@ -57,7 +57,7 @@ public class SetSpawnCommandTest {
ExecutableCommand command = new SetSpawnCommand(); ExecutableCommand command = new SetSpawnCommand();
// when // when
command.executeCommand(player, Collections.EMPTY_LIST, service); command.executeCommand(player, Collections.<String> emptyList(), service);
// then // then
verify(spawnLoader).setSpawn(location); verify(spawnLoader).setSpawn(location);

View File

@ -35,7 +35,7 @@ public class SpawnCommandTest {
ExecutableCommand command = new SpawnCommand(); ExecutableCommand command = new SpawnCommand();
// when // when
command.executeCommand(player, Collections.EMPTY_LIST, service); command.executeCommand(player, Collections.<String> emptyList(), service);
// then // then
verify(player).teleport(spawn); verify(player).teleport(spawn);
@ -53,7 +53,7 @@ public class SpawnCommandTest {
ExecutableCommand command = new SpawnCommand(); ExecutableCommand command = new SpawnCommand();
// when // when
command.executeCommand(player, Collections.EMPTY_LIST, service); command.executeCommand(player, Collections.<String> emptyList(), service);
// then // then
verify(player).sendMessage(argThat(containsString("Spawn has failed"))); verify(player).sendMessage(argThat(containsString("Spawn has failed")));

View File

@ -44,7 +44,7 @@ public class ChangePasswordCommandTest {
when(commandService.getProperty(SecuritySettings.MAX_PASSWORD_LENGTH)).thenReturn(50); when(commandService.getProperty(SecuritySettings.MAX_PASSWORD_LENGTH)).thenReturn(50);
// Only allow passwords with alphanumerical characters for the test // Only allow passwords with alphanumerical characters for the test
when(commandService.getProperty(RestrictionSettings.ALLOWED_PASSWORD_REGEX)).thenReturn("[a-zA-Z0-9]+"); 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.<String> emptyList());
} }
@Test @Test

View File

@ -253,7 +253,7 @@ public class HelpProviderTest {
public void shouldHandleUnboundFoundCommandResult() { public void shouldHandleUnboundFoundCommandResult() {
// given // given
FoundCommandResult result = new FoundCommandResult(null, Arrays.asList("authme", "test"), FoundCommandResult result = new FoundCommandResult(null, Arrays.asList("authme", "test"),
Collections.EMPTY_LIST, 0.0, FoundResultStatus.UNKNOWN_LABEL); Collections.<String> emptyList(), 0.0, FoundResultStatus.UNKNOWN_LABEL);
// when // when
List<String> lines = helpProvider.printHelp(sender, result, ALL_OPTIONS); List<String> lines = helpProvider.printHelp(sender, result, ALL_OPTIONS);
@ -317,7 +317,7 @@ public class HelpProviderTest {
* @return The generated FoundCommandResult object * @return The generated FoundCommandResult object
*/ */
private static FoundCommandResult newFoundResult(CommandDescription command, List<String> labels) { private static FoundCommandResult newFoundResult(CommandDescription command, List<String> labels) {
return new FoundCommandResult(command, labels, Collections.EMPTY_LIST, 0.0, FoundResultStatus.SUCCESS); return new FoundCommandResult(command, labels, Collections.<String> emptyList(), 0.0, FoundResultStatus.SUCCESS);
} }
private static String removeColors(String str) { private static String removeColors(String str) {

View File

@ -97,6 +97,7 @@ public abstract class AbstractResourceClosingTest {
} }
/** Initialize the settings mock and makes it return the default of any given property by default. */ /** Initialize the settings mock and makes it return the default of any given property by default. */
@SuppressWarnings({ "unchecked", "rawtypes" })
@BeforeClass @BeforeClass
public static void initializeSettings() throws IOException, ClassNotFoundException { public static void initializeSettings() throws IOException, ClassNotFoundException {
settings = mock(NewSetting.class); settings = mock(NewSetting.class);

View File

@ -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}. * Set up the settings mock to return specific values for database settings and load {@link #sqlInitialize}.
*/ */
@SuppressWarnings({ "unchecked", "rawtypes" })
@BeforeClass @BeforeClass
public static void initializeSettings() throws IOException, ClassNotFoundException { public static void initializeSettings() throws IOException, ClassNotFoundException {
// Check that we have an H2 driver // Check that we have an H2 driver

View File

@ -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}. * Set up the settings mock to return specific values for database settings and load {@link #sqlInitialize}.
*/ */
@SuppressWarnings({ "unchecked", "rawtypes" })
@BeforeClass @BeforeClass
public static void initializeSettings() throws IOException, ClassNotFoundException { public static void initializeSettings() throws IOException, ClassNotFoundException {
// Check that we have an implementation for SQLite // Check that we have an implementation for SQLite

View File

@ -112,6 +112,7 @@ public class SettingsClassConsistencyTest {
return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers); return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers);
} }
@SuppressWarnings("unchecked")
private static Class<? extends SettingsClass> getSettingsClassFromFile(File file) { private static Class<? extends SettingsClass> getSettingsClassFromFile(File file) {
String fileName = file.getPath(); String fileName = file.getPath();
String className = fileName String className = fileName

View File

@ -110,8 +110,8 @@ public class UtilsTest {
public void shouldAcceptEmailWithEmptyLists() { public void shouldAcceptEmailWithEmptyLists() {
// given // given
NewSetting settings = mock(NewSetting.class); NewSetting settings = mock(NewSetting.class);
given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.EMPTY_LIST); given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.<String> emptyList());
given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)).willReturn(Collections.EMPTY_LIST); given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)).willReturn(Collections.<String> emptyList());
// when // when
boolean result = Utils.isEmailCorrect("test@example.org", settings); boolean result = Utils.isEmailCorrect("test@example.org", settings);
@ -126,7 +126,7 @@ public class UtilsTest {
NewSetting settings = mock(NewSetting.class); NewSetting settings = mock(NewSetting.class);
given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)) given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST))
.willReturn(Arrays.asList("domain.tld", "example.com")); .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.<String> emptyList());
// when // when
boolean result = Utils.isEmailCorrect("TesT@Example.com", settings); boolean result = Utils.isEmailCorrect("TesT@Example.com", settings);
@ -141,7 +141,7 @@ public class UtilsTest {
NewSetting settings = mock(NewSetting.class); NewSetting settings = mock(NewSetting.class);
given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)) given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST))
.willReturn(Arrays.asList("domain.tld", "example.com")); .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.<String> emptyList());
// when // when
boolean result = Utils.isEmailCorrect("email@other-domain.abc", settings); boolean result = Utils.isEmailCorrect("email@other-domain.abc", settings);
@ -154,7 +154,7 @@ public class UtilsTest {
public void shouldAcceptEmailNotInBlacklist() { public void shouldAcceptEmailNotInBlacklist() {
// given // given
NewSetting settings = mock(NewSetting.class); NewSetting settings = mock(NewSetting.class);
given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.EMPTY_LIST); given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.<String> emptyList());
given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)) given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST))
.willReturn(Arrays.asList("Example.org", "a-test-name.tld")); .willReturn(Arrays.asList("Example.org", "a-test-name.tld"));
@ -169,7 +169,7 @@ public class UtilsTest {
public void shouldRejectEmailInBlacklist() { public void shouldRejectEmailInBlacklist() {
// given // given
NewSetting settings = mock(NewSetting.class); NewSetting settings = mock(NewSetting.class);
given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.EMPTY_LIST); given(settings.getProperty(EmailSettings.DOMAIN_WHITELIST)).willReturn(Collections.<String> emptyList());
given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST)) given(settings.getProperty(EmailSettings.DOMAIN_BLACKLIST))
.willReturn(Arrays.asList("Example.org", "a-test-name.tld")); .willReturn(Arrays.asList("Example.org", "a-test-name.tld"));