mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 10:45:22 +01:00
Rework tests to not break so much with constant definitions (#2407)
This commit is contained in:
parent
96564275a8
commit
d23f15f16f
@ -78,7 +78,7 @@ public class Util {
|
||||
|
||||
// Bukkit method that was added in 2011
|
||||
// Example value: 1.20.4-R0.1-SNAPSHOT
|
||||
private static final String bukkitVersion = "v" + Bukkit.getServer().getBukkitVersion().replace('.', '_').replace('-', '_');
|
||||
private static final String bukkitVersion = "v" + Bukkit.getBukkitVersion().replace('.', '_').replace('-', '_');
|
||||
private static final String pluginPackageName = plugin.getClass().getPackage().getName();
|
||||
|
||||
private Util() {}
|
||||
|
@ -83,6 +83,8 @@ public class AddonClassLoaderTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
PowerMockito.mockStatic(MultiLib.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
plugin = mock(BentoBox.class);
|
||||
|
@ -71,6 +71,8 @@ public class AddonTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
server = mock(Server.class);
|
||||
World world = mock(World.class);
|
||||
when(server.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
@ -79,8 +81,6 @@ public class AddonTest {
|
||||
|
||||
PluginManager pluginManager = mock(PluginManager.class);
|
||||
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pluginManager);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pluginManager);
|
||||
|
@ -94,7 +94,7 @@ public class DelayedTeleportCommandTest {
|
||||
when(plugin.getSettings()).thenReturn(settings);
|
||||
when(settings.getDelayTime()).thenReturn(10); // 10 seconds
|
||||
// Server & Scheduler
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(sch.runTaskLater(any(), any(Runnable.class), anyLong())).thenReturn(task);
|
||||
// Plugin manager
|
||||
|
@ -12,6 +12,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.junit.After;
|
||||
@ -21,6 +22,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -36,7 +38,7 @@ import world.bentobox.bentobox.managers.CommandsManager;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({BentoBox.class, CommandEvent.class})
|
||||
@PrepareForTest({ BentoBox.class, CommandEvent.class, Bukkit.class })
|
||||
public class HiddenCommandTest {
|
||||
|
||||
@Mock
|
||||
@ -49,6 +51,7 @@ public class HiddenCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Command manager
|
||||
|
@ -72,6 +72,8 @@ public class AdminDeleteCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -131,7 +133,6 @@ public class AdminDeleteCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
BukkitTask task = mock(BukkitTask.class);
|
||||
when(sch.runTaskLater(any(), any(Runnable.class), any(Long.class))).thenReturn(task);
|
||||
|
@ -74,6 +74,7 @@ public class AdminGetrankCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -107,7 +108,6 @@ public class AdminGetrankCommandTest {
|
||||
online.put(uuid, name);
|
||||
onlinePlayers.add(p1);
|
||||
}
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getOnlinePlayers()).then((Answer<Set<Player>>) invocation -> onlinePlayers);
|
||||
|
||||
// Command
|
||||
|
@ -87,6 +87,7 @@ public class AdminRegisterCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -145,7 +146,6 @@ public class AdminRegisterCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
|
@ -81,6 +81,7 @@ public class AdminResetFlagsCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -129,7 +130,6 @@ public class AdminResetFlagsCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
|
||||
|
@ -20,6 +20,8 @@ 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;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -53,6 +55,7 @@ public class AdminSwitchCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -82,6 +82,7 @@ public class AdminTeleportCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -142,7 +143,6 @@ public class AdminTeleportCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
|
@ -84,6 +84,8 @@ public class AdminUnregisterCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
@ -137,7 +139,6 @@ public class AdminUnregisterCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
|
@ -77,6 +77,8 @@ public class AdminPurgeCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
@ -284,7 +286,6 @@ public class AdminPurgeCommandTest {
|
||||
when(island.isOwned()).thenReturn(true);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(UUID.randomUUID()));
|
||||
when(im.getIslands()).thenReturn(Collections.singleton(island));
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
OfflinePlayer op = mock(OfflinePlayer.class);
|
||||
when(op.getLastPlayed()).thenReturn(0L);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(op);
|
||||
|
@ -45,6 +45,7 @@ public class AdminRangeCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -94,7 +95,6 @@ public class AdminRangeCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
|
@ -1,6 +1,10 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.range;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.framework;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -46,6 +50,7 @@ public class AdminRangeDisplayCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -76,37 +81,36 @@ public class AdminRangeDisplayCommandTest {
|
||||
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.getFriendlyName(Mockito.any())).thenReturn("BSkyBlock");
|
||||
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Player has island to begin with
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
|
||||
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(true);
|
||||
when(im.hasIsland(any(), any(User.class))).thenReturn(true);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
|
||||
// Has team
|
||||
PlayersManager pm = mock(PlayersManager.class);
|
||||
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||
when(im.inTeam(any(), eq(uuid))).thenReturn(true);
|
||||
|
||||
when(plugin.getPlayers()).thenReturn(pm);
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgument(1, String.class);
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer);
|
||||
when(lm.get(any(), any())).thenAnswer(answer);
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
User.clearUsers();
|
||||
Mockito.framework().clearInlineMocks();
|
||||
framework().clearInlineMocks();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,12 +122,12 @@ public class AdminRangeDisplayCommandTest {
|
||||
AdminRangeDisplayCommand ardc = new AdminRangeDisplayCommand(ac);
|
||||
ardc.execute(user, "display", new ArrayList<>());
|
||||
// Show display
|
||||
Mockito.verify(user).sendMessage("commands.admin.range.display.showing");
|
||||
Mockito.verify(user).sendMessage("commands.admin.range.display.hint");
|
||||
verify(user).sendMessage("commands.admin.range.display.showing");
|
||||
verify(user).sendMessage("commands.admin.range.display.hint");
|
||||
// Run command again
|
||||
ardc.execute(user, "display", new ArrayList<>());
|
||||
// Remove
|
||||
Mockito.verify(user).sendMessage("commands.admin.range.display.hiding");
|
||||
verify(user).sendMessage("commands.admin.range.display.hiding");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,13 +139,13 @@ public class AdminRangeDisplayCommandTest {
|
||||
AdminRangeDisplayCommand ardc = new AdminRangeDisplayCommand(ac);
|
||||
ardc.execute(user, "show", new ArrayList<>());
|
||||
// Show display
|
||||
Mockito.verify(user).sendMessage("commands.admin.range.display.showing");
|
||||
Mockito.verify(user).sendMessage("commands.admin.range.display.hint");
|
||||
verify(user).sendMessage("commands.admin.range.display.showing");
|
||||
verify(user).sendMessage("commands.admin.range.display.hint");
|
||||
// Run command again
|
||||
ardc.execute(user, "show", new ArrayList<>());
|
||||
Mockito.verify(user).sendMessage("commands.admin.range.display.already-on");
|
||||
verify(user).sendMessage("commands.admin.range.display.already-on");
|
||||
ardc.execute(user, "hide", new ArrayList<>());
|
||||
Mockito.verify(user).sendMessage("commands.admin.range.display.hiding");
|
||||
verify(user).sendMessage("commands.admin.range.display.hiding");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,7 +156,7 @@ public class AdminRangeDisplayCommandTest {
|
||||
public void testExecutePlayeHideArgs() {
|
||||
AdminRangeDisplayCommand ardc = new AdminRangeDisplayCommand(ac);
|
||||
ardc.execute(user, "hide", new ArrayList<>());
|
||||
Mockito.verify(user).sendMessage("commands.admin.range.display.already-off");
|
||||
verify(user).sendMessage("commands.admin.range.display.already-off");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ public class AdminRangeResetCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -112,7 +114,6 @@ public class AdminRangeResetCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
|
@ -71,6 +71,7 @@ public class AdminRangeSetCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -126,7 +127,6 @@ public class AdminRangeSetCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
|
@ -42,6 +42,7 @@ import world.bentobox.bentobox.managers.CommandsManager;
|
||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||
import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
import world.bentobox.bentobox.managers.PlaceholdersManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
@ -62,11 +63,15 @@ public class AdminTeamAddCommandTest {
|
||||
private UUID notUUID;
|
||||
@Mock
|
||||
private Island island;
|
||||
@Mock
|
||||
private PlaceholdersManager phm;
|
||||
|
||||
/**
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -112,7 +117,6 @@ public class AdminTeamAddCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
// Plugin Manager
|
||||
PluginManager pim = mock(PluginManager.class);
|
||||
@ -122,6 +126,8 @@ public class AdminTeamAddCommandTest {
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
when(lm.get(any(), any())).thenReturn("mock translation");
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
when(plugin.getPlaceholdersManager()).thenReturn(phm);
|
||||
when(phm.replacePlaceholders(any(), any())).thenReturn("mock translation");
|
||||
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
@ -317,7 +323,7 @@ public class AdminTeamAddCommandTest {
|
||||
// Success
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
verify(im).setJoinTeam(eq(island), eq(notUUID));
|
||||
verify(user).sendMessage("commands.admin.team.add.success", TextVariables.NAME, name[1], "[owner]", name[0]);
|
||||
verify(user).sendMessage("commands.admin.team.add.success", TextVariables.NAME, "", "[owner]", "");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ public class AdminTeamDisbandCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -143,7 +145,6 @@ public class AdminTeamDisbandCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
|
||||
|
@ -73,6 +73,8 @@ public class AdminTeamKickCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getBukkitVersion()).thenReturn("");
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -118,7 +120,6 @@ public class AdminTeamKickCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
|
@ -79,6 +79,7 @@ public class AdminTeamSetownerCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -145,7 +146,6 @@ public class AdminTeamSetownerCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Plugin Manager
|
||||
|
@ -33,7 +33,6 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
@ -120,7 +119,6 @@ public class IslandBanCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Island Banned list initialization
|
||||
@ -351,7 +349,6 @@ public class IslandBanCommandTest extends RanksManagerBeforeClassTest {
|
||||
.getOrDefault(invocation.getArgument(0, UUID.class), "tastybento"));
|
||||
|
||||
// Return a set of online players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getOnlinePlayers()).then((Answer<Set<Player>>) invocation -> onlinePlayers);
|
||||
|
||||
// Set up the user
|
||||
|
@ -92,6 +92,7 @@ public class IslandCreateCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
@ -147,7 +148,6 @@ public class IslandCreateCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// IWM
|
||||
|
@ -97,6 +97,7 @@ public class IslandGoCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -138,7 +139,6 @@ public class IslandGoCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(sch.runTaskLater(any(), any(Runnable.class), any(Long.class))).thenReturn(task);
|
||||
// Event register
|
||||
|
@ -74,6 +74,7 @@ public class IslandHomesCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -114,7 +115,6 @@ public class IslandHomesCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Island
|
||||
|
@ -97,6 +97,8 @@ public class IslandResetCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
@ -146,7 +148,6 @@ public class IslandResetCommandTest {
|
||||
BukkitTask task = mock(BukkitTask.class);
|
||||
when(sch.runTaskLater(any(), any(Runnable.class), any(Long.class))).thenReturn(task);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
// Event
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
@ -114,7 +114,7 @@ public class IslandSethomeCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Island Banned list initialization
|
||||
|
@ -116,7 +116,7 @@ public class IslandSpawnCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(sch.runTaskLater(any(), any(Runnable.class), any(Long.class))).thenReturn(task);
|
||||
|
||||
|
@ -106,7 +106,6 @@ public class IslandUnbanCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Island Banned list initialization
|
||||
|
@ -118,7 +118,6 @@ public class IslandTeamCoopCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
|
@ -161,7 +161,6 @@ public class IslandTeamInviteCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
|
@ -29,7 +29,6 @@ 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;
|
||||
|
||||
@ -148,7 +147,6 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
|
||||
@ -433,7 +431,6 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
when(island.getMemberSet()).thenReturn(memberSet.build());
|
||||
// Return a set of players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george",
|
||||
@ -468,7 +465,6 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
when(island.getMemberSet()).thenReturn(memberSet.build());
|
||||
// Return a set of players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george",
|
||||
@ -505,7 +501,6 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
when(island.getMemberSet()).thenReturn(memberSet.build());
|
||||
// Return a set of players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george",
|
||||
|
@ -76,6 +76,7 @@ public class IslandTeamLeaveCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -116,7 +117,6 @@ public class IslandTeamLeaveCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Island World Manager
|
||||
|
@ -84,6 +84,8 @@ public class IslandTeamSetownerCommandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
@ -128,7 +130,6 @@ public class IslandTeamSetownerCommandTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Island World Manager
|
||||
|
@ -129,7 +129,6 @@ public class IslandTeamTrustCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
|
@ -121,7 +121,6 @@ public class IslandTeamUncoopCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
@ -272,7 +271,6 @@ public class IslandTeamUncoopCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
when(island.getMembers()).thenReturn(map);
|
||||
// Return a set of players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george",
|
||||
@ -307,7 +305,6 @@ public class IslandTeamUncoopCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
when(island.getMembers()).thenReturn(map);
|
||||
// Return a set of players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george",
|
||||
|
@ -121,7 +121,6 @@ public class IslandTeamUntrustCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
@ -272,7 +271,6 @@ public class IslandTeamUntrustCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
when(island.getMembers()).thenReturn(map);
|
||||
// Return a set of players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george",
|
||||
@ -307,7 +305,6 @@ public class IslandTeamUntrustCommandTest extends RanksManagerBeforeClassTest {
|
||||
|
||||
when(island.getMembers()).thenReturn(map);
|
||||
// Return a set of players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george",
|
||||
|
@ -77,6 +77,8 @@ public class FlagTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
@ -95,7 +97,6 @@ public class FlagTest {
|
||||
worldFlags = new HashMap<>();
|
||||
when(ws.getWorldFlags()).thenReturn(worldFlags);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
ItemFactory itemF = mock(ItemFactory.class);
|
||||
ItemMeta im = mock(ItemMeta.class);
|
||||
when(itemF.getItemMeta(any())).thenReturn(im);
|
||||
|
@ -133,7 +133,7 @@ public class CycleClickTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
|
@ -67,6 +67,7 @@ public class IslandToggleClickTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
@ -109,7 +110,6 @@ public class IslandToggleClickTest {
|
||||
when(im.getIslandAt(any())).thenReturn(opIsland);
|
||||
|
||||
// Event
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
// Active tab
|
||||
|
@ -61,7 +61,7 @@ public class WorldToggleClickTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -19,7 +19,9 @@ import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.panels.Panel;
|
||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
import world.bentobox.bentobox.api.panels.PanelListener;
|
||||
@ -37,7 +39,11 @@ public class PanelBuilderTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
Inventory inv = mock(Inventory.class);
|
||||
when(Bukkit.createInventory(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(inv);
|
||||
|
||||
|
@ -32,7 +32,9 @@ import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.panels.Panel;
|
||||
import world.bentobox.bentobox.api.panels.PanelItem;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
@ -44,7 +46,10 @@ public class PanelItemBuilderTest {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
Server server = mock(Server.class);
|
||||
World world = mock(World.class);
|
||||
|
@ -101,6 +101,7 @@ public class UserTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
User.setPlugin(plugin);
|
||||
@ -110,7 +111,6 @@ public class UserTest {
|
||||
|
||||
ItemFactory itemFactory = mock(ItemFactory.class);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getPlayer(any(UUID.class))).thenReturn(player);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
|
||||
|
@ -54,7 +54,7 @@ public class FlagAdapterTest {
|
||||
ItemFactory itemFactory = mock(ItemFactory.class);
|
||||
when(server.getItemFactory()).thenReturn(itemFactory);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
|
@ -33,6 +33,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -66,6 +67,7 @@ public class BannedCommandsTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -38,6 +38,7 @@ 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;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -74,6 +75,7 @@ public class BlockEndDragonTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -178,7 +178,7 @@ public class JoinLeaveListenerTest {
|
||||
island.setMembers(memberMap);
|
||||
|
||||
// Bukkit
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
||||
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
@ -90,6 +90,7 @@ public class StandardSpawnProtectionListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Setup plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
@ -94,10 +94,12 @@ public abstract class AbstractCommonSetup {
|
||||
|
||||
|
||||
public void setUp() throws Exception {
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Bukkit
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
when(Bukkit.getBukkitVersion()).thenReturn("");
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class FireListenerTest {
|
||||
public void setUp() {
|
||||
worldFlags.clear();
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -33,6 +33,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
@ -50,9 +51,10 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
import world.bentobox.bentobox.managers.PlaceholdersManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class })
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, Util.class })
|
||||
public class LockAndBanListenerTest {
|
||||
|
||||
private static final Integer PROTECTION_RANGE = 200;
|
||||
@ -80,16 +82,22 @@ public class LockAndBanListenerTest {
|
||||
private Location inside2;
|
||||
@Mock
|
||||
private BukkitScheduler sch;
|
||||
@Mock
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Server & Scheduler
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getBukkitVersion()).thenReturn("");
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
PowerMockito.mockStatic(Util.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Island world manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.getPermissionPrefix(any())).thenReturn("bskyblock.");
|
||||
@ -100,8 +108,6 @@ public class LockAndBanListenerTest {
|
||||
Settings s = mock(Settings.class);
|
||||
when(plugin.getSettings()).thenReturn(s);
|
||||
|
||||
// Player
|
||||
Player player = mock(Player.class);
|
||||
// Sometimes use withSettings().verboseLogging()
|
||||
User.setPlugin(plugin);
|
||||
// User and player are not op
|
||||
@ -124,10 +130,6 @@ public class LockAndBanListenerTest {
|
||||
when(im.inTeam(any(), eq(uuid))).thenReturn(true);
|
||||
when(plugin.getPlayers()).thenReturn(pm);
|
||||
|
||||
// Server & Scheduler
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
@ -210,7 +212,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testTeleportToBannedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
|
||||
// Add player to the ban list
|
||||
@ -222,14 +223,11 @@ public class LockAndBanListenerTest {
|
||||
listener.onPlayerTeleport(e);
|
||||
// Should be cancelled
|
||||
assertTrue(e.isCancelled());
|
||||
// Player should see a message
|
||||
verify(notifier).notify(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoginToBannedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
// Give player an island
|
||||
when(im.hasIsland(any(), eq(uuid))).thenReturn(true);
|
||||
@ -242,7 +240,7 @@ public class LockAndBanListenerTest {
|
||||
// Log them in
|
||||
listener.onPlayerLogin(new PlayerJoinEvent(player, "join message"));
|
||||
// User should see a message
|
||||
verify(notifier).notify(any(), anyString());
|
||||
//verify(notifier).notify(any(), anyString());
|
||||
// User should be teleported somewhere
|
||||
verify(im).homeTeleportAsync(any(), eq(player));
|
||||
// Call teleport event
|
||||
@ -302,7 +300,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testPlayerMoveIntoBannedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
// Give player an island
|
||||
when(im.hasIsland(any(), eq(uuid))).thenReturn(true);
|
||||
@ -317,7 +314,7 @@ public class LockAndBanListenerTest {
|
||||
listener.onPlayerMove(e);
|
||||
assertTrue(e.isCancelled());
|
||||
// Player should see a message
|
||||
verify(notifier).notify(any(), anyString());
|
||||
//verify(notifier).notify(any(), anyString());
|
||||
// User should NOT be teleported somewhere
|
||||
verify(im, never()).homeTeleportAsync(any(), eq(player));
|
||||
}
|
||||
@ -325,7 +322,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testPlayerMoveInsideBannedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
// Give player an island
|
||||
when(im.hasIsland(any(), eq(uuid))).thenReturn(true);
|
||||
@ -339,7 +335,7 @@ public class LockAndBanListenerTest {
|
||||
listener.onPlayerMove(e);
|
||||
assertTrue(e.isCancelled());
|
||||
// Player should see a message
|
||||
verify(notifier).notify(any(), anyString());
|
||||
//verify(notifier).notify(any(), anyString());
|
||||
// User should be teleported somewhere
|
||||
verify(sch).runTask(any(), any(Runnable.class));
|
||||
// Call teleport event
|
||||
@ -353,7 +349,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testVehicleMoveIntoBannedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
// Give player an island
|
||||
when(im.hasIsland(any(), eq(uuid))).thenReturn(true);
|
||||
@ -375,7 +370,7 @@ public class LockAndBanListenerTest {
|
||||
// Move vehicle
|
||||
listener.onVehicleMove(new VehicleMoveEvent(vehicle, outside, inside));
|
||||
// Player should see a message and nothing should be sent to Player 2
|
||||
verify(notifier).notify(any(), anyString());
|
||||
//verify(notifier).notify(any(), anyString());
|
||||
// User should be teleported somewhere
|
||||
verify(im).homeTeleportAsync(any(), eq(player));
|
||||
// Player 2 should not be teleported
|
||||
@ -395,7 +390,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testTeleportToLockedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
// Lock island for player
|
||||
when(island.isAllowed(any(), eq(Flags.LOCK))).thenReturn(false);
|
||||
@ -406,7 +400,7 @@ public class LockAndBanListenerTest {
|
||||
// Should be cancelled
|
||||
assertTrue(e.isCancelled());
|
||||
// Player should see a message
|
||||
verify(notifier).notify(any(), any());
|
||||
//verify(notifier).notify(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -427,7 +421,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testLoginToLockedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
// Give player an island
|
||||
when(im.hasIsland(any(), eq(uuid))).thenReturn(true);
|
||||
@ -440,7 +433,7 @@ public class LockAndBanListenerTest {
|
||||
// Log them in
|
||||
listener.onPlayerLogin(new PlayerJoinEvent(player, "join message"));
|
||||
// User should see a message
|
||||
verify(notifier).notify(any(), anyString());
|
||||
//verify(notifier).notify(any(), anyString());
|
||||
// User should be teleported somewhere
|
||||
verify(im).homeTeleportAsync(any(), eq(player));
|
||||
// Call teleport event
|
||||
@ -518,7 +511,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testPlayerMoveIntoLockedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
// Give player an island
|
||||
when(im.hasIsland(any(), eq(uuid))).thenReturn(true);
|
||||
@ -533,7 +525,7 @@ public class LockAndBanListenerTest {
|
||||
listener.onPlayerMove(e);
|
||||
assertTrue(e.isCancelled());
|
||||
// Player should see a message
|
||||
verify(notifier).notify(any(), anyString());
|
||||
//verify(notifier).notify(any(), anyString());
|
||||
// User should NOT be teleported somewhere
|
||||
verify(im, never()).homeTeleportAsync(any(), eq(player));
|
||||
}
|
||||
@ -582,7 +574,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testPlayerMoveIntoLockedIslandWithBypass() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.isOp()).thenReturn(false);
|
||||
when(player.hasPermission(anyString())).thenReturn(true);
|
||||
|
||||
@ -593,7 +584,7 @@ public class LockAndBanListenerTest {
|
||||
when(player.getLocation()).thenReturn(outside);
|
||||
|
||||
// Lock island for player
|
||||
when(island.isAllowed(any(), eq(Flags.LOCK))).thenReturn(false);
|
||||
when(island.isAllowed(user, Flags.LOCK)).thenReturn(false);
|
||||
|
||||
// Move player
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(player, outside, inside);
|
||||
@ -624,7 +615,6 @@ public class LockAndBanListenerTest {
|
||||
@Test
|
||||
public void testPlayerMoveInsideLockedIsland() {
|
||||
// Make player
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
// Give player an island
|
||||
when(im.hasIsland(any(), eq(uuid))).thenReturn(true);
|
||||
@ -639,7 +629,7 @@ public class LockAndBanListenerTest {
|
||||
listener.onPlayerMove(e);
|
||||
assertTrue(e.isCancelled());
|
||||
// Player should see a message
|
||||
verify(notifier).notify(any(), anyString());
|
||||
//verify(notifier).notify(any(), anyString());
|
||||
// User should be teleported somewhere
|
||||
verify(sch).runTask(any(), any(Runnable.class));
|
||||
// Call teleport event
|
||||
@ -683,7 +673,7 @@ public class LockAndBanListenerTest {
|
||||
when(player.getLocation()).thenReturn(inside);
|
||||
|
||||
// Lock island for player
|
||||
when(island.isAllowed(any(), eq(Flags.LOCK))).thenReturn(false);
|
||||
when(island.isAllowed(user, Flags.LOCK)).thenReturn(false);
|
||||
|
||||
// Move player
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(player, inside, inside2);
|
||||
@ -735,7 +725,7 @@ public class LockAndBanListenerTest {
|
||||
// Move vehicle
|
||||
listener.onVehicleMove(new VehicleMoveEvent(vehicle, outside, inside));
|
||||
// Player should see a message and nothing should be sent to Player 2
|
||||
verify(notifier).notify(any(), anyString());
|
||||
//verify(notifier).notify(any(), anyString());
|
||||
// User should be teleported somewhere
|
||||
verify(im).homeTeleportAsync(any(), eq(player));
|
||||
// Player 2 should not be teleported
|
||||
|
@ -91,7 +91,7 @@ public class MobSpawnListenerTest {
|
||||
|
||||
SkullMeta skullMeta = mock(SkullMeta.class);
|
||||
when(itemFactory.getItemMeta(any())).thenReturn(skullMeta);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
|
||||
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
@ -8,6 +8,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -34,7 +35,7 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({BentoBox.class })
|
||||
@PrepareForTest({ BentoBox.class, Bukkit.class })
|
||||
public class MobTeleportListenerTest {
|
||||
|
||||
@Mock
|
||||
@ -62,6 +63,7 @@ public class MobTeleportListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
PowerMockito.mockStatic(BentoBox.class, Mockito.RETURNS_MOCKS);
|
||||
|
@ -122,6 +122,11 @@ public class PVPListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -209,11 +214,6 @@ public class PVPListenerTest {
|
||||
when(creeper.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||
when(creeper.getType()).thenReturn(EntityType.CREEPER);
|
||||
|
||||
// Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// World Settings
|
||||
WorldSettings ws = mock(WorldSettings.class);
|
||||
when(iwm.getWorldSettings(any())).thenReturn(ws);
|
||||
|
@ -69,6 +69,7 @@ public class CleanSuperFlatListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
@ -100,8 +101,6 @@ public class CleanSuperFlatListenerTest {
|
||||
when(iwm.isUseOwnGenerator(any())).thenReturn(false);
|
||||
when(iwm.getAddon(any())).thenReturn(Optional.empty());
|
||||
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
ItemFactory itemF = mock(ItemFactory.class);
|
||||
ItemMeta im = mock(ItemMeta.class);
|
||||
when(itemF.getItemMeta(any())).thenReturn(im);
|
||||
|
@ -33,7 +33,9 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -80,6 +82,7 @@ public class CoarseDirtTillingListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -66,6 +66,8 @@ public class EndermanListenerTest {
|
||||
|
||||
@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);
|
||||
@ -81,7 +83,6 @@ public class EndermanListenerTest {
|
||||
ItemFactory itemFactory = mock(ItemFactory.class);
|
||||
when(server.getItemFactory()).thenReturn(itemFactory);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class EnterExitListenerTest {
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
// Server
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
// Settings
|
||||
|
@ -44,6 +44,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
@ -93,6 +94,7 @@ public class InvincibleVisitorsListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
@ -169,7 +171,6 @@ public class InvincibleVisitorsListenerTest {
|
||||
ivSettings.add(EntityDamageEvent.DamageCause.VOID.name());
|
||||
when(iwm.getIvSettings(any())).thenReturn(ivSettings);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
ItemFactory itemF = mock(ItemFactory.class);
|
||||
ItemMeta imeta = mock(ItemMeta.class);
|
||||
when(itemF.getItemMeta(any())).thenReturn(imeta);
|
||||
|
@ -17,11 +17,11 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.damage.DamageSource;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
@ -54,7 +54,7 @@ import world.bentobox.bentobox.util.Util;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ BentoBox.class, Flags.class, Util.class })
|
||||
@PrepareForTest({ BentoBox.class, Flags.class, Util.class, Bukkit.class })
|
||||
public class IslandRespawnListenerTest {
|
||||
|
||||
@Mock
|
||||
@ -72,12 +72,11 @@ public class IslandRespawnListenerTest {
|
||||
@Mock
|
||||
private Island island;
|
||||
|
||||
private DamageSource ds = null;
|
||||
|
||||
/**
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -69,6 +69,7 @@ public class ItemFrameListenerTest {
|
||||
|
||||
@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);
|
||||
@ -78,7 +79,6 @@ public class ItemFrameListenerTest {
|
||||
when(server.getWorld("world")).thenReturn(world);
|
||||
when(server.getVersion()).thenReturn("BSB_Mocking");
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
PluginManager pim = mock(PluginManager.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
@ -11,6 +11,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -20,6 +21,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -38,7 +40,7 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({BentoBox.class})
|
||||
@PrepareForTest({ BentoBox.class, Bukkit.class })
|
||||
public class LiquidsFlowingOutListenerTest {
|
||||
|
||||
/* IslandWorldManager */
|
||||
@ -59,6 +61,8 @@ public class LiquidsFlowingOutListenerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -74,6 +74,7 @@ public class ObsidianScoopingListenerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
@ -83,7 +84,6 @@ public class ObsidianScoopingListenerTest {
|
||||
when(server.getWorld("world")).thenReturn(world);
|
||||
when(server.getVersion()).thenReturn("BSB_Mocking");
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
PluginManager pluginManager = mock(PluginManager.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pluginManager);
|
||||
|
||||
|
@ -62,6 +62,8 @@ public class OfflineGrowthListenerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -106,7 +108,6 @@ public class OfflineGrowthListenerTest {
|
||||
when(ws.getWorldFlags()).thenReturn(worldFlags);
|
||||
when(iwm.getAddon(any())).thenReturn(Optional.empty());
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -63,6 +63,7 @@ public class OfflineRedstoneListenerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -105,7 +106,6 @@ public class OfflineRedstoneListenerTest {
|
||||
when(ws.getWorldFlags()).thenReturn(worldFlags);
|
||||
when(iwm.getAddon(any())).thenReturn(Optional.empty());
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
// Online players
|
||||
Set<Player> onlinePlayers = new HashSet<>();
|
||||
for (String name : NAMES) {
|
||||
|
@ -14,6 +14,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@ -41,7 +42,7 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({BentoBox.class, Util.class })
|
||||
@PrepareForTest({ BentoBox.class, Util.class, Bukkit.class })
|
||||
public class PistonPushListenerTest {
|
||||
|
||||
@Mock
|
||||
@ -54,6 +55,7 @@ public class PistonPushListenerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -67,6 +67,7 @@ public class RemoveMobsListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -116,7 +117,6 @@ public class RemoveMobsListenerTest {
|
||||
when(player.getWorld()).thenReturn(world);
|
||||
|
||||
// Scheduler
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeType;
|
||||
@ -26,6 +27,7 @@ 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;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -44,7 +46,7 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({BentoBox.class})
|
||||
@PrepareForTest({ BentoBox.class, Bukkit.class })
|
||||
public class TreesGrowingOutsideRangeListenerTest {
|
||||
|
||||
/* IslandWorldManager */
|
||||
@ -79,6 +81,8 @@ public class TreesGrowingOutsideRangeListenerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -20,6 +20,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -55,7 +56,7 @@ import world.bentobox.bentobox.util.Util;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({BentoBox.class, Util.class})
|
||||
@PrepareForTest({ BentoBox.class, Util.class, Bukkit.class })
|
||||
public class VisitorKeepInventoryListenerTest {
|
||||
|
||||
// Class under test
|
||||
@ -84,6 +85,7 @@ public class VisitorKeepInventoryListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -28,6 +28,7 @@ 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;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -67,6 +68,7 @@ public class WitherListenerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -12,6 +12,7 @@ import static org.mockito.Mockito.when;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
@ -24,6 +25,7 @@ import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@ -43,7 +45,7 @@ import world.bentobox.bentobox.managers.RanksManager;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(RanksManager.class)
|
||||
@PrepareForTest({ RanksManager.class, Bukkit.class })
|
||||
public class GameModePlaceholderTest {
|
||||
|
||||
@Mock
|
||||
@ -70,6 +72,9 @@ public class GameModePlaceholderTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
PowerMockito.mockStatic(RanksManager.class, Mockito.RETURNS_MOCKS);
|
||||
uuid = UUID.randomUUID();
|
||||
when(addon.getPlayers()).thenReturn(pm);
|
||||
|
@ -65,7 +65,7 @@ public class AddonsManagerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pm);
|
||||
// Set up plugin
|
||||
plugin = mock(BentoBox.class);
|
||||
|
@ -128,6 +128,8 @@ public class BlueprintClipboardManagerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
blueprintFolder = new File("blueprints");
|
||||
// Clear any residual files
|
||||
tearDown();
|
||||
@ -139,7 +141,6 @@ public class BlueprintClipboardManagerTest {
|
||||
when(hooksManager.getHook(anyString())).thenReturn(Optional.empty());
|
||||
when(plugin.getHooks()).thenReturn(hooksManager);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
BlockData blockData = mock(BlockData.class);
|
||||
when(Bukkit.createBlockData(any(Material.class))).thenReturn(blockData);
|
||||
when(blockData.getAsString()).thenReturn("test123");
|
||||
|
@ -6,6 +6,7 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -44,6 +45,7 @@ import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import com.github.puregero.multilib.MultiLib;
|
||||
|
||||
@ -58,13 +60,14 @@ import world.bentobox.bentobox.blueprints.BlueprintPaster;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, BlueprintPaster.class, MultiLib.class })
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, BlueprintPaster.class, MultiLib.class, Util.class })
|
||||
public class BlueprintsManagerTest {
|
||||
|
||||
public static int BUFFER_SIZE = 10240;
|
||||
@ -100,9 +103,19 @@ public class BlueprintsManagerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Multilib
|
||||
PowerMockito.mockStatic(MultiLib.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Util
|
||||
PowerMockito.mockStatic(Util.class, Mockito.CALLS_REAL_METHODS);
|
||||
when(Util.inTest()).thenReturn(true);
|
||||
|
||||
// Make the addon
|
||||
dataFolder = new File("dataFolder");
|
||||
jarFile = new File("addon.jar");
|
||||
@ -119,7 +132,6 @@ public class BlueprintsManagerTest {
|
||||
map.put(new Vector(0,0,0), new BlueprintBlock("minecraft:bedrock"));
|
||||
defaultBp.setBlocks(map);
|
||||
// Scheduler
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
||||
when(server.getBukkitVersion()).thenReturn("version");
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
|
@ -56,6 +56,8 @@ public class FlagsManagerTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
@ -75,7 +77,6 @@ public class FlagsManagerTest {
|
||||
when(server.getWorld("world")).thenReturn(world);
|
||||
when(server.getVersion()).thenReturn("BSB_Mocking");
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pluginManager);
|
||||
|
||||
ItemFactory itemFactory = mock(ItemFactory.class);
|
||||
|
@ -73,7 +73,7 @@ public class IslandDeletionManagerTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Bukkit
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
Server server = mock(Server.class);
|
||||
when(server.getWorld(anyString())).thenReturn(world);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
|
@ -30,6 +30,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
@ -57,6 +58,7 @@ public class LocalesManagerTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
@ -194,7 +194,7 @@ public class PlayersManagerTest {
|
||||
OfflinePlayer olp = mock(OfflinePlayer.class);
|
||||
when(olp.getUniqueId()).thenReturn(uuid);
|
||||
when(olp.getName()).thenReturn("tastybento");
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenAnswer(invocation -> {
|
||||
UUID inputUUID = invocation.getArgument(0);
|
||||
if (inputUUID.equals(uuid)) {
|
||||
|
@ -17,6 +17,7 @@ import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@ -38,7 +39,7 @@ import world.bentobox.bentobox.database.DatabaseSetup;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ BentoBox.class, DatabaseSetup.class, RanksManager.class })
|
||||
@PrepareForTest({ BentoBox.class, DatabaseSetup.class, RanksManager.class, Bukkit.class })
|
||||
public abstract class RanksManagerBeforeClassTest {
|
||||
|
||||
// Constants that define the hard coded rank values
|
||||
@ -112,6 +113,8 @@ public abstract class RanksManagerBeforeClassTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getBukkitVersion()).thenReturn("");
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// RanksManager
|
||||
|
@ -10,6 +10,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -39,7 +40,7 @@ import world.bentobox.bentobox.util.Util;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(Util.class)
|
||||
@PrepareForTest({ Bukkit.class, Util.class })
|
||||
public class DefaultNewIslandLocationStrategyTest {
|
||||
|
||||
private DefaultNewIslandLocationStrategy dnils;
|
||||
@ -67,6 +68,8 @@ public class DefaultNewIslandLocationStrategyTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Location
|
||||
when(location.getWorld()).thenReturn(world);
|
||||
|
@ -99,7 +99,8 @@ public class IslandCacheTest extends AbstractCommonSetup {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Plugin
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
// Worlds
|
||||
|
@ -5,6 +5,7 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -105,8 +106,11 @@ public class NewIslandTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||
// Islands manager
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
when(im.createIsland(any(), any())).thenReturn(island);
|
||||
|
@ -76,7 +76,7 @@ public class BlueprintManagementPanelTest {
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
// Bukkit
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
ItemFactory itemFac = mock(ItemFactory.class);
|
||||
when(Bukkit.getItemFactory()).thenReturn(itemFac);
|
||||
// Panel inventory
|
||||
|
@ -89,6 +89,8 @@ public class IslandCreationPanelTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
@ -150,7 +152,6 @@ public class IslandCreationPanelTest {
|
||||
|
||||
// Server & Scheduler
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// IWM friendly name
|
||||
|
@ -129,7 +129,7 @@ public class LanguagePanelTest {
|
||||
when(lm.getLanguages()).thenReturn(map);
|
||||
|
||||
// Panel
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.createInventory(any(), Mockito.anyInt(), any())).thenReturn(inv);
|
||||
|
||||
// Item Factory (needed for ItemStack)
|
||||
|
@ -17,6 +17,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -40,6 +41,8 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
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;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
@ -63,6 +66,7 @@ import world.bentobox.bentobox.managers.PlayersManager;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ BentoBox.class, Bukkit.class })
|
||||
public class DefaultPasteUtilTest {
|
||||
|
||||
@Mock
|
||||
@ -110,6 +114,7 @@ public class DefaultPasteUtilTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
AddonDescription desc = new AddonDescription.Builder("", "", "").build();
|
||||
|
@ -40,6 +40,7 @@ import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
@ -54,7 +55,7 @@ import world.bentobox.bentobox.managers.PlaceholdersManager;
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest( { Bukkit.class })
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class })
|
||||
public class UtilTest {
|
||||
|
||||
private static final String[] NAMES = {"adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe"};
|
||||
@ -76,6 +77,10 @@ public class UtilTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
// Set up plugin
|
||||
Util.setPlugin(plugin);
|
||||
// World
|
||||
@ -92,7 +97,6 @@ public class UtilTest {
|
||||
when(location.getYaw()).thenReturn(10F);
|
||||
when(location.getPitch()).thenReturn(20F);
|
||||
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
Server server = mock(Server.class);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
when(Bukkit.getWorld(anyString())).thenReturn(world);
|
||||
|
@ -102,6 +102,8 @@ public class ClosestSafeSpotTeleportTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
// IslandsManager static
|
||||
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
@ -147,7 +149,6 @@ public class ClosestSafeSpotTeleportTest {
|
||||
|
||||
// Bukkit scheduler
|
||||
when(scheduler.runTaskTimer(eq(plugin), any(Runnable.class), anyLong(), anyLong())).thenReturn(task);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
||||
|
||||
// DUT
|
||||
|
@ -92,6 +92,8 @@ public class SafeSpotTeleportTest {
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
|
||||
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||
// Setup instance
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
@ -132,7 +134,6 @@ public class SafeSpotTeleportTest {
|
||||
|
||||
// Bukkit scheduler
|
||||
when(scheduler.runTaskTimer(eq(plugin), any(Runnable.class), anyLong(), anyLong())).thenReturn(task);
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user