From 356e4c874ae854ec3cbf101b6574a09966404996 Mon Sep 17 00:00:00 2001 From: utarwyn Date: Thu, 20 Feb 2025 23:49:35 +0100 Subject: [PATCH] Fix few maintainability issues --- README.md | 2 +- .../configuration/LocalizedExceptionTest.java | 4 +-- .../dependency/PlotSquaredDependencyTest.java | 12 ++++---- .../WorldGuard6DependencyTest.java | 9 +++--- .../dependency/WorldGuard7DependencyTest.java | 9 +++--- .../compatibility/CompatibilityHelper.java | 1 + .../endercontainers/AbstractManagerTest.java | 6 ++-- .../endercontainers/EnderContainersTest.java | 10 +++---- .../utarwyn/endercontainers/ManagersTest.java | 8 ++--- .../utarwyn/endercontainers/TestHelper.java | 6 ++-- .../backup/BackupManagerTest.java | 14 ++++----- .../endercontainers/backup/BackupTest.java | 4 +-- .../backup/action/BackupApplyTaskTest.java | 4 +-- .../backup/action/BackupCreateTaskTest.java | 6 ++-- .../backup/action/BackupRemoveTaskTest.java | 4 +-- .../command/CommandManagerTest.java | 8 ++--- .../command/EnderchestCommandTest.java | 18 ++++++------ .../command/MainCommandTest.java | 6 ++-- .../command/ParameterTest.java | 16 +++++----- .../command/backup/CreateCommandTest.java | 6 ++-- .../command/backup/InfoCommandTest.java | 10 +++---- .../command/backup/ListCommandTest.java | 10 +++---- .../command/backup/LoadCommandTest.java | 6 ++-- .../command/backup/RemoveCommandTest.java | 6 ++-- .../command/main/BackupCommandTest.java | 10 +++---- .../command/main/HelpCommandTest.java | 8 ++--- .../command/main/OpenCommandTest.java | 18 ++++++------ .../command/main/ReloadCommandTest.java | 8 ++--- .../command/main/UpdateCommandTest.java | 10 +++---- .../CompatibilityHelperTest.java | 12 ++++---- .../compatibility/ServerVersionTest.java | 6 ++-- .../bukkit/BukkitArmorStandAdapterTest.java | 7 ++--- .../nms/NMSArmorStandAdapterTest.java | 12 ++++---- .../compatibility/nms/NMSUtilTest.java | 4 +-- .../configuration/ConfigurationTest.java | 8 ++--- .../configuration/FilesTest.java | 4 +-- .../database/DatabaseManagerTest.java | 28 +++++++++--------- .../DatabaseSecureCredentialsTest.java | 8 ++--- .../database/DatabaseSetTest.java | 20 ++++++------- .../database/DatabaseTest.java | 24 +++++++-------- .../database/adapter/MySQLAdapterTest.java | 8 ++--- .../database/request/DeleteRequestTest.java | 12 ++++---- .../database/request/SavingRequestTest.java | 14 ++++----- .../dependency/DependenciesManagerTest.java | 20 ++++++------- .../dependency/DependencyTest.java | 2 +- .../resolve/DependencyResolverTest.java | 10 +++---- .../enderchest/EnderChestManagerTest.java | 26 ++++++++--------- .../enderchest/EnderChestTest.java | 14 ++++----- .../enderchest/VanillaEnderChestTest.java | 23 ++++++++------- .../enderchest/context/LoadTaskTest.java | 6 ++-- .../enderchest/context/PlayerContextTest.java | 29 ++++++++++--------- .../enderchest/context/SaveTaskTest.java | 4 +-- .../EnderChestInventoryListenerTest.java | 20 ++++++------- .../listener/EnderChestListenerTest.java | 18 ++++++------ .../hologram/HologramManagerTest.java | 14 ++++----- .../hologram/HologramTest.java | 14 ++------- .../AbstractInventoryHolderTest.java | 16 +++++----- .../inventory/EnderChestInventoryTest.java | 16 +++++----- .../inventory/InventoryManagerTest.java | 24 +++++++-------- .../storage/StorageManagerTest.java | 6 ++-- .../storage/backups/BackupsFlatDataTest.java | 15 +++++----- .../storage/backups/BackupsSQLDataTest.java | 14 ++++----- .../storage/player/PlayerDataTest.java | 4 +-- .../storage/player/PlayerFlatDataTest.java | 14 ++++----- .../storage/player/PlayerSQLDataTest.java | 12 ++++---- .../Base64ItemSerializerTest.java | 4 +-- .../endercontainers/util/PluginMsgTest.java | 14 ++++----- .../util/SemanticVersionTest.java | 12 ++++---- .../endercontainers/util/UpdaterTest.java | 10 +++---- 69 files changed, 384 insertions(+), 383 deletions(-) diff --git a/README.md b/README.md index 34a1c23..f8ef9fd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Works with Bukkit/Spigot 1.8 to 1.21!

- Java CI + Build CI SonarQube Quality gate diff --git a/api/src/test/java/fr/utarwyn/endercontainers/configuration/LocalizedExceptionTest.java b/api/src/test/java/fr/utarwyn/endercontainers/configuration/LocalizedExceptionTest.java index 2c69761..e848667 100644 --- a/api/src/test/java/fr/utarwyn/endercontainers/configuration/LocalizedExceptionTest.java +++ b/api/src/test/java/fr/utarwyn/endercontainers/configuration/LocalizedExceptionTest.java @@ -9,7 +9,7 @@ public class LocalizedExceptionTest { @Test - public void createWithoutParameter() { + void createWithoutParameter() { try { throw new LocalizedException(LocaleKey.CMD_UPDATE); } catch (LocalizedException e) { @@ -19,7 +19,7 @@ public void createWithoutParameter() { } @Test - public void createWithParameters() { + void createWithParameters() { try { throw new LocalizedException(LocaleKey.CMD_NO_UPDATE, Collections.singletonMap("key", "value")); } catch (LocalizedException e) { diff --git a/dependencies/plotsquared/src/test/java/fr/utarwyn/endercontainers/dependency/PlotSquaredDependencyTest.java b/dependencies/plotsquared/src/test/java/fr/utarwyn/endercontainers/dependency/PlotSquaredDependencyTest.java index 009d68c..1f639fb 100644 --- a/dependencies/plotsquared/src/test/java/fr/utarwyn/endercontainers/dependency/PlotSquaredDependencyTest.java +++ b/dependencies/plotsquared/src/test/java/fr/utarwyn/endercontainers/dependency/PlotSquaredDependencyTest.java @@ -31,7 +31,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class PlotSquaredDependencyTest { +class PlotSquaredDependencyTest { private PlotSquaredDependency dependency; @@ -70,7 +70,7 @@ public void setUp() throws ReflectiveOperationException { } @Test - public void invalidateIfPlotProtected() { + void invalidateIfPlotProtected() { try { this.dependency.validateBlockChestOpening(this.block, this.player); fail("should throw block chest opening exception when not in plot"); @@ -81,7 +81,7 @@ public void invalidateIfPlotProtected() { } @Test - public void validateNotInPlot() { + void validateNotInPlot() { try { when(this.plotArea.getPlot(any(com.plotsquared.core.location.Location.class))).thenReturn(null); this.dependency.validateBlockChestOpening(this.block, this.player); @@ -91,7 +91,7 @@ public void validateNotInPlot() { } @Test - public void validateIfOperator() { + void validateIfOperator() { try { when(this.player.isOp()).thenReturn(true); this.dependency.validateBlockChestOpening(this.block, this.player); @@ -101,7 +101,7 @@ public void validateIfOperator() { } @Test - public void validateIfPermGranted() { + void validateIfPermGranted() { try { when(this.plot.isAdded(this.player.getUniqueId())).thenReturn(true); this.dependency.validateBlockChestOpening(this.block, this.player); @@ -111,7 +111,7 @@ public void validateIfPermGranted() { } @Test - public void validateIfNoProtection() { + void validateIfNoProtection() { try { when(this.plot.getFlag(UseFlag.class)).thenReturn(new ArrayList<>()); this.dependency.validateBlockChestOpening(this.block, this.player); diff --git a/dependencies/worldguard6/src/test/java/fr/utarwyn/endercontainers/WorldGuard6DependencyTest.java b/dependencies/worldguard6/src/test/java/fr/utarwyn/endercontainers/WorldGuard6DependencyTest.java index e198b08..df61c41 100644 --- a/dependencies/worldguard6/src/test/java/fr/utarwyn/endercontainers/WorldGuard6DependencyTest.java +++ b/dependencies/worldguard6/src/test/java/fr/utarwyn/endercontainers/WorldGuard6DependencyTest.java @@ -23,7 +23,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class WorldGuard6DependencyTest { +class WorldGuard6DependencyTest { private WorldGuard6Dependency dependency; @@ -49,7 +49,7 @@ public void setUp() { } @Test - public void validateIfOperator() { + void validateIfOperator() { try { when(this.player.isOp()).thenReturn(true); this.dependency.validateBlockChestOpening(this.block, this.player); @@ -59,7 +59,7 @@ public void validateIfOperator() { } @Test - public void validateIfCanBuildSucceed() { + void validateIfCanBuildSucceed() { try { when(this.regionQuery.testBuild(eq(this.block.getLocation()), any(LocalPlayer.class), eq(DefaultFlag.CHEST_ACCESS))) .thenReturn(true); @@ -70,13 +70,14 @@ public void validateIfCanBuildSucceed() { } @Test - public void invalidateIfCanBuildErrored() { + void invalidateIfCanBuildErrored() { try { when(this.regionQuery.testBuild(eq(this.block.getLocation()), any(LocalPlayer.class), eq(DefaultFlag.CHEST_ACCESS))) .thenReturn(false); this.dependency.validateBlockChestOpening(this.block, this.player); fail("should throw block chest opening exception because build is forbidden by WorldGuard"); } catch (BlockChestOpeningException ignored) { + // ignored } } diff --git a/dependencies/worldguard7/src/test/java/fr/utarwyn/endercontainers/dependency/WorldGuard7DependencyTest.java b/dependencies/worldguard7/src/test/java/fr/utarwyn/endercontainers/dependency/WorldGuard7DependencyTest.java index 516aef6..d790bc5 100644 --- a/dependencies/worldguard7/src/test/java/fr/utarwyn/endercontainers/dependency/WorldGuard7DependencyTest.java +++ b/dependencies/worldguard7/src/test/java/fr/utarwyn/endercontainers/dependency/WorldGuard7DependencyTest.java @@ -28,7 +28,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class WorldGuard7DependencyTest { +class WorldGuard7DependencyTest { private static boolean serverReplaced = false; @@ -93,7 +93,7 @@ public void setUp() { } @Test - public void validateIfOperator() { + void validateIfOperator() { try { when(this.player.isOp()).thenReturn(true); this.dependency.validateBlockChestOpening(this.block, this.player); @@ -103,7 +103,7 @@ public void validateIfOperator() { } @Test - public void validateIfCanBuildSucceed() { + void validateIfCanBuildSucceed() { try { when(this.regionQuery.testBuild(any(com.sk89q.worldedit.util.Location.class), eq(this.localPlayer), eq(Flags.CHEST_ACCESS))) .thenReturn(true); @@ -114,13 +114,14 @@ public void validateIfCanBuildSucceed() { } @Test - public void invalidateIfCanBuildErrored() { + void invalidateIfCanBuildErrored() { try { when(this.regionQuery.testBuild(any(com.sk89q.worldedit.util.Location.class), eq(this.localPlayer), eq(Flags.CHEST_ACCESS))) .thenReturn(false); this.dependency.validateBlockChestOpening(this.block, this.player); fail("should throw block chest opening exception because build is forbidden by WorldGuard"); } catch (BlockChestOpeningException ignored) { + // ignored } } diff --git a/plugin/src/main/java/fr/utarwyn/endercontainers/compatibility/CompatibilityHelper.java b/plugin/src/main/java/fr/utarwyn/endercontainers/compatibility/CompatibilityHelper.java index 9b3fbc4..bf1234f 100644 --- a/plugin/src/main/java/fr/utarwyn/endercontainers/compatibility/CompatibilityHelper.java +++ b/plugin/src/main/java/fr/utarwyn/endercontainers/compatibility/CompatibilityHelper.java @@ -59,6 +59,7 @@ public static Sound searchSound(String... names) throws IllegalArgumentException try { return Sound.valueOf(soundKey); } catch (IllegalArgumentException ignored) { + // ignored } } throw new IllegalArgumentException(String.format("no sound found using key %s", names[0])); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/AbstractManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/AbstractManagerTest.java index 52b61f2..e9577fa 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/AbstractManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/AbstractManagerTest.java @@ -15,7 +15,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class AbstractManagerTest { +class AbstractManagerTest { @Mock(answer = Answers.CALLS_REAL_METHODS) private AbstractManager manager; @@ -24,7 +24,7 @@ public class AbstractManagerTest { private EnderContainers plugin; @Test - public void registerListener() { + void registerListener() { Server server = mock(Server.class); PluginManager pluginManager = mock(PluginManager.class); @@ -40,7 +40,7 @@ public void registerListener() { } @Test - public void setPlugin() { + void setPlugin() { Logger logger = mock(Logger.class); when(this.plugin.getLogger()).thenReturn(logger); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/EnderContainersTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/EnderContainersTest.java index 8ad31c2..20de636 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/EnderContainersTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/EnderContainersTest.java @@ -14,7 +14,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class EnderContainersTest { +class EnderContainersTest { private EnderContainers plugin; @@ -34,7 +34,7 @@ public void setUp() throws TestInitializationException { } @Test - public void enable() { + void enable() { Map instances = mock(Map.class); CommandManager commandManager = mock(CommandManager.class); @@ -52,13 +52,13 @@ public void enable() { } @Test - public void disable() { + void disable() { this.plugin.onDisable(); assertThat(Managers.instances).isEmpty(); } @Test - public void executeTaskOnMainThread() { + void executeTaskOnMainThread() { Runnable run = mock(Runnable.class); // Primary thread @@ -74,7 +74,7 @@ public void executeTaskOnMainThread() { } @Test - public void executeTaskOnOtherThread() { + void executeTaskOnOtherThread() { Runnable run = mock(Runnable.class); this.plugin.executeTaskOnOtherThread(run); verify(this.plugin.getServer().getScheduler()).runTaskAsynchronously(this.plugin, run); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/ManagersTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/ManagersTest.java index da5f699..d3ccf4b 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/ManagersTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/ManagersTest.java @@ -11,7 +11,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class ManagersTest { +class ManagersTest { @Mock private AbstractManager manager; @@ -22,7 +22,7 @@ public void setUp() { } @Test - public void register() throws TestInitializationException { + void register() throws TestInitializationException { EnderContainers plugin = TestHelper.getPlugin(); assertThat(Managers.instances).isEmpty(); @@ -39,7 +39,7 @@ public void register() throws TestInitializationException { } @Test - public void get() { + void get() { Managers.instances.put(this.manager.getClass(), this.manager); assertThat(Managers.get(this.manager.getClass())).isNotNull() @@ -55,7 +55,7 @@ public void get() { } @Test - public void reload() { + void reload() { Managers.instances.put(this.manager.getClass(), this.manager); assertThat(Managers.reload(this.manager.getClass())).isTrue(); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/TestHelper.java b/plugin/src/test/java/fr/utarwyn/endercontainers/TestHelper.java index cc63efc..97af9d7 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/TestHelper.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/TestHelper.java @@ -24,14 +24,16 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitTask; -import org.mockito.stubbing.Answer; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Field; import java.net.URL; -import java.util.*; +import java.util.Collections; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; import java.util.logging.Logger; import static org.mockito.Mockito.*; diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/BackupManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/BackupManagerTest.java index 3ebddf4..b219d37 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/BackupManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/BackupManagerTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class BackupManagerTest { +class BackupManagerTest { private BackupManager manager; @@ -30,7 +30,7 @@ public void setUp() { } @Test - public void loadAndGetters() throws TestInitializationException { + void loadAndGetters() throws TestInitializationException { StorageManager storageManager = mock(StorageManager.class); BackupsData storage = mock(BackupsData.class); List backupList = new ArrayList<>(); @@ -43,13 +43,13 @@ public void loadAndGetters() throws TestInitializationException { } @Test - public void unload() { + void unload() { this.manager.unload(); assertThat(this.manager.getStorage()).isNull(); } @Test - public void getBackupByName() throws TestInitializationException { + void getBackupByName() throws TestInitializationException { Backup backup = mock(Backup.class); List backupList = new ArrayList<>(); @@ -63,7 +63,7 @@ public void getBackupByName() throws TestInitializationException { } @Test - public void createBackup() throws TestInitializationException { + void createBackup() throws TestInitializationException { List backupList = new ArrayList<>(); TestHelper.setUpServer(); @@ -87,7 +87,7 @@ public void createBackup() throws TestInitializationException { } @Test - public void applyBackup() throws TestInitializationException { + void applyBackup() throws TestInitializationException { List backupList = new ArrayList<>(); TestHelper.setUpServer(); @@ -110,7 +110,7 @@ public void applyBackup() throws TestInitializationException { } @Test - public void removeBackup() throws TestInitializationException { + void removeBackup() throws TestInitializationException { List backupList = new ArrayList<>(); TestHelper.setUpServer(); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/BackupTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/BackupTest.java index 7337eb7..4f0704f 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/BackupTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/BackupTest.java @@ -6,10 +6,10 @@ import static org.assertj.core.api.Assertions.assertThat; -public class BackupTest { +class BackupTest { @Test - public void backupCreation() { + void backupCreation() { String name = "test"; Timestamp date = new Timestamp(1); String createdBy = "Utarwyn"; diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupApplyTaskTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupApplyTaskTest.java index 4b59874..a14b158 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupApplyTaskTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupApplyTaskTest.java @@ -16,7 +16,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class BackupApplyTaskTest { +class BackupApplyTaskTest { private EnderChestManager enderChestManager; @@ -29,7 +29,7 @@ public void setUp() throws TestInitializationException { } @Test - public void run() throws TestInitializationException { + void run() throws TestInitializationException { EnderContainers plugin = TestHelper.getPlugin(); BackupManager manager = mock(BackupManager.class); Backup backup = mock(Backup.class); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupCreateTaskTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupCreateTaskTest.java index 7b94ebe..cb701e9 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupCreateTaskTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupCreateTaskTest.java @@ -16,7 +16,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class BackupCreateTaskTest { +class BackupCreateTaskTest { private static final String NAME = "TestBackup"; @@ -41,7 +41,7 @@ public void setUp() throws TestInitializationException { } @Test - public void valid() { + void valid() { when(storage.saveNewBackup(any())).thenReturn(true); when(storage.executeStorage(any())).thenReturn(true); @@ -54,7 +54,7 @@ public void valid() { } @Test - public void withStorageError() { + void withStorageError() { // Cannot save the backup when(storage.saveNewBackup(any())).thenReturn(false); when(storage.executeStorage(any())).thenReturn(true); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupRemoveTaskTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupRemoveTaskTest.java index 77a42cd..076db28 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupRemoveTaskTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/backup/action/BackupRemoveTaskTest.java @@ -17,10 +17,10 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class BackupRemoveTaskTest { +class BackupRemoveTaskTest { @Test - public void run() throws TestInitializationException { + void run() throws TestInitializationException { EnderContainers plugin = TestHelper.getPlugin(); BackupManager manager = mock(BackupManager.class); Backup backup = mock(Backup.class); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/CommandManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/CommandManagerTest.java index e1e9fcd..6ee75f5 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/CommandManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/CommandManagerTest.java @@ -19,7 +19,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class CommandManagerTest { +class CommandManagerTest { private static final String NAME = "name"; private static final String ALIAS = "alias"; @@ -42,7 +42,7 @@ public void setUp() throws TestInitializationException { } @Test - public void registerCommand() throws ReflectiveOperationException { + void registerCommand() throws ReflectiveOperationException { CommandMap commandMap = mock(CommandMap.class); registerCommandMap(commandMap); @@ -52,7 +52,7 @@ public void registerCommand() throws ReflectiveOperationException { } @Test - public void unregisterCommand() { + void unregisterCommand() { CommandMap commandMap = new SimpleCommandMap(Bukkit.getServer()); registerCommandMap(commandMap); @@ -72,7 +72,7 @@ public void unregisterCommand() { } @Test - public void cannotUnregisterIfPluginCommand() { + void cannotUnregisterIfPluginCommand() { CommandMap commandMap = new SimpleCommandMap(Bukkit.getServer()); registerCommandMap(commandMap); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/EnderchestCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/EnderchestCommandTest.java index d0ba08a..4e598ce 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/EnderchestCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/EnderchestCommandTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class EnderchestCommandTest extends CommandTestHelper { +class EnderchestCommandTest extends CommandTestHelper { @Mock private EnderChestManager manager; @@ -49,20 +49,20 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { assertThat(this.command.getName()).isEqualTo("enderchest"); assertThat(this.command.getAliases()).containsExactly("ec", "endchest"); } @Test - public void disableInConsole() { + void disableInConsole() { ConsoleCommandSender sender = mock(ConsoleCommandSender.class); this.run(sender); verify(sender).sendMessage(contains("player")); } @Test - public void disabledWorld() { + void disabledWorld() { when(this.player.getWorld().getName()).thenReturn("disabled"); this.run(this.player); verify(this.player).sendMessage(contains("disabled")); @@ -70,14 +70,14 @@ public void disabledWorld() { } @Test - public void openChestListInventory() { + void openChestListInventory() { this.givePermission(this.player); this.run(this.player); verify(this.context).openListInventory(this.player); } @Test - public void openSpecificChestInventory() { + void openSpecificChestInventory() { // With global permission this.givePermission(this.player); this.run(this.player, "10"); @@ -91,7 +91,7 @@ public void openSpecificChestInventory() { } @Test - public void noPermission() { + void noPermission() { // No permission for all chests this.run(this.player); @@ -103,7 +103,7 @@ public void noPermission() { } @Test - public void errorEnderchestNumber() { + void errorEnderchestNumber() { this.givePermission(this.player); this.run(this.player, "-20"); this.run(this.player, "0"); @@ -115,7 +115,7 @@ public void errorEnderchestNumber() { } @Test - public void errorEnderchestNotAccessible() { + void errorEnderchestNotAccessible() { this.givePermission(this.player); when(this.context.openEnderchestInventory(this.player, 4)).thenReturn(false); this.run(this.player, "5"); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/MainCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/MainCommandTest.java index d0c64a2..0dffdc7 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/MainCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/MainCommandTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class MainCommandTest { +class MainCommandTest { private MainCommand command; @@ -31,13 +31,13 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { assertThat(this.command.getName()).isEqualTo("endercontainers"); assertThat(this.command.getAliases()).containsExactly("ecp"); } @Test - public void perform() { + void perform() { this.command.perform(this.player); // Verify that basic informations are sent to the player verify(this.player).sendMessage(contains("Utarwyn")); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/ParameterTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/ParameterTest.java index 2eaed27..e1d6f1c 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/ParameterTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/ParameterTest.java @@ -11,25 +11,25 @@ public class ParameterTest { @Test - public void staticParameters() { + void staticParameters() { assertThat(Parameter.integer()).isNotEqualTo(Parameter.integer()); assertThat(Parameter.string()).isNotEqualTo(Parameter.string()); } @Test - public void isNeeded() { + void isNeeded() { Parameter parameter = Parameter.integer(); assertThat(parameter.isNeeded()).isTrue(); } @Test - public void isCustomCompletions() { + void isCustomCompletions() { Parameter parameter = Parameter.integer(); assertThat(parameter.isCustomCompletions()).isTrue(); } @Test - public void withPlayersCompletions() { + void withPlayersCompletions() { Parameter parameter = Parameter.string(); assertThat(parameter.isCustomCompletions()).isTrue(); @@ -39,7 +39,7 @@ public void withPlayersCompletions() { } @Test - public void withCustomCompletions() { + void withCustomCompletions() { Parameter parameter = Parameter.string(); List completions = Arrays.asList("eza", "123"); @@ -54,13 +54,13 @@ public void withCustomCompletions() { } @Test - public void optional() { + void optional() { Parameter parameter = Parameter.integer(); assertThat(parameter.optional().isNeeded()).isFalse(); } @Test - public void checkValue() { + void checkValue() { Parameter parameter = Parameter.integer(); assertThat(parameter.checkValue("123")).isTrue(); @@ -71,7 +71,7 @@ public void checkValue() { } @Test - public void convertValue() { + void convertValue() { Parameter parameter = Parameter.integer(); assertThat(parameter.convertValue("123")).isEqualTo(123); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/CreateCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/CreateCommandTest.java index 7588ec3..898e099 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/CreateCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/CreateCommandTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class CreateCommandTest { +class CreateCommandTest { @Mock private BackupManager backupManager; @@ -31,14 +31,14 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { CreateCommand command = new CreateCommand(this.backupManager); assertThat(command.manager).isNotNull().isEqualTo(this.backupManager); assertThat(command.getName()).isEqualTo("create"); } @Test - public void noPermission() { + void noPermission() { CreateCommand command = spy(new CreateCommand(this.backupManager)); command.onCommand(this.player, command, null, new String[]{"noperm"}); verify(command, never()).perform(this.player); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/InfoCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/InfoCommandTest.java index d9b02f4..684a3bd 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/InfoCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/InfoCommandTest.java @@ -18,7 +18,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class InfoCommandTest { +class InfoCommandTest { @Mock private BackupManager backupManager; @@ -32,21 +32,21 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { InfoCommand command = new InfoCommand(this.backupManager); assertThat(command.manager).isNotNull().isEqualTo(this.backupManager); assertThat(command.getName()).isEqualTo("info"); } @Test - public void noPermission() { + void noPermission() { InfoCommand command = spy(new InfoCommand(this.backupManager)); command.onCommand(this.player, command, null, new String[]{"noperm"}); verify(command, never()).perform(this.player); } @Test - public void performWithNoBackup() { + void performWithNoBackup() { InfoCommand command = new InfoCommand(this.backupManager); when(player.hasPermission(anyString())).thenReturn(true); @@ -58,7 +58,7 @@ public void performWithNoBackup() { } @Test - public void perform() { + void perform() { InfoCommand command = new InfoCommand(this.backupManager); Optional backup = Optional.of(new Backup("backupname", new Timestamp(System.currentTimeMillis()), "Utarwyn")); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/ListCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/ListCommandTest.java index 273c2db..db06151 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/ListCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/ListCommandTest.java @@ -18,7 +18,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class ListCommandTest { +class ListCommandTest { @Mock private BackupManager backupManager; @@ -32,21 +32,21 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { ListCommand command = new ListCommand(this.backupManager); assertThat(command.manager).isNotNull().isEqualTo(this.backupManager); assertThat(command.getName()).isEqualTo("list"); } @Test - public void noPermission() { + void noPermission() { ListCommand command = spy(new ListCommand(this.backupManager)); command.onCommand(this.player, command, null, new String[]{"noperm"}); verify(command, never()).perform(this.player); } @Test - public void performWithNoBackup() { + void performWithNoBackup() { ListCommand command = new ListCommand(this.backupManager); when(player.hasPermission(anyString())).thenReturn(true); @@ -58,7 +58,7 @@ public void performWithNoBackup() { } @Test - public void perform() { + void perform() { ListCommand command = new ListCommand(this.backupManager); List backups = Arrays.asList( new Backup("backup1", null, "user1"), diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/LoadCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/LoadCommandTest.java index 186773d..508c77d 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/LoadCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/LoadCommandTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class LoadCommandTest { +class LoadCommandTest { @Mock private BackupManager backupManager; @@ -31,14 +31,14 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { LoadCommand command = new LoadCommand(this.backupManager); assertThat(command.manager).isNotNull().isEqualTo(this.backupManager); assertThat(command.getName()).isEqualTo("load"); } @Test - public void noPermission() { + void noPermission() { LoadCommand command = spy(new LoadCommand(this.backupManager)); command.onCommand(this.player, command, null, new String[]{"noperm"}); verify(command, never()).perform(this.player); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/RemoveCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/RemoveCommandTest.java index 63a978a..0bce8ae 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/RemoveCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/backup/RemoveCommandTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class RemoveCommandTest { +class RemoveCommandTest { @Mock private BackupManager backupManager; @@ -31,14 +31,14 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { RemoveCommand command = new RemoveCommand(this.backupManager); assertThat(command.manager).isNotNull().isEqualTo(this.backupManager); assertThat(command.getName()).isEqualTo("remove"); } @Test - public void noPermission() { + void noPermission() { RemoveCommand command = spy(new RemoveCommand(this.backupManager)); command.onCommand(this.player, command, null, new String[]{"noperm"}); verify(command, never()).perform(this.player); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/BackupCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/BackupCommandTest.java index 5535a20..e4c4d2f 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/BackupCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/BackupCommandTest.java @@ -19,7 +19,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class BackupCommandTest extends CommandTestHelper { +class BackupCommandTest extends CommandTestHelper { @Mock private BackupManager manager; @@ -39,12 +39,12 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { assertThat(this.command.getName()).isEqualTo("backup"); } @Test - public void withPermission() { + void withPermission() { when(this.player.hasPermission(anyString())).thenReturn(false); when(this.player.hasPermission("endercontainers.backup.list")).thenReturn(true); when(this.player.hasPermission("endercontainers.backup.remove")).thenReturn(true); @@ -56,14 +56,14 @@ public void withPermission() { } @Test - public void withoutPermission() { + void withoutPermission() { this.run(this.player); verify(this.player).sendMessage(contains("§m/ecp backup list")); verify(this.player).sendMessage(contains("§m/ecp backup remove")); } @Test - public void runSubCommand() { + void runSubCommand() { when(this.player.hasPermission("endercontainers.backup.list")).thenReturn(true); this.run(this.player, "list"); verify(this.player).sendMessage(contains("No backup")); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/HelpCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/HelpCommandTest.java index 9b47afc..46b21a4 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/HelpCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/HelpCommandTest.java @@ -13,7 +13,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class HelpCommandTest extends CommandTestHelper { +class HelpCommandTest extends CommandTestHelper { @Mock private Player player; @@ -24,13 +24,13 @@ public void setUp() { } @Test - public void create() { + void create() { assertThat(this.command.getName()).isEqualTo("help"); assertThat(this.command.getAliases()).containsExactly("h", "?"); } @Test - public void withPermission() { + void withPermission() { when(this.player.hasPermission(anyString())).thenReturn(false); when(this.player.hasPermission("endercontainers.reload")).thenReturn(true); when(this.player.hasPermission("endercontainers.update")).thenReturn(true); @@ -42,7 +42,7 @@ public void withPermission() { } @Test - public void withoutPermission() { + void withoutPermission() { this.run(this.player); verify(this.player).sendMessage(contains("§m/ecp update")); verify(this.player).sendMessage(contains("§m/ecp reload")); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/OpenCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/OpenCommandTest.java index b808682..0be5473 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/OpenCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/OpenCommandTest.java @@ -21,7 +21,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class OpenCommandTest extends CommandTestHelper { +class OpenCommandTest extends CommandTestHelper { @Mock private EnderChestManager manager; @@ -50,19 +50,19 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { assertThat(this.command.getName()).isEqualTo("open"); } @Test - public void disableInConsole() { + void disableInConsole() { ConsoleCommandSender sender = mock(ConsoleCommandSender.class); this.run(sender, "test"); verify(sender).sendMessage(contains("player")); } @Test - public void disabledWorld() { + void disabledWorld() { this.givePermission(this.player); when(this.player.getWorld().getName()).thenReturn("disabled"); @@ -73,14 +73,14 @@ public void disabledWorld() { } @Test - public void openMainChest() { + void openMainChest() { this.givePermission(this.player); this.run(this.player, this.player.getName()); verify(this.context).openListInventory(this.player); } @Test - public void tabCompletion() { + void tabCompletion() { // No completions without permission assertThat(this.tabComplete(this.player, "")).isEmpty(); @@ -92,19 +92,19 @@ public void tabCompletion() { } @Test - public void noPermission() { + void noPermission() { this.run(this.player, "test"); this.verifyNoPerm(this.player); } @Test - public void errorArgumentCount() { + void errorArgumentCount() { this.run(this.player); verify(this.player).sendMessage(contains("argument count")); } @Test - public void errorPlayerNotFound() { + void errorPlayerNotFound() { this.givePermission(this.player); this.run(this.player, "unknown"); verify(this.player).sendMessage(contains("not found")); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/ReloadCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/ReloadCommandTest.java index a708ea2..90577fb 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/ReloadCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/ReloadCommandTest.java @@ -16,7 +16,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class ReloadCommandTest extends CommandTestHelper { +class ReloadCommandTest extends CommandTestHelper { @Mock private Player player; @@ -34,20 +34,20 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { assertThat(this.command.getName()).isEqualTo("reload"); assertThat(this.command.getAliases()).containsExactly("rl"); } @Test - public void successful() { + void successful() { this.givePermission(this.player); this.run(this.player); verify(this.player).sendMessage(contains("reloaded")); } @Test - public void noPermission() { + void noPermission() { this.run(this.player); this.verifyNoPerm(this.player); } diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/UpdateCommandTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/UpdateCommandTest.java index 919e0b5..ea24ad3 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/UpdateCommandTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/command/main/UpdateCommandTest.java @@ -18,7 +18,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class UpdateCommandTest extends CommandTestHelper { +class UpdateCommandTest extends CommandTestHelper { @Mock private Player player; @@ -39,25 +39,25 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { assertThat(this.command.getName()).isEqualTo("update"); } @Test - public void sentByPlayer() { + void sentByPlayer() { this.givePermission(this.player); this.run(this.player); verify(this.updater).notifyPlayer(this.player); } @Test - public void sentByConsole() { + void sentByConsole() { this.run(mock(ConsoleCommandSender.class)); verify(this.updater).notifyConsole(); } @Test - public void noPermission() { + void noPermission() { this.run(this.player); this.verifyNoPerm(this.player); } diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/CompatibilityHelperTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/CompatibilityHelperTest.java index 19c6176..e81426d 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/CompatibilityHelperTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/CompatibilityHelperTest.java @@ -16,7 +16,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class CompatibilityHelperTest { +class CompatibilityHelperTest { @BeforeAll public static void setUpClass() { @@ -24,12 +24,13 @@ public static void setUpClass() { } @Test - public void searchMaterial() { + void searchMaterial() { // null value try { CompatibilityHelper.searchMaterial(null); fail("must reject null values"); } catch (NullPointerException ignored) { + // ignored } // Prepare Bukkit unsafe @@ -41,12 +42,13 @@ public void searchMaterial() { } @Test - public void searchSound() { + void searchSound() { // unknown value try { CompatibilityHelper.searchSound("UNKNOWN_1", "UNKNOWN_2"); fail("must reject unknown values"); } catch (IllegalArgumentException ignored) { + // ignored } // one of provided values is valid @@ -56,7 +58,7 @@ public void searchSound() { } @Test - public void createBukkitArmorStandAdapter() { + void createBukkitArmorStandAdapter() { ServerVersion def = ServerVersion.get(); TestHelper.overrideServerVersion(ServerVersion.V1_20); assertThat(CompatibilityHelper.createArmorStandAdapter()).isInstanceOf(BukkitArmorStandAdapter.class); @@ -64,7 +66,7 @@ public void createBukkitArmorStandAdapter() { } @Test - public void createNMSArmorStandAdapter() { + void createNMSArmorStandAdapter() { ServerVersion def = ServerVersion.get(); TestHelper.overrideServerVersion(ServerVersion.V1_8); assertThat(CompatibilityHelper.createArmorStandAdapter()).isInstanceOf(NMSArmorStandAdapter.class); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/ServerVersionTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/ServerVersionTest.java index e5928b6..8db13a6 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/ServerVersionTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/ServerVersionTest.java @@ -10,7 +10,7 @@ import static org.assertj.core.api.Assertions.assertThat; @ExtendWith(MockitoExtension.class) -public class ServerVersionTest { +class ServerVersionTest { @BeforeEach public void setUpClass() { @@ -18,7 +18,7 @@ public void setUpClass() { } @Test - public void getVersion() { + void getVersion() { // Should retrieve the package of the Server class. // In testing env, the fake server is in a package named v1_15. assertThat(ServerVersion.getBukkitVersion()).isEqualTo("v1_15"); @@ -26,7 +26,7 @@ public void getVersion() { } @Test - public void comparison() { + void comparison() { // Equality assertThat(ServerVersion.is(V1_12)).isFalse(); assertThat(ServerVersion.is(V1_15)).isTrue(); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/bukkit/BukkitArmorStandAdapterTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/bukkit/BukkitArmorStandAdapterTest.java index 18e91eb..33635f3 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/bukkit/BukkitArmorStandAdapterTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/bukkit/BukkitArmorStandAdapterTest.java @@ -15,7 +15,6 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -23,7 +22,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class BukkitArmorStandAdapterTest { +class BukkitArmorStandAdapterTest { private static final String TEXT = "text"; @@ -52,7 +51,7 @@ public void setUp() { } @Test - public void spawnArmorStandFor() throws TestInitializationException { + void spawnArmorStandFor() throws TestInitializationException { doReturn(this.armorStand).when(this.world).spawnEntity(any(Location.class), eq(EntityType.ARMOR_STAND)); this.armorStandAdapter.spawnArmorStandFor(TestHelper.getPlugin(), this.observer, this.location, TEXT); @@ -63,7 +62,7 @@ public void spawnArmorStandFor() throws TestInitializationException { } @Test - public void destroyArmorStandFor() { + void destroyArmorStandFor() { List entities = Arrays.asList(mock(Entity.class), mock(Entity.class)); doReturn(1).when(entities.get(0)).getEntityId(); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/nms/NMSArmorStandAdapterTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/nms/NMSArmorStandAdapterTest.java index 54c4d99..a0784bb 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/nms/NMSArmorStandAdapterTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/nms/NMSArmorStandAdapterTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class NMSArmorStandAdapterTest { +class NMSArmorStandAdapterTest { private static final String TEXT = "text"; @@ -40,13 +40,13 @@ public void setUp() { } @Test - public void spawnArmorStandFor() throws HologramException, ReflectiveOperationException, TestInitializationException { + void spawnArmorStandFor() throws HologramException, ReflectiveOperationException, TestInitializationException { this.armorStandAdapter.spawnArmorStandFor(TestHelper.getPlugin(), this.observer, this.location, TEXT); verify(NMSHologramUtil.get()).spawnHologram(this.location, TEXT, this.observer); } @Test - public void handleErrorWhenSpawningArmorStand() throws ReflectiveOperationException, TestInitializationException { + void handleErrorWhenSpawningArmorStand() throws ReflectiveOperationException, TestInitializationException { doThrow(ReflectiveOperationException.class).when(NMSHologramUtil.get()).spawnHologram(this.location, TEXT, this.observer); try { this.armorStandAdapter.spawnArmorStandFor(TestHelper.getPlugin(), this.observer, this.location, TEXT); @@ -57,21 +57,21 @@ public void handleErrorWhenSpawningArmorStand() throws ReflectiveOperationExcept } @Test - public void destroyArmorStandForOnlineObserver() throws HologramException, ReflectiveOperationException { + void destroyArmorStandForOnlineObserver() throws HologramException, ReflectiveOperationException { doReturn(true).when(this.observer).isOnline(); this.armorStandAdapter.destroyArmorStandFor(this.observer, 1); verify(NMSHologramUtil.get()).destroyEntity(1, this.observer); } @Test - public void doNotDestroyArmorStandForOfflineObserver() throws HologramException, ReflectiveOperationException { + void doNotDestroyArmorStandForOfflineObserver() throws HologramException, ReflectiveOperationException { doReturn(false).when(this.observer).isOnline(); this.armorStandAdapter.destroyArmorStandFor(this.observer, 1); verify(NMSHologramUtil.get(), never()).destroyEntity(1, this.observer); } @Test - public void handleErrorWhenDestroyingArmorStandFor() throws ReflectiveOperationException { + void handleErrorWhenDestroyingArmorStandFor() throws ReflectiveOperationException { doReturn(true).when(this.observer).isOnline(); doThrow(ReflectiveOperationException.class).when(NMSHologramUtil.get()).destroyEntity(10, this.observer); try { diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/nms/NMSUtilTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/nms/NMSUtilTest.java index 515ad19..e93b6d9 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/nms/NMSUtilTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/compatibility/nms/NMSUtilTest.java @@ -17,7 +17,7 @@ public static void setUpClass() { } @Test - public void getNMSClass() { + void getNMSClass() { try { NMSUtil.getNMSClass("Fake", "package1_17"); fail("class retrieving must fail"); @@ -27,7 +27,7 @@ public void getNMSClass() { } @Test - public void getNMSDynamicMethod() throws ReflectiveOperationException { + void getNMSDynamicMethod() throws ReflectiveOperationException { ServerVersion defVersion = ServerVersion.get(); overrideServerVersion(ServerVersion.V1_8); assertThat(NMSUtil.getNMSDynamicMethod(String.class, "toLowerCase", "toUpperCase").invoke("TeSt")).isEqualTo("test"); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/ConfigurationTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/ConfigurationTest.java index 195c2d9..e368c08 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/ConfigurationTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/ConfigurationTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class ConfigurationTest { +class ConfigurationTest { @BeforeAll public static void setUpClass() throws TestInitializationException { @@ -25,7 +25,7 @@ public static void setUpClass() throws TestInitializationException { } @Test - public void loadFromTestFile() throws ConfigLoadingException, TestInitializationException { + void loadFromTestFile() throws ConfigLoadingException, TestInitializationException { Configuration config = new Configuration(TestHelper.getPlugin().getConfig()); assertThat(config.getLocale()).isEqualTo("en"); assertThat(config.getDisabledWorlds()).containsExactly("disabled"); @@ -42,7 +42,7 @@ public void loadFromTestFile() throws ConfigLoadingException, TestInitialization } @Test - public void loadDatabaseSSLValues() throws ConfigLoadingException, TestInitializationException { + void loadDatabaseSSLValues() throws ConfigLoadingException, TestInitializationException { FileConfiguration fileConfiguration = new YamlConfiguration(); fileConfiguration.setDefaults(TestHelper.getPlugin().getConfig()); fileConfiguration.set("mysql.ssl.enabled", true); @@ -56,7 +56,7 @@ public void loadDatabaseSSLValues() throws ConfigLoadingException, TestInitializ } @Test - public void loadValueError() { + void loadValueError() { FileConfiguration fileConfiguration = mock(FileConfiguration.class); // Throw an exception on every string retrieved when(fileConfiguration.isString(any())).thenReturn(true); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/FilesTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/FilesTest.java index ff03702..9a6d405 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/FilesTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/FilesTest.java @@ -10,7 +10,7 @@ import static org.assertj.core.api.Assertions.assertThat; @ExtendWith(MockitoExtension.class) -public class FilesTest { +class FilesTest { @BeforeAll public static void setUpClass() throws TestInitializationException { @@ -18,7 +18,7 @@ public static void setUpClass() throws TestInitializationException { } @Test - public void reload() throws ConfigLoadingException, TestInitializationException { + void reload() throws ConfigLoadingException, TestInitializationException { assertThat(Files.getConfiguration()).isNotNull(); assertThat(Files.getLocale()).isNotNull(); Files.reload(TestHelper.getPlugin()); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseManagerTest.java index 61f2218..79714a2 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseManagerTest.java @@ -28,7 +28,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class DatabaseManagerTest { +class DatabaseManagerTest { private DatabaseManager databaseManager; @@ -63,7 +63,7 @@ public void setUp() throws TestInitializationException, ReflectiveOperationExcep } @Test - public void load() { + void load() { try { this.databaseManager.load(); fail("load must fail because of unknown driver"); @@ -74,13 +74,13 @@ public void load() { } @Test - public void unload() { + void unload() { this.databaseManager.unload(); verify(this.database).close(); } @Test - public void ready() { + void ready() { when(this.database.isRunning()).thenReturn(true); assertThat(this.databaseManager.isReady()).isTrue(); when(this.database.isRunning()).thenReturn(false); @@ -88,7 +88,7 @@ public void ready() { } @Test - public void saveEnderchestInsert() throws SQLException { + void saveEnderchestInsert() throws SQLException { UUID uuid = UUID.randomUUID(); ArgumentCaptor request = ArgumentCaptor.forClass(SavingRequest.class); @@ -99,7 +99,7 @@ public void saveEnderchestInsert() throws SQLException { } @Test - public void saveEnderchestUpdate() throws SQLException { + void saveEnderchestUpdate() throws SQLException { UUID uuid = UUID.randomUUID(); ArgumentCaptor request = ArgumentCaptor.forClass(SavingRequest.class); @@ -110,7 +110,7 @@ public void saveEnderchestUpdate() throws SQLException { } @Test - public void getAllEnderchests() throws SQLException { + void getAllEnderchests() throws SQLException { ArgumentCaptor request = ArgumentCaptor.forClass(SelectRequest.class); when(this.database.execQueryStatement(request.capture())).thenReturn(Collections.singletonList(new DatabaseSet())); assertThat(this.databaseManager.getAllEnderchests()).isNotEmpty().hasSize(1); @@ -118,7 +118,7 @@ public void getAllEnderchests() throws SQLException { } @Test - public void getEnderchestsOf() throws SQLException { + void getEnderchestsOf() throws SQLException { UUID uuid = UUID.randomUUID(); ArgumentCaptor request = ArgumentCaptor.forClass(SelectRequest.class); @@ -128,7 +128,7 @@ public void getEnderchestsOf() throws SQLException { } @Test - public void replaceEnderchests() throws SQLException { + void replaceEnderchests() throws SQLException { List sets = Arrays.asList(new DatabaseSet(), new DatabaseSet()); this.databaseManager.replaceEnderchests(sets); verify(this.database).execUpdateStatement(any(DeleteRequest.class)); @@ -136,7 +136,7 @@ public void replaceEnderchests() throws SQLException { } @Test - public void getBackups() throws SQLException { + void getBackups() throws SQLException { when(this.database.execQueryStatement(any(SelectRequest.class))) .thenReturn(Arrays.asList(new DatabaseSet(), new DatabaseSet())); @@ -144,7 +144,7 @@ public void getBackups() throws SQLException { } @Test - public void getBackup() throws SQLException { + void getBackup() throws SQLException { ArgumentCaptor request = ArgumentCaptor.forClass(SelectRequest.class); when(this.database.execQueryStatement(request.capture())).thenReturn(Collections.singletonList(new DatabaseSet())); @@ -153,7 +153,7 @@ public void getBackup() throws SQLException { } @Test - public void saveBackup() throws SQLException { + void saveBackup() throws SQLException { ArgumentCaptor request = ArgumentCaptor.forClass(SavingRequest.class); this.databaseManager.saveBackup("name", 0L, "data", "Utarwyn"); @@ -163,7 +163,7 @@ public void saveBackup() throws SQLException { } @Test - public void removeExisitingBackup() throws SQLException { + void removeExisitingBackup() throws SQLException { ArgumentCaptor request = ArgumentCaptor.forClass(DeleteRequest.class); DatabaseSet set = new DatabaseSet(); @@ -178,7 +178,7 @@ public void removeExisitingBackup() throws SQLException { } @Test - public void removeUnknownBackup() throws SQLException { + void removeUnknownBackup() throws SQLException { assertThat(this.databaseManager.removeBackup("name")).isFalse(); } diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseSecureCredentialsTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseSecureCredentialsTest.java index 6c23a1e..7b6bb21 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseSecureCredentialsTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseSecureCredentialsTest.java @@ -15,7 +15,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class DatabaseSecureCredentialsTest { +class DatabaseSecureCredentialsTest { private static final String DEFAULT_FILE = "test.p12"; @@ -32,7 +32,7 @@ public void setUp() { } @Test - public void withClientKeystore() { + void withClientKeystore() { // Valid client keystore parameters this.credentials.setClientKeystore(DEFAULT_FILE, DEFAULT_PASSWORD); @@ -58,7 +58,7 @@ public void withClientKeystore() { } @Test - public void withTrustKeystore() { + void withTrustKeystore() { // Also put the client keystore first this.credentials.setClientKeystore(DEFAULT_FILE, DEFAULT_PASSWORD); @@ -84,7 +84,7 @@ public void withTrustKeystore() { } @Test - public void fromConfig() { + void fromConfig() { // From an empty config Configuration configuration = mock(Configuration.class); when(configuration.isMysqlSsl()).thenReturn(false); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseSetTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseSetTest.java index f62689b..dc20146 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseSetTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseSetTest.java @@ -16,9 +16,9 @@ public class DatabaseSetTest { - private final static String KEY = "test"; + private static final String KEY = "test"; - private final static String KEY_UNKNOWN = "unknown"; + private static final String KEY_UNKNOWN = "unknown"; private DatabaseSet set; @@ -28,7 +28,7 @@ public void setUp() { } @Test - public void getString() { + void getString() { // Correct value type this.set.setObject(KEY, "hello world"); assertThat(this.set.getString(KEY)) @@ -43,7 +43,7 @@ public void getString() { } @Test - public void getInteger() { + void getInteger() { // Correct value type this.set.setObject(KEY, 55); assertThat(this.set.getInteger(KEY)).isNotNull().isEqualTo(55); @@ -57,7 +57,7 @@ public void getInteger() { } @Test - public void getTimestamp() { + void getTimestamp() { // Correct value type Timestamp ts = new Timestamp(System.currentTimeMillis()); this.set.setObject(KEY, ts); @@ -72,7 +72,7 @@ public void getTimestamp() { } @Test - public void getKeys() { + void getKeys() { // No keys by default assertThat(this.set.getKeys()).isNotNull().isEmpty(); @@ -86,7 +86,7 @@ public void getKeys() { } @Test - public void getValues() { + void getValues() { // No values by default assertThat(this.set.getValues()).isNotNull().isEmpty(); @@ -100,7 +100,7 @@ public void getValues() { } @Test - public void stringRepresentation() { + void stringRepresentation() { // Default toString assertThat(this.set.toString()).isNotNull() .matches("\\{DatabaseSet #([0-9]+) \\(\\)}"); @@ -116,7 +116,7 @@ public void stringRepresentation() { } @Test - public void equals() { + void equals() { DatabaseSet other = new DatabaseSet(); other.setObject(KEY, "test"); @@ -127,7 +127,7 @@ public void equals() { } @Test - public void resultSetToDatabaseSet() throws SQLException { + void resultSetToDatabaseSet() throws SQLException { ResultSet resultSet = mock(ResultSet.class); ResultSetMetaData metaData = mock(ResultSetMetaData.class); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseTest.java index 8849bc3..f9c0272 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/database/DatabaseTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class DatabaseTest { +class DatabaseTest { @Mock(answer = Answers.CALLS_REAL_METHODS) private Database database; @@ -38,13 +38,13 @@ public void setUp() { } @Test - public void serverUrl() { + void serverUrl() { Database mySQLDatabase = new Database(new MySQLAdapter(), null); assertThat(mySQLDatabase.getServerUrl()).isEqualTo("localhost:3306"); } @Test - public void withSecureCredentials() { + void withSecureCredentials() { DatabaseSecureCredentials credentials = new DatabaseSecureCredentials(); credentials.setClientKeystore("client.p12", "changeit"); credentials.setTrustKeystore("trust.p12", "changeit"); @@ -54,7 +54,7 @@ public void withSecureCredentials() { } @Test - public void initializationErrors() { + void initializationErrors() { // With a MySQL adapter Database mySQLDatabase = new Database(new MySQLAdapter(), null); assertThatExceptionOfType(RuntimeException.class) @@ -65,7 +65,7 @@ public void initializationErrors() { } @Test - public void isRunning() { + void isRunning() { // Not connected if the connection pool is not running when(this.database.source.isRunning()).thenReturn(false); assertThat(this.database.isRunning()).isFalse(); @@ -76,7 +76,7 @@ public void isRunning() { } @Test - public void close() { + void close() { // Can call the close method without a valid opened connection this.database.close(); @@ -87,7 +87,7 @@ public void close() { } @Test - public void getServerVersion() throws SQLException { + void getServerVersion() throws SQLException { Connection connection = mock(Connection.class); DatabaseMetaData metaData = mock(DatabaseMetaData.class); @@ -101,7 +101,7 @@ public void getServerVersion() throws SQLException { } @Test - public void getTables() throws SQLException { + void getTables() throws SQLException { Connection connection = mock(Connection.class); DatabaseMetaData metaData = mock(DatabaseMetaData.class); ResultSet resultSet = mock(ResultSet.class); @@ -117,7 +117,7 @@ public void getTables() throws SQLException { } @Test - public void performSelect() throws SQLException { + void performSelect() throws SQLException { PreparedStatement statement = this.createFakeStatement(); SelectRequest request = this.database.select("any", "field", "here") @@ -129,7 +129,7 @@ public void performSelect() throws SQLException { } @Test - public void performUpdate() throws SQLException { + void performUpdate() throws SQLException { PreparedStatement statement = this.createFakeStatement(); when(statement.executeUpdate()).thenReturn(1); @@ -143,7 +143,7 @@ public void performUpdate() throws SQLException { } @Test - public void performDelete() throws SQLException { + void performDelete() throws SQLException { PreparedStatement statement = this.createFakeStatement(); when(statement.executeUpdate()).thenReturn(1); @@ -157,7 +157,7 @@ public void performDelete() throws SQLException { } @Test - public void performCustomRequest() throws SQLException { + void performCustomRequest() throws SQLException { Statement statement = mock(Statement.class); String request = "SELECT * FROM dual"; diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/database/adapter/MySQLAdapterTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/database/adapter/MySQLAdapterTest.java index 8cbc4e8..2ed66d0 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/database/adapter/MySQLAdapterTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/database/adapter/MySQLAdapterTest.java @@ -12,7 +12,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class MySQLAdapterTest { +class MySQLAdapterTest { private MySQLAdapter adapter; @@ -25,7 +25,7 @@ public void setUp() { } @Test - public void getServerUrl() { + void getServerUrl() { when(this.pluginConfig.getMysqlHost()).thenReturn("localhost"); when(this.pluginConfig.getMysqlPort()).thenReturn(3307); @@ -34,13 +34,13 @@ public void getServerUrl() { } @Test - public void getSourceUrl() { + void getSourceUrl() { assertThat(this.adapter.getSourceUrl("localhost:3307", "database")) .isEqualTo("jdbc:mysql://localhost:3307/database"); } @Test - public void configure() { + void configure() { HikariConfig config = new HikariConfig(); when(this.pluginConfig.getMysqlUser()).thenReturn("username"); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/database/request/DeleteRequestTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/database/request/DeleteRequestTest.java index d63f07f..6e24a87 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/database/request/DeleteRequestTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/database/request/DeleteRequestTest.java @@ -13,7 +13,7 @@ public class DeleteRequestTest { @Test - public void conditions() { + void conditions() { DeleteRequest request1 = new DeleteRequest(null, "`test` = ?"); DeleteRequest request2 = new DeleteRequest(null, "`eaz` > 50", "`test` = ?"); @@ -25,13 +25,13 @@ public void conditions() { } @Test - public void from() { + void from() { DeleteRequest request = new DeleteRequest(null, "`test` = ?").from("data"); assertThat(request.getRequest()).startsWith("DELETE FROM `data`"); } @Test - public void attributes() { + void attributes() { DeleteRequest request1 = new DeleteRequest(null, "test"); DeleteRequest request2 = new DeleteRequest(null, "field = ?", "eza > ?"); request2.attributes(1234, 42.3); @@ -41,7 +41,7 @@ public void attributes() { } @Test - public void execute() throws SQLException { + void execute() throws SQLException { Database database = mock(Database.class); DeleteRequest request = new DeleteRequest(database, "test = ?"); @@ -52,13 +52,13 @@ public void execute() throws SQLException { } @Test - public void withoutCondition() { + void withoutCondition() { DeleteRequest request = new DeleteRequest(null).from("table"); assertThat(request.getRequest()).isEqualTo("DELETE FROM `table`"); } @Test - public void illegalParameters() { + void illegalParameters() { DeleteRequest request = new DeleteRequest(null, "null"); assertThatNullPointerException().isThrownBy(request::getRequest) .withMessage("Table seems to be null") diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/database/request/SavingRequestTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/database/request/SavingRequestTest.java index 7a9d73f..f043923 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/database/request/SavingRequestTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/database/request/SavingRequestTest.java @@ -12,7 +12,7 @@ public class SavingRequestTest { @Test - public void fields() { + void fields() { SavingRequest request1 = new SavingRequest(null, "test"); request1.fields("id", "test").values(null, null); @@ -28,7 +28,7 @@ public void fields() { } @Test - public void values() { + void values() { SavingRequest request1 = new SavingRequest(null, "test"); request1.fields("field1", "field2", "field3").values(null, null, null); @@ -40,7 +40,7 @@ public void values() { } @Test - public void conditions() { + void conditions() { SavingRequest request1 = new SavingRequest(null, "test"); request1.fields("field").values("eza").where("field = ?"); @@ -56,7 +56,7 @@ public void conditions() { } @Test - public void attributes() { + void attributes() { SavingRequest request1 = new SavingRequest(null, "test"); request1.fields("field1", "field2").values("eza", 45); @@ -68,7 +68,7 @@ public void attributes() { } @Test - public void replaceIfExists() { + void replaceIfExists() { SavingRequest request1 = new SavingRequest(null, "test"); request1.fields("field1", "field2").values("eza", 45).replaceIfExists(); @@ -80,7 +80,7 @@ public void replaceIfExists() { } @Test - public void execute() throws SQLException { + void execute() throws SQLException { Database database = mock(Database.class); SavingRequest request = new SavingRequest(database, "test"); @@ -91,7 +91,7 @@ public void execute() throws SQLException { } @Test - public void illegalParameters() { + void illegalParameters() { SavingRequest request1 = new SavingRequest(null, null); SavingRequest request2 = new SavingRequest(null, "test"); SavingRequest request3 = new SavingRequest(null, "test").fields("eza", "aze").values(2); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/DependenciesManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/DependenciesManagerTest.java index 4fe7803..7625f0c 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/DependenciesManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/DependenciesManagerTest.java @@ -24,7 +24,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class DependenciesManagerTest { +class DependenciesManagerTest { private DependenciesManager manager; @@ -40,13 +40,13 @@ public void setUp() throws TestInitializationException { } @Test - public void loadWithoutDependency() { + void loadWithoutDependency() { this.manager.load(); assertThat(this.manager.getDependencies()).isNotNull().isEmpty(); } @Test - public void loadWithDependencies() { + void loadWithDependencies() { this.registerFakePlugin("WorldGuard", "7.6"); this.manager.load(); @@ -59,7 +59,7 @@ public void loadWithDependencies() { } @Test - public void unload() { + void unload() { Dependency dependency = mock(Dependency.class); this.registerFakeDependencies(dependency); @@ -70,7 +70,7 @@ public void unload() { } @Test - public void validateBlockChestOpening() throws BlockChestOpeningException { + void validateBlockChestOpening() throws BlockChestOpeningException { Dependency dep1 = mock(Dependency.class); Dependency dep2 = mock(Dependency.class); Block block = mock(Block.class); @@ -84,7 +84,7 @@ public void validateBlockChestOpening() throws BlockChestOpeningException { } @Test - public void blockChestOpeningException() { + void blockChestOpeningException() { Map parameters = Collections.singletonMap("faction", "test"); BlockChestOpeningException exception1 = new BlockChestOpeningException(); @@ -108,16 +108,16 @@ public void blockChestOpeningException() { * @param version version of the fake plugin */ private void registerFakePlugin(String name, String version) { - PluginManager manager = Bukkit.getServer().getPluginManager(); + PluginManager pluginManager = Bukkit.getServer().getPluginManager(); Plugin plugin = mock(Plugin.class); PluginDescriptionFile descriptionFile = mock(PluginDescriptionFile.class); when(plugin.getName()).thenReturn(name); when(plugin.getDescription()).thenReturn(descriptionFile); when(descriptionFile.getVersion()).thenReturn(version); - when(manager.isPluginEnabled(anyString())).thenReturn(false); - when(manager.isPluginEnabled(name)).thenReturn(true); - when(manager.getPlugin(name)).thenReturn(plugin); + when(pluginManager.isPluginEnabled(anyString())).thenReturn(false); + when(pluginManager.isPluginEnabled(name)).thenReturn(true); + when(pluginManager.getPlugin(name)).thenReturn(plugin); } /** diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/DependencyTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/DependencyTest.java index 69419ad..46f382e 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/DependencyTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/DependencyTest.java @@ -10,7 +10,7 @@ public class DependencyTest { @Test - public void create() { + void create() { Plugin plugin = mock(Plugin.class); Dependency dependency = new DependencyMock(plugin); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/resolve/DependencyResolverTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/resolve/DependencyResolverTest.java index 04bcabd..09bf1c3 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/resolve/DependencyResolverTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/dependency/resolve/DependencyResolverTest.java @@ -18,7 +18,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class DependencyResolverTest { +class DependencyResolverTest { @Mock private PluginManager pluginManager; @@ -41,7 +41,7 @@ public void setUp() { } @Test - public void resolveFailure() { + void resolveFailure() { DependencyResolver resolver = new DependencyResolver(this.pluginManager); // Empty name @@ -65,7 +65,7 @@ public void resolveFailure() { } @Test - public void resolveWithUse() { + void resolveWithUse() { DependencyResolver resolver = new DependencyResolver(this.pluginManager) .name("Plugin").use(DependencyMock.class); @@ -82,7 +82,7 @@ public void resolveWithUse() { } @Test - public void resolveWithMatcher() { + void resolveWithMatcher() { DependencyResolver resolver = new DependencyResolver(this.pluginManager) .name("Plugin").matchVersion("^2.*", Dependency.class); @@ -95,7 +95,7 @@ public void resolveWithMatcher() { } @Test - public void resolvingOrder() { + void resolvingOrder() { DependencyResolver resolver = new DependencyResolver(this.pluginManager) .name("Plugin") .matchAuthor("Utarwyn", DependencyMock.class) diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/EnderChestManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/EnderChestManagerTest.java index e048342..de1ce21 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/EnderChestManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/EnderChestManagerTest.java @@ -27,7 +27,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class EnderChestManagerTest { +class EnderChestManagerTest { private EnderChestManager manager; @@ -44,7 +44,7 @@ public void setUp() { } @Test - public void initialize() throws TestInitializationException { + void initialize() throws TestInitializationException { DependenciesManager dependenciesManager = mock(DependenciesManager.class); InventoryManager inventoryManager = mock(InventoryManager.class); @@ -59,7 +59,7 @@ public void initialize() throws TestInitializationException { } @Test - public void unload() throws TestInitializationException { + void unload() throws TestInitializationException { InventoryManager inventoryManager = mock(InventoryManager.class); PlayerContext context = mock(PlayerContext.class); @@ -77,13 +77,13 @@ public void unload() throws TestInitializationException { } @Test - public void getMaxEnderchests() { + void getMaxEnderchests() { // Max amount of enderchests defined in the test config file assertThat(this.manager.getMaxEnderchests()).isEqualTo(27); } @Test - public void isContextUnused() throws TestInitializationException { + void isContextUnused() throws TestInitializationException { UUID uuid = UUID.randomUUID(); TestHelper.setupManager(this.manager); @@ -100,15 +100,15 @@ public void isContextUnused() throws TestInitializationException { } @Test - public void loadPlayerContext() throws TestInitializationException { + void loadPlayerContext() throws TestInitializationException { // Setup the manager correctly - StorageManager manager = mock(StorageManager.class); + StorageManager storageManager = mock(StorageManager.class); PlayerData storage = mock(PlayerData.class); when(storage.getEnderchestContents(any())).thenReturn(new ConcurrentHashMap<>()); - when(manager.createPlayerDataStorage(any())).thenReturn(storage); + when(storageManager.createPlayerDataStorage(any())).thenReturn(storage); - TestHelper.registerManagers(manager); + TestHelper.registerManagers(storageManager); TestHelper.setupManager(this.manager); Player player = TestHelper.getPlayer(); @@ -127,7 +127,7 @@ public void loadPlayerContext() throws TestInitializationException { } @Test - public void registerPlayerContext() throws TestInitializationException { + void registerPlayerContext() throws TestInitializationException { UUID uuid = UUID.randomUUID(); TestHelper.setupManager(this.manager); @@ -144,7 +144,7 @@ public void registerPlayerContext() throws TestInitializationException { } @Test - public void noDuplicateIfContextLoadingIsLong() throws TestInitializationException { + void noDuplicateIfContextLoadingIsLong() throws TestInitializationException { UUID uuid = UUID.randomUUID(); PlayerContext playerContext = mock(PlayerContext.class); Consumer consumer = mock(Consumer.class); @@ -161,7 +161,7 @@ public void noDuplicateIfContextLoadingIsLong() throws TestInitializationExcepti } @Test - public void savePlayerContext() throws TestInitializationException { + void savePlayerContext() throws TestInitializationException { UUID uuid = UUID.randomUUID(); // Setup the manager correctly @@ -180,7 +180,7 @@ public void savePlayerContext() throws TestInitializationException { } @Test - public void deletePlayerContextIfUnused() throws TestInitializationException { + void deletePlayerContextIfUnused() throws TestInitializationException { UUID uuid = UUID.randomUUID(); // Setup the manager correctly diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/EnderChestTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/EnderChestTest.java index 48988df..e079fc2 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/EnderChestTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/EnderChestTest.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class EnderChestTest { +class EnderChestTest { @Mock private PlayerData storage; @@ -53,7 +53,7 @@ public void setUp() throws TestInitializationException { } @Test - public void initialState() { + void initialState() { assertThat(this.chest.container).isNotNull(); assertThat(this.chest.getNum()).isEqualTo(1); assertThat(this.chest.getRows()).isEqualTo(3); @@ -62,7 +62,7 @@ public void initialState() { } @Test - public void size() { + void size() { // Default size assertThat(this.chest.getSize()).isZero(); assertThat(this.chest.getFillPercentage()).isZero(); @@ -86,7 +86,7 @@ public void size() { } @Test - public void contents() { + void contents() { assertThat(this.chest.getContents()).isNotNull().isEmpty(); // Custom already initialized container @@ -97,7 +97,7 @@ public void contents() { verify(this.storage, times(2)).getEnderchestContents(any()); // With an existing and loaded container - ConcurrentMap fakeContents = new ConcurrentHashMap() {{ + ConcurrentMap fakeContents = new ConcurrentHashMap<>() {{ put(10, new ItemStack(Material.STONE)); put(15, new ItemStack(Material.FIREWORK_ROCKET)); }}; @@ -109,7 +109,7 @@ public void contents() { } @Test - public void accessibility() { + void accessibility() { EnderChest defaultChest = new EnderChest(this.context, 0); // Default behavior @@ -123,7 +123,7 @@ public void accessibility() { } @Test - public void container() { + void container() { this.chest.container = mock(EnderChestInventory.class); Inventory inventory = mock(Inventory.class); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/VanillaEnderChestTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/VanillaEnderChestTest.java index a32d778..d002e20 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/VanillaEnderChestTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/VanillaEnderChestTest.java @@ -21,7 +21,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class VanillaEnderChestTest { +class VanillaEnderChestTest { @Mock private PlayerContext context; @@ -39,7 +39,7 @@ public static void setUpClass() throws TestInitializationException { } @BeforeEach - public void setUp() throws PlayerOfflineLoadException { + public void setUp() { this.player = TestHelper.getPlayer(); lenient().when(this.player.getEnderChest()).thenReturn(inventory); @@ -49,16 +49,16 @@ public void setUp() throws PlayerOfflineLoadException { } @Test - public void initialize() { + void initialize() { assertThat(this.chest.container).isNull(); - assertThat(this.chest.getNum()).isEqualTo(0); + assertThat(this.chest.getNum()).isZero(); assertThat(this.chest.getRows()).isEqualTo(3); assertThat(this.chest.getMaxSize()).isEqualTo(27); assertThat(this.chest.getOwnerAsPlayer()).isEqualTo(this.player); } @Test - public void isContainerUsed() { + void isContainerUsed() { // No viewer when(this.inventory.getViewers()).thenReturn(Collections.emptyList()); assertThat(this.chest.isContainerUsed()).isFalse(); @@ -69,7 +69,7 @@ public void isContainerUsed() { } @Test - public void isUsedBy() { + void isUsedBy() { Player viewer = mock(Player.class); when(this.inventory.getViewers()).thenReturn(Collections.singletonList(viewer)); @@ -78,19 +78,19 @@ public void isUsedBy() { } @Test - public void updateRowCount() { + void updateRowCount() { this.chest.updateRowCount(); assertThat(this.chest.getRows()).isEqualTo(3); } @Test - public void doNotUpdateContainer() { + void doNotUpdateContainer() { this.chest.updateContainer(); assertThat(this.chest.container).isNull(); } @Test - public void getSize() { + void getSize() { // Inventory without owner when(this.context.getOwnerAsObject()).thenReturn(null); assertThat((new VanillaEnderChest(this.context)).getSize()).isZero(); @@ -108,19 +108,20 @@ public void getSize() { } @Test - public void openContainerFor() { + void openContainerFor() { this.chest.openContainerFor(this.player); verify(this.player).openInventory(this.inventory); } @Test - public void unknownPlayer() { + void unknownPlayer() { when(this.context.getOwnerAsObject()).thenReturn(null); this.chest = new VanillaEnderChest(this.context); try { this.chest.loadOfflinePlayer(); } catch (PlayerOfflineLoadException ignored) { + // ignored } assertThat(this.chest.isContainerUsed()).isFalse(); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/LoadTaskTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/LoadTaskTest.java index 5f899f5..75da48c 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/LoadTaskTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/LoadTaskTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class LoadTaskTest { +class LoadTaskTest { private UUID uuid; @@ -54,7 +54,7 @@ public void setUp() throws TestInitializationException { } @Test - public void run() throws TestInitializationException { + void run() throws TestInitializationException { when(playerData.getEnderchestContents(any())).thenReturn(new ConcurrentHashMap<>()); when(this.storageManager.createPlayerDataStorage(any())).thenReturn(playerData); @@ -64,7 +64,7 @@ public void run() throws TestInitializationException { } @Test - public void loadError() throws TestInitializationException { + void loadError() throws TestInitializationException { Logger initialLogger = TestHelper.getPlugin().getLogger(); Logger logger = mock(Logger.class); when(TestHelper.getPlugin().getLogger()).thenReturn(logger); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/PlayerContextTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/PlayerContextTest.java index 72583df..4ce981e 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/PlayerContextTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/PlayerContextTest.java @@ -31,7 +31,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class PlayerContextTest { +class PlayerContextTest { private static final int ENDERCHEST_AMOUNT = 27; @@ -63,33 +63,33 @@ public void setUp() throws TestInitializationException { } @Test - public void create() { + void create() { assertThat(this.context.getOwner()).isEqualTo(this.player.getUniqueId()); assertThat(this.context.getOwnerAsObject()).isEqualTo(this.player); assertThat(this.context.getData()).isEqualTo(this.playerData); } @Test - public void offlineOwner() { + void offlineOwner() { assertThat(new PlayerContext(UUID.randomUUID()).getOwnerAsObject()).isNull(); } @Test - public void getChest() { + void getChest() { assertThat(this.context.getChest(0)).isPresent(); assertThat(this.context.getChest(ENDERCHEST_AMOUNT - 1)).isPresent(); assertThat(this.context.getChest(ENDERCHEST_AMOUNT)).isNotPresent(); } @Test - public void getAccessibleChestCount() { + void getAccessibleChestCount() { assertThat(this.context.getAccessibleChestCount()).isEqualTo(1); when(this.player.hasPermission(anyString())).thenReturn(true); assertThat(this.context.getAccessibleChestCount()).isEqualTo(ENDERCHEST_AMOUNT); } @Test - public void isChestsUnused() { + void isChestsUnused() { assertThat(this.context.isChestsUnused()).isTrue(); when(this.player.getEnderChest().getViewers()).thenReturn(Collections.singletonList(this.player)); @@ -97,7 +97,7 @@ public void isChestsUnused() { } @Test - public void loadOfflinePlayerProfile() throws PlayerOfflineLoadException { + void loadOfflinePlayerProfile() throws PlayerOfflineLoadException { // by default, method can be called but do nothing this.context.loadOfflinePlayerProfile(); @@ -115,17 +115,18 @@ public void loadOfflinePlayerProfile() throws PlayerOfflineLoadException { try { this.context.loadOfflinePlayerProfile(); } catch (PlayerOfflineLoadException ignored) { + // ignored } } @Test - public void openListInventory() { + void openListInventory() { this.context.openListInventory(this.player); assertThatPlayerOpenListInventory(); } @Test - public void openListInventoryWithOneChest() throws TestInitializationException { + void openListInventoryWithOneChest() throws TestInitializationException { // If only 1 chest accessible, but can see other enderchests, so open list inventory TestHelper.overrideConfigurationValue("onlyShowAccessibleEnderchests", false); this.context.openListInventory(this.player); @@ -133,7 +134,7 @@ public void openListInventoryWithOneChest() throws TestInitializationException { } @Test - public void openListInventoryWithOneChestAndOthersAreHidden() throws TestInitializationException { + void openListInventoryWithOneChestAndOthersAreHidden() throws TestInitializationException { // If only 1 chest accessible, open it directly TestHelper.overrideConfigurationValue("onlyShowAccessibleEnderchests", true); this.context.openListInventory(this.player); @@ -141,7 +142,7 @@ public void openListInventoryWithOneChestAndOthersAreHidden() throws TestInitial } @Test - public void openListInventorySound() { + void openListInventorySound() { Block block = mock(Block.class); Location location = mock(Location.class); World world = mock(World.class); @@ -155,7 +156,7 @@ public void openListInventorySound() { } @Test - public void openEnderchestInventory() { + void openEnderchestInventory() { assertThat(this.context.openEnderchestInventory(this.player, 0)).isTrue(); assertThat(this.context.openEnderchestInventory(this.player, 2)).isFalse(); when(this.player.hasPermission(anyString())).thenReturn(true); @@ -164,7 +165,7 @@ public void openEnderchestInventory() { } @Test - public void update() { + void update() { this.context.update(); Optional chest = this.context.getChest(1); assertThat(chest).isPresent(); @@ -172,7 +173,7 @@ public void update() { } @Test - public void save() { + void save() { this.context.save(); verify(this.playerData).saveContext(any()); } diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/SaveTaskTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/SaveTaskTest.java index 38c5c5c..6a058e8 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/SaveTaskTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/context/SaveTaskTest.java @@ -9,7 +9,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class SaveTaskTest { +class SaveTaskTest { private SaveTask task; @@ -22,7 +22,7 @@ public void setUp() { } @Test - public void run() { + void run() { this.task.run(); verify(this.context).save(); } diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/listener/EnderChestInventoryListenerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/listener/EnderChestInventoryListenerTest.java index 4cd49af..83a22c7 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/listener/EnderChestInventoryListenerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/listener/EnderChestInventoryListenerTest.java @@ -31,7 +31,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class EnderChestInventoryListenerTest { +class EnderChestInventoryListenerTest { private EnderChestInventoryListener listener; @@ -77,7 +77,7 @@ public void setUp() throws TestInitializationException { } @Test - public void inventoryClickVanillaChest() { + void inventoryClickVanillaChest() { when(this.inventory.getType()).thenReturn(InventoryType.ENDER_CHEST); InventoryClickEvent event = createInventoryClickEvent(false); @@ -98,7 +98,7 @@ public void inventoryClickVanillaChest() { } @Test - public void inventoryClickEnderChest() { + void inventoryClickEnderChest() { InventoryClickEvent event = createInventoryClickEvent(false); // No item @@ -117,7 +117,7 @@ public void inventoryClickEnderChest() { } @Test - public void inventoryShiftClick() { + void inventoryShiftClick() { InventoryClickEvent event = createInventoryClickEvent(true); // No item @@ -136,7 +136,7 @@ public void inventoryShiftClick() { } @Test - public void inventoryDragVanillaChest() { + void inventoryDragVanillaChest() { when(this.inventory.getType()).thenReturn(InventoryType.ENDER_CHEST); InventoryDragEvent event = createInventoryDragEvent(new HashMap<>()); @@ -157,7 +157,7 @@ public void inventoryDragVanillaChest() { } @Test - public void inventoryDragEnderChest() { + void inventoryDragEnderChest() { InventoryDragEvent event = createInventoryDragEvent(new HashMap<>()); // No item @@ -176,7 +176,7 @@ public void inventoryDragEnderChest() { } @Test - public void inventoryCloseSaveOfflineVanillaChest() { + void inventoryCloseSaveOfflineVanillaChest() { when(this.inventory.getType()).thenReturn(InventoryType.ENDER_CHEST); Player player2 = mock(Player.class); @@ -210,14 +210,14 @@ public void inventoryCloseSaveOfflineVanillaChest() { } @Test - public void inventoryCloseGlobalSound() { + void inventoryCloseGlobalSound() { when(this.inventory.getType()).thenReturn(InventoryType.ENDER_CHEST); this.listener.onInventoryClose(new InventoryCloseEvent(this.inventoryView)); verify(this.world).playSound(this.player.getLocation(), Sound.BLOCK_CHEST_CLOSE, 1f, 1f); } @Test - public void inventoryClosePlayerSound() throws TestInitializationException { + void inventoryClosePlayerSound() throws TestInitializationException { when(this.inventory.getType()).thenReturn(InventoryType.ENDER_CHEST); TestHelper.overrideConfigurationValue("globalSound", false); @@ -226,7 +226,7 @@ public void inventoryClosePlayerSound() throws TestInitializationException { } @Test - public void inventoryCloseUnsupportedActions() { + void inventoryCloseUnsupportedActions() { when(this.inventory.getType()).thenReturn(InventoryType.ENDER_CHEST); InventoryCloseEvent event = new InventoryCloseEvent(this.inventoryView); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/listener/EnderChestListenerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/listener/EnderChestListenerTest.java index f78f986..4ecf680 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/listener/EnderChestListenerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/enderchest/listener/EnderChestListenerTest.java @@ -39,7 +39,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class EnderChestListenerTest { +class EnderChestListenerTest { private EnderChestListener listener; @@ -91,8 +91,8 @@ public void playerInteract() { } @Test - public void playerInteractBlockedByDependency() throws BlockChestOpeningException { - doThrow(new BlockChestOpeningException(LocaleKey.ERR_DEP_FACTIONS, new HashMap() {{ + void playerInteractBlockedByDependency() throws BlockChestOpeningException { + doThrow(new BlockChestOpeningException(LocaleKey.ERR_DEP_FACTIONS, new HashMap<>() {{ put("faction", "awesome_faction"); }})).when(this.dependenciesManager).validateBlockChestOpening(this.block, this.player); @@ -106,7 +106,7 @@ public void playerInteractBlockedByDependency() throws BlockChestOpeningExceptio } @Test - public void playerInteractNoBlockAction() { + void playerInteractNoBlockAction() { // No block registered in this test case this.block = null; @@ -122,7 +122,7 @@ public void playerInteractNoBlockAction() { } @Test - public void playerInteractWrongBlockType() { + void playerInteractWrongBlockType() { when(this.block.getType()).thenReturn(Material.CHEST); PlayerInteractEvent event = this.createInteractEvent(RIGHT_CLICK_BLOCK); this.listener.onPlayerInteract(event); @@ -130,7 +130,7 @@ public void playerInteractWrongBlockType() { } @Test - public void playerInteractWhileSneaking() { + void playerInteractWhileSneaking() { ItemStack item = new ItemStack(Material.STICK); PlayerInventory inventory = mock(PlayerInventory.class); @@ -144,7 +144,7 @@ public void playerInteractWhileSneaking() { } @Test - public void playerInteractDisabledWorld() { + void playerInteractDisabledWorld() { when(this.world.getName()).thenReturn("disabled"); PlayerInteractEvent event = this.createInteractEvent(RIGHT_CLICK_BLOCK); @@ -153,7 +153,7 @@ public void playerInteractDisabledWorld() { } @Test - public void playerLeaveSaveContext() { + void playerLeaveSaveContext() { PlayerQuitEvent event = new PlayerQuitEvent(this.player, ""); this.listener.onPlayerQuit(event); @@ -162,7 +162,7 @@ public void playerLeaveSaveContext() { } @Test - public void worldSaveSaveContext() throws TestInitializationException { + void worldSaveSaveContext() throws TestInitializationException { WorldSaveEvent event = new WorldSaveEvent(this.player.getWorld()); // Do nothing by default diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/hologram/HologramManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/hologram/HologramManagerTest.java index f5a70a8..ad6b9ce 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/hologram/HologramManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/hologram/HologramManagerTest.java @@ -28,7 +28,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class HologramManagerTest { +class HologramManagerTest { private HologramManager manager; @@ -80,7 +80,7 @@ public void tearDown() { } @Test - public void taskTimer() throws TestInitializationException { + void taskTimer() throws TestInitializationException { this.manager.load(); verify(Bukkit.getServer().getScheduler()).runTaskTimer( eq(TestHelper.getPlugin()), eq(this.manager), anyLong(), anyLong() @@ -88,7 +88,7 @@ public void taskTimer() throws TestInitializationException { } @Test - public void unload() { + void unload() { this.manager.load(); this.manager.unload(); assertThat(this.manager.task).isNull(); @@ -96,7 +96,7 @@ public void unload() { } @Test - public void spawnHologram() throws BlockChestOpeningException, TestInitializationException, HologramException { + void spawnHologram() throws BlockChestOpeningException, TestInitializationException, HologramException { assertThat(this.manager.holograms).isNull(); doReturn(5).when(this.armorStandAdapter).spawnArmorStandFor( @@ -121,7 +121,7 @@ public void spawnHologram() throws BlockChestOpeningException, TestInitializatio } @Test - public void disabledByDependency() throws BlockChestOpeningException { + void disabledByDependency() throws BlockChestOpeningException { doThrow(new BlockChestOpeningException()).when(this.dependenciesManager) .validateBlockChestOpening(this.targetedBlock, this.observer); @@ -130,14 +130,14 @@ public void disabledByDependency() throws BlockChestOpeningException { } @Test - public void disabledWorld() { + void disabledWorld() { when(this.observer.getWorld().getName()).thenReturn("disabled"); this.manager.load(); assertThat(this.manager.holograms).isEmpty(); } @Test - public void dispawnHologram() throws HologramException { + void dispawnHologram() throws HologramException { // Spawn hologram after first load this.manager.load(); this.manager.armorStandAdapter = this.armorStandAdapter; diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/hologram/HologramTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/hologram/HologramTest.java index 5477722..ebb6ed6 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/hologram/HologramTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/hologram/HologramTest.java @@ -2,7 +2,6 @@ import fr.utarwyn.endercontainers.TestHelper; import fr.utarwyn.endercontainers.TestInitializationException; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -14,18 +13,11 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class HologramTest { - - private static final String TITLE = "title"; - - private static final Integer ENTITY_ID = 10; +class HologramTest { @Mock private Player observer; - @Mock - private Location location; - @BeforeAll public static void setUpClass() throws TestInitializationException { TestHelper.setUpServer(); @@ -33,8 +25,8 @@ public static void setUpClass() throws TestInitializationException { } @Test - public void observerOnline() throws HologramException { - Hologram hologram = new Hologram(this.observer, ENTITY_ID); + void observerOnline() { + Hologram hologram = new Hologram(this.observer, 10); when(this.observer.isOnline()).thenReturn(true); assertThat(hologram.isObserverOnline()).isTrue(); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/AbstractInventoryHolderTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/AbstractInventoryHolderTest.java index 2722f4a..b506c03 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/AbstractInventoryHolderTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/AbstractInventoryHolderTest.java @@ -19,7 +19,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class AbstractInventoryHolderTest { +class AbstractInventoryHolderTest { @Mock(answer = Answers.CALLS_REAL_METHODS) private AbstractInventoryHolder holder; @@ -33,7 +33,7 @@ public static void setUpClass() { } @Test - public void itemMovingRestricted() { + void itemMovingRestricted() { this.holder.itemMovingRestricted = true; assertThat(this.holder.isItemMovingRestricted()).isTrue(); this.holder.itemMovingRestricted = false; @@ -41,7 +41,7 @@ public void itemMovingRestricted() { } @Test - public void isUsed() { + void isUsed() { // With no inventory assertThat(this.holder.isUsed()).isFalse(); this.holder.inventory = this.inventory; @@ -53,14 +53,14 @@ public void isUsed() { } @Test - public void inventory() { + void inventory() { assertThat(this.holder.inventory).isNull(); this.holder.inventory = this.inventory; assertThat(this.holder.getInventory()).isNotNull().isEqualTo(this.holder.inventory); } @Test - public void reloadInventory() { + void reloadInventory() { int rows = 5; String title = "very long default inventory title"; @@ -89,7 +89,7 @@ public void reloadInventory() { } @Test - public void open() { + void open() { Player player = mock(Player.class); this.holder.inventory = this.inventory; @@ -101,7 +101,7 @@ public void open() { } @Test - public void close() { + void close() { Player player = mock(Player.class); this.holder.inventory = this.inventory; @@ -113,7 +113,7 @@ public void close() { } @Test - public void filledSlotsNb() { + void filledSlotsNb() { this.holder.inventory = this.inventory; when(this.holder.inventory.getContents()).thenReturn(this.getFakeItemList(27)); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/EnderChestInventoryTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/EnderChestInventoryTest.java index 42c1176..f7db545 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/EnderChestInventoryTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/EnderChestInventoryTest.java @@ -29,7 +29,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class EnderChestInventoryTest { +class EnderChestInventoryTest { private EnderChestInventory inventory; @@ -50,14 +50,14 @@ public void setUp() throws TestInitializationException { } @Test - public void prepare() { + void prepare() { // some fake items stored in the chest ItemStack[] containerItems = new ItemStack[27]; ItemStack item1 = new ItemStack(Material.JUKEBOX, 2); ItemStack item2 = new ItemStack(Material.BONE_MEAL, 17); ItemStack item3 = new ItemStack(Material.GOLD_INGOT, 25); - when(this.chest.getContents()).thenReturn(new ConcurrentHashMap() {{ + when(this.chest.getContents()).thenReturn(new ConcurrentHashMap<>() {{ put(4, item1); put(7, item2); put(38, item3); @@ -85,7 +85,7 @@ public void prepare() { } @Test - public void updateContentsFromContainer() { + void updateContentsFromContainer() { // Create fake items for the testing container ItemStack[] itemList = new ItemStack[27]; itemList[2] = new ItemStack(Material.ENDER_CHEST); @@ -93,7 +93,7 @@ public void updateContentsFromContainer() { itemList[9] = new ItemStack(Material.DIRT, 20); // Reload items of the chest - when(this.chest.getContents()).thenReturn(new ConcurrentHashMap() {{ + when(this.chest.getContents()).thenReturn(new ConcurrentHashMap<>() {{ put(1, new ItemStack(Material.DIAMOND, 3)); // This item should be replaced by the one in the fake container: put(9, new ItemStack(Material.GOLDEN_AXE, 1)); @@ -118,7 +118,7 @@ public void updateContentsFromContainer() { } @Test - public void saveOnClose() throws TestInitializationException { + void saveOnClose() throws TestInitializationException { EnderChestManager manager = mock(EnderChestManager.class); Player viewer = mock(Player.class); Location location = mock(Location.class); @@ -148,7 +148,7 @@ public void saveOnClose() throws TestInitializationException { } @Test - public void globalSoundOnClose() { + void globalSoundOnClose() { Player viewer = mock(Player.class); Location location = mock(Location.class); World world = mock(World.class); @@ -161,7 +161,7 @@ public void globalSoundOnClose() { } @Test - public void playerSoundOnClose() throws TestInitializationException { + void playerSoundOnClose() throws TestInitializationException { Player viewer = mock(Player.class); Location location = mock(Location.class); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/InventoryManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/InventoryManagerTest.java index d69fd92..4b52c71 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/InventoryManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/inventory/InventoryManagerTest.java @@ -26,7 +26,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class InventoryManagerTest { +class InventoryManagerTest { private InventoryManager manager; @@ -53,7 +53,7 @@ public void setUp() { } @Test - public void initialize() throws TestInitializationException { + void initialize() throws TestInitializationException { TestHelper.setupManager(this.manager); this.manager.initialize(); @@ -64,7 +64,7 @@ public void initialize() throws TestInitializationException { } @Test - public void inventoryClickInside() { + void inventoryClickInside() { when(this.inventory.getSize()).thenReturn(27); InventoryClickEvent event = new InventoryClickEvent( @@ -86,7 +86,7 @@ public void inventoryClickInside() { } @Test - public void inventoryClickOutside() { + void inventoryClickOutside() { when(this.inventory.getSize()).thenReturn(27); // With an unvalid slot position in the inventory @@ -121,7 +121,7 @@ public void inventoryClickOutside() { } @Test - public void inventoryClickSpectateMode() { + void inventoryClickSpectateMode() { when(this.inventory.getSize()).thenReturn(27); InventoryClickEvent event = new InventoryClickEvent( @@ -137,7 +137,7 @@ public void inventoryClickSpectateMode() { } @Test - public void inventoryClickOtherInventory() { + void inventoryClickOtherInventory() { when(this.inventory.getHolder()).thenReturn(mock(Furnace.class)); InventoryClickEvent event = new InventoryClickEvent( @@ -150,7 +150,7 @@ public void inventoryClickOtherInventory() { } @Test - public void inventoryDragInside() { + void inventoryDragInside() { when(this.inventory.getSize()).thenReturn(27); InventoryDragEvent event = new InventoryDragEvent( @@ -172,7 +172,7 @@ this.inventoryView, null, new ItemStack(Material.STONE), false, } @Test - public void inventoryDragOutside() { + void inventoryDragOutside() { when(this.inventory.getSize()).thenReturn(27); InventoryDragEvent event = new InventoryDragEvent( @@ -195,7 +195,7 @@ this.inventoryView, null, new ItemStack(Material.STONE), false, } @Test - public void inventoryDragSpectateMode() { + void inventoryDragSpectateMode() { when(this.inventory.getSize()).thenReturn(27); InventoryDragEvent event = new InventoryDragEvent( @@ -209,7 +209,7 @@ this.inventoryView, null, new ItemStack(Material.STONE), false, } @Test - public void inventoryDragOtherInventory() { + void inventoryDragOtherInventory() { when(this.inventory.getHolder()).thenReturn(mock(Furnace.class)); InventoryDragEvent event = new InventoryDragEvent( @@ -222,7 +222,7 @@ public void inventoryDragOtherInventory() { } @Test - public void inventoryClose() { + void inventoryClose() { InventoryCloseEvent event = new InventoryCloseEvent(inventoryView); this.manager.onInventoryClose(event); @@ -230,7 +230,7 @@ public void inventoryClose() { } @Test - public void closeAll() { + void closeAll() { Inventory enderchestInv = mock(Inventory.class); InventoryView enderchestView = mock(InventoryView.class); Player player = mock(Player.class); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/StorageManagerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/StorageManagerTest.java index e4130ed..5c9678e 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/StorageManagerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/StorageManagerTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) -public class StorageManagerTest { +class StorageManagerTest { private StorageManager manager; @@ -40,7 +40,7 @@ public void setUp() throws TestInitializationException { } @Test - public void loadFileWrappers() { + void loadFileWrappers() { when(this.databaseManager.isReady()).thenReturn(false); this.manager.load(); @@ -53,7 +53,7 @@ public void loadFileWrappers() { } @Test - public void loadSQLWrappers() { + void loadSQLWrappers() { when(this.databaseManager.isReady()).thenReturn(true); this.manager.load(); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/backups/BackupsFlatDataTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/backups/BackupsFlatDataTest.java index acc2723..fd48fde 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/backups/BackupsFlatDataTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/backups/BackupsFlatDataTest.java @@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.fail; @ExtendWith(MockitoExtension.class) -public class BackupsFlatDataTest { +class BackupsFlatDataTest { private BackupsFlatData data; @@ -74,7 +74,7 @@ public void setUp() throws TestInitializationException, IOException { } @Test - public void load() { + void load() { assertThat(this.data.configuration).isNotNull(); assertThat(this.data.configuration.isConfigurationSection("backups")).isTrue(); @@ -84,7 +84,7 @@ public void load() { } @Test - public void save() { + void save() { this.data.save(); try (Scanner reader = new Scanner(file)) { @@ -98,12 +98,13 @@ public void save() { } @Test - public void saveNewBackup() throws IOException { + void saveNewBackup() throws IOException { FileTime beforeTime = getLastModifiedTime(this.file); try { Thread.sleep(200); } catch (Exception ignored) { + // ignored } assertThat(this.data.saveNewBackup(this.backup)).isTrue(); @@ -114,7 +115,7 @@ public void saveNewBackup() throws IOException { } @Test - public void executeStorage() throws IOException { + void executeStorage() throws IOException { // Prepare test emptyFolder(this.backupFolder); emptyFolder(this.dataFolder); @@ -131,7 +132,7 @@ public void executeStorage() throws IOException { } @Test - public void applyBackup() throws IOException { + void applyBackup() throws IOException { // Prepare test emptyFolder(this.backupFolder); emptyFolder(this.dataFolder); @@ -148,7 +149,7 @@ public void applyBackup() throws IOException { } @Test - public void removeBackup() throws IOException { + void removeBackup() throws IOException { // Prepare test emptyFolder(this.backupFolder); copy(this.fakeFile, this.backupFolder); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/backups/BackupsSQLDataTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/backups/BackupsSQLDataTest.java index b97e651..bf4c5cc 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/backups/BackupsSQLDataTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/backups/BackupsSQLDataTest.java @@ -21,7 +21,7 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class BackupsSQLDataTest { +class BackupsSQLDataTest { private static final Timestamp CURRENT = new Timestamp(new Date().getTime()); @@ -69,7 +69,7 @@ public void setUp() throws TestInitializationException { } @Test - public void load() throws SQLException { + void load() throws SQLException { when(this.databaseManager.getBackups()).thenReturn(Arrays.asList( generateBackupSet(NAME + '1', AUTHOR + '1', ""), generateBackupSet(NAME + '2', AUTHOR + '2', "") @@ -88,12 +88,12 @@ public void load() throws SQLException { } @Test - public void executeStorage() { + void executeStorage() { assertThat(this.data.executeStorage(null)).isTrue(); } @Test - public void saveNewBackup() throws SQLException { + void saveNewBackup() throws SQLException { // Without chest in the database assertThat(this.data.saveNewBackup(backup)).isTrue(); verify(this.databaseManager).saveBackup(NAME, CURRENT.getTime(), "", AUTHOR); @@ -109,7 +109,7 @@ public void saveNewBackup() throws SQLException { } @Test - public void applyBackup() throws SQLException { + void applyBackup() throws SQLException { // No backup found when(this.databaseManager.getBackup(NAME)).thenReturn(Optional.empty()); assertThat(this.data.applyBackup(this.backup)).isFalse(); @@ -124,7 +124,7 @@ public void applyBackup() throws SQLException { } @Test - public void removeBackup() throws SQLException { + void removeBackup() throws SQLException { assertThat(this.data.removeBackup(this.backup)).isFalse(); when(this.databaseManager.removeBackup(NAME)).thenReturn(true); @@ -132,7 +132,7 @@ public void removeBackup() throws SQLException { } @Test - public void withSQLErrors() throws SQLException { + void withSQLErrors() throws SQLException { // Load backup doThrow(SQLException.class).when(this.databaseManager).getBackups(); this.data.load(); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerDataTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerDataTest.java index e58d01c..0246850 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerDataTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerDataTest.java @@ -12,13 +12,13 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class PlayerDataTest { +class PlayerDataTest { @Mock(answer = Answers.CALLS_REAL_METHODS) private PlayerData playerData; @Test - public void saveContext() { + void saveContext() { EnderChest enderchest1 = mock(VanillaEnderChest.class); EnderChest enderchest2 = mock(EnderChest.class); EnderChest enderchest3 = mock(EnderChest.class); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerFlatDataTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerFlatDataTest.java index db2bff1..e8c9c06 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerFlatDataTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerFlatDataTest.java @@ -25,13 +25,13 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class PlayerFlatDataTest { +class PlayerFlatDataTest { private static final UUID TEST_UUID = UUID.fromString("06242f9a-6fcf-4504-b69a-9420da52ee9d"); private static final String VALID = "VALID"; - private static final ConcurrentMap ITEMS = new ConcurrentHashMap() {{ + private static final ConcurrentMap ITEMS = new ConcurrentHashMap<>() {{ put(1, new ItemStack(Material.OAK_BOAT)); }}; @@ -56,12 +56,12 @@ public void setUp() throws TestInitializationException, IOException { } @Test - public void load() { + void load() { assertThat(this.data.configuration).isNotNull(); } @Test - public void save() throws TestInitializationException { + void save() throws TestInitializationException { this.data.configuration.set("check", true); this.data.save(); @@ -78,7 +78,7 @@ public void save() throws TestInitializationException { } @Test - public void getEnderchestContents() throws IOException { + void getEnderchestContents() throws IOException { this.data.configuration.set("enderchests.1.contents", VALID); // valid chest with data @@ -92,7 +92,7 @@ public void getEnderchestContents() throws IOException { } @Test - public void getEnderchestRows() { + void getEnderchestRows() { this.data.configuration.set("enderchests.1.rows", 5); // valid chest with row data @@ -105,7 +105,7 @@ public void getEnderchestRows() { } @Test - public void saveEnderchest() { + void saveEnderchest() { when(this.chest.getNum()).thenReturn(1); when(this.chest.getRows()).thenReturn(4); when(this.chest.getContents()).thenReturn(ITEMS); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerSQLDataTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerSQLDataTest.java index 4ac18b9..4fec080 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerSQLDataTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/player/PlayerSQLDataTest.java @@ -25,11 +25,11 @@ import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) -public class PlayerSQLDataTest { +class PlayerSQLDataTest { private static final String FAKE_DATA = "FAKE_DATA"; - private static final ConcurrentHashMap CONTENTS = new ConcurrentHashMap() {{ + private static final ConcurrentHashMap CONTENTS = new ConcurrentHashMap<>() {{ put(14, new ItemStack(Material.DIRT, 2)); put(26, new ItemStack(Material.DIAMOND, 34)); }}; @@ -67,7 +67,7 @@ public void setUp() throws TestInitializationException, IOException, SQLExceptio } @Test - public void getEnderchestContents() throws SQLException { + void getEnderchestContents() throws SQLException { this.data.load(); this.data.save(); @@ -89,7 +89,7 @@ public void getEnderchestContents() throws SQLException { } @Test - public void getEnderchestRows() { + void getEnderchestRows() { this.data.load(); // Valid chests @@ -104,7 +104,7 @@ public void getEnderchestRows() { } @Test - public void saveNewEnderchest() throws SQLException { + void saveNewEnderchest() throws SQLException { // Insert a new enderchest when(this.chest.getNum()).thenReturn(12); when(this.chest.getRows()).thenReturn(6); @@ -125,7 +125,7 @@ public void saveNewEnderchest() throws SQLException { } @Test - public void saveExistingEnderchest() throws SQLException { + void saveExistingEnderchest() throws SQLException { when(this.chest.getNum()).thenReturn(1); when(this.chest.getRows()).thenReturn(4); when(this.chest.getContents()).thenReturn(CONTENTS); diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/serialization/Base64ItemSerializerTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/serialization/Base64ItemSerializerTest.java index 2168595..3caf863 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/storage/serialization/Base64ItemSerializerTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/storage/serialization/Base64ItemSerializerTest.java @@ -28,7 +28,7 @@ public void setUp() { } @Test - public void serialize() throws IOException { + void serialize() throws IOException { ConcurrentMap map = new ConcurrentHashMap<>(); map.put(1, new ItemStack(Material.OAK_LOG, 10)); map.put(17, new ItemStack(Material.DIRT, 20)); @@ -54,7 +54,7 @@ public void serialize() throws IOException { } @Test - public void deserialize() throws IOException { + void deserialize() throws IOException { ConcurrentMap result = this.serializer.deserialize( "rO0ABXcIAAAAAgAAAAFzcgAab3JnLmJ1a2tpdC51dGlsLmlvLldyYXBwZXLyUEfs8RJvBQIAAUwAA21hcHQAD0" + "xqYXZhL3V0aWwvTWFwO3hwc3IANWNvbS5nb29nbGUuY29tbW9uLmNvbGxlY3QuSW1tdXRhYmxlTWFwJFNlcmlhbGl6ZWRGb3Jt" + diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/util/PluginMsgTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/util/PluginMsgTest.java index 085978e..b805f6f 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/util/PluginMsgTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/util/PluginMsgTest.java @@ -16,7 +16,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(MockitoExtension.class) -public class PluginMsgTest { +class PluginMsgTest { @Mock private Player player; @@ -30,25 +30,25 @@ public static void setUpClass() throws TestInitializationException { } @Test - public void errorMessage() { + void errorMessage() { PluginMsg.errorMessage(this.player, LocaleKey.CMD_NO_UPDATE); verify(this.player).sendMessage(startsWith("§c")); } @Test - public void successMessage() { + void successMessage() { PluginMsg.successMessage(this.player, LocaleKey.CMD_NO_UPDATE); verify(this.player).sendMessage(startsWith("§a")); } @Test - public void infoMessage() { + void infoMessage() { PluginMsg.infoMessage(this.player, LocaleKey.CMD_NO_UPDATE); verify(this.player).sendMessage(startsWith("§7")); } @Test - public void accessDenied() { + void accessDenied() { PluginMsg.accessDenied(this.player); verify(this.player).sendMessage(contains("don't have the permission")); PluginMsg.accessDenied(this.console); @@ -56,13 +56,13 @@ public void accessDenied() { } @Test - public void pluginBar() { + void pluginBar() { PluginMsg.pluginBar(this.console); verify(this.console).sendMessage(contains("EnderContainers")); } @Test - public void endBar() { + void endBar() { PluginMsg.endBar(this.console); verify(this.console).sendMessage(contains("++")); } diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/util/SemanticVersionTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/util/SemanticVersionTest.java index e6f8434..5643318 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/util/SemanticVersionTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/util/SemanticVersionTest.java @@ -14,7 +14,7 @@ public class SemanticVersionTest { @Test - public void construct() { + void construct() { SemanticVersion v1 = new SemanticVersion("2.5.6"); assertThat(v1.getMajor()).isEqualTo(2); assertThat(v1.getMinor()).isEqualTo(5); @@ -29,7 +29,7 @@ public void construct() { } @Test - public void malformed() { + void malformed() { assertThatIllegalArgumentException().isThrownBy(() -> new SemanticVersion("")); assertThatIllegalArgumentException().isThrownBy(() -> new SemanticVersion("2.2")); assertThatIllegalArgumentException().isThrownBy(() -> new SemanticVersion("a.6.7")); @@ -37,7 +37,7 @@ public void malformed() { } @Test - public void compareStableBuild() { + void compareStableBuild() { SemanticVersion v1 = new SemanticVersion("1.0.0"); SemanticVersion v2 = new SemanticVersion("2.0.0"); SemanticVersion v3 = new SemanticVersion("1.1.0"); @@ -49,7 +49,7 @@ public void compareStableBuild() { } @Test - public void compareDevBuild() { + void compareDevBuild() { SemanticVersion vStable = new SemanticVersion("1.1.0"); SemanticVersion vDev = new SemanticVersion("1.1.0-dev"); assertThat(vStable).isGreaterThan(vDev); @@ -60,7 +60,7 @@ public void compareDevBuild() { } @Test - public void equal() { + void equal() { SemanticVersion v1 = new SemanticVersion("2.2.2"); SemanticVersion v2 = new SemanticVersion("2.2.2"); @@ -72,7 +72,7 @@ public void equal() { } @Test - public void string() { + void string() { assertThat(new SemanticVersion("3.3.3")).hasToString("3.3.3"); assertThat(new SemanticVersion("1.3.2-dev")).hasToString("1.3.2-dev"); } diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/util/UpdaterTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/util/UpdaterTest.java index 9f1120b..774ae96 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/util/UpdaterTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/util/UpdaterTest.java @@ -26,7 +26,7 @@ * @since 2.2.1 */ @ExtendWith(MockitoExtension.class) -public class UpdaterTest { +class UpdaterTest { private Updater updater; @@ -57,7 +57,7 @@ public void tearDown() { } @Test - public void withUpdate() { + void withUpdate() { when(this.plugin.getDescription().getVersion()).thenReturn("1.0.0"); this.updater.load(); @@ -67,7 +67,7 @@ public void withUpdate() { } @Test - public void withoutUpdate() { + void withoutUpdate() { String currentVersion = "99.99.99-dev"; when(this.plugin.getDescription().getVersion()).thenReturn(currentVersion); this.updater.load(); @@ -79,7 +79,7 @@ public void withoutUpdate() { } @Test - public void playerJoinUpdateNotification() throws TestInitializationException { + void playerJoinUpdateNotification() throws TestInitializationException { PlayerJoinEvent event = new PlayerJoinEvent(this.player, ""); // Register a fake updater @@ -106,7 +106,7 @@ public void playerJoinUpdateNotification() throws TestInitializationException { } @Test - public void unload() { + void unload() { this.updater.unload(); }