From f83f20070b6c2bfabef3af0ffd64c9fd64b45026 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2019 17:48:50 +0200 Subject: [PATCH 01/14] Bump jacoco-maven-plugin from 0.8.4 to 0.8.5 (#1925) Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.4 to 0.8.5. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.4...v0.8.5) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d50442eae..7282c09e9 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ org.jacoco jacoco-maven-plugin - 0.8.4 + 0.8.5 pre-unit-test From 004cccf3c21db611e40175a7f5df8e64d90c350a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2019 17:49:08 +0200 Subject: [PATCH 02/14] Bump h2 from 1.4.199 to 1.4.200 (#1926) Bumps [h2](https://github.com/h2database/h2database) from 1.4.199 to 1.4.200. - [Release notes](https://github.com/h2database/h2database/releases) - [Commits](https://github.com/h2database/h2database/compare/version-1.4.199...version-1.4.200) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7282c09e9..db1047744 100644 --- a/pom.xml +++ b/pom.xml @@ -927,7 +927,7 @@ com.h2database h2 - 1.4.199 + 1.4.200 test From d6711d83b39a4aaa09dcad34907cb790ddc3a024 Mon Sep 17 00:00:00 2001 From: Arvind Kumar Date: Thu, 17 Oct 2019 06:34:27 +0000 Subject: [PATCH 03/14] Fixes in documentation (#1927) * Fixed typos and grammer in documentation --- docs/config.md | 18 ++++---- samples/NewConfig.yml | 46 +++++++++---------- .../properties/RegistrationSettings.java | 2 +- src/test/java/tools/docs/config/config.tpl.md | 6 +-- .../resources/fr/xephi/authme/config.test.yml | 6 +-- 5 files changed, 38 insertions(+), 40 deletions(-) diff --git a/docs/config.md b/docs/config.md index 811481d5e..e032daa82 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,9 +1,9 @@ - + ## AuthMe Configuration -The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, -with which you can configure various settings. This following is the initial contents of +The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, +with which you can configure various settings. The following is the initial contents of the generated config.yml file. ```yml @@ -70,6 +70,8 @@ DataSource: mySQLlastlocYaw: yaw # Column for storing player LastLocation - Pitch mySQLlastlocPitch: pitch + # Column for storing players uuids (optional) + mySQLPlayerUUID: '' # Overrides the size of the DB Connection Pool, default = 10 poolSize: 10 # The maximum lifetime of a connection in the pool, default = 1800 seconds @@ -124,10 +126,6 @@ settings: # By default we schedule async tasks when talking to the database. If you want # typical communication with the database to happen synchronously, set this to false useAsyncTasks: true - # By default we handle the AsyncPlayerPreLoginEvent which makes the plugin faster - # but it is incompatible with any permission plugin not included in our compatibility list. - # If you have issues with permission checks on player join please disable this option. - useAsyncPreLoginEvent: true # The name of the server, used in some placeholders. serverName: Your Minecraft Server restrictions: @@ -327,7 +325,7 @@ settings: removeJoinMessage: false # Should we remove leave messages altogether? removeLeaveMessage: false - # Do we need to add potion effect Blinding before login/reigster? + # Do we need to add potion effect Blinding before login/register? applyBlindEffect: false # Do we need to prevent people to login with another case? # If Xephi is registered, then Xephi can login, but not XEPHI/xephi/XePhI @@ -573,9 +571,9 @@ Converter: ``` -To change settings on a running server, save your changes to config.yml and use +To change settings on a running server, save your changes to config.yml and use `/authme reload`. --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Tue Apr 23 17:17:02 CEST 2019 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Thu Oct 17 08:29:25 CEST 2019 diff --git a/samples/NewConfig.yml b/samples/NewConfig.yml index 91e063d08..c0b392c4b 100644 --- a/samples/NewConfig.yml +++ b/samples/NewConfig.yml @@ -121,7 +121,7 @@ settings: # If the server change fails the player will be kicked. target: LoginLobby1 failKickMessage: 'Failed to connect to the lobby! Please try to join the server again!' - + # Variables: # %p playername bungee_commands: @@ -174,7 +174,7 @@ settings: # Registration settings. # =========================== - registration: + registration: # After how many time unregistered players should be kicked? # Set to 0 to disable. (default: 30) timeout: 30 @@ -205,12 +205,12 @@ settings: # Login settings. # =========================== - login: + login: # After how many time unlogged players should be kicked? # Set to 0 to disable. (default: 30) timeout: 30 - + # =========================== # Encryption parameters. @@ -235,7 +235,7 @@ settings: unlogged_restrictions: # Deny chat messages send for unlogged users. deny_chat: true - # Hide chat to unlogged users. + # Hide chat to unlogged users. # Only player messages, plugins will be able to send messages to the player anyway. hide_chat: false @@ -257,16 +257,16 @@ settings: # Should unlogged players have speed = 0? # After the login the walking/flying speeed will be reset to the default value. removeSpeed: true - + # End is there atm xD - + # This option will save the quit location of the players. SaveQuitLocation: false # Should not logged in players be teleported to the spawn? # After the authentication, if SaveQuitLocation is enabled, # they will be teleported back to their normal position. teleportUnAuthedToSpawn: false - + # If enabled, after the login, if the ForceSpawnOnTheseWorlds setting contains # the player's world, he will be teleported to the world spawnpoint. # The quit location of the player will be overwritten. @@ -306,22 +306,22 @@ settings: # =========================== # Address restrictions # =========================== - + # Max number of registrations per IP (default: 1) maxRegPerIp: 1 # Maximum allowed number of Logins per IP, 0 to disable (default: 0) maxLoginPerIp: 0 # Maximum allowed number of Joins per IP, 0 to disable (default: 0) maxJoinPerIp: 0 - + # When this setting is enabled, online players can't be kicked out # due to "Logged in from another Location" - # This setting will prevent potetial security exploits. + # This setting will prevent potential security exploits. ForceSingleSession: true - + # To activate the restricted user feature you need # to enable this option and configure the - # AllowedRestrctedUser field. + # AllowedRestrictedUser field. AllowRestrictedUser: false # The restricted user feature will kick players listed below # if they dont match of the defined ip address. @@ -332,35 +332,35 @@ settings: - playername;127.0.0. # Ban ip when the ip is not the ip registered in database banUnsafedIP: false - - + + # =============================== # Other restrictions # =============================== - + # Should we protect the player inventory before logging in? # Warning: Requires the latest version of ProtocolLib! ProtectInventoryBeforeLogIn: true - + # Should unregistered players be kicked immediately? kickNonRegistered: false # Should players be kicked on wrong password? kickOnWrongPassword: false - + # Should we display all other accounts of a player when he joins? # Required permission: authme.admin.accounts displayOtherAccounts: true - + # =============================== # Restrictions compatibility # =============================== - + # Spawn Priority. Avariable values : authme, essentials, multiverse, default spawnPriority: authme,essentials,multiverse,default # AuthMe will NEVER teleport players! noTeleport: false - + GameMode: # Do you want to set player's gamemode to survival when he joins? # This enables also the settings below. @@ -369,9 +369,9 @@ settings: ResetInventoryIfCreative: false # Do you want to force the survival mode ONLY after the /login process? ForceOnlyAfterLogin: false - + # sgdc3: Ok, our configuration is shit.... xD Today I will stop there - + registration: # enable registration on the server? diff --git a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java index 324f0f1f9..daefe92cf 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java @@ -97,7 +97,7 @@ public final class RegistrationSettings implements SettingsHolder { public static final Property REMOVE_LEAVE_MESSAGE = newProperty("settings.removeLeaveMessage", false); - @Comment("Do we need to add potion effect Blinding before login/reigster?") + @Comment("Do we need to add potion effect Blinding before login/register?") public static final Property APPLY_BLIND_EFFECT = newProperty("settings.applyBlindEffect", false); diff --git a/src/test/java/tools/docs/config/config.tpl.md b/src/test/java/tools/docs/config/config.tpl.md index 25cf8c2c0..1de5c99df 100644 --- a/src/test/java/tools/docs/config/config.tpl.md +++ b/src/test/java/tools/docs/config/config.tpl.md @@ -2,15 +2,15 @@ ## AuthMe Configuration -The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, -with which you can configure various settings. This following is the initial contents of +The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, +with which you can configure various settings. The following is the initial contents of the generated config.yml file. ```yml {config} ``` -To change settings on a running server, save your changes to config.yml and use +To change settings on a running server, save your changes to config.yml and use `/authme reload`. {gen_footer} diff --git a/src/test/resources/fr/xephi/authme/config.test.yml b/src/test/resources/fr/xephi/authme/config.test.yml index 54548e628..f77d55ddc 100644 --- a/src/test/resources/fr/xephi/authme/config.test.yml +++ b/src/test/resources/fr/xephi/authme/config.test.yml @@ -42,7 +42,7 @@ settings: maxNicknameLength: 16 # When this setting is enabled, online players can't be kicked out # due to "Logged in from another Location" - # This setting will prevent potetial security exploits. + # This setting will prevent potential security exploits. ForceSingleSession: true ForceSpawnLocOnJoin: # If enabled, every player will be teleported to the world spawnpoint @@ -61,7 +61,7 @@ settings: SaveQuitLocation: false # To activate the restricted user feature you need # to enable this option and configure the - # AllowedRestrctedUser field. + # AllowedRestrictedUser field. AllowRestrictedUser: false # The restricted user feature will kick players listed below # if they don't match of the defined ip address. @@ -87,7 +87,7 @@ settings: # After how many time players who fail to login or register # should be kicked? Set to 0 to disable. timeout: 30 - # Regex sintax of allowed characters in the player name. + # Regex syntax of allowed characters in the player name. allowedNicknameCharacters: '[a-zA-Z0-9_]*' # How far can unregistered players walk? Set to 0 # for unlimited radius From 4e62b815953bba144ebad72fdb6b00f131909eba Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2019 17:52:50 +0200 Subject: [PATCH 04/14] Bump googleauth from 1.2.0 to 1.3.0 (#1928) Bumps [googleauth](https://github.com/wstrange/GoogleAuth) from 1.2.0 to 1.3.0. - [Release notes](https://github.com/wstrange/GoogleAuth/releases) - [Changelog](https://github.com/wstrange/GoogleAuth/blob/master/NEWS) - [Commits](https://github.com/wstrange/GoogleAuth/compare/1.2.0...1.3.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index db1047744..5585f8310 100644 --- a/pom.xml +++ b/pom.xml @@ -606,7 +606,7 @@ com.warrenstrange googleauth - 1.2.0 + 1.3.0 true From 17dee96166b33301759ffd8e6ec50552aa7e78d4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 24 Oct 2019 10:08:41 +0200 Subject: [PATCH 05/14] Bump googleauth from 1.3.0 to 1.4.0 (#1929) Bumps [googleauth](https://github.com/wstrange/GoogleAuth) from 1.3.0 to 1.4.0. - [Release notes](https://github.com/wstrange/GoogleAuth/releases) - [Changelog](https://github.com/wstrange/GoogleAuth/blob/master/NEWS) - [Commits](https://github.com/wstrange/GoogleAuth/compare/1.3.0...1.4.0) Signed-off-by: dependabot-preview[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5585f8310..e6a0175b5 100644 --- a/pom.xml +++ b/pom.xml @@ -606,7 +606,7 @@ com.warrenstrange googleauth - 1.3.0 + 1.4.0 true From 7f832d4b16243f74837c56d032348e55b1d8779f Mon Sep 17 00:00:00 2001 From: Maxime Michaud <14856114+MaximeMichaud@users.noreply.github.com> Date: Sat, 26 Oct 2019 09:39:53 -0400 Subject: [PATCH 06/14] Small mistakes (#1931) --- src/main/resources/messages/messages_fr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/messages/messages_fr.yml b/src/main/resources/messages/messages_fr.yml index f9817cc6e..cfcf67b22 100644 --- a/src/main/resources/messages/messages_fr.yml +++ b/src/main/resources/messages/messages_fr.yml @@ -82,7 +82,7 @@ on_join_validation: country_banned: 'Votre pays est banni de ce serveur.' not_owner_error: 'Vous n''êtes pas le propriétaire de ce compte. Veuillez utiliser un autre pseudo !' invalid_name_case: 'Veuillez vous connecter avec "%valid" et non pas avec "%invalid".' - quick_command: '&cUtilisation trop rapide de commande! Veuillez vous reconnecter et attendre un peu avant d''executer une commande.' + quick_command: '&cUtilisation trop rapide de commande! Veuillez vous reconnecter et attendre un peu avant d''exécuter une commande.' # Email email: @@ -122,7 +122,7 @@ captcha: usage_captcha: '&cTrop de tentatives de connexion ont échoué, faites: /captcha %captcha_code' wrong_captcha: '&cCaptcha incorrect, écrivez de nouveau: /captcha %captcha_code' valid_captcha: '&aCaptcha validé! Vous pouvez maintenant réessayer de vous connecter.' - captcha_for_registration: 'Avant de vous inscrire veuillez rentrer un captcha en faisant "/captcha %captcha_code"' + captcha_for_registration: 'Avant de vous inscrire, veuillez rentrer un captcha en faisant "/captcha %captcha_code"' register_captcha_valid: '&aCaptcha validé! Vous pouvez maintenant vous inscrire.' # Verification code From 0cf9ec475933b8e04fd198d9136be9aa6f07c628 Mon Sep 17 00:00:00 2001 From: Maxime Michaud <14856114+MaximeMichaud@users.noreply.github.com> Date: Sat, 26 Oct 2019 09:40:37 -0400 Subject: [PATCH 07/14] One mistake corrected in help_fr.yml (#1932) vour ---> vous --- src/main/resources/messages/help_fr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/messages/help_fr.yml b/src/main/resources/messages/help_fr.yml index 7d53ae799..dce54f167 100644 --- a/src/main/resources/messages/help_fr.yml +++ b/src/main/resources/messages/help_fr.yml @@ -30,7 +30,7 @@ section: # ------------------------------------------------------- # Vous pouvez traduire tous les textes d'aide en utilisant la syntaxe ci-dessous. # Par exemple, pour traduire l'aide du "/authme reload" créez une section nommée "authme.reload", ou "login" pour "/login". -# Si la commande a des arguments, vour pouvez utiliser "arg1" pour traduire le premier argument, "arg2" pour le 2ème, ainsi de suite. +# Si la commande a des arguments, vous pouvez utiliser "arg1" pour traduire le premier argument, "arg2" pour le 2ème, ainsi de suite. # Les sections non traduites auront leur texte par défaut (en anglais), il n'est donc pas obligatoire de tout traduire. # Important: Il faut mettre la commande principale (authme) avant sa sous-commande (ex. "authme.register" pour "/authme register") commands: From 776d1e5fa314d9da7d0a6b99d55d872fb27d17a5 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sat, 26 Oct 2019 21:52:43 +0200 Subject: [PATCH 08/14] Fix failing test - googleauth uses a new website to generate QR codes, cf. https://github.com/wstrange/GoogleAuth/issues/77 --- .../fr/xephi/authme/security/totp/TotpAuthenticatorTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java b/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java index 52f8b9906..22ab394b0 100644 --- a/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java +++ b/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java @@ -62,9 +62,9 @@ public class TotpAuthenticatorTest { // then assertThat(key1.getTotpKey(), stringWithLength(16)); assertThat(key2.getTotpKey(), stringWithLength(16)); - assertThat(key1.getAuthenticatorQrCodeUrl(), startsWith("https://chart.googleapis.com/chart?chs=200x200")); + assertThat(key1.getAuthenticatorQrCodeUrl(), startsWith("https://api.qrserver.com/v1/create-qr-code/?data=")); assertThat(key1.getAuthenticatorQrCodeUrl(), containsString("MCtopia")); - assertThat(key2.getAuthenticatorQrCodeUrl(), startsWith("https://chart.googleapis.com/chart?chs=200x200")); + assertThat(key2.getAuthenticatorQrCodeUrl(), startsWith("https://api.qrserver.com/v1/create-qr-code/?data=")); assertThat(key1.getTotpKey(), not(equalTo(key2.getTotpKey()))); } From 2673eb0f8e29171178ba233ed8fd20e5708c1d96 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sat, 26 Oct 2019 21:56:54 +0200 Subject: [PATCH 09/14] Mockito: Replace deprecated verifyZeroInteractions with verifyNoInteractions --- .../fr/xephi/authme/api/v3/AuthMeApiTest.java | 6 +-- .../command/executable/HelpCommandTest.java | 6 +-- .../ChangePasswordAdminCommandTest.java | 4 +- .../authme/ConverterCommandTest.java | 6 +-- .../authme/ForceLoginCommandTest.java | 8 ++-- .../executable/authme/PurgeCommandTest.java | 6 +-- .../authme/PurgePlayerCommandTest.java | 4 +- .../authme/SetEmailCommandTest.java | 6 +-- .../authme/UpdateHelpMessagesCommandTest.java | 4 +- .../executable/email/AddEmailCommandTest.java | 6 +-- .../email/ChangeEmailCommandTest.java | 6 +-- .../email/EmailSetPasswordCommandTest.java | 4 +- .../email/RecoverEmailCommandTest.java | 6 +-- .../executable/login/LoginCommandTest.java | 4 +- .../executable/logout/LogoutCommandTest.java | 4 +- .../register/RegisterCommandTest.java | 24 +++++------ .../executable/totp/AddTotpCommandTest.java | 6 +-- .../totp/ConfirmTotpCommandTest.java | 10 ++--- .../totp/RemoveTotpCommandTest.java | 8 ++-- .../unregister/UnregisterCommandTest.java | 8 ++-- .../xephi/authme/data/TempbanManagerTest.java | 4 +- .../data/VerificationCodeManagerTest.java | 6 +-- .../limbo/AllowFlightRestoreTypeTest.java | 6 +-- .../limbo/LimboPlayerTaskManagerTest.java | 6 +-- .../data/limbo/LimboServiceHelperTest.java | 4 +- .../authme/data/limbo/LimboServiceTest.java | 4 +- .../AbstractDataSourceConverterTest.java | 6 +-- .../converter/CrazyLoginConverterTest.java | 4 +- .../mysqlextensions/NoOpExtensionTest.java | 4 +- .../authme/listener/EntityListenerTest.java | 8 ++-- .../authme/listener/EventCancelVerifier.java | 4 +- .../authme/listener/ListenerServiceTest.java | 12 +++--- .../authme/listener/OnJoinVerifierTest.java | 28 ++++++------- .../authme/listener/PlayerListenerTest.java | 40 +++++++++---------- .../authme/listener/ServerListenerTest.java | 8 ++-- .../process/login/AsynchronousLoginTest.java | 8 ++-- .../process/register/AsyncRegisterTest.java | 8 ++-- .../executors/EmailRegisterExecutorTest.java | 4 +- .../PasswordRegisterExecutorTest.java | 4 +- .../AsynchronousUnregisterTest.java | 14 +++---- .../security/totp/TotpAuthenticatorTest.java | 4 +- .../authme/service/AntiBotServiceTest.java | 4 +- .../authme/service/BukkitServiceTest.java | 6 +-- .../authme/service/SessionServiceTest.java | 4 +- .../service/TeleportationServiceTest.java | 18 ++++----- .../authme/service/ValidationServiceTest.java | 4 +- .../authme/settings/SettingsWarnerTest.java | 4 +- .../WelcomeMessageConfigurationTest.java | 6 +-- .../commandconfig/CommandManagerTest.java | 26 ++++++------ .../authme/task/purge/PurgeServiceTest.java | 10 ++--- .../java/fr/xephi/authme/util/UtilsTest.java | 7 ++-- 51 files changed, 205 insertions(+), 206 deletions(-) diff --git a/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java b/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java index 6021b3a92..daccc537a 100644 --- a/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java +++ b/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java @@ -24,11 +24,11 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import java.time.Instant; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.stream.Collectors; -import java.time.Instant; import static fr.xephi.authme.IsEqualByReflectionMatcher.hasEqualValuesOnAllFields; import static org.hamcrest.Matchers.contains; @@ -43,7 +43,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -478,7 +478,7 @@ public class AuthMeApiTest { // then assertThat(result, equalTo(false)); verify(dataSource, only()).isAuthAvailable(name); - verifyZeroInteractions(management, passwordSecurity); + verifyNoInteractions(management, passwordSecurity); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/HelpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/HelpCommandTest.java index bb5694e94..33e0508e6 100644 --- a/src/test/java/fr/xephi/authme/command/executable/HelpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/HelpCommandTest.java @@ -33,7 +33,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -64,7 +64,7 @@ public class HelpCommandTest { // then verify(sender).sendMessage(argThat(containsString("Could not get base command"))); - verifyZeroInteractions(helpProvider); + verifyNoInteractions(helpProvider); } @Test @@ -102,7 +102,7 @@ public class HelpCommandTest { ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); verify(sender).sendMessage(captor.capture()); assertThat(removeColors(captor.getValue()), containsString("Unknown command")); - verifyZeroInteractions(helpProvider); + verifyNoInteractions(helpProvider); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommandTest.java index b10b9c45f..8e1a60815 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ChangePasswordAdminCommandTest.java @@ -17,7 +17,7 @@ import java.util.Arrays; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link ChangePasswordAdminCommand}. @@ -68,6 +68,6 @@ public class ChangePasswordAdminCommandTest { // then verify(validationService).validatePassword(pass, name); verify(commonService).send(sender, MessageKey.INVALID_PASSWORD_LENGTH, "7"); - verifyZeroInteractions(management); + verifyNoInteractions(management); } } diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java index 626e9c90d..43c1c9067 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java @@ -29,8 +29,8 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -67,7 +67,7 @@ public class ConverterCommandTest { // then String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet()); verify(sender).sendMessage(argThat(containsString(converters))); - verifyZeroInteractions(commonService, converterFactory, bukkitService); + verifyNoInteractions(commonService, converterFactory, bukkitService); } @Test @@ -81,7 +81,7 @@ public class ConverterCommandTest { // then String converters = String.join(", ", ConverterCommand.CONVERTERS.keySet()); verify(sender).sendMessage(argThat(containsString(converters))); - verifyZeroInteractions(commonService, converterFactory, bukkitService); + verifyNoInteractions(commonService, converterFactory, bukkitService); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ForceLoginCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ForceLoginCommandTest.java index 46671d8af..b07b84596 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ForceLoginCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ForceLoginCommandTest.java @@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.containsString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -53,7 +53,7 @@ public class ForceLoginCommandTest { // then verify(bukkitService).getPlayerExact(playerName); verify(sender).sendMessage("Player needs to be online!"); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -69,7 +69,7 @@ public class ForceLoginCommandTest { // then verify(bukkitService).getPlayerExact(playerName); verify(sender).sendMessage("Player needs to be online!"); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -87,7 +87,7 @@ public class ForceLoginCommandTest { // then verify(bukkitService).getPlayerExact(playerName); verify(sender).sendMessage(argThat(containsString("You cannot force login the player"))); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeCommandTest.java index 2400cb1c4..70e4f03a1 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeCommandTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -45,7 +45,7 @@ public class PurgeCommandTest { // then verify(sender).sendMessage(argThat(containsString("The value you've entered is invalid"))); - verifyZeroInteractions(purgeService); + verifyNoInteractions(purgeService); } @Test @@ -59,7 +59,7 @@ public class PurgeCommandTest { // then verify(sender).sendMessage(argThat(containsString("You can only purge data older than 30 days"))); - verifyZeroInteractions(purgeService); + verifyNoInteractions(purgeService); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommandTest.java index 7eee787a3..370ba1294 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommandTest.java @@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.containsString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -52,7 +52,7 @@ public class PurgePlayerCommandTest { // then verify(sender).sendMessage(argThat(containsString("This player is still registered"))); - verifyZeroInteractions(purgeExecutor); + verifyNoInteractions(purgeExecutor); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/SetEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/SetEmailCommandTest.java index 9e8ed7703..3b96070d6 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/SetEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/SetEmailCommandTest.java @@ -22,8 +22,8 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * Test for {@link SetEmailCommand}. @@ -63,7 +63,7 @@ public class SetEmailCommandTest { // then verify(validationService).validateEmail(email); verify(commandService).send(sender, MessageKey.INVALID_EMAIL); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -107,7 +107,7 @@ public class SetEmailCommandTest { verify(validationService).isEmailFreeForRegistration(email, sender); verify(commandService).send(sender, MessageKey.EMAIL_ALREADY_USED_ERROR); verifyNoMoreInteractions(dataSource); - verifyZeroInteractions(auth); + verifyNoInteractions(auth); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/UpdateHelpMessagesCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/UpdateHelpMessagesCommandTest.java index 94e53ff27..64113da4a 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/UpdateHelpMessagesCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/UpdateHelpMessagesCommandTest.java @@ -18,7 +18,7 @@ import java.util.Collections; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link UpdateHelpMessagesCommand}. @@ -65,6 +65,6 @@ public class UpdateHelpMessagesCommandTest { // then verify(sender).sendMessage("Could not update help file: Couldn't do the thing"); - verifyZeroInteractions(helpMessagesService); + verifyNoInteractions(helpMessagesService); } } diff --git a/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java index 9a039b50e..c8a57562f 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java @@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link AddEmailCommand}. @@ -45,7 +45,7 @@ public class AddEmailCommandTest { command.executeCommand(sender, Collections.emptyList()); // then - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -71,7 +71,7 @@ public class AddEmailCommandTest { command.executeCommand(sender, Arrays.asList(email, "wrongConf")); // then - verifyZeroInteractions(management); + verifyNoInteractions(management); verify(commandService).send(sender, MessageKey.CONFIRM_EMAIL_MESSAGE); } diff --git a/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java index c990c81ef..3c99e17dc 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; /** @@ -52,7 +52,7 @@ public class ChangeEmailCommandTest { command.executeCommand(sender, Collections.emptyList()); // then - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -68,7 +68,7 @@ public class ChangeEmailCommandTest { // then verify(codeManager).codeExistOrGenerateNew(name); verify(commonService).send(player, MessageKey.VERIFICATION_CODE_REQUIRED); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/email/EmailSetPasswordCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/EmailSetPasswordCommandTest.java index bf7fba782..a0338492e 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/EmailSetPasswordCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/EmailSetPasswordCommandTest.java @@ -21,7 +21,7 @@ import java.util.Collections; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Tests for {@link EmailSetPasswordCommand}. @@ -102,7 +102,7 @@ public class EmailSetPasswordCommandTest { command.runCommand(player, Collections.singletonList("abc123")); // then - verifyZeroInteractions(validationService, dataSource); + verifyNoInteractions(validationService, dataSource); verify(commonService).send(player, MessageKey.CHANGE_PASSWORD_EXPIRED); } } diff --git a/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java index 5842ec300..4e629d6da 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java @@ -30,8 +30,8 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * Test for {@link RecoverEmailCommand}. @@ -89,7 +89,7 @@ public class RecoverEmailCommandTest { // then verify(commonService).send(sender, MessageKey.INCOMPLETE_EMAIL_SETTINGS); - verifyZeroInteractions(dataSource, passwordSecurity); + verifyNoInteractions(dataSource, passwordSecurity); } @Test @@ -106,7 +106,7 @@ public class RecoverEmailCommandTest { // then verify(emailService).hasAllInformation(); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); verify(commonService).send(sender, MessageKey.ALREADY_LOGGED_IN_ERROR); } diff --git a/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java index b5ce86a53..7f6c66759 100644 --- a/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java @@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -43,7 +43,7 @@ public class LoginCommandTest { command.executeCommand(sender, Collections.emptyList()); // then - verifyZeroInteractions(management); + verifyNoInteractions(management); verify(sender).sendMessage(argThat(containsString("/authme forcelogin "))); } diff --git a/src/test/java/fr/xephi/authme/command/executable/logout/LogoutCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/logout/LogoutCommandTest.java index c5c66a161..ba80d6ebb 100644 --- a/src/test/java/fr/xephi/authme/command/executable/logout/LogoutCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/logout/LogoutCommandTest.java @@ -16,7 +16,7 @@ import java.util.Collections; import static org.hamcrest.Matchers.containsString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -41,7 +41,7 @@ public class LogoutCommandTest { command.executeCommand(sender, new ArrayList()); // then - verifyZeroInteractions(management); + verifyNoInteractions(management); verify(sender).sendMessage(argThat(containsString("only for players"))); } diff --git a/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java index 48b13c931..cd695b65a 100644 --- a/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java @@ -37,7 +37,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -86,7 +86,7 @@ public class RegisterCommandTest { // then verify(sender).sendMessage(argThat(containsString("Player only!"))); - verifyZeroInteractions(management, emailService); + verifyNoInteractions(management, emailService); } @Test @@ -102,7 +102,7 @@ public class RegisterCommandTest { verify(registrationCaptchaManager).isCaptchaRequired("test2"); verify(management).performRegister(eq(RegistrationMethod.TWO_FACTOR_REGISTRATION), argThat(hasEqualValuesOnAllFields(TwoFactorRegisterParams.of(player)))); - verifyZeroInteractions(emailService); + verifyNoInteractions(emailService); } @Test @@ -115,7 +115,7 @@ public class RegisterCommandTest { // then verify(commonService).send(player, MessageKey.USAGE_REGISTER); - verifyZeroInteractions(management, emailService); + verifyNoInteractions(management, emailService); } @Test @@ -130,7 +130,7 @@ public class RegisterCommandTest { // then verify(commonService).send(player, MessageKey.USAGE_REGISTER); - verifyZeroInteractions(management, emailService); + verifyNoInteractions(management, emailService); } @Test @@ -147,7 +147,7 @@ public class RegisterCommandTest { // then verify(commonService).send(player, MessageKey.USAGE_REGISTER); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -163,7 +163,7 @@ public class RegisterCommandTest { // then verify(commonService).send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS); verify(emailService).hasAllInformation(); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -181,7 +181,7 @@ public class RegisterCommandTest { // then verify(validationService).validateEmail(playerMail); verify(commonService).send(player, MessageKey.INVALID_EMAIL); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -200,7 +200,7 @@ public class RegisterCommandTest { // then verify(commonService).send(player, MessageKey.USAGE_REGISTER); verify(emailService).hasAllInformation(); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -236,7 +236,7 @@ public class RegisterCommandTest { // then verify(commonService).send(player, MessageKey.PASSWORD_MATCH_ERROR); - verifyZeroInteractions(management, emailService); + verifyNoInteractions(management, emailService); } @Test @@ -287,7 +287,7 @@ public class RegisterCommandTest { verify(registrationCaptchaManager).isCaptchaRequired("Waaa"); verify(validationService).validateEmail(email); verify(commonService).send(player, MessageKey.INVALID_EMAIL); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -321,7 +321,7 @@ public class RegisterCommandTest { // then verify(registrationCaptchaManager).isCaptchaRequired(name); verify(commonService).send(player, MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, captcha); - verifyZeroInteractions(management, validationService); + verifyNoInteractions(management, validationService); } private static Player mockPlayerWithName(String name) { diff --git a/src/test/java/fr/xephi/authme/command/executable/totp/AddTotpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/totp/AddTotpCommandTest.java index ff8608b37..598200c58 100644 --- a/src/test/java/fr/xephi/authme/command/executable/totp/AddTotpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/totp/AddTotpCommandTest.java @@ -18,7 +18,7 @@ import java.util.Collections; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link AddTotpCommand}. @@ -47,7 +47,7 @@ public class AddTotpCommandTest { // then verify(messages).send(player, MessageKey.NOT_LOGGED_IN); - verifyZeroInteractions(generateTotpService); + verifyNoInteractions(generateTotpService); } @Test @@ -63,7 +63,7 @@ public class AddTotpCommandTest { // then verify(messages).send(player, MessageKey.TWO_FACTOR_ALREADY_ENABLED); - verifyZeroInteractions(generateTotpService); + verifyNoInteractions(generateTotpService); } @Test diff --git a/src/test/java/fr/xephi/authme/command/executable/totp/ConfirmTotpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/totp/ConfirmTotpCommandTest.java index 17a011ee8..4c3053647 100644 --- a/src/test/java/fr/xephi/authme/command/executable/totp/ConfirmTotpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/totp/ConfirmTotpCommandTest.java @@ -27,7 +27,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link ConfirmTotpCommand}. @@ -98,7 +98,7 @@ public class ConfirmTotpCommandTest { verify(generateTotpService, never()).removeGenerateTotpKey(any(Player.class)); verify(playerCache, only()).getAuth(playerName); verify(messages).send(player, MessageKey.TWO_FACTOR_ENABLE_ERROR_WRONG_CODE); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -118,7 +118,7 @@ public class ConfirmTotpCommandTest { verify(generateTotpService, only()).getGeneratedTotpKey(player); verify(playerCache, only()).getAuth(playerName); verify(messages).send(player, MessageKey.TWO_FACTOR_ENABLE_ERROR_NO_CODE); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -135,7 +135,7 @@ public class ConfirmTotpCommandTest { // then verify(playerCache, only()).getAuth(playerName); - verifyZeroInteractions(generateTotpService, dataSource); + verifyNoInteractions(generateTotpService, dataSource); verify(messages).send(player, MessageKey.TWO_FACTOR_ALREADY_ENABLED); } @@ -152,7 +152,7 @@ public class ConfirmTotpCommandTest { // then verify(playerCache, only()).getAuth(playerName); - verifyZeroInteractions(generateTotpService, dataSource); + verifyNoInteractions(generateTotpService, dataSource); verify(messages).send(player, MessageKey.NOT_LOGGED_IN); } } diff --git a/src/test/java/fr/xephi/authme/command/executable/totp/RemoveTotpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/totp/RemoveTotpCommandTest.java index 18903972d..26c7e8719 100644 --- a/src/test/java/fr/xephi/authme/command/executable/totp/RemoveTotpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/totp/RemoveTotpCommandTest.java @@ -22,7 +22,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link RemoveTotpCommand}. @@ -105,7 +105,7 @@ public class RemoveTotpCommandTest { command.runCommand(player, singletonList(inputCode)); // then - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); verify(messages, only()).send(player, MessageKey.TWO_FACTOR_INVALID_CODE); verify(playerCache, only()).getAuth(name); } @@ -124,7 +124,7 @@ public class RemoveTotpCommandTest { command.runCommand(player, singletonList(inputCode)); // then - verifyZeroInteractions(dataSource, totpAuthenticator); + verifyNoInteractions(dataSource, totpAuthenticator); verify(messages, only()).send(player, MessageKey.TWO_FACTOR_NOT_ENABLED_ERROR); verify(playerCache, only()).getAuth(name); } @@ -142,7 +142,7 @@ public class RemoveTotpCommandTest { command.runCommand(player, singletonList(inputCode)); // then - verifyZeroInteractions(dataSource, totpAuthenticator); + verifyNoInteractions(dataSource, totpAuthenticator); verify(messages, only()).send(player, MessageKey.NOT_LOGGED_IN); verify(playerCache, only()).getAuth(name); } diff --git a/src/test/java/fr/xephi/authme/command/executable/unregister/UnregisterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/unregister/UnregisterCommandTest.java index 5ee573a2b..a0fc8d3d1 100644 --- a/src/test/java/fr/xephi/authme/command/executable/unregister/UnregisterCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/unregister/UnregisterCommandTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -60,7 +60,7 @@ public class UnregisterCommandTest { // then verify(playerCache).isAuthenticated(name); verify(commonService).send(player, MessageKey.NOT_LOGGED_IN); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -79,7 +79,7 @@ public class UnregisterCommandTest { verify(playerCache).isAuthenticated(name); verify(codeManager).codeExistOrGenerateNew(name); verify(commonService).send(player, MessageKey.VERIFICATION_CODE_REQUIRED); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -110,7 +110,7 @@ public class UnregisterCommandTest { command.executeCommand(sender, Collections.singletonList("password")); // then - verifyZeroInteractions(playerCache, management); + verifyNoInteractions(playerCache, management); verify(sender).sendMessage(argThat(containsString("/authme unregister "))); } diff --git a/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java b/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java index 154098e88..5c5264bdc 100644 --- a/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java @@ -29,7 +29,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link TempbanManager}. @@ -139,7 +139,7 @@ public class TempbanManagerTest { manager.tempbanPlayer(player); // then - verifyZeroInteractions(player, bukkitService); + verifyNoInteractions(player, bukkitService); } @Test diff --git a/src/test/java/fr/xephi/authme/data/VerificationCodeManagerTest.java b/src/test/java/fr/xephi/authme/data/VerificationCodeManagerTest.java index 732b1ad70..147b0dd05 100644 --- a/src/test/java/fr/xephi/authme/data/VerificationCodeManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/VerificationCodeManagerTest.java @@ -20,7 +20,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link VerificationCodeManager}. @@ -82,7 +82,7 @@ public class VerificationCodeManagerTest { // then assertThat(result, equalTo(false)); - verifyZeroInteractions(permissionsManager, dataSource); + verifyNoInteractions(permissionsManager, dataSource); } @Test @@ -98,7 +98,7 @@ public class VerificationCodeManagerTest { // then assertThat(result, equalTo(false)); verify(permissionsManager).hasPermission(player, PlayerPermission.VERIFICATION_CODE); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test diff --git a/src/test/java/fr/xephi/authme/data/limbo/AllowFlightRestoreTypeTest.java b/src/test/java/fr/xephi/authme/data/limbo/AllowFlightRestoreTypeTest.java index 1f56cdfda..eb7ee3893 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/AllowFlightRestoreTypeTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/AllowFlightRestoreTypeTest.java @@ -6,7 +6,7 @@ import org.junit.Test; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link AllowFlightRestoreType}. @@ -78,7 +78,7 @@ public class AllowFlightRestoreTypeTest { AllowFlightRestoreType.NOTHING.restoreAllowFlight(player2, limboWithoutFly); // then - verifyZeroInteractions(player1, player2); + verifyNoInteractions(player1, player2); } @Test @@ -94,7 +94,7 @@ public class AllowFlightRestoreTypeTest { // then if (type == noInteractionType) { - verifyZeroInteractions(player); + verifyNoInteractions(player); } else { verify(player).setAllowFlight(false); } diff --git a/src/test/java/fr/xephi/authme/data/limbo/LimboPlayerTaskManagerTest.java b/src/test/java/fr/xephi/authme/data/limbo/LimboPlayerTaskManagerTest.java index ff0743001..4151843c6 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/LimboPlayerTaskManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/LimboPlayerTaskManagerTest.java @@ -34,7 +34,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link LimboPlayerTaskManager}. @@ -97,7 +97,7 @@ public class LimboPlayerTaskManagerTest { limboPlayerTaskManager.registerMessageTask(player, limboPlayer, LimboMessageType.LOG_IN); // then - verifyZeroInteractions(limboPlayer, bukkitService); + verifyNoInteractions(limboPlayer, bukkitService); } @Test @@ -173,7 +173,7 @@ public class LimboPlayerTaskManagerTest { limboPlayerTaskManager.registerTimeoutTask(player, limboPlayer); // then - verifyZeroInteractions(limboPlayer, bukkitService); + verifyNoInteractions(limboPlayer, bukkitService); } @Test diff --git a/src/test/java/fr/xephi/authme/data/limbo/LimboServiceHelperTest.java b/src/test/java/fr/xephi/authme/data/limbo/LimboServiceHelperTest.java index da3bc00f8..a2aceee18 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/LimboServiceHelperTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/LimboServiceHelperTest.java @@ -15,7 +15,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link LimboServiceHelper}. @@ -83,7 +83,7 @@ public class LimboServiceHelperTest { LimboPlayer result3 = limboServiceHelper.merge(null, null); // then - verifyZeroInteractions(limbo); + verifyNoInteractions(limbo); assertThat(result1, equalTo(limbo)); assertThat(result2, equalTo(limbo)); assertThat(result3, nullValue()); diff --git a/src/test/java/fr/xephi/authme/data/limbo/LimboServiceTest.java b/src/test/java/fr/xephi/authme/data/limbo/LimboServiceTest.java index 8bcfaff79..eb7bdfe9e 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/LimboServiceTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/LimboServiceTest.java @@ -34,7 +34,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link LimboService}, and {@link LimboServiceHelper}. @@ -222,7 +222,7 @@ public class LimboServiceTest { limboService.replaceTasksAfterRegistration(player); // then - verifyZeroInteractions(taskManager); + verifyNoInteractions(taskManager); verify(authGroupHandler).setGroup(player, null, AuthGroupType.REGISTERED_UNAUTHENTICATED); } diff --git a/src/test/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverterTest.java b/src/test/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverterTest.java index f4c70280c..5dd032444 100644 --- a/src/test/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverterTest.java +++ b/src/test/java/fr/xephi/authme/datasource/converter/AbstractDataSourceConverterTest.java @@ -21,8 +21,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -51,7 +51,7 @@ public class AbstractDataSourceConverterTest { // then verify(sender).sendMessage(argThat(containsString("Please configure your connection to SQLITE"))); verify(destination, only()).getType(); - verifyZeroInteractions(source); + verifyNoInteractions(source); } @Test @@ -72,7 +72,7 @@ public class AbstractDataSourceConverterTest { // then verify(sender).sendMessage("The data source to convert from could not be initialized"); verify(destination, only()).getType(); - verifyZeroInteractions(source); + verifyNoInteractions(source); } @Test diff --git a/src/test/java/fr/xephi/authme/datasource/converter/CrazyLoginConverterTest.java b/src/test/java/fr/xephi/authme/datasource/converter/CrazyLoginConverterTest.java index 453ede994..8819772de 100644 --- a/src/test/java/fr/xephi/authme/datasource/converter/CrazyLoginConverterTest.java +++ b/src/test/java/fr/xephi/authme/datasource/converter/CrazyLoginConverterTest.java @@ -26,7 +26,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -81,7 +81,7 @@ public class CrazyLoginConverterTest { crazyLoginConverter.execute(sender); // then - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); verify(sender).sendMessage(argThat(containsString("file not found"))); } diff --git a/src/test/java/fr/xephi/authme/datasource/mysqlextensions/NoOpExtensionTest.java b/src/test/java/fr/xephi/authme/datasource/mysqlextensions/NoOpExtensionTest.java index 95a5dfa88..40f98247f 100644 --- a/src/test/java/fr/xephi/authme/datasource/mysqlextensions/NoOpExtensionTest.java +++ b/src/test/java/fr/xephi/authme/datasource/mysqlextensions/NoOpExtensionTest.java @@ -14,7 +14,7 @@ import java.sql.Connection; import java.sql.SQLException; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link NoOpExtension}. @@ -49,6 +49,6 @@ public class NoOpExtensionTest { extension.saveAuth(auth, connection); // then - verifyZeroInteractions(connection, auth); + verifyNoInteractions(connection, auth); } } diff --git a/src/test/java/fr/xephi/authme/listener/EntityListenerTest.java b/src/test/java/fr/xephi/authme/listener/EntityListenerTest.java index 067ff889f..ce9fabb07 100644 --- a/src/test/java/fr/xephi/authme/listener/EntityListenerTest.java +++ b/src/test/java/fr/xephi/authme/listener/EntityListenerTest.java @@ -27,7 +27,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link EntityListener}. @@ -76,7 +76,7 @@ public class EntityListenerTest { // then verify(listenerService).shouldCancelEvent(event); - verifyZeroInteractions(event); + verifyNoInteractions(event); } @Test @@ -140,7 +140,7 @@ public class EntityListenerTest { // then verify(listenerService).shouldCancelEvent(event); - verifyZeroInteractions(event); + verifyNoInteractions(event); } @Test @@ -156,7 +156,7 @@ public class EntityListenerTest { listener.onProjectileLaunch(event); // then - verifyZeroInteractions(listenerService); + verifyNoInteractions(listenerService); verify(event, never()).setCancelled(anyBoolean()); } diff --git a/src/test/java/fr/xephi/authme/listener/EventCancelVerifier.java b/src/test/java/fr/xephi/authme/listener/EventCancelVerifier.java index f74dc24bd..351013c33 100644 --- a/src/test/java/fr/xephi/authme/listener/EventCancelVerifier.java +++ b/src/test/java/fr/xephi/authme/listener/EventCancelVerifier.java @@ -10,7 +10,7 @@ import java.util.function.Consumer; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Tests simple listener methods that should cancel an event when the listener service says so. @@ -54,7 +54,7 @@ public final class EventCancelVerifier { event = mock(clazz); mockShouldCancel(false, listenerService, event); listenerMethod.accept(event); - verifyZeroInteractions(event); + verifyNoInteractions(event); return this; } diff --git a/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java b/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java index a3ae6d9f5..76877fcac 100644 --- a/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java +++ b/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link ListenerService}. @@ -91,7 +91,7 @@ public class ListenerServiceTest { // then assertThat(result, equalTo(false)); verify(playerCache).isAuthenticated(playerName); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -110,7 +110,7 @@ public class ListenerServiceTest { assertThat(result, equalTo(true)); verify(playerCache).isAuthenticated(playerName); // makes sure the setting is checked first = avoid unnecessary DB operation - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -147,7 +147,7 @@ public class ListenerServiceTest { // then assertThat(result, equalTo(false)); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -182,7 +182,7 @@ public class ListenerServiceTest { // then assertThat(result, equalTo(false)); verify(playerCache).isAuthenticated(playerName); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -210,7 +210,7 @@ public class ListenerServiceTest { // then assertThat(result, equalTo(true)); verify(playerCache).isAuthenticated(playerName); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } private static Player mockPlayerWithName(String name) { diff --git a/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java b/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java index ddcd5bc70..295bcacb7 100644 --- a/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java +++ b/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java @@ -39,8 +39,8 @@ import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * Test for {@link OnJoinVerifier}. @@ -89,7 +89,7 @@ public class OnJoinVerifierTest { assertThat(result, equalTo(false)); verify(event).getResult(); verifyNoMoreInteractions(event); - verifyZeroInteractions(bukkitService, dataSource, permissionsManager); + verifyNoInteractions(bukkitService, dataSource, permissionsManager); } @Test @@ -109,7 +109,7 @@ public class OnJoinVerifierTest { assertThat(result, equalTo(true)); assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.KICK_FULL)); assertThat(event.getKickMessage(), equalTo(serverFullMessage)); - verifyZeroInteractions(bukkitService, dataSource); + verifyNoInteractions(bukkitService, dataSource); } @Test @@ -133,7 +133,7 @@ public class OnJoinVerifierTest { assertThat(result, equalTo(false)); assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.ALLOWED)); // First player is VIP, so expect no interactions there and second player to have been kicked - verifyZeroInteractions(onlinePlayers.get(0)); + verifyNoInteractions(onlinePlayers.get(0)); verify(onlinePlayers.get(1)).kickPlayer("kick for vip"); } @@ -157,7 +157,7 @@ public class OnJoinVerifierTest { assertThat(result, equalTo(true)); assertThat(event.getResult(), equalTo(PlayerLoginEvent.Result.KICK_FULL)); assertThat(event.getKickMessage(), equalTo("kick full server")); - verifyZeroInteractions(onlinePlayers.get(0)); + verifyNoInteractions(onlinePlayers.get(0)); } @Test @@ -254,7 +254,7 @@ public class OnJoinVerifierTest { onJoinVerifier.checkNameCasing(name, auth); // then - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -269,7 +269,7 @@ public class OnJoinVerifierTest { // when / then onJoinVerifier.checkNameCasing(name, auth); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -311,7 +311,7 @@ public class OnJoinVerifierTest { onJoinVerifier.checkNameCasing(name, auth); // then - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -324,7 +324,7 @@ public class OnJoinVerifierTest { onJoinVerifier.checkNameCasing(name, auth); // then - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -368,7 +368,7 @@ public class OnJoinVerifierTest { onJoinVerifier.checkSingleSession(name); // then - verifyZeroInteractions(bukkitService); + verifyNoInteractions(bukkitService); } @Test @@ -397,7 +397,7 @@ public class OnJoinVerifierTest { onJoinVerifier.checkAntibot(name, isAuthAvailable); // then - verifyZeroInteractions(permissionsManager, antiBotService); + verifyNoInteractions(permissionsManager, antiBotService); } @Test @@ -412,7 +412,7 @@ public class OnJoinVerifierTest { // then verify(permissionsManager).hasPermissionOffline(name, PlayerStatePermission.BYPASS_ANTIBOT); - verifyZeroInteractions(antiBotService); + verifyNoInteractions(antiBotService); } @Test @@ -446,12 +446,12 @@ public class OnJoinVerifierTest { given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION)).willReturn(false); given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED)).willReturn(true); onJoinVerifier.checkPlayerCountry(name, ip, false); - verifyZeroInteractions(validationService); + verifyNoInteractions(validationService); // protection for registered players disabled given(settings.getProperty(ProtectionSettings.ENABLE_PROTECTION_REGISTERED)).willReturn(false); onJoinVerifier.checkPlayerCountry(name, ip, true); - verifyZeroInteractions(validationService); + verifyNoInteractions(validationService); } @Test diff --git a/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java b/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java index acb12cce5..e72d48be6 100644 --- a/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java +++ b/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java @@ -83,8 +83,8 @@ import static org.mockito.Mockito.only; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * Test for {@link PlayerListener}. @@ -140,7 +140,7 @@ public class PlayerListenerTest { // then assertThat(event.isCancelled(), equalTo(true)); - verifyZeroInteractions(player, management, antiBotService); + verifyNoInteractions(player, management, antiBotService); } @Test @@ -176,7 +176,7 @@ public class PlayerListenerTest { // then assertThat(event.isCancelled(), equalTo(false)); verify(antiBotService).wasPlayerKicked(name); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -205,7 +205,7 @@ public class PlayerListenerTest { // then verify(event, only()).getMessage(); - verifyZeroInteractions(listenerService, messages); + verifyNoInteractions(listenerService, messages); } @Test @@ -220,7 +220,7 @@ public class PlayerListenerTest { // then verify(event, only()).getMessage(); - verifyZeroInteractions(listenerService, messages); + verifyNoInteractions(listenerService, messages); } @Test @@ -241,7 +241,7 @@ public class PlayerListenerTest { verify(event).getMessage(); verifyNoMoreInteractions(event); verify(listenerService).shouldCancelEvent(player); - verifyZeroInteractions(messages); + verifyNoInteractions(messages); } @Test @@ -290,7 +290,7 @@ public class PlayerListenerTest { listener.onPlayerChat(event); // then - verifyZeroInteractions(event, listenerService, messages); + verifyNoInteractions(event, listenerService, messages); } @Test @@ -324,7 +324,7 @@ public class PlayerListenerTest { // then verify(listenerService).shouldCancelEvent(event.getPlayer()); - verifyZeroInteractions(event, messages); + verifyNoInteractions(event, messages); } @Test @@ -400,7 +400,7 @@ public class PlayerListenerTest { listener.onPlayerMove(event); // then - verifyZeroInteractions(event); + verifyNoInteractions(event); } @Test @@ -551,7 +551,7 @@ public class PlayerListenerTest { listener.onPlayerRespawn(event); // then - verifyZeroInteractions(listenerService); + verifyNoInteractions(listenerService); verify(event, never()).setRespawnLocation(any()); } @@ -568,7 +568,7 @@ public class PlayerListenerTest { listener.onPlayerRespawn(event); // then - verifyZeroInteractions(spawnLoader); + verifyNoInteractions(spawnLoader); verify(event, never()).setRespawnLocation(any()); } @@ -659,7 +659,7 @@ public class PlayerListenerTest { // then verify(validationService).isUnrestricted(name); verifyNoModifyingCalls(event); - verifyZeroInteractions(onJoinVerifier); + verifyNoInteractions(onJoinVerifier); } @Test @@ -717,7 +717,7 @@ public class PlayerListenerTest { verify(validationService).isUnrestricted(name); verify(onJoinVerifier).checkSingleSession(name); verify(onJoinVerifier).checkIsValidName(name); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); verifyNoModifyingCalls(preLoginEvent); } @@ -780,7 +780,7 @@ public class PlayerListenerTest { // then verify(validationService).isUnrestricted(name); verify(onJoinVerifier).refusePlayerForFullServer(loginEvent); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); verifyNoModifyingCalls(loginEvent); } @@ -805,7 +805,7 @@ public class PlayerListenerTest { verify(validationService).isUnrestricted(name); verify(onJoinVerifier).checkIsValidName(name); // Check that we don't talk with the data source before performing checks that don't require it - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); verify(event).setKickMessage(message); verify(event).setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); } @@ -844,7 +844,7 @@ public class PlayerListenerTest { // then assertThat(event.getQuitMessage(), nullValue()); verify(antiBotService).wasPlayerKicked(name); - verifyZeroInteractions(management); + verifyNoInteractions(management); } @Test @@ -942,7 +942,7 @@ public class PlayerListenerTest { // then assertThat(event.isCancelled(), equalTo(false)); - verifyZeroInteractions(bukkitService); + verifyNoInteractions(bukkitService); } @Test @@ -980,7 +980,7 @@ public class PlayerListenerTest { // then assertThat(event.getJoinMessage(), equalTo(joinMsg)); - verifyZeroInteractions(joinMessageService); + verifyNoInteractions(joinMessageService); } @Test @@ -996,7 +996,7 @@ public class PlayerListenerTest { // then assertThat(event.getJoinMessage(), nullValue()); - verifyZeroInteractions(joinMessageService); + verifyNoInteractions(joinMessageService); } @Test @@ -1017,7 +1017,7 @@ public class PlayerListenerTest { // then assertThat(event.getJoinMessage(), equalTo("Hello doooew (aka Displ)")); - verifyZeroInteractions(joinMessageService); + verifyNoInteractions(joinMessageService); } @Test diff --git a/src/test/java/fr/xephi/authme/listener/ServerListenerTest.java b/src/test/java/fr/xephi/authme/listener/ServerListenerTest.java index 7b82bc4cc..51ce46f08 100644 --- a/src/test/java/fr/xephi/authme/listener/ServerListenerTest.java +++ b/src/test/java/fr/xephi/authme/listener/ServerListenerTest.java @@ -1,9 +1,9 @@ package fr.xephi.authme.listener; import fr.xephi.authme.TestHelper; -import fr.xephi.authme.service.PluginHookService; import fr.xephi.authme.listener.protocollib.ProtocolLibService; import fr.xephi.authme.permission.PermissionsManager; +import fr.xephi.authme.service.PluginHookService; import fr.xephi.authme.settings.SpawnLoader; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginEnableEvent; @@ -20,8 +20,8 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * Test for {@link ServerListener}. @@ -65,7 +65,7 @@ public class ServerListenerTest { }); checkEnableHandling(MULTIVERSE, () -> verify(pluginHookService).tryHookToMultiverse()); checkEnableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).setup()); - checkEnableHandling("UnknownPlugin", () -> verifyZeroInteractions(pluginHookService, spawnLoader)); + checkEnableHandling("UnknownPlugin", () -> verifyNoInteractions(pluginHookService, spawnLoader)); } @Test @@ -78,7 +78,7 @@ public class ServerListenerTest { }); checkDisableHandling(MULTIVERSE, () -> verify(pluginHookService).unhookMultiverse()); checkDisableHandling(PROTOCOL_LIB, () -> verify(protocolLibService).disable()); - checkDisableHandling("UnknownPlugin", () -> verifyZeroInteractions(pluginHookService, spawnLoader)); + checkDisableHandling("UnknownPlugin", () -> verifyNoInteractions(pluginHookService, spawnLoader)); } private void checkEnableHandling(String pluginName, Runnable verifier) { diff --git a/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java b/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java index 33ef76f09..40e3076e1 100644 --- a/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java +++ b/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.internal.verification.VerificationModeFactory.only; /** @@ -78,7 +78,7 @@ public class AsynchronousLoginTest { // then verify(playerCache, only()).isAuthenticated(name); verify(commonService).send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test @@ -198,7 +198,7 @@ public class AsynchronousLoginTest { // then assertThat(result, equalTo(false)); - verifyZeroInteractions(bukkitService); + verifyNoInteractions(bukkitService); } @Test @@ -214,7 +214,7 @@ public class AsynchronousLoginTest { // then assertThat(result, equalTo(false)); verify(commonService).hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS); - verifyZeroInteractions(bukkitService); + verifyNoInteractions(bukkitService); } @Test diff --git a/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java b/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java index 029ff90ce..c61ed7f59 100644 --- a/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java +++ b/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java @@ -28,7 +28,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link AsyncRegister}. @@ -64,7 +64,7 @@ public class AsyncRegisterTest { // then verify(commonService).send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); - verifyZeroInteractions(dataSource, executor); + verifyNoInteractions(dataSource, executor); } @Test @@ -82,7 +82,7 @@ public class AsyncRegisterTest { // then verify(commonService).send(player, MessageKey.REGISTRATION_DISABLED); - verifyZeroInteractions(dataSource, executor); + verifyNoInteractions(dataSource, executor); } @Test @@ -102,7 +102,7 @@ public class AsyncRegisterTest { // then verify(commonService).send(player, MessageKey.NAME_ALREADY_REGISTERED); verify(dataSource, only()).isAuthAvailable(name); - verifyZeroInteractions(executor); + verifyNoInteractions(executor); } @Test diff --git a/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorTest.java b/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorTest.java index 290566bcd..c76c0fb36 100644 --- a/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorTest.java +++ b/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorTest.java @@ -28,7 +28,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link EmailRegisterExecutor}. @@ -158,7 +158,7 @@ public class EmailRegisterExecutorTest { // then verify(emailService).sendPasswordMail("Laleh", "test@example.com", password); verify(commonService).send(player, MessageKey.EMAIL_SEND_FAILURE); - verifyZeroInteractions(syncProcessManager); + verifyNoInteractions(syncProcessManager); } private static void assertIsCloseTo(long value1, long value2, long tolerance) { diff --git a/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java b/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java index 08465aca6..6b41f2c1a 100644 --- a/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java +++ b/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java @@ -31,7 +31,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link PasswordRegisterExecutor}. @@ -138,7 +138,7 @@ public class PasswordRegisterExecutorTest { executor.executePostPersistAction(params); // then - verifyZeroInteractions(bukkitService, asynchronousLogin); + verifyNoInteractions(bukkitService, asynchronousLogin); verify(syncProcessManager).processSyncPasswordRegister(player); } diff --git a/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java b/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java index 1e703fcf4..99a1913b3 100644 --- a/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java +++ b/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java @@ -40,7 +40,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link AsynchronousUnregister}. @@ -94,7 +94,7 @@ public class AsynchronousUnregisterTest { // then verify(service).send(player, MessageKey.WRONG_PASSWORD); verify(passwordSecurity).comparePassword(userPassword, password, name); - verifyZeroInteractions(dataSource, limboService, teleportationService, bukkitService, bungeeSender); + verifyNoInteractions(dataSource, limboService, teleportationService, bukkitService, bungeeSender); verify(player, only()).getName(); } @@ -189,7 +189,7 @@ public class AsynchronousUnregisterTest { verify(passwordSecurity).comparePassword(userPassword, password, name); verify(dataSource).removeAuth(name); verify(playerCache).removePlayer(name); - verifyZeroInteractions(teleportationService, limboService); + verifyNoInteractions(teleportationService, limboService); verifyCalledUnregisterEventFor(player); verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); verify(commandManager).runCommandsOnUnregister(player); @@ -216,7 +216,7 @@ public class AsynchronousUnregisterTest { verify(passwordSecurity).comparePassword(userPassword, password, name); verify(dataSource).removeAuth(name); verify(service).send(player, MessageKey.ERROR); - verifyZeroInteractions(teleportationService, bukkitService, bungeeSender); + verifyNoInteractions(teleportationService, bukkitService, bungeeSender); } @Test @@ -241,7 +241,7 @@ public class AsynchronousUnregisterTest { verify(passwordSecurity).comparePassword(userPassword, password, name); verify(dataSource).removeAuth(name); verify(playerCache).removePlayer(name); - verifyZeroInteractions(teleportationService); + verifyNoInteractions(teleportationService); verifyCalledUnregisterEventFor(player); verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); } @@ -285,7 +285,7 @@ public class AsynchronousUnregisterTest { // then verify(dataSource).removeAuth(name); verify(playerCache).removePlayer(name); - verifyZeroInteractions(teleportationService); + verifyNoInteractions(teleportationService); verifyCalledUnregisterEventFor(null); verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); } @@ -303,7 +303,7 @@ public class AsynchronousUnregisterTest { // then verify(dataSource).removeAuth(name); verify(service).send(initiator, MessageKey.ERROR); - verifyZeroInteractions(playerCache, teleportationService, bukkitService, bungeeSender); + verifyNoInteractions(playerCache, teleportationService, bukkitService, bungeeSender); } @SuppressWarnings("unchecked") diff --git a/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java b/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java index 22ab394b0..0e7d9c37f 100644 --- a/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java +++ b/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link TotpAuthenticator}. @@ -92,7 +92,7 @@ public class TotpAuthenticatorTest { // then assertThat(result, equalTo(false)); - verifyZeroInteractions(googleAuthenticator); + verifyNoInteractions(googleAuthenticator); } @Test diff --git a/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java b/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java index f3f1f3f80..8a41671a3 100644 --- a/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java @@ -29,7 +29,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link AntiBotService}. @@ -76,7 +76,7 @@ public class AntiBotServiceTest { // then assertThat(antiBotService.getAntiBotStatus(), equalTo(AntiBotService.AntiBotStatus.DISABLED)); - verifyZeroInteractions(bukkitService); + verifyNoInteractions(bukkitService); } @Test diff --git a/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java b/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java index 504c342f7..031f3ed8e 100644 --- a/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java @@ -29,7 +29,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link BukkitService}. @@ -127,7 +127,7 @@ public class BukkitServiceTest { // then verify(spy).scheduleSyncDelayedTask(task); - verifyZeroInteractions(task); + verifyNoInteractions(task); } @Test @@ -188,7 +188,7 @@ public class BukkitServiceTest { spy.runTaskOptionallyAsync(task); // then - verifyZeroInteractions(task); + verifyNoInteractions(task); verify(spy).runTaskAsynchronously(task); } diff --git a/src/test/java/fr/xephi/authme/service/SessionServiceTest.java b/src/test/java/fr/xephi/authme/service/SessionServiceTest.java index b631c67e5..ac2d64349 100644 --- a/src/test/java/fr/xephi/authme/service/SessionServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/SessionServiceTest.java @@ -25,8 +25,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * Test for {@link SessionService}. @@ -66,7 +66,7 @@ public class SessionServiceTest { // then assertThat(result, equalTo(false)); - verifyZeroInteractions(dataSource); + verifyNoInteractions(dataSource); } @Test diff --git a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java index bf44ca0e9..46db5e05c 100644 --- a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java @@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link TeleportationService}. @@ -77,8 +77,8 @@ public class TeleportationServiceTest { teleportationService.teleportOnJoin(player); // then - verifyZeroInteractions(player); - verifyZeroInteractions(bukkitService); + verifyNoInteractions(player); + verifyNoInteractions(bukkitService); } @Test @@ -134,7 +134,7 @@ public class TeleportationServiceTest { verify(player, never()).teleport(any(Location.class)); verify(spawnLoader).getFirstSpawn(); verify(spawnLoader, never()).getSpawnLocation(any(Player.class)); - verifyZeroInteractions(bukkitService); + verifyNoInteractions(bukkitService); } @Test @@ -148,7 +148,7 @@ public class TeleportationServiceTest { // then verify(player, never()).teleport(any(Location.class)); - verifyZeroInteractions(bukkitService); + verifyNoInteractions(bukkitService); } @Test @@ -162,7 +162,7 @@ public class TeleportationServiceTest { // then verify(player, never()).teleport(any(Location.class)); - verifyZeroInteractions(bukkitService); + verifyNoInteractions(bukkitService); } @Test @@ -226,7 +226,7 @@ public class TeleportationServiceTest { teleportationService.teleportOnLogin(player, auth, limbo); // then - verifyZeroInteractions(player, auth, limbo, bukkitService, spawnLoader); + verifyNoInteractions(player, auth, limbo, bukkitService, spawnLoader); } @Test @@ -270,7 +270,7 @@ public class TeleportationServiceTest { // then verify(player, never()).teleport(spawn); - verifyZeroInteractions(bukkitService, spawnLoader); + verifyNoInteractions(bukkitService, spawnLoader); } @Test @@ -387,7 +387,7 @@ public class TeleportationServiceTest { teleportationService.teleportOnLogin(player, auth, limbo); // then - verifyZeroInteractions(player); + verifyNoInteractions(player); verify(limbo, times(2)).getLocation(); } diff --git a/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java b/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java index 003036542..dafc8c3dc 100644 --- a/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java @@ -33,7 +33,7 @@ import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link ValidationService}. @@ -277,7 +277,7 @@ public class ValidationServiceTest { // then assertThat(result, equalTo(true)); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test diff --git a/src/test/java/fr/xephi/authme/settings/SettingsWarnerTest.java b/src/test/java/fr/xephi/authme/settings/SettingsWarnerTest.java index 16271bd94..cdf4f8ac1 100644 --- a/src/test/java/fr/xephi/authme/settings/SettingsWarnerTest.java +++ b/src/test/java/fr/xephi/authme/settings/SettingsWarnerTest.java @@ -21,7 +21,7 @@ import java.util.logging.Logger; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.internal.verification.VerificationModeFactory.times; /** @@ -76,6 +76,6 @@ public class SettingsWarnerTest { settingsWarner.logWarningsForMisconfigurations(); // then - verifyZeroInteractions(logger); + verifyNoInteractions(logger); } } diff --git a/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java b/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java index 7550ed694..0be553d7b 100644 --- a/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java +++ b/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java @@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link WelcomeMessageConfiguration}. @@ -81,7 +81,7 @@ public class WelcomeMessageConfigurationTest { // then assertThat(result, hasSize(2)); assertThat(result, contains(welcomeMessage.split("\\n"))); - verifyZeroInteractions(player, playerCache, geoIpService, bukkitService, server); + verifyNoInteractions(player, playerCache, geoIpService, bukkitService, server); } @Test @@ -104,7 +104,7 @@ public class WelcomeMessageConfigurationTest { assertThat(result.get(0), equalTo("Hello Bobby, your IP is 123.45.66.77")); assertThat(result.get(1), equalTo("Your country is Syldavia.")); assertThat(result.get(2), equalTo("Welcome to CrazyServer!")); - verifyZeroInteractions(server, playerCache); + verifyNoInteractions(server, playerCache); } @Test diff --git a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java index 828ec15d0..9c585aedc 100644 --- a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java +++ b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java @@ -28,8 +28,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; /** * Test for {@link CommandManager}. @@ -80,7 +80,7 @@ public class CommandManagerTest { verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(60L)); verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L)); verifyNoMoreInteractions(bukkitService); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -101,7 +101,7 @@ public class CommandManagerTest { verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L)); verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L)); verifyNoMoreInteractions(bukkitService); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -124,7 +124,7 @@ public class CommandManagerTest { verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L)); verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(240L)); verifyNoMoreInteractions(bukkitService); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -145,7 +145,7 @@ public class CommandManagerTest { verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(120L)); verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(180L)); verifyNoMoreInteractions(bukkitService); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -163,7 +163,7 @@ public class CommandManagerTest { verify(bukkitService).dispatchCommand(any(Player.class), eq("list")); verify(bukkitService).scheduleSyncDelayedTask(any(Runnable.class), eq(100L)); verifyNoMoreInteractions(bukkitService); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -178,7 +178,7 @@ public class CommandManagerTest { // then verify(bukkitService).dispatchConsoleCommand("msg Bobby Session login!"); verifyNoMoreInteractions(bukkitService); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -193,7 +193,7 @@ public class CommandManagerTest { // then verify(bukkitService).dispatchConsoleCommand("pay Bobby 30"); verifyNoMoreInteractions(bukkitService); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -206,7 +206,7 @@ public class CommandManagerTest { manager.runCommandsOnFirstLogin(player, Arrays.asList("u", "wot", "m8")); // then - verifyZeroInteractions(bukkitService, geoIpService); + verifyNoInteractions(bukkitService, geoIpService); } @Test @@ -220,7 +220,7 @@ public class CommandManagerTest { // then verify(bukkitService, only()).dispatchConsoleCommand("broadcast bob has joined"); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -234,7 +234,7 @@ public class CommandManagerTest { // then verify(bukkitService, only()).dispatchConsoleCommand("broadcast Bobby has joined"); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -265,7 +265,7 @@ public class CommandManagerTest { // then verify(bukkitService).dispatchConsoleCommand("broadcast Bobby (127.0.0.3) logged out"); verifyNoMoreInteractions(bukkitService); - verifyZeroInteractions(geoIpService); + verifyNoInteractions(geoIpService); } @Test @@ -278,7 +278,7 @@ public class CommandManagerTest { manager.runCommandsOnRegister(player); // then - verifyZeroInteractions(bukkitService, geoIpService); + verifyNoInteractions(bukkitService, geoIpService); } @Test diff --git a/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java b/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java index f27e01ed4..8b0864e59 100644 --- a/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java +++ b/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java @@ -39,7 +39,7 @@ import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.hamcrest.MockitoHamcrest.argThat; /** @@ -77,7 +77,7 @@ public class PurgeServiceTest { purgeService.runAutoPurge(); // then - verifyZeroInteractions(bukkitService, dataSource); + verifyNoInteractions(bukkitService, dataSource); } @Test @@ -90,7 +90,7 @@ public class PurgeServiceTest { purgeService.runAutoPurge(); // then - verifyZeroInteractions(bukkitService, dataSource); + verifyNoInteractions(bukkitService, dataSource); } @Test @@ -127,7 +127,7 @@ public class PurgeServiceTest { verify(dataSource).getRecordsToPurge(delay); verify(dataSource, never()).purgeRecords(anyCollection()); verify(sender).sendMessage("No players to purge"); - verifyZeroInteractions(bukkitService, permissionsManager); + verifyNoInteractions(bukkitService, permissionsManager); } @Test @@ -160,7 +160,7 @@ public class PurgeServiceTest { // then verify(sender).sendMessage(argThat(containsString("Purge is already in progress"))); - verifyZeroInteractions(bukkitService, dataSource, permissionsManager); + verifyNoInteractions(bukkitService, dataSource, permissionsManager); } @Test diff --git a/src/test/java/fr/xephi/authme/util/UtilsTest.java b/src/test/java/fr/xephi/authme/util/UtilsTest.java index 154137ef4..1b1064873 100644 --- a/src/test/java/fr/xephi/authme/util/UtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/UtilsTest.java @@ -16,11 +16,10 @@ import java.util.logging.Logger; import java.util.regex.Pattern; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; /** * Test for {@link Utils}. @@ -102,7 +101,7 @@ public class UtilsTest { // then verify(logger).info(message); - verifyZeroInteractions(sender); + verifyNoInteractions(sender); } @Test @@ -144,7 +143,7 @@ public class UtilsTest { // then verify(logger).warning(message); - verifyZeroInteractions(sender); + verifyNoInteractions(sender); } @Test From e31cb5bb9e8fcbb34641a3c315320f68938ef76a Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sun, 3 Nov 2019 10:54:43 +0100 Subject: [PATCH 10/14] Fix some CodeClimate issues - Mostly missing Javadoc on methods & line length violations --- .../fr/xephi/authme/data/auth/PlayerAuth.java | 1 + .../fr/xephi/authme/datasource/MySQL.java | 1 + .../fr/xephi/authme/datasource/SQLite.java | 1 + .../mysqlextensions/WordpressExtension.java | 102 ++++++++---------- .../protocollib/InventoryPacketAdapter.java | 10 ++ .../service/bungeecord/BungeeReceiver.java | 16 ++- .../translations/TranslationsGatherer.java | 6 +- .../HelpTranslationVerifier.java | 6 ++ .../tools/messages/VerifyMessagesTask.java | 11 +- 9 files changed, 83 insertions(+), 71 deletions(-) diff --git a/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java index 4aebd88db..23aa8116d 100644 --- a/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java +++ b/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java @@ -13,6 +13,7 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * AuthMe player data. */ +@SuppressWarnings("checkstyle:FinalClass") // Justification: class is mocked in multiple tests public class PlayerAuth { /** Default email used in the database if the email column is defined to be NOT NULL. */ diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 768af7320..501758181 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -170,6 +170,7 @@ public class MySQL extends AbstractSqlDataSource { /** * Creates the table or any of its required columns if they don't exist. */ + @SuppressWarnings({"checkstyle:CyclomaticComplexity", "checkstyle:JavaNCSS"}) private void checkTablesAndColumns() throws SQLException { try (Connection con = getConnection(); Statement st = con.createStatement()) { // Create table with ID column if it doesn't exist diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite.java b/src/main/java/fr/xephi/authme/datasource/SQLite.java index 29b6a87c1..3ca138d59 100644 --- a/src/main/java/fr/xephi/authme/datasource/SQLite.java +++ b/src/main/java/fr/xephi/authme/datasource/SQLite.java @@ -98,6 +98,7 @@ public class SQLite extends AbstractSqlDataSource { * @throws SQLException when an SQL error occurs while initializing the database */ @VisibleForTesting + @SuppressWarnings("checkstyle:CyclomaticComplexity") protected void setup() throws SQLException { try (Statement st = con.createStatement()) { // Note: cannot add unique fields later on in SQLite, so we add it on initialization diff --git a/src/main/java/fr/xephi/authme/datasource/mysqlextensions/WordpressExtension.java b/src/main/java/fr/xephi/authme/datasource/mysqlextensions/WordpressExtension.java index 22ef97f3c..8105d2e55 100644 --- a/src/main/java/fr/xephi/authme/datasource/mysqlextensions/WordpressExtension.java +++ b/src/main/java/fr/xephi/authme/datasource/mysqlextensions/WordpressExtension.java @@ -30,73 +30,55 @@ class WordpressExtension extends MySqlExtension { } } + /** + * Saves the required data to Wordpress tables. + * + * @param auth the player data + * @param id the player id + * @param con the sql connection + * @throws SQLException . + */ private void saveSpecifics(PlayerAuth auth, int id, Connection con) throws SQLException { String sql = "INSERT INTO " + wordpressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?)"; try (PreparedStatement pst = con.prepareStatement(sql)) { - // First Name - pst.setInt(1, id); - pst.setString(2, "first_name"); - pst.setString(3, ""); - pst.addBatch(); - // Last Name - pst.setInt(1, id); - pst.setString(2, "last_name"); - pst.setString(3, ""); - pst.addBatch(); - // Nick Name - pst.setInt(1, id); - pst.setString(2, "nickname"); - pst.setString(3, auth.getNickname()); - pst.addBatch(); - // Description - pst.setInt(1, id); - pst.setString(2, "description"); - pst.setString(3, ""); - pst.addBatch(); - // Rich_Editing - pst.setInt(1, id); - pst.setString(2, "rich_editing"); - pst.setString(3, "true"); - pst.addBatch(); - // Comments_Shortcuts - pst.setInt(1, id); - pst.setString(2, "comment_shortcuts"); - pst.setString(3, "false"); - pst.addBatch(); - // admin_color - pst.setInt(1, id); - pst.setString(2, "admin_color"); - pst.setString(3, "fresh"); - pst.addBatch(); - // use_ssl - pst.setInt(1, id); - pst.setString(2, "use_ssl"); - pst.setString(3, "0"); - pst.addBatch(); - // show_admin_bar_front - pst.setInt(1, id); - pst.setString(2, "show_admin_bar_front"); - pst.setString(3, "true"); - pst.addBatch(); - // wp_capabilities - pst.setInt(1, id); - pst.setString(2, wordpressPrefix + "capabilities"); - pst.setString(3, "a:1:{s:10:\"subscriber\";b:1;}"); - pst.addBatch(); - // wp_user_level - pst.setInt(1, id); - pst.setString(2, wordpressPrefix + "user_level"); - pst.setString(3, "0"); - pst.addBatch(); - // default_password_nag - pst.setInt(1, id); - pst.setString(2, "default_password_nag"); - pst.setString(3, ""); - pst.addBatch(); + + new UserMetaBatchAdder(pst, id) + .addMetaRow("first_name", "") + .addMetaRow("last_name", "") + .addMetaRow("nickname", auth.getNickname()) + .addMetaRow("description", "") + .addMetaRow("rich_editing", "true") + .addMetaRow("comment_shortcuts", "false") + .addMetaRow("admin_color", "fresh") + .addMetaRow("use_ssl", "0") + .addMetaRow("show_admin_bar_front", "true") + .addMetaRow(wordpressPrefix + "capabilities", "a:1:{s:10:\"subscriber\";b:1;}") + .addMetaRow(wordpressPrefix + "user_level", "0") + .addMetaRow("default_password_nag", ""); // Execute queries pst.executeBatch(); pst.clearBatch(); } } + + /** Helper to add batch entries to the wrapped prepared statement. */ + private static final class UserMetaBatchAdder { + + private final PreparedStatement pst; + private final int userId; + + UserMetaBatchAdder(PreparedStatement pst, int userId) { + this.pst = pst; + this.userId = userId; + } + + UserMetaBatchAdder addMetaRow(String metaKey, String metaValue) throws SQLException { + pst.setInt(1, userId); + pst.setString(2, metaKey); + pst.setString(3, metaValue); + pst.addBatch(); + return this; + } + } } diff --git a/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java index 5ebaadb46..bceeaca7a 100644 --- a/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java +++ b/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java @@ -69,6 +69,11 @@ class InventoryPacketAdapter extends PacketAdapter { } } + /** + * Registers itself to ProtocolLib and blanks out the inventory packet to any applicable players. + * + * @param bukkitService the bukkit service (for retrieval of online players) + */ public void register(BukkitService bukkitService) { ProtocolLibrary.getProtocolManager().addPacketListener(this); @@ -85,6 +90,11 @@ class InventoryPacketAdapter extends PacketAdapter { ProtocolLibrary.getProtocolManager().removePacketListener(this); } + /** + * Sends a blanked out packet to the given player in order to hide the inventory. + * + * @param player the player to send the blank inventory packet to + */ public void sendBlankInventoryPacket(Player player) { ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS); diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java index fd38d50b3..ae1b79cd9 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java @@ -30,8 +30,8 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent private boolean isEnabled; @Inject - BungeeReceiver(final AuthMe plugin, final BukkitService bukkitService, final Management management, - final DataSource dataSource, final Settings settings) { + BungeeReceiver(AuthMe plugin, BukkitService bukkitService, Management management, + DataSource dataSource, Settings settings) { this.plugin = plugin; this.bukkitService = bukkitService; this.management = management; @@ -51,6 +51,11 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent } } + /** + * Processes the given data input and attempts to translate it to a message for the "AuthMe.v2.Broadcast" channel. + * + * @param in the input to handle + */ private void handleBroadcast(final ByteArrayDataInput in) { // Read data byte array final short dataLength = in.readShort(); @@ -91,7 +96,12 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent } } - private void handle(final ByteArrayDataInput in) { + /** + * Processes the given data input and attempts to translate it to a message for the "AuthMe.v2" channel. + * + * @param in the input to handle + */ + private void handle(ByteArrayDataInput in) { // Parse type final String typeId = in.readUTF(); final Optional type = MessageType.fromId(typeId); diff --git a/src/test/java/tools/docs/translations/TranslationsGatherer.java b/src/test/java/tools/docs/translations/TranslationsGatherer.java index 9a08bd50d..ebe72f7a8 100644 --- a/src/test/java/tools/docs/translations/TranslationsGatherer.java +++ b/src/test/java/tools/docs/translations/TranslationsGatherer.java @@ -2,9 +2,8 @@ package tools.docs.translations; import ch.jalu.configme.resource.PropertyReader; import ch.jalu.configme.resource.YamlFileReader; -import fr.xephi.authme.message.MessagePathHelper; import fr.xephi.authme.message.MessageKey; -import tools.utils.ToolsConstants; +import fr.xephi.authme.message.MessagePathHelper; import java.io.File; import java.util.ArrayList; @@ -12,13 +11,14 @@ import java.util.Comparator; import java.util.List; import static tools.utils.FileIoUtils.listFilesOrThrow; +import static tools.utils.ToolsConstants.MAIN_RESOURCES_ROOT; /** * Gathers all available translations of AuthMe. */ public class TranslationsGatherer { - private static final String MESSAGES_FOLDER = ToolsConstants.MAIN_RESOURCES_ROOT + MessagePathHelper.MESSAGES_FOLDER; + private static final String MESSAGES_FOLDER = MAIN_RESOURCES_ROOT + MessagePathHelper.MESSAGES_FOLDER; private List translationInfo = new ArrayList<>(); diff --git a/src/test/java/tools/helptranslation/HelpTranslationVerifier.java b/src/test/java/tools/helptranslation/HelpTranslationVerifier.java index f40af5175..08a446ded 100644 --- a/src/test/java/tools/helptranslation/HelpTranslationVerifier.java +++ b/src/test/java/tools/helptranslation/HelpTranslationVerifier.java @@ -109,6 +109,12 @@ public class HelpTranslationVerifier { return commandPaths; } + /** + * Creates all paths of the properties that are used to define the help translation of the given command definition. + * + * @param command the command to create the paths for + * @return all yaml paths that can be used to translate the command + */ private List getYamlPaths(CommandDescription command) { // e.g. commands.authme.register String commandPath = "commands." + CommandUtils.constructParentList(command).stream() diff --git a/src/test/java/tools/messages/VerifyMessagesTask.java b/src/test/java/tools/messages/VerifyMessagesTask.java index c6e82cd80..5b8407c7e 100644 --- a/src/test/java/tools/messages/VerifyMessagesTask.java +++ b/src/test/java/tools/messages/VerifyMessagesTask.java @@ -1,13 +1,12 @@ package tools.messages; import com.google.common.collect.Multimap; -import fr.xephi.authme.message.MessagePathHelper; import fr.xephi.authme.message.MessageKey; +import fr.xephi.authme.message.MessagePathHelper; import fr.xephi.authme.util.StringUtils; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import tools.utils.ToolTask; -import tools.utils.ToolsConstants; import java.io.File; import java.util.ArrayList; @@ -19,6 +18,7 @@ import java.util.Set; import static fr.xephi.authme.message.MessagePathHelper.DEFAULT_MESSAGES_FILE; import static tools.utils.FileIoUtils.listFilesOrThrow; +import static tools.utils.ToolsConstants.MAIN_RESOURCES_ROOT; /** * Task to verify the keys in the messages files. @@ -26,7 +26,7 @@ import static tools.utils.FileIoUtils.listFilesOrThrow; public final class VerifyMessagesTask implements ToolTask { /** The folder containing the message files. */ - private static final String MESSAGES_FOLDER = ToolsConstants.MAIN_RESOURCES_ROOT + MessagePathHelper.MESSAGES_FOLDER; + private static final String MESSAGES_FOLDER = MAIN_RESOURCES_ROOT + MessagePathHelper.MESSAGES_FOLDER; @Override public String getTaskName() { @@ -47,13 +47,14 @@ public final class VerifyMessagesTask implements ToolTask { if (StringUtils.isEmpty(inputFile)) { messageFiles = getMessagesFiles(); } else { - File customFile = new File(ToolsConstants.MAIN_RESOURCES_ROOT, MessagePathHelper.createMessageFilePath(inputFile)); + File customFile = new File(MAIN_RESOURCES_ROOT, MessagePathHelper.createMessageFilePath(inputFile)); messageFiles = Collections.singletonList(customFile); } FileConfiguration defaultFileConfiguration = null; if (addMissingKeys) { - defaultFileConfiguration = YamlConfiguration.loadConfiguration(new File(ToolsConstants.MAIN_RESOURCES_ROOT, DEFAULT_MESSAGES_FILE)); + defaultFileConfiguration = YamlConfiguration.loadConfiguration( + new File(MAIN_RESOURCES_ROOT, DEFAULT_MESSAGES_FILE)); } // Verify the given files From 39fbb4ac050b1f6f685a62334dba89c4867820c2 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sun, 3 Nov 2019 11:27:18 +0100 Subject: [PATCH 11/14] Remove tests calling hidden constructor of util classes - Newer versions of JaCoCo now ignore hidden constructors out of the box so we don't need the dummy method that calls the constructor for coverage anymore --- src/test/java/fr/xephi/authme/TestHelper.java | 30 ------------------- .../authme/command/CommandUtilsTest.java | 7 ----- .../authme/debug/DebugSectionUtilsTest.java | 5 ---- .../datasource/SqlDataSourceUtilsTest.java | 5 ---- .../PlayerAuthBuilderHelperTest.java | 6 ---- .../authme/service/MigrationServiceTest.java | 16 ++-------- .../commandconfig/CommandManagerTest.java | 6 ---- .../AuthMeSettingsRetrieverTest.java | 6 ---- .../SettingsClassConsistencyTest.java | 7 ----- .../xephi/authme/util/ExceptionUtilsTest.java | 7 ----- .../fr/xephi/authme/util/FileUtilsTest.java | 6 ---- .../util/InternetProtocolUtilsTest.java | 7 ----- .../fr/xephi/authme/util/PlayerUtilsTest.java | 8 ----- .../authme/util/RandomStringUtilsTest.java | 8 ----- .../fr/xephi/authme/util/StringUtilsTest.java | 6 ---- .../java/fr/xephi/authme/util/UtilsTest.java | 6 ---- .../authme/util/lazytags/TagBuilderTest.java | 8 ----- 17 files changed, 3 insertions(+), 141 deletions(-) diff --git a/src/test/java/fr/xephi/authme/TestHelper.java b/src/test/java/fr/xephi/authme/TestHelper.java index 9e846d0f3..baab8ca67 100644 --- a/src/test/java/fr/xephi/authme/TestHelper.java +++ b/src/test/java/fr/xephi/authme/TestHelper.java @@ -6,9 +6,6 @@ import org.bukkit.entity.Player; import org.mockito.Mockito; import java.io.File; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Modifier; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.URI; @@ -95,33 +92,6 @@ public final class TestHelper { return logger; } - /** - * Check that a class only has a hidden, zero-argument constructor, preventing the - * instantiation of such classes (utility classes). Invokes the hidden constructor - * as to register the code coverage. - * - * @param clazz The class to validate - */ - public static void validateHasOnlyPrivateEmptyConstructor(Class clazz) { - Constructor[] constructors = clazz.getDeclaredConstructors(); - if (constructors.length > 1) { - throw new IllegalStateException("Class " + clazz.getSimpleName() + " has more than one constructor"); - } else if (constructors[0].getParameterTypes().length != 0) { - throw new IllegalStateException("Constructor of " + clazz + " does not have empty parameter list"); - } else if (!Modifier.isPrivate(constructors[0].getModifiers())) { - throw new IllegalStateException("Constructor of " + clazz + " is not private"); - } - - // Ugly hack to get coverage on the private constructors - // http://stackoverflow.com/questions/14077842/how-to-test-a-private-constructor-in-java-application - try { - constructors[0].setAccessible(true); - constructors[0].newInstance(); - } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) { - throw new UnsupportedOperationException(e); - } - } - /** * Configures the player mock to return the given IP address. * diff --git a/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java b/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java index 9d1f757e0..be17f6cfb 100644 --- a/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java @@ -1,6 +1,5 @@ package fr.xephi.authme.command; -import fr.xephi.authme.TestHelper; import org.bukkit.ChatColor; import org.junit.BeforeClass; import org.junit.Test; @@ -83,12 +82,6 @@ public class CommandUtilsTest { checkArgumentCount(command, 1, 3); } - @Test - public void shouldHaveHiddenConstructor() { - // given / when / then - TestHelper.validateHasOnlyPrivateEmptyConstructor(CommandUtils.class); - } - @Test public void shouldFormatSimpleArgument() { // given diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionUtilsTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionUtilsTest.java index aadcfa405..1157663ba 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionUtilsTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionUtilsTest.java @@ -58,11 +58,6 @@ public class DebugSectionUtilsTest { assertThat(DebugSectionUtils.formatLocation(null), equalTo("null")); } - @Test - public void shouldHaveHiddenConstructor() { - TestHelper.validateHasOnlyPrivateEmptyConstructor(DebugSectionUtils.class); - } - @Test public void shouldFetchMapInLimboService() { // given diff --git a/src/test/java/fr/xephi/authme/datasource/SqlDataSourceUtilsTest.java b/src/test/java/fr/xephi/authme/datasource/SqlDataSourceUtilsTest.java index e196fabd9..ae2974085 100644 --- a/src/test/java/fr/xephi/authme/datasource/SqlDataSourceUtilsTest.java +++ b/src/test/java/fr/xephi/authme/datasource/SqlDataSourceUtilsTest.java @@ -30,11 +30,6 @@ public class SqlDataSourceUtilsTest { logger = TestHelper.setupLogger(); } - @Test - public void shouldHaveHiddenConstructor() { - TestHelper.validateHasOnlyPrivateEmptyConstructor(SqlDataSourceUtils.class); - } - @Test public void shouldLogException() { // given diff --git a/src/test/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelperTest.java b/src/test/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelperTest.java index a5d583df4..607ba8a43 100644 --- a/src/test/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelperTest.java +++ b/src/test/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelperTest.java @@ -38,10 +38,4 @@ public class PlayerAuthBuilderHelperTest { assertThat(Math.abs(auth.getRegistrationDate() - System.currentTimeMillis()), lessThan(1000L)); assertThat(auth.getPassword(), equalToHash("myHash0001")); } - - @Test - public void shouldHaveHiddenConstructor() { - TestHelper.validateHasOnlyPrivateEmptyConstructor(PlayerAuthBuilderHelper.class); - } - } diff --git a/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java index c62b0b40d..e1579710c 100644 --- a/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java @@ -12,9 +12,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.invocation.InvocationOnMock; import org.mockito.junit.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; import java.util.Arrays; @@ -110,11 +108,6 @@ public class MigrationServiceTest { verifyNoMoreInteractions(settings, dataSource, sha256); } - @Test - public void shouldHaveHiddenEmptyConstructorOnly() { - TestHelper.validateHasOnlyPrivateEmptyConstructor(MigrationService.class); - } - private static PlayerAuth authWithNickAndHash(String nick, String hash) { return PlayerAuth.builder() .name(nick) @@ -123,12 +116,9 @@ public class MigrationServiceTest { } private static void setSha256MockToUppercase(Sha256 sha256) { - given(sha256.computeHash(anyString(), anyString())).willAnswer(new Answer() { - @Override - public HashedPassword answer(InvocationOnMock invocation) { - String plainPassword = invocation.getArgument(0); - return new HashedPassword(plainPassword.toUpperCase(), null); - } + given(sha256.computeHash(anyString(), anyString())).willAnswer(invocation -> { + String plainPassword = invocation.getArgument(0); + return new HashedPassword(plainPassword.toUpperCase(), null); }); } } diff --git a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java index 9c585aedc..a42a83a37 100644 --- a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java +++ b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java @@ -294,12 +294,6 @@ public class CommandManagerTest { verify(bukkitService).dispatchConsoleCommand("msg Bobby sad to see you go!"); } - @Test - public void shouldHaveHiddenConstructorInSettingsHolderClass() { - // given / when / then - TestHelper.validateHasOnlyPrivateEmptyConstructor(CommandSettingsHolder.class); - } - private void initManager() { manager = new CommandManager(testFolder, bukkitService, geoIpService, commandMigrationService); } diff --git a/src/test/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetrieverTest.java b/src/test/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetrieverTest.java index 1860480f5..35ab9627a 100644 --- a/src/test/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetrieverTest.java +++ b/src/test/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetrieverTest.java @@ -1,7 +1,6 @@ package fr.xephi.authme.settings.properties; import ch.jalu.configme.configurationdata.ConfigurationData; -import fr.xephi.authme.TestHelper; import org.junit.Test; import static org.hamcrest.Matchers.closeTo; @@ -24,9 +23,4 @@ public class AuthMeSettingsRetrieverTest { assertThat((double) configurationData.getProperties().size(), closeTo(182, 10)); } - - @Test - public void shouldHaveHiddenConstructor() { - TestHelper.validateHasOnlyPrivateEmptyConstructor(AuthMeSettingsRetriever.class); - } } 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 d0d741359..178576bc1 100644 --- a/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java @@ -98,13 +98,6 @@ public class SettingsClassConsistencyTest { configData.getProperties(), hasSize((int) totalProperties)); } - @Test - public void shouldHaveHiddenEmptyConstructorOnly() { - for (Class clazz : classes) { - TestHelper.validateHasOnlyPrivateEmptyConstructor(clazz); - } - } - private static boolean isValidConstantField(Field field) { int modifiers = field.getModifiers(); return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers); diff --git a/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java b/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java index 9f60c53af..e6931b082 100644 --- a/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java @@ -1,7 +1,6 @@ package fr.xephi.authme.util; import fr.xephi.authme.ReflectionTestUtils; -import fr.xephi.authme.TestHelper; import org.junit.Test; import java.net.MalformedURLException; @@ -55,12 +54,6 @@ public class ExceptionUtilsTest { assertThat(resultUoe, sameInstance(uoe)); } - @Test - public void shouldHaveHiddenConstructor() { - // given / when / then - TestHelper.validateHasOnlyPrivateEmptyConstructor(ExceptionUtils.class); - } - @Test public void shouldFormatException() { // given diff --git a/src/test/java/fr/xephi/authme/util/FileUtilsTest.java b/src/test/java/fr/xephi/authme/util/FileUtilsTest.java index 91145cc8c..36af67242 100644 --- a/src/test/java/fr/xephi/authme/util/FileUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/FileUtilsTest.java @@ -185,12 +185,6 @@ public class FileUtilsTest { assertThat(dirAsFile.isFile(), equalTo(true)); } - @Test - public void shouldHaveHiddenConstructor() { - TestHelper.validateHasOnlyPrivateEmptyConstructor(FileUtils.class); - } - - @Test public void shouldCreateCurrentTimestampString() { // given / when diff --git a/src/test/java/fr/xephi/authme/util/InternetProtocolUtilsTest.java b/src/test/java/fr/xephi/authme/util/InternetProtocolUtilsTest.java index 02d8872a2..54bc7dcba 100644 --- a/src/test/java/fr/xephi/authme/util/InternetProtocolUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/InternetProtocolUtilsTest.java @@ -1,6 +1,5 @@ package fr.xephi.authme.util; -import fr.xephi.authme.TestHelper; import org.junit.Test; import static org.hamcrest.Matchers.equalTo; @@ -50,10 +49,4 @@ public class InternetProtocolUtilsTest { assertThat(InternetProtocolUtils.isLoopbackAddress("127.0.0.1"), equalTo(true)); assertThat(InternetProtocolUtils.isLoopbackAddress("::1"), equalTo(true)); } - - @Test - public void shouldHavePrivateConstructor() { - // given / when / then - TestHelper.validateHasOnlyPrivateEmptyConstructor(InternetProtocolUtils.class); - } } diff --git a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java index 767276e26..124011c79 100644 --- a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java @@ -5,11 +5,9 @@ import org.bukkit.entity.Player; import org.junit.BeforeClass; import org.junit.Test; -import java.util.UUID; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; /** @@ -36,12 +34,6 @@ public class PlayerUtilsTest { assertThat(result, equalTo(ip)); } - @Test - public void shouldHaveHiddenConstructor() { - // given / when / then - TestHelper.validateHasOnlyPrivateEmptyConstructor(PlayerUtils.class); - } - @Test public void shouldCheckIfIsNpc() { // given diff --git a/src/test/java/fr/xephi/authme/util/RandomStringUtilsTest.java b/src/test/java/fr/xephi/authme/util/RandomStringUtilsTest.java index 1af9851a6..a89b4922d 100644 --- a/src/test/java/fr/xephi/authme/util/RandomStringUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/RandomStringUtilsTest.java @@ -1,6 +1,5 @@ package fr.xephi.authme.util; -import fr.xephi.authme.TestHelper; import org.junit.Test; import java.util.regex.Pattern; @@ -84,11 +83,4 @@ public class RandomStringUtilsTest { // then - throw exception } - - @Test - public void shouldHaveHiddenConstructor() { - // given / when / then - TestHelper.validateHasOnlyPrivateEmptyConstructor(RandomStringUtils.class); - } - } diff --git a/src/test/java/fr/xephi/authme/util/StringUtilsTest.java b/src/test/java/fr/xephi/authme/util/StringUtilsTest.java index 76e7ae754..39a3eb934 100644 --- a/src/test/java/fr/xephi/authme/util/StringUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/StringUtilsTest.java @@ -1,6 +1,5 @@ package fr.xephi.authme.util; -import fr.xephi.authme.TestHelper; import org.junit.Test; import static java.util.Arrays.asList; @@ -77,11 +76,6 @@ public class StringUtilsTest { assertThat(StringUtils.getDifference("test", "something"), greaterThan(0.88)); } - @Test - public void shouldHaveHiddenConstructor() { - TestHelper.validateHasOnlyPrivateEmptyConstructor(StringUtils.class); - } - @Test public void shouldCheckIfHasNeedleInWord() { // given/when/then diff --git a/src/test/java/fr/xephi/authme/util/UtilsTest.java b/src/test/java/fr/xephi/authme/util/UtilsTest.java index 1b1064873..37d52163d 100644 --- a/src/test/java/fr/xephi/authme/util/UtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/UtilsTest.java @@ -55,12 +55,6 @@ public class UtilsTest { assertThat(result.toString(), equalTo(".*?")); } - @Test - public void shouldHavePrivateConstructorOnly() { - // given / when / then - TestHelper.validateHasOnlyPrivateEmptyConstructor(Utils.class); - } - @Test public void shouldLogAndSendMessage() { // given diff --git a/src/test/java/fr/xephi/authme/util/lazytags/TagBuilderTest.java b/src/test/java/fr/xephi/authme/util/lazytags/TagBuilderTest.java index 60b5b68ec..53362b5ff 100644 --- a/src/test/java/fr/xephi/authme/util/lazytags/TagBuilderTest.java +++ b/src/test/java/fr/xephi/authme/util/lazytags/TagBuilderTest.java @@ -1,6 +1,5 @@ package fr.xephi.authme.util.lazytags; -import fr.xephi.authme.TestHelper; import org.junit.Test; import java.util.function.Function; @@ -40,11 +39,4 @@ public class TagBuilderTest { assertThat(tag, instanceOf(DependentTag.class)); assertThat(tag.getValue(24d), equalTo("26.4")); } - - @Test - public void shouldHaveHiddenConstructor() { - // given / when / then - TestHelper.validateHasOnlyPrivateEmptyConstructor(TagBuilder.class); - } - } From 901b9adb8acd5e1effab6090fc095caab9bb280c Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sun, 3 Nov 2019 16:33:39 +0100 Subject: [PATCH 12/14] Github action: remove duplicate test step - `mvn clean package` already runs tests - Add -B switch to skip detailed logging of dependency download progress --- .github/workflows/maven.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0676c7add..b6a309674 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -14,6 +14,4 @@ jobs: with: java-version: 1.8 - name: Build with Maven - run: mvn clean package --file pom.xml - - name: Tests with Maven - run: mvn test --file pom.xml + run: mvn -B clean package --file pom.xml From 51260fd22dda8ed1b8e93776353fb01d4925f447 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sun, 3 Nov 2019 17:38:14 +0100 Subject: [PATCH 13/14] Disable regular Hikari log statements during test execution - Also use mock logger instead of a real one in a few select tests to reduce the log output during tests --- .../AbstractSqlDataSourceResourceClosingTest.java | 14 ++++++-------- .../authme/datasource/SQLiteIntegrationTest.java | 2 +- .../PermissionsManagerInitializationTest.java | 2 +- src/test/resources/simplelogger.properties | 2 ++ 4 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 src/test/resources/simplelogger.properties diff --git a/src/test/java/fr/xephi/authme/datasource/AbstractSqlDataSourceResourceClosingTest.java b/src/test/java/fr/xephi/authme/datasource/AbstractSqlDataSourceResourceClosingTest.java index 1827a93a6..4443c54c7 100644 --- a/src/test/java/fr/xephi/authme/datasource/AbstractSqlDataSourceResourceClosingTest.java +++ b/src/test/java/fr/xephi/authme/datasource/AbstractSqlDataSourceResourceClosingTest.java @@ -9,9 +9,11 @@ import org.junit.runners.Parameterized; import java.lang.reflect.Method; import java.sql.Connection; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import static org.mockito.Mockito.mock; @@ -21,7 +23,7 @@ import static org.mockito.Mockito.mock; public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractResourceClosingTest { /** List of DataSource method names not to test. */ - private static final Set IGNORED_METHODS = ImmutableSet.of("reload", "getType"); + private static final Set IGNORED_METHODS = ImmutableSet.of("reload", "getType", "isCached"); private static Settings settings; @@ -64,12 +66,8 @@ public abstract class AbstractSqlDataSourceResourceClosingTest extends AbstractR /* Get all methods of the DataSource interface, minus the ones in the ignored list. */ private static List getDataSourceMethods() { - List publicMethods = new ArrayList<>(); - for (Method method : DataSource.class.getDeclaredMethods()) { - if (!IGNORED_METHODS.contains(method.getName()) && !method.isSynthetic()) { - publicMethods.add(method); - } - } - return publicMethods; + return Arrays.stream(DataSource.class.getDeclaredMethods()) + .filter(method -> !IGNORED_METHODS.contains(method.getName()) && !method.isSynthetic()) + .collect(Collectors.toList()); } } diff --git a/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java b/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java index bf6e915c6..06e60eeb6 100644 --- a/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java @@ -47,7 +47,7 @@ public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest { TestHelper.returnDefaultsForAllProperties(settings); set(DatabaseSettings.MYSQL_DATABASE, "sqlite-test"); set(DatabaseSettings.MYSQL_TABLE, "authme"); - TestHelper.setRealLogger(); + TestHelper.setupLogger(); Path sqlInitFile = TestHelper.getJarPath(TestHelper.PROJECT_ROOT + "datasource/sql-initialize.sql"); // Note ljacqu 20160221: It appears that we can only run one statement per Statement.execute() so we split diff --git a/src/test/java/fr/xephi/authme/permission/PermissionsManagerInitializationTest.java b/src/test/java/fr/xephi/authme/permission/PermissionsManagerInitializationTest.java index 26b29a83f..9e1c5be6a 100644 --- a/src/test/java/fr/xephi/authme/permission/PermissionsManagerInitializationTest.java +++ b/src/test/java/fr/xephi/authme/permission/PermissionsManagerInitializationTest.java @@ -64,7 +64,7 @@ public class PermissionsManagerInitializationTest { @BeforeClass public static void setUpLogger() { - TestHelper.setRealLogger(); + TestHelper.setupLogger(); } @Before diff --git a/src/test/resources/simplelogger.properties b/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..56bab2197 --- /dev/null +++ b/src/test/resources/simplelogger.properties @@ -0,0 +1,2 @@ +# Suppress INFO statements when a new Hikari pool is being created +org.slf4j.simpleLogger.log.com.zaxxer.hikari=WARN From 108284df8e084992f2efa3b901c20184ec3ff30e Mon Sep 17 00:00:00 2001 From: ljacqu Date: Mon, 4 Nov 2019 12:32:14 +0100 Subject: [PATCH 14/14] Update dependencies as found by dependabot Closes #1933, closes #1934, closes #1935, closes #1936, closes #1937 --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index e6a0175b5..69654b0e0 100644 --- a/pom.xml +++ b/pom.xml @@ -241,7 +241,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.1.2 + 3.2.0 @@ -265,7 +265,7 @@ org.apache.maven.plugins maven-source-plugin - 3.1.0 + 3.2.0 ${project.finalNameBase} @@ -582,7 +582,7 @@ org.slf4j slf4j-simple - 1.7.28 + 1.7.29 true @@ -855,7 +855,7 @@ at.favre.lib bcrypt - 0.8.0 + 0.9.0 true @@ -913,7 +913,7 @@ org.checkerframework checker-qual - 2.11.1 + 3.0.0 test