Added Mockito.framework().clearInlineMocks() to all test classes per

https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2

This is just e defensive measure and may not have an affect on any
particular class.
This commit is contained in:
tastybento 2019-12-06 08:29:29 -08:00
parent 4b9b24e121
commit 3f1d6d16ff
117 changed files with 634 additions and 134 deletions

View File

@ -37,6 +37,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -92,7 +93,7 @@ public class TestBentoBox {
Mockito.when(server.getVersion()).thenReturn("BentoBox_Mocking"); Mockito.when(server.getVersion()).thenReturn("BentoBox_Mocking");
PluginManager pluginManager = mock(PluginManager.class); PluginManager pluginManager = mock(PluginManager.class);
ItemFactory itemFactory = mock(ItemFactory.class); ItemFactory itemFactory = mock(ItemFactory.class);
when(server.getItemFactory()).thenReturn(itemFactory); when(server.getItemFactory()).thenReturn(itemFactory);
@ -170,6 +171,12 @@ public class TestBentoBox {
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<>()); Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<>());
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testIslandEvent() { public void testIslandEvent() {
// Test island events // Test island events

View File

@ -76,7 +76,7 @@ public class AddonTest {
when(server.getVersion()).thenReturn("BSB_Mocking"); when(server.getVersion()).thenReturn("BSB_Mocking");
PluginManager pluginManager = mock(PluginManager.class); PluginManager pluginManager = mock(PluginManager.class);
PowerMockito.mockStatic(Bukkit.class); PowerMockito.mockStatic(Bukkit.class);
when(Bukkit.getPluginManager()).thenReturn(pluginManager); when(Bukkit.getPluginManager()).thenReturn(pluginManager);
@ -137,6 +137,7 @@ public class AddonTest {
.map(Path::toFile) .map(Path::toFile)
.forEach(File::delete); .forEach(File::delete);
} }
Mockito.framework().clearInlineMocks();
} }
class TestClass extends Addon { class TestClass extends Addon {

View File

@ -13,6 +13,7 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -112,6 +113,11 @@ public class DefaultHelpCommandTest {
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test for {@link DefaultHelpCommand} * Test for {@link DefaultHelpCommand}
*/ */

View File

@ -20,10 +20,12 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -148,6 +150,12 @@ public class DelayedTeleportCommandTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.DelayedTeleportCommand#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}. * Test method for {@link world.bentobox.bentobox.api.commands.DelayedTeleportCommand#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
*/ */

View File

@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -121,6 +122,11 @@ public class AdminDeleteCommandTest {
when(plugin.getLocalesManager()).thenReturn(lm); when(plugin.getLocalesManager()).thenReturn(lm);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link AdminDeleteCommand#execute(User, String, java.util.List) * Test method for {@link AdminDeleteCommand#execute(User, String, java.util.List)

View File

@ -26,6 +26,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -115,8 +116,9 @@ public class AdminGetrankCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -17,6 +17,7 @@ import org.bukkit.Location;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -119,6 +120,11 @@ public class AdminInfoCommandTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link AdminInfoCommand#execute(User, String, List)}. * Test method for {@link AdminInfoCommand#execute(User, String, List)}.

View File

@ -20,10 +20,12 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -58,9 +60,9 @@ public class AdminRegisterCommandTest {
private IslandsManager im; private IslandsManager im;
@Mock @Mock
private PlayersManager pm; private PlayersManager pm;
private UUID notUUID; private UUID notUUID;
private IslandDeletionManager idm; private IslandDeletionManager idm;
/** /**
@ -131,6 +133,11 @@ public class AdminRegisterCommandTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}. * Test method for {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}.

View File

@ -28,6 +28,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -142,8 +143,9 @@ public class AdminResetFlagsCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -23,6 +23,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox; import org.powermock.reflect.Whitebox;
@ -90,8 +91,9 @@ public class AdminSetrankCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -17,6 +17,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -116,6 +117,11 @@ public class AdminSetspawnCommandTest {
when(settings.getConfirmationTime()).thenReturn(10); when(settings.getConfirmationTime()).thenReturn(10);
when(plugin.getSettings()).thenReturn(settings); when(plugin.getSettings()).thenReturn(settings);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.AdminSetspawnCommand#AdminSetspawnCommand(world.bentobox.bentobox.api.commands.CompositeCommand)}. * Test method for {@link world.bentobox.bentobox.api.commands.admin.AdminSetspawnCommand#AdminSetspawnCommand(world.bentobox.bentobox.api.commands.CompositeCommand)}.
*/ */

View File

@ -3,8 +3,8 @@ package world.bentobox.bentobox.api.commands.admin;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -20,6 +20,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -134,6 +135,11 @@ public class AdminTeleportCommandTest {
when(im.getIslandAt(any())).thenReturn(nothing ); when(im.getIslandAt(any())).thenReturn(nothing );
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test all the various commands * Test all the various commands

View File

@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -123,6 +124,11 @@ public class AdminUnregisterCommandTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for . * Test method for .

View File

@ -106,6 +106,7 @@ public class AdminBlueprintsListCommandTest {
.sorted(Comparator.reverseOrder()) .sorted(Comparator.reverseOrder())
.map(Path::toFile) .map(Path::toFile)
.forEach(File::delete); .forEach(File::delete);
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -6,8 +6,8 @@ package world.bentobox.bentobox.api.commands.admin.purge;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -104,7 +104,8 @@ public class AdminPurgeCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -13,6 +13,7 @@ import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -109,6 +110,11 @@ public class AdminRangeCommandTest {
when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty()); when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty());
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testExecuteConsoleNoArgs() { public void testExecuteConsoleNoArgs() {

View File

@ -13,6 +13,7 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -108,6 +109,12 @@ public class AdminRangeDisplayCommandTest {
when(plugin.getLocalesManager()).thenReturn(lm); when(plugin.getLocalesManager()).thenReturn(lm);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.range.AdminRangeDisplayCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. * Test method for {@link world.bentobox.bentobox.api.commands.admin.range.AdminRangeDisplayCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/ */

View File

@ -18,6 +18,7 @@ import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -126,6 +127,12 @@ public class AdminRangeResetCommandTest {
when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty()); when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty());
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.range.AdminRangeResetCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. * Test method for {@link world.bentobox.bentobox.api.commands.admin.range.AdminRangeResetCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/ */

View File

@ -18,6 +18,7 @@ import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -128,6 +129,12 @@ public class AdminRangeSetCommandTest {
when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty()); when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty());
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.range.AdminRangeSetCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. * Test method for {@link world.bentobox.bentobox.api.commands.admin.range.AdminRangeSetCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/ */

View File

@ -16,6 +16,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -124,6 +125,11 @@ public class AdminTeamAddCommandTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link AdminTeamAddCommand#execute(User, String, List)}. * Test method for {@link AdminTeamAddCommand#execute(User, String, List)}.

View File

@ -18,6 +18,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -123,6 +124,12 @@ public class AdminTeamDisbandCommandTest {
when(Bukkit.getPluginManager()).thenReturn(pim); when(Bukkit.getPluginManager()).thenReturn(pim);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}. * Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
*/ */

View File

@ -25,10 +25,12 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -132,6 +134,11 @@ public class AdminTeamKickCommandTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link AdminTeamKickCommand#canExecute(User, String, List)}. * Test method for {@link AdminTeamKickCommand#canExecute(User, String, List)}.

View File

@ -20,10 +20,12 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -122,6 +124,11 @@ public class AdminTeamSetownerCommandTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link AdminTeamSetownerCommand#execute(User, String, List)}. * Test method for {@link AdminTeamSetownerCommand#execute(User, String, List)}.

View File

@ -110,9 +110,9 @@ public class CustomIslandMultiHomeHelpTest {
// IWM friendly name // IWM friendly name
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
when(plugin.getIWM()).thenReturn(iwm); when(plugin.getIWM()).thenReturn(iwm);
// Locales // Locales
// Command // Command
ch = new CustomIslandMultiHomeHelp(ic); ch = new CustomIslandMultiHomeHelp(ic);
@ -124,6 +124,7 @@ public class CustomIslandMultiHomeHelpTest {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**
@ -198,5 +199,5 @@ public class CustomIslandMultiHomeHelpTest {
"description" "description"
); );
} }
} }

View File

@ -168,6 +168,7 @@ public class IslandBanCommandTest {
@After @After
public void tearDown() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -3,13 +3,13 @@ package world.bentobox.bentobox.api.commands.island;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -21,10 +21,12 @@ import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -120,6 +122,11 @@ public class IslandBanlistCommandTest {
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link IslandBanlistCommand#canExecute(User, String, java.util.List)}. * Test method for {@link IslandBanlistCommand#canExecute(User, String, java.util.List)}.
*/ */

View File

@ -3,8 +3,8 @@ package world.bentobox.bentobox.api.commands.island;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -163,8 +163,9 @@ public class IslandCreateCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -155,8 +155,9 @@ public class IslandExpelCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -183,6 +183,7 @@ public class IslandGoCommandTest {
@After @After
public void tearDown() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -119,8 +119,9 @@ public class IslandInfoCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -163,8 +163,9 @@ public class IslandNearCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -262,6 +262,7 @@ public class IslandResetCommandTest {
@After @After
public void tearDown() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -15,6 +15,7 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -125,6 +126,11 @@ public class IslandSethomeCommandTest {
when(user.getPermissionValue(Mockito.anyString(), Mockito.anyInt())).thenReturn(1); when(user.getPermissionValue(Mockito.anyString(), Mockito.anyInt())).thenReturn(1);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSethomeCommand#IslandSethomeCommand(world.bentobox.bentobox.api.commands.CompositeCommand)}. * Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSethomeCommand#IslandSethomeCommand(world.bentobox.bentobox.api.commands.CompositeCommand)}.
*/ */

View File

@ -50,7 +50,7 @@ import world.bentobox.bentobox.managers.PlaceholdersManager;
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({Bukkit.class, BentoBox.class}) @PrepareForTest({Bukkit.class, BentoBox.class})
public class IslandSpawnCommandTest { public class IslandSpawnCommandTest {
@Mock @Mock
private BentoBox plugin; private BentoBox plugin;
@Mock @Mock
@ -81,7 +81,7 @@ public class IslandSpawnCommandTest {
// Command manager // Command manager
CommandsManager cm = mock(CommandsManager.class); CommandsManager cm = mock(CommandsManager.class);
when(plugin.getCommandsManager()).thenReturn(cm); when(plugin.getCommandsManager()).thenReturn(cm);
// Player // Player
when(player.isOp()).thenReturn(false); when(player.isOp()).thenReturn(false);
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
@ -91,7 +91,7 @@ public class IslandSpawnCommandTest {
User.setPlugin(plugin); User.setPlugin(plugin);
// Set up user already // Set up user already
user = User.getInstance(player); user = User.getInstance(player);
// Addon // Addon
GameModeAddon addon = mock(GameModeAddon.class); GameModeAddon addon = mock(GameModeAddon.class);
@ -110,10 +110,10 @@ public class IslandSpawnCommandTest {
when(iwm.getWorldSettings(any())).thenReturn(ws); when(iwm.getWorldSettings(any())).thenReturn(ws);
map = new HashMap<>(); map = new HashMap<>();
when(ws.getWorldFlags()).thenReturn(map); when(ws.getWorldFlags()).thenReturn(map);
// Island Manager // Island Manager
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
LocalesManager lm = mock(LocalesManager.class); LocalesManager lm = mock(LocalesManager.class);
// Locales // Locales
when(plugin.getLocalesManager()).thenReturn(lm); when(plugin.getLocalesManager()).thenReturn(lm);
@ -130,8 +130,9 @@ public class IslandSpawnCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**
@ -160,7 +161,7 @@ public class IslandSpawnCommandTest {
assertTrue(isc.execute(user, "spawn", Collections.emptyList())); assertTrue(isc.execute(user, "spawn", Collections.emptyList()));
verify(im).spawnTeleport(any(), any()); verify(im).spawnTeleport(any(), any());
} }
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSpawnCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. * Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSpawnCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/ */
@ -173,7 +174,7 @@ public class IslandSpawnCommandTest {
verify(im, never()).spawnTeleport(any(), any()); verify(im, never()).spawnTeleport(any(), any());
verify(player).sendMessage(eq("protection.flags.PREVENT_TELEPORT_WHEN_FALLING.hint")); verify(player).sendMessage(eq("protection.flags.PREVENT_TELEPORT_WHEN_FALLING.hint"));
} }
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSpawnCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. * Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSpawnCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/ */
@ -186,7 +187,7 @@ public class IslandSpawnCommandTest {
verify(im).spawnTeleport(any(), any()); verify(im).spawnTeleport(any(), any());
verify(player, never()).sendMessage(eq("protection.flags.PREVENT_TELEPORT_WHEN_FALLING.hint")); verify(player, never()).sendMessage(eq("protection.flags.PREVENT_TELEPORT_WHEN_FALLING.hint"));
} }
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSpawnCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. * Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSpawnCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/ */
@ -199,7 +200,7 @@ public class IslandSpawnCommandTest {
verify(im).spawnTeleport(any(), any()); verify(im).spawnTeleport(any(), any());
verify(player, never()).sendMessage(eq("protection.flags.PREVENT_TELEPORT_WHEN_FALLING.hint")); verify(player, never()).sendMessage(eq("protection.flags.PREVENT_TELEPORT_WHEN_FALLING.hint"));
} }
/** /**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSpawnCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. * Test method for {@link world.bentobox.bentobox.api.commands.island.IslandSpawnCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
*/ */

View File

@ -25,6 +25,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -129,6 +130,11 @@ public class IslandUnbanCommandTest {
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link IslandUnbanCommand#canExecute(User, String, List)} * Test method for {@link IslandUnbanCommand#canExecute(User, String, List)}
*/ */

View File

@ -5,7 +5,7 @@ package world.bentobox.bentobox.api.commands.island.team;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;

View File

@ -5,7 +5,7 @@ package world.bentobox.bentobox.api.commands.island.team;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;

View File

@ -7,7 +7,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -107,7 +107,8 @@ public class FlagTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -2,9 +2,9 @@ package world.bentobox.bentobox.api.flags.clicklisteners;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -23,6 +23,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -215,6 +216,11 @@ public class CycleClickTest {
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testNoPremission() { public void testNoPremission() {
when(user.hasPermission(anyString())).thenReturn(false); when(user.hasPermission(anyString())).thenReturn(false);

View File

@ -1,7 +1,7 @@
package world.bentobox.bentobox.api.flags.clicklisteners; package world.bentobox.bentobox.api.flags.clicklisteners;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@ -17,6 +17,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -116,6 +117,11 @@ public class IslandToggleClickTest {
when(settingsTab.getIsland()).thenReturn(island); when(settingsTab.getIsland()).thenReturn(island);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testOnClickNoPermission() { public void testOnClickNoPermission() {
when(user.hasPermission(Mockito.anyString())).thenReturn(false); when(user.hasPermission(Mockito.anyString())).thenReturn(false);

View File

@ -1,6 +1,6 @@
package world.bentobox.bentobox.api.flags.clicklisteners; package world.bentobox.bentobox.api.flags.clicklisteners;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -96,6 +97,11 @@ public class WorldToggleClickTest {
when(Bukkit.getPluginManager()).thenReturn(pim); when(Bukkit.getPluginManager()).thenReturn(pim);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testOnClickWrongWorld() { public void testOnClickWrongWorld() {
when(iwm.inWorld(any(World.class))).thenReturn(false); when(iwm.inWorld(any(World.class))).thenReturn(false);

View File

@ -6,7 +6,7 @@ package world.bentobox.bentobox.api.localization;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -20,6 +20,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.BannerMeta;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -63,6 +64,11 @@ public class BentoBoxLocaleTest {
localeObject = new BentoBoxLocale(locale, config); localeObject = new BentoBoxLocale(locale, config);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.api.localization.BentoBoxLocale#get(java.lang.String)}. * Test method for {@link world.bentobox.bentobox.api.localization.BentoBoxLocale#get(java.lang.String)}.
*/ */

View File

@ -75,7 +75,8 @@ public class PanelTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -11,6 +11,7 @@ import static org.mockito.Mockito.when;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -43,6 +44,11 @@ public class PanelBuilderTest {
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.api.panels.builders.PanelBuilder#name(java.lang.String)}. * Test method for {@link world.bentobox.bentobox.api.panels.builders.PanelBuilder#name(java.lang.String)}.
*/ */

View File

@ -24,6 +24,7 @@ import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -72,6 +73,11 @@ public class PanelItemBuilderTest {
//when(Bukkit.getServer()).thenReturn(server); //when(Bukkit.getServer()).thenReturn(server);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testIconMaterial() { public void testIconMaterial() {
PanelItemBuilder builder = new PanelItemBuilder(); PanelItemBuilder builder = new PanelItemBuilder();

View File

@ -29,7 +29,8 @@ public class NotifierTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -37,6 +37,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -112,8 +113,9 @@ public class UserTest {
} }
@After @After
public void cleanUp() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
@Test @Test

View File

@ -111,7 +111,8 @@ public class BentoBoxReloadCommandTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -85,6 +85,7 @@ public class DatabaseTest {
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
dbSetup = null; dbSetup = null;
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -15,6 +15,7 @@ import org.bukkit.Server;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -65,6 +66,11 @@ public class FlagAdapterTest {
when(plugin.getFlagsManager()).thenReturn(flagsManager); when(plugin.getFlagsManager()).thenReturn(flagsManager);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testWriteJsonWriterFlag() throws IOException { public void testWriteJsonWriterFlag() throws IOException {
FlagTypeAdapter fa = new FlagTypeAdapter(plugin); FlagTypeAdapter fa = new FlagTypeAdapter(plugin);

View File

@ -26,6 +26,7 @@ import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -53,7 +54,7 @@ import world.bentobox.bentobox.BentoBox;
public class ItemStackTypeAdapterTest { public class ItemStackTypeAdapterTest {
@Mock @Mock
private BentoBox plugin; private BentoBox plugin;
private ItemStackTypeAdapter isa; private ItemStackTypeAdapter isa;
@Mock @Mock
private JsonWriter out; private JsonWriter out;
@ -67,10 +68,10 @@ public class ItemStackTypeAdapterTest {
*/ */
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
// Set up plugin // Set up plugin
plugin = mock(BentoBox.class); plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin); Whitebox.setInternalState(BentoBox.class, "instance", plugin);
Server server = mock(Server.class); Server server = mock(Server.class);
PluginManager pim = mock(PluginManager.class); PluginManager pim = mock(PluginManager.class);
@ -97,6 +98,11 @@ public class ItemStackTypeAdapterTest {
when(ItemStack.deserialize(any())).thenReturn(new ItemStack(Material.STONE, 4)); when(ItemStack.deserialize(any())).thenReturn(new ItemStack(Material.STONE, 4));
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#write(com.google.gson.stream.JsonWriter, org.bukkit.inventory.ItemStack)}. * Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#write(com.google.gson.stream.JsonWriter, org.bukkit.inventory.ItemStack)}.
* @throws IOException * @throws IOException
@ -155,7 +161,7 @@ public class ItemStackTypeAdapterTest {
// Delete temp file // Delete temp file
Files.deleteIfExists(tmp.toPath()); Files.deleteIfExists(tmp.toPath());
} }
/** /**
* Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#read(com.google.gson.stream.JsonReader)}. * Test method for {@link world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter#read(com.google.gson.stream.JsonReader)}.
* @throws IOException * @throws IOException

View File

@ -13,10 +13,12 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -92,6 +94,11 @@ public class IslandDeletionTest {
id = new IslandDeletion(island); id = new IslandDeletion(island);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.database.objects.IslandDeletion#getLocation()}. * Test method for {@link world.bentobox.bentobox.database.objects.IslandDeletion#getLocation()}.
*/ */

View File

@ -15,6 +15,7 @@ import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -90,6 +91,11 @@ public class PlayersTest {
p = new Players(plugin, uuid); p = new Players(plugin, uuid);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testPlayersBSkyBlockUUID() { public void testPlayersBSkyBlockUUID() {
assertNotNull(new Players(plugin, UUID.randomUUID())); assertNotNull(new Players(plugin, UUID.randomUUID()));

View File

@ -12,8 +12,10 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito;
import world.bentobox.bentobox.api.logs.LogEntry; import world.bentobox.bentobox.api.logs.LogEntry;
@ -47,6 +49,11 @@ public class LogEntryListAdapterTest {
toLog.forEach(history::add); toLog.forEach(history::add);
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter#serialize(java.lang.Object)} * Test method for {@link world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter#serialize(java.lang.Object)}
* and {@link world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter#deserialize(java.lang.Object)}. * and {@link world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter#deserialize(java.lang.Object)}.

View File

@ -3,7 +3,7 @@ package world.bentobox.bentobox.database.sql.mysql;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.mockStatic;
@ -20,6 +20,7 @@ import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -68,7 +69,8 @@ public class MySQLDatabaseConnectorTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -5,8 +5,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -21,6 +21,7 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@ -112,6 +113,11 @@ public class MySQLDatabaseHandlerTest {
} }
@After
public void tearDown() {
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObjects()}. * Test method for {@link world.bentobox.bentobox.database.sql.mysql.MySQLDatabaseHandler#loadObjects()}.
* @throws SQLException * @throws SQLException

View File

@ -138,6 +138,7 @@ public class YamlDatabaseHandlerTest {
.sorted(Comparator.reverseOrder()) .sorted(Comparator.reverseOrder())
.map(Path::toFile) .map(Path::toFile)
.forEach(File::delete); .forEach(File::delete);
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -26,6 +26,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNull;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -123,6 +124,12 @@ public class BannedCommandsTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test for {@link BannedCommands#onCommand(PlayerCommandPreprocessEvent)} * Test for {@link BannedCommands#onCommand(PlayerCommandPreprocessEvent)}
*/ */
@ -254,8 +261,8 @@ public class BannedCommandsTest {
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
} }
/** /**
* Test for {@link BannedCommands#onCommand(PlayerCommandPreprocessEvent)} * Test for {@link BannedCommands#onCommand(PlayerCommandPreprocessEvent)}
*/ */
@ -272,7 +279,7 @@ public class BannedCommandsTest {
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
} }
/** /**
* Test for {@link BannedCommands#onCommand(PlayerCommandPreprocessEvent)} * Test for {@link BannedCommands#onCommand(PlayerCommandPreprocessEvent)}
*/ */

View File

@ -1,13 +1,14 @@
package world.bentobox.bentobox.listeners; package world.bentobox.bentobox.listeners;
import static org.junit.Assert.*; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -36,6 +37,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox; import org.powermock.reflect.Whitebox;
@ -113,8 +115,9 @@ public class BlockEndDragonTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -12,6 +12,7 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -22,6 +23,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
import world.bentobox.bentobox.managers.PlayersManager; import world.bentobox.bentobox.managers.PlayersManager;
import world.bentobox.bentobox.util.Util; import world.bentobox.bentobox.util.Util;
@ -69,6 +71,12 @@ public class DeathListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testOnPlayerDeathEventDeathsCounted() { public void testOnPlayerDeathEventDeathsCounted() {
// Test // Test

View File

@ -34,6 +34,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -205,8 +206,9 @@ public class JoinLeaveListenerTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -164,7 +164,9 @@ public class PanelListenerManagerTest {
} }
@After @After
public void cleanUp() { public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
PanelListenerManager.getOpenPanels().clear(); PanelListenerManager.getOpenPanels().clear();
} }

View File

@ -20,6 +20,7 @@ import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -139,6 +140,12 @@ public class PortalTeleportationListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
private void wrongWorld() { private void wrongWorld() {
when(iwm.inWorld(any(World.class))).thenReturn(false); when(iwm.inWorld(any(World.class))).thenReturn(false);
when(iwm.inWorld(any(Location.class))).thenReturn(false); when(iwm.inWorld(any(Location.class))).thenReturn(false);

View File

@ -140,8 +140,9 @@ public class StandardSpawnProtectionListenerTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }

View File

@ -43,6 +43,7 @@ import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -292,8 +293,9 @@ public class BlockInteractionListenerTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -198,8 +198,9 @@ public class BreakBlocksListenerTest {
} }
@After @After
public void cleanUp() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -37,6 +37,7 @@ import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -197,6 +198,12 @@ public class BreedingListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link BreedingListener#onPlayerInteract(org.bukkit.event.player.PlayerInteractAtEntityEvent)}. * Test method for {@link BreedingListener#onPlayerInteract(org.bukkit.event.player.PlayerInteractAtEntityEvent)}.
*/ */

View File

@ -186,8 +186,9 @@ public class BucketListenerTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -3,11 +3,11 @@ package world.bentobox.bentobox.listeners.flags.protection;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -180,8 +180,9 @@ public class EggListenerTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -44,6 +44,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -168,8 +169,9 @@ public class EntityInteractListenerTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -5,8 +5,8 @@ package world.bentobox.bentobox.listeners.flags.protection;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -27,6 +27,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent; import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -41,6 +42,7 @@ import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.Notifier; import world.bentobox.bentobox.api.user.Notifier;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -150,6 +152,12 @@ public class ExperiencePickupListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link ExperiencePickupListener#onExperienceOrbTargetPlayer(org.bukkit.event.entity.EntityTargetLivingEntityEvent)}. * Test method for {@link ExperiencePickupListener#onExperienceOrbTargetPlayer(org.bukkit.event.entity.EntityTargetLivingEntityEvent)}.
*/ */

View File

@ -27,6 +27,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -143,6 +144,12 @@ public class FireListenerTest {
when(Util.getWorld(Mockito.any())).thenReturn(mock(World.class)); when(Util.getWorld(Mockito.any())).thenReturn(mock(World.class));
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testCheckFire() { public void testCheckFire() {
// Island // Island

View File

@ -190,6 +190,7 @@ public class HurtingListenerTest {
@After @After
public void tearDown() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -197,8 +197,9 @@ public class InventoryListenerTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -2,7 +2,7 @@ package world.bentobox.bentobox.listeners.flags.protection;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -23,6 +23,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.event.vehicle.VehicleMoveEvent;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -181,6 +182,12 @@ public class LockAndBanListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testTeleportToNotBannedIsland() { public void testTeleportToNotBannedIsland() {
// Setup location outside island, one inside banned island // Setup location outside island, one inside banned island

View File

@ -44,6 +44,7 @@ import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -195,8 +196,9 @@ public class PhysicalInteractionListenerTest {
} }
@After @After
public void cleanUp() { public void tearDown() {
User.removePlayer(player); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -186,8 +186,9 @@ public class PlaceBlocksListenerTest {
} }
@After @After
public void cleanUp() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -40,6 +40,7 @@ import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -178,6 +179,12 @@ public class TNTListenerTest {
when(Util.stripSpaceAfterColorCodes(anyString())).thenCallRealMethod(); when(Util.stripSpaceAfterColorCodes(anyString())).thenCallRealMethod();
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testOnTNTPriming() { public void testOnTNTPriming() {
BlockFace clickedFace = BlockFace.DOWN; BlockFace clickedFace = BlockFace.DOWN;

View File

@ -176,8 +176,9 @@ public class ThrowingListenerTest {
} }
@After @After
public void cleanUp() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -24,6 +24,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -37,6 +38,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.FlagsManager; import world.bentobox.bentobox.managers.FlagsManager;
@ -87,7 +89,7 @@ public class MobSpawnListenerTest {
when(Bukkit.getItemFactory()).thenReturn(itemFactory); when(Bukkit.getItemFactory()).thenReturn(itemFactory);
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger()); when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
when(Bukkit.getPluginManager()).thenReturn(pim); when(Bukkit.getPluginManager()).thenReturn(pim);
location = mock(Location.class); location = mock(Location.class);
when(location.getWorld()).thenReturn(world); when(location.getWorld()).thenReturn(world);
when(location.getBlockX()).thenReturn(0); when(location.getBlockX()).thenReturn(0);
@ -130,6 +132,12 @@ public class MobSpawnListenerTest {
when(livingEntity.getLocation()).thenReturn(location); when(livingEntity.getLocation()).thenReturn(location);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testNotLoaded() { public void testNotLoaded() {
when(plugin.isLoaded()).thenReturn(false); when(plugin.isLoaded()).thenReturn(false);
@ -199,7 +207,7 @@ public class MobSpawnListenerTest {
for (SpawnReason reason: SpawnReason.values()) { for (SpawnReason reason: SpawnReason.values()) {
when(e.getSpawnReason()).thenReturn(reason); when(e.getSpawnReason()).thenReturn(reason);
switch (reason) { switch (reason) {
// Natural // Natural
case DEFAULT: case DEFAULT:
case DROWNED: case DROWNED:
case JOCKEY: case JOCKEY:
@ -216,10 +224,10 @@ public class MobSpawnListenerTest {
case TRAP: case TRAP:
case VILLAGE_DEFENSE: case VILLAGE_DEFENSE:
case VILLAGE_INVASION: case VILLAGE_INVASION:
// These should be blocked // These should be blocked
assertTrue("Should be blocked: " + reason.toString(), l.onNaturalMobSpawn(e)); assertTrue("Should be blocked: " + reason.toString(), l.onNaturalMobSpawn(e));
break; break;
// Unnatural - player involved // Unnatural - player involved
case BREEDING: case BREEDING:
case BUILD_IRONGOLEM: case BUILD_IRONGOLEM:
case BUILD_SNOWMAN: case BUILD_SNOWMAN:
@ -239,7 +247,7 @@ public class MobSpawnListenerTest {
break; break;
default: default:
break; break;
} }
} }

View File

@ -236,6 +236,7 @@ public class PVPListenerTest {
@After @After
public void tearDown() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
private void wrongWorld() { private void wrongWorld() {

View File

@ -34,6 +34,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -164,6 +165,12 @@ public class ChestDamageListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link ChestDamageListener#onExplosion(org.bukkit.event.entity.EntityExplodeEvent)}. * Test method for {@link ChestDamageListener#onExplosion(org.bukkit.event.entity.EntityExplodeEvent)}.
*/ */

View File

@ -26,6 +26,7 @@ import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -39,6 +40,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.events.BentoBoxReadyEvent; import world.bentobox.bentobox.api.events.BentoBoxReadyEvent;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.AddonsManager; import world.bentobox.bentobox.managers.AddonsManager;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -132,6 +134,12 @@ public class CleanSuperFlatListenerTest {
when(am.getDefaultWorldGenerator(anyString(), anyString())).thenReturn(cg); when(am.getDefaultWorldGenerator(anyString(), anyString())).thenReturn(cg);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link CleanSuperFlatListener#onChunkLoad(org.bukkit.event.world.ChunkLoadEvent)}. * Test method for {@link CleanSuperFlatListener#onChunkLoad(org.bukkit.event.world.ChunkLoadEvent)}.
*/ */

View File

@ -158,8 +158,9 @@ public class EnderChestListenerTest {
} }
@After @After
public void cleanUp() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
@Test @Test

View File

@ -28,6 +28,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -40,6 +41,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.FlagsManager; import world.bentobox.bentobox.managers.FlagsManager;
@ -139,6 +141,11 @@ public class EndermanListenerTest {
Flags.ENDERMAN_GRIEFING.setSetting(world, false); Flags.ENDERMAN_GRIEFING.setSetting(world, false);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link EndermanListener#onEndermanGrief(org.bukkit.event.entity.EntityChangeBlockEvent)}. * Test method for {@link EndermanListener#onEndermanGrief(org.bukkit.event.entity.EntityChangeBlockEvent)}.

View File

@ -28,6 +28,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
@ -206,6 +207,7 @@ public class EnterExitListenerTest {
@After @After
public void tearDown() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -2,13 +2,13 @@ package world.bentobox.bentobox.listeners.flags.worldsettings;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -33,6 +33,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -153,6 +154,12 @@ public class InvincibleVisitorsListenerTest {
when(Bukkit.createInventory(any(), Mockito.anyInt(), any())).thenReturn(top); when(Bukkit.createInventory(any(), Mockito.anyInt(), any())).thenReturn(top);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testOnClickWrongWorld() { public void testOnClickWrongWorld() {
when(user.inWorld()).thenReturn(false); when(user.inWorld()).thenReturn(false);

View File

@ -114,10 +114,11 @@ public class IslandRespawnListenerTest {
User.setPlugin(plugin); User.setPlugin(plugin);
User.getInstance(player); User.getInstance(player);
} }
@After @After
public void tearDown() { public void tearDown() {
User.clearUsers(); User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**
@ -131,7 +132,7 @@ public class IslandRespawnListenerTest {
new IslandRespawnListener().onPlayerDeath(e); new IslandRespawnListener().onPlayerDeath(e);
verify(world, never()).getUID(); verify(world, never()).getUID();
} }
/** /**
* Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}. * Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/ */
@ -143,7 +144,7 @@ public class IslandRespawnListenerTest {
new IslandRespawnListener().onPlayerDeath(e); new IslandRespawnListener().onPlayerDeath(e);
verify(world, never()).getUID(); verify(world, never()).getUID();
} }
/** /**
* Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}. * Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/ */
@ -156,7 +157,7 @@ public class IslandRespawnListenerTest {
new IslandRespawnListener().onPlayerDeath(e); new IslandRespawnListener().onPlayerDeath(e);
verify(world, never()).getUID(); verify(world, never()).getUID();
} }
/** /**
* Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}. * Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/ */
@ -169,7 +170,7 @@ public class IslandRespawnListenerTest {
new IslandRespawnListener().onPlayerDeath(e); new IslandRespawnListener().onPlayerDeath(e);
verify(world).getUID(); verify(world).getUID();
} }
/** /**
* Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}. * Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/ */
@ -182,7 +183,7 @@ public class IslandRespawnListenerTest {
new IslandRespawnListener().onPlayerDeath(e); new IslandRespawnListener().onPlayerDeath(e);
verify(world).getUID(); verify(world).getUID();
} }
/** /**
* Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}. * Test method for {@link IslandRespawnListener#onPlayerDeath(org.bukkit.event.entity.PlayerDeathEvent)}.
*/ */

View File

@ -28,6 +28,7 @@ import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -41,6 +42,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.FlagsManager; import world.bentobox.bentobox.managers.FlagsManager;
@ -82,7 +84,7 @@ public class ItemFrameListenerTest {
when(Bukkit.getPluginManager()).thenReturn(pim); when(Bukkit.getPluginManager()).thenReturn(pim);
ItemFactory itemFactory = mock(ItemFactory.class); ItemFactory itemFactory = mock(ItemFactory.class);
when(server.getItemFactory()).thenReturn(itemFactory); when(server.getItemFactory()).thenReturn(itemFactory);
SkullMeta skullMeta = mock(SkullMeta.class); SkullMeta skullMeta = mock(SkullMeta.class);
when(itemFactory.getItemMeta(any())).thenReturn(skullMeta); when(itemFactory.getItemMeta(any())).thenReturn(skullMeta);
@ -140,6 +142,12 @@ public class ItemFrameListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link ItemFrameListener#onItemFrameDamage(org.bukkit.event.entity.EntityDamageByEntityEvent)}. * Test method for {@link ItemFrameListener#onItemFrameDamage(org.bukkit.event.entity.EntityDamageByEntityEvent)}.
*/ */

View File

@ -15,6 +15,7 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -25,6 +26,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -106,6 +108,12 @@ public class LiquidsFlowingOutListenerTest {
when(islandsManager.getProtectedIslandAt(toLocation)).thenReturn(Optional.empty()); when(islandsManager.getProtectedIslandAt(toLocation)).thenReturn(Optional.empty());
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Asserts that the event is never cancelled when the 'from' block is not in the world. * Asserts that the event is never cancelled when the 'from' block is not in the world.
*/ */

View File

@ -27,6 +27,7 @@ import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -150,6 +151,12 @@ public class ObsidianScoopingListenerTest {
when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty()); when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty());
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testOnPlayerInteract() { public void testOnPlayerInteract() {
// Test incorrect items // Test incorrect items

View File

@ -2,8 +2,8 @@ package world.bentobox.bentobox.listeners.flags.worldsettings;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -19,6 +19,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockGrowEvent; import org.bukkit.event.block.BlockGrowEvent;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -34,6 +35,7 @@ import com.google.common.collect.ImmutableSet.Builder;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -102,6 +104,12 @@ public class OfflineGrowthListenerTest {
PowerMockito.mockStatic(Bukkit.class); PowerMockito.mockStatic(Bukkit.class);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link OfflineGrowthListener#OnCropGrow(BlockGrowEvent)}. * Test method for {@link OfflineGrowthListener#OnCropGrow(BlockGrowEvent)}.
*/ */

View File

@ -1,8 +1,8 @@
package world.bentobox.bentobox.listeners.flags.worldsettings; package world.bentobox.bentobox.listeners.flags.worldsettings;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -17,6 +17,7 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -32,6 +33,7 @@ import com.google.common.collect.ImmutableSet.Builder;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -100,6 +102,12 @@ public class OfflineRedstoneListenerTest {
PowerMockito.mockStatic(Bukkit.class); PowerMockito.mockStatic(Bukkit.class);
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link OfflineRedstoneListener#onBlockRedstone(BlockRedstoneEvent)}. * Test method for {@link OfflineRedstoneListener#onBlockRedstone(BlockRedstoneEvent)}.
*/ */

View File

@ -2,7 +2,7 @@ package world.bentobox.bentobox.listeners.flags.worldsettings;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -18,6 +18,7 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonExtendEvent;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -30,6 +31,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -107,6 +109,12 @@ public class PistonPushListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
@Test @Test
public void testOnPistonExtendFlagNotSet() { public void testOnPistonExtendFlagNotSet() {
Flags.PISTON_PUSH.setSetting(world, false); Flags.PISTON_PUSH.setSetting(world, false);

View File

@ -3,8 +3,8 @@ package world.bentobox.bentobox.listeners.flags.worldsettings;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -17,6 +17,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -30,6 +31,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -116,6 +118,12 @@ public class RemoveMobsListenerTest {
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Test method for {@link RemoveMobsListener#onUserTeleport(org.bukkit.event.player.PlayerTeleportEvent)}. * Test method for {@link RemoveMobsListener#onUserTeleport(org.bukkit.event.player.PlayerTeleportEvent)}.
*/ */

View File

@ -21,6 +21,7 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -32,6 +33,7 @@ import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -115,6 +117,12 @@ public class TreesGrowingOutsideRangeListenerTest {
when(islandsManager.getProtectedIslandAt(any())).thenReturn(Optional.of(island)); when(islandsManager.getProtectedIslandAt(any())).thenReturn(Optional.of(island));
} }
@After
public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
}
/** /**
* Populates {@link TreesGrowingOutsideRangeListenerTest#blockStates} with a tree schema. * Populates {@link TreesGrowingOutsideRangeListenerTest#blockStates} with a tree schema.
*/ */

View File

@ -27,12 +27,14 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox; import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.IslandWorldManager; import world.bentobox.bentobox.managers.IslandWorldManager;
@ -80,7 +82,7 @@ public class WitherListenerTest {
when(location.getBlockX()).thenReturn(0); when(location.getBlockX()).thenReturn(0);
when(location.getBlockY()).thenReturn(0); when(location.getBlockY()).thenReturn(0);
when(location.getBlockZ()).thenReturn(0); when(location.getBlockZ()).thenReturn(0);
when(location2.getWorld()).thenReturn(world2); when(location2.getWorld()).thenReturn(world2);
when(location2.getBlockX()).thenReturn(0); when(location2.getBlockX()).thenReturn(0);
when(location2.getBlockY()).thenReturn(0); when(location2.getBlockY()).thenReturn(0);
@ -105,7 +107,9 @@ public class WitherListenerTest {
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@After @After
public void tearDown() throws Exception { public void tearDown() {
User.clearUsers();
Mockito.framework().clearInlineMocks();
} }
/** /**
@ -122,7 +126,7 @@ public class WitherListenerTest {
assertTrue(blocks.isEmpty()); assertTrue(blocks.isEmpty());
} }
/** /**
* Test method for {@link world.bentobox.bentobox.listeners.flags.worldsettings.WitherListener#onExplosion(org.bukkit.event.entity.EntityExplodeEvent)}. * Test method for {@link world.bentobox.bentobox.listeners.flags.worldsettings.WitherListener#onExplosion(org.bukkit.event.entity.EntityExplodeEvent)}.
*/ */
@ -198,7 +202,7 @@ public class WitherListenerTest {
wl.onWitherChangeBlocks(e); wl.onWitherChangeBlocks(e);
assertTrue(e.isCancelled()); assertTrue(e.isCancelled());
} }
/** /**
* Test method for {@link world.bentobox.bentobox.listeners.flags.worldsettings.WitherListener#WitherChangeBlocks(org.bukkit.event.entity.EntityChangeBlockEvent)}. * Test method for {@link world.bentobox.bentobox.listeners.flags.worldsettings.WitherListener#WitherChangeBlocks(org.bukkit.event.entity.EntityChangeBlockEvent)}.
*/ */

View File

@ -22,6 +22,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -75,6 +76,7 @@ public class AddonsManagerTest {
// Delete the addons folder // Delete the addons folder
File f = new File(plugin.getDataFolder(), "addons"); File f = new File(plugin.getDataFolder(), "addons");
Files.deleteIfExists(f.toPath()); Files.deleteIfExists(f.toPath());
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -29,6 +29,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -143,6 +144,7 @@ public class BlueprintClipboardManagerTest {
.map(Path::toFile) .map(Path::toFile)
.forEach(File::delete); .forEach(File::delete);
} }
Mockito.framework().clearInlineMocks();
} }
/** /**

View File

@ -4,8 +4,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -174,6 +174,7 @@ public class BlueprintsManagerTest {
// Delete addon.jar // Delete addon.jar
Files.deleteIfExists(jarFile.toPath()); Files.deleteIfExists(jarFile.toPath());
Mockito.framework().clearInlineMocks();
} }
private void deleteDir(Path path) throws Exception { private void deleteDir(Path path) throws Exception {

Some files were not shown because too many files have changed in this diff Show More