diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..9bb88d3 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +/.DS_Store diff --git a/pom.xml b/pom.xml index 4e244ec..45b270d 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ 2.0.9 1.20.6-R0.1-SNAPSHOT - 2.4.0-SNAPSHOT + 2.5.4 ${build.version}-SNAPSHOT diff --git a/src/test/java/world/bentobox/bank/BankManagerTest.java b/src/test/java/world/bentobox/bank/BankManagerTest.java index bb1f28c..2ed1271 100644 --- a/src/test/java/world/bentobox/bank/BankManagerTest.java +++ b/src/test/java/world/bentobox/bank/BankManagerTest.java @@ -56,7 +56,7 @@ * */ @RunWith(PowerMockRunner.class) -@PrepareForTest({Bukkit.class, BentoBox.class, DatabaseSetup.class, Util.class}) +@PrepareForTest({ Bukkit.class, BentoBox.class, DatabaseSetup.class, Util.class, IslandsManager.class }) public class BankManagerTest { @Mock @@ -105,6 +105,7 @@ public void setUp() { Whitebox.setInternalState(BentoBox.class, "instance", plugin); PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); + PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS); // The database type has to be created one line before the thenReturn() to work! DatabaseType value = DatabaseType.JSON; when(plugin.getSettings()).thenReturn(pluginSettings); diff --git a/src/test/java/world/bentobox/bank/BankTest.java b/src/test/java/world/bentobox/bank/BankTest.java index 4816c19..303b7aa 100644 --- a/src/test/java/world/bentobox/bank/BankTest.java +++ b/src/test/java/world/bentobox/bank/BankTest.java @@ -68,7 +68,7 @@ @SuppressWarnings("deprecation") @RunWith(PowerMockRunner.class) -@PrepareForTest({Bukkit.class, BentoBox.class, User.class}) +@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, IslandsManager.class }) public class BankTest { private static File jFile; @@ -136,6 +136,7 @@ public static void beforeClass() throws IOException { @Before public void setUp() throws Exception { PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS); + PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS); // Set up plugin Whitebox.setInternalState(BentoBox.class, "instance", plugin); diff --git a/src/test/java/world/bentobox/bank/PhManagerTest.java b/src/test/java/world/bentobox/bank/PhManagerTest.java index fe03767..2158e29 100644 --- a/src/test/java/world/bentobox/bank/PhManagerTest.java +++ b/src/test/java/world/bentobox/bank/PhManagerTest.java @@ -25,6 +25,8 @@ 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; @@ -33,6 +35,7 @@ import world.bentobox.bentobox.api.addons.AddonDescription; import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.user.User; +import world.bentobox.bentobox.database.DatabaseSetup; import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.hooks.VaultHook; import world.bentobox.bentobox.managers.IslandsManager; @@ -44,7 +47,7 @@ * */ @RunWith(PowerMockRunner.class) -@PrepareForTest({Bukkit.class, BentoBox.class}) +@PrepareForTest({ Bukkit.class, BentoBox.class, DatabaseSetup.class, IslandsManager.class }) public class PhManagerTest { // Class under test @@ -73,12 +76,11 @@ public class PhManagerTest { @Mock private PlayersManager plm; - - /** - */ @Before public void setUp() { + PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS); + AddonDescription desc = new AddonDescription.Builder("main", "AcidIsland", "1.0.2").build(); when(gm.getDescription()).thenReturn(desc); when(addon.getPlugin()).thenReturn(plugin); @@ -91,6 +93,7 @@ public void setUp() { when(addon.getVault()).thenReturn(vh); when(addon.getIslands()).thenReturn(im); when(user.getLocation()).thenReturn(location); + when(im.getIslandAt(eq(location))).thenReturn(Optional.of(island)); when(bm.getBalance(eq(island))).thenReturn(new Money(1234.56D)); map = new LinkedHashMap<>();