diff --git a/src/test/java/world/bentobox/bank/BankTest.java b/src/test/java/world/bentobox/bank/BankTest.java index 475f325..4816c19 100644 --- a/src/test/java/world/bentobox/bank/BankTest.java +++ b/src/test/java/world/bentobox/bank/BankTest.java @@ -135,6 +135,7 @@ public static void beforeClass() throws IOException { @Before public void setUp() throws Exception { + PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); // Set up plugin Whitebox.setInternalState(BentoBox.class, "instance", plugin); @@ -169,7 +170,6 @@ public void setUp() throws Exception { when(user.getTranslation(anyString())).thenAnswer((Answer) invocation -> invocation.getArgument(0, String.class)); // Server - PowerMockito.mockStatic(Bukkit.class); Server server = mock(Server.class); when(Bukkit.getServer()).thenReturn(server); when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger()); @@ -204,7 +204,6 @@ public void setUp() throws Exception { // Bukkit - PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); when(Bukkit.getScheduler()).thenReturn(scheduler); ItemMeta meta = mock(ItemMeta.class); ItemFactory itemFactory = mock(ItemFactory.class); diff --git a/src/test/java/world/bentobox/bank/commands/admin/AdminBalanceCommandTest.java b/src/test/java/world/bentobox/bank/commands/admin/AdminBalanceCommandTest.java index a15397e..7ecddf3 100644 --- a/src/test/java/world/bentobox/bank/commands/admin/AdminBalanceCommandTest.java +++ b/src/test/java/world/bentobox/bank/commands/admin/AdminBalanceCommandTest.java @@ -13,12 +13,14 @@ import java.util.Collections; +import org.bukkit.Bukkit; import org.bukkit.World; import org.eclipse.jdt.annotation.Nullable; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -45,7 +47,7 @@ * */ @RunWith(PowerMockRunner.class) -@PrepareForTest({BentoBox.class, Util.class}) +@PrepareForTest({ BentoBox.class, Util.class, Bukkit.class }) public class AdminBalanceCommandTest { @Mock @@ -73,6 +75,7 @@ public class AdminBalanceCommandTest { @Before public void setUp() { + PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); // Set up plugin BentoBox plugin = mock(BentoBox.class); Whitebox.setInternalState(BentoBox.class, "instance", plugin); diff --git a/src/test/java/world/bentobox/bank/commands/user/BalanceCommandTest.java b/src/test/java/world/bentobox/bank/commands/user/BalanceCommandTest.java index bd5d754..d214b8e 100644 --- a/src/test/java/world/bentobox/bank/commands/user/BalanceCommandTest.java +++ b/src/test/java/world/bentobox/bank/commands/user/BalanceCommandTest.java @@ -12,12 +12,14 @@ import java.util.Collections; +import org.bukkit.Bukkit; import org.bukkit.World; import org.eclipse.jdt.annotation.Nullable; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -43,7 +45,7 @@ * */ @RunWith(PowerMockRunner.class) -@PrepareForTest({BentoBox.class, Util.class}) +@PrepareForTest({ BentoBox.class, Util.class, Bukkit.class }) public class BalanceCommandTest { @Mock @@ -70,6 +72,7 @@ public class BalanceCommandTest { */ @Before public void setUp() { + PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); // Set up plugin BentoBox plugin = mock(BentoBox.class); Whitebox.setInternalState(BentoBox.class, "instance", plugin); diff --git a/src/test/java/world/bentobox/bank/commands/user/DepositCommandTest.java b/src/test/java/world/bentobox/bank/commands/user/DepositCommandTest.java index 2832d0f..6653cb8 100644 --- a/src/test/java/world/bentobox/bank/commands/user/DepositCommandTest.java +++ b/src/test/java/world/bentobox/bank/commands/user/DepositCommandTest.java @@ -17,12 +17,14 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; +import org.bukkit.Bukkit; import org.bukkit.World; import org.eclipse.jdt.annotation.Nullable; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -50,7 +52,7 @@ * */ @RunWith(PowerMockRunner.class) -@PrepareForTest({BentoBox.class, Util.class}) +@PrepareForTest({ BentoBox.class, Util.class, Bukkit.class }) public class DepositCommandTest { /** @@ -81,6 +83,7 @@ public class DepositCommandTest { */ @Before public void setUp() { + PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); // Set up plugin BentoBox plugin = mock(BentoBox.class); Whitebox.setInternalState(BentoBox.class, "instance", plugin); diff --git a/src/test/java/world/bentobox/bank/commands/user/WithdrawCommandTest.java b/src/test/java/world/bentobox/bank/commands/user/WithdrawCommandTest.java index 90c48c5..96d79f4 100644 --- a/src/test/java/world/bentobox/bank/commands/user/WithdrawCommandTest.java +++ b/src/test/java/world/bentobox/bank/commands/user/WithdrawCommandTest.java @@ -16,12 +16,14 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; +import org.bukkit.Bukkit; import org.bukkit.World; import org.eclipse.jdt.annotation.Nullable; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -47,7 +49,7 @@ * */ @RunWith(PowerMockRunner.class) -@PrepareForTest({BentoBox.class, Util.class}) +@PrepareForTest({ BentoBox.class, Util.class, Bukkit.class }) public class WithdrawCommandTest { /** @@ -79,6 +81,7 @@ public class WithdrawCommandTest { */ @Before public void setUp() { + PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); // Set up plugin BentoBox plugin = mock(BentoBox.class); Whitebox.setInternalState(BentoBox.class, "instance", plugin);