Code cleanup using Intellij

This commit is contained in:
tastybento 2018-08-04 21:50:10 -07:00
parent 492a0b9105
commit 765268aa25
62 changed files with 255 additions and 472 deletions

View File

@ -676,23 +676,23 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
}
/**
* Check if cool down has expired or not
* Check if cool down is in progress
* @param user - the caller of the command
* @param targetUUID - the target (if any)
* @return true if cool down does not exist, false if it is still active
* @return true if cool down in place, false if not
*/
protected boolean checkCooldown(User user, UUID targetUUID) {
if (!cooldowns.containsKey(user.getUniqueId()) || user.isOp() || user.hasPermission(getPermissionPrefix() + ".mod.bypasscooldowns")) {
return true;
return false;
}
cooldowns.putIfAbsent(user.getUniqueId(), new HashMap<>());
if (cooldowns.get(user.getUniqueId()).getOrDefault(targetUUID, 0L) - System.currentTimeMillis() <= 0) {
// Cool down is done
cooldowns.get(user.getUniqueId()).remove(targetUUID);
return true;
return false;
}
int timeToGo = (int) ((cooldowns.get(user.getUniqueId()).getOrDefault(targetUUID, 0L) - System.currentTimeMillis()) / 1000);
user.sendMessage("general.errors.you-must-wait", TextVariables.NUMBER, String.valueOf(timeToGo));
return false;
return true;
}
}

View File

@ -65,7 +65,7 @@ public class IslandBanCommand extends CompositeCommand {
user.sendMessage("commands.island.ban.player-already-banned");
return false;
}
if (getSettings().getBanWait() > 0 && !checkCooldown(user, targetUUID)) {
if (getSettings().getBanWait() > 0 && checkCooldown(user, targetUUID)) {
return false;
}
User target = User.getInstance(targetUUID);

View File

@ -75,7 +75,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
return false;
}
// Check cool down
if (getSettings().getInviteWait() > 0 && !checkCooldown(user, invitedPlayerUUID)) {
if (getSettings().getInviteWait() > 0 && checkCooldown(user, invitedPlayerUUID)) {
return false;
}
// Player cannot invite someone already on a team

View File

@ -45,7 +45,7 @@ public interface WorldSettings {
/**
* Set the world difficulty
* @param difficulty
* @param difficulty - difficulty
*/
void setDifficulty(Difficulty difficulty);

View File

@ -10,7 +10,7 @@ public class AboutCommand extends CompositeCommand {
/**
* About
* @param islandCommand - parent command
* @param parent - parent command
*/
public AboutCommand(CompositeCommand parent) {
super(parent, "about");

View File

@ -8,8 +8,7 @@ import world.bentobox.bentobox.api.user.User;
public class BentoBoxCommand extends CompositeCommand {
/**
* About
* @param islandCommand - parent command
* BentoBox main command
*/
public BentoBoxCommand() {
super("bentobox", "bbox");

View File

@ -10,7 +10,7 @@ public class InfoCommand extends CompositeCommand {
/**
* Info command
* @param parent
* @param parent - command parent
*/
public InfoCommand(CompositeCommand parent) {
super(parent, "info");

View File

@ -212,7 +212,7 @@ public class Players implements DataObject {
}
/**
* @param world
* @param world - world
* @param deaths the deaths to set
*/
public void setDeaths(World world, int deaths) {

View File

@ -66,7 +66,7 @@ public class GeoLimitMobsListener extends AbstractFlagListener {
/**
* Deal with projectiles fired by entities
* @param e
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void ProjectileExplode(final ExplosionPrimeEvent e) {

View File

@ -44,7 +44,6 @@ public class ItemFrameListener extends AbstractFlagListener {
} else {
e.setCancelled(true);
}
return;
}
}

View File

@ -54,7 +54,7 @@ public class TNTListener extends AbstractFlagListener {
/**
* Protect against priming of TNT unless break blocks is allowed
* @param e
* @param e - event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onTNTPriming(PlayerInteractEvent e) {

View File

@ -61,7 +61,7 @@ public class FlagsManager {
/**
* Tries to register a listener if the plugin is loaded
* @param l
* @param l - listener
*/
private void registerListener(Listener l) {
registeredListeners.putIfAbsent(l, false);

View File

@ -647,7 +647,7 @@ public class IslandWorldManager {
/**
* Gets the time stamp for when all player resets were zeroed
* @param world
* @param world - world
*/
public long getResetEpoch(World world) {
return worldSettings.get(Util.getWorld(world)).getResetEpoch();
@ -655,7 +655,7 @@ public class IslandWorldManager {
/**
* Sets the time stamp for when all player resets were zeroed
* @param world
* @param world - world
*/
public void setResetEpoch(World world) {
worldSettings.get(Util.getWorld(world)).setResetEpoch(System.currentTimeMillis());

View File

@ -299,7 +299,7 @@ public class IslandsManager {
/**
* Used for testing only to inject the islandCache mock object
* @param islandCache
* @param islandCache - island cache
*/
public void setIslandCache(IslandCache islandCache) {
this.islandCache = islandCache;

View File

@ -293,7 +293,7 @@ public class PlayersManager {
/**
* Gets how many island resets the player has done
* @param world
* @param world - world
*
* @param playerUUID - the player's UUID
* @return number of resets
@ -350,7 +350,7 @@ public class PlayersManager {
/**
* Set death number for player
* @param world
* @param world - world
* @param playerUUID - the player's UUID
* @param deaths - number of deaths
*/

View File

@ -20,7 +20,7 @@ public class SchemsManager {
private Map<World, Clipboard> islandSchems;
/**
* @param plugin
* @param plugin - plugin
*/
public SchemsManager(BentoBox plugin) {
this.plugin = plugin;
@ -103,8 +103,8 @@ public class SchemsManager {
/**
* Paste the schem to world for island
* @param world
* @param island
* @param world - world
* @param island - island
*/
public void paste(World world, Island island) {
paste(world, island, null);

View File

@ -197,7 +197,7 @@ public class Clipboard {
/**
* Paste clipboard at this location
* @param location
* @param location - location
*/
public void pasteClipboard(Location location) {
blockConfig.getConfigurationSection(BLOCK).getKeys(false).forEach(b -> pasteBlock(location.getWorld(), null, location, blockConfig.getConfigurationSection(BLOCK + "." + b)));
@ -259,9 +259,9 @@ public class Clipboard {
/**
* Sets any entity that is in this location
* @param island
* @param block
* @param config
* @param island - island
* @param location - locaton
* @param config - config section
*/
private void setEntity(Island island, Location location, ConfigurationSection config) {
ConfigurationSection en = config.getConfigurationSection(ENTITY);

View File

@ -235,7 +235,7 @@ public class Util {
* Converts block face direction to radial degrees. Returns 0 if block face
* is not radial.
*
* @param face
* @param face - blockface
* @return degrees
*/
public static float blockFaceToFloat(BlockFace face) {

View File

@ -37,9 +37,6 @@ public class AdminClearResetsAllCommandTest {
private CompositeCommand ac;
private User user;
private IslandsManager im;
private PlayersManager pm;
private UUID notUUID;
/**
* @throws java.lang.Exception
@ -65,7 +62,7 @@ public class AdminClearResetsAllCommandTest {
user = mock(User.class);
when(user.isOp()).thenReturn(false);
UUID uuid = UUID.randomUUID();
notUUID = UUID.randomUUID();
UUID notUUID = UUID.randomUUID();
while(notUUID.equals(uuid)) {
notUUID = UUID.randomUUID();
}
@ -83,7 +80,7 @@ public class AdminClearResetsAllCommandTest {
when(plugin.getIWM()).thenReturn(iwm);
// Player has island to begin with
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
@ -91,7 +88,7 @@ public class AdminClearResetsAllCommandTest {
when(plugin.getIslands()).thenReturn(im);
// Has team
pm = mock(PlayersManager.class);
PlayersManager pm = mock(PlayersManager.class);
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(plugin.getPlayers()).thenReturn(pm);
@ -108,7 +105,7 @@ public class AdminClearResetsAllCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.AdminClearResetsAllCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteCheckConfirm() {

View File

@ -116,7 +116,7 @@ public class AdminClearResetsCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.AdminClearResetsCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoTarget() {
@ -127,7 +127,7 @@ public class AdminClearResetsCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.AdminClearResetsCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteUnknownPlayer() {
@ -139,7 +139,7 @@ public class AdminClearResetsCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.AdminClearResetsCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecutePlayerNoIsland() {
@ -151,9 +151,6 @@ public class AdminClearResetsCommandTest {
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.player-has-no-island"));
}
/**
* Test method for {@link us.AdminClearResetsCommand.tastybento.bskyblock.commands.admin.AdminClearResetCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
*/
@Test
public void testExecuteSuccess() {
String[] name = {"tastybento"};

View File

@ -148,7 +148,7 @@ public class AdminInfoCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.admin.AdminInfoCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecutePlayerHasNoIsland() {

View File

@ -121,7 +121,7 @@ public class AdminRegisterCommandTest {
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminRegisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoTarget() {
@ -131,7 +131,7 @@ public class AdminRegisterCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminRegisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteUnknownPlayer() {
@ -143,7 +143,7 @@ public class AdminRegisterCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminRegisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecutePlayerHasIsland() {
@ -157,7 +157,7 @@ public class AdminRegisterCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminRegisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteInTeam() {
@ -171,7 +171,7 @@ public class AdminRegisterCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminRegisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteAlreadyOwnedIsland() {
@ -192,9 +192,6 @@ public class AdminRegisterCommandTest {
Mockito.verify(user).sendMessage("commands.admin.register.already-owned");
}
/**
* Test method for {@link us.world.bentobox.bbox.commands.admin.teams.AdminRegisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
*/
@Test
public void testExecuteSuccess() {
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(false);

View File

@ -119,7 +119,7 @@ public class AdminUnregisterCommandTest {
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminUnregisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoTarget() {
@ -129,7 +129,7 @@ public class AdminUnregisterCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminUnregisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteUnknownPlayer() {
@ -141,7 +141,7 @@ public class AdminUnregisterCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminUnregisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecutePlayerNoIsland() {
@ -154,7 +154,7 @@ public class AdminUnregisterCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.commands.admin.team.AdminUnregisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteInTeam() {
@ -167,7 +167,7 @@ public class AdminUnregisterCommandTest {
}
/**
* Test method for {@link us.world.bentobox.bbox.commands.admin.teams.AdminUnregisterCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteSuccess() {

View File

@ -37,13 +37,8 @@ import world.bentobox.bentobox.managers.PlayersManager;
@PrepareForTest({Bukkit.class, BentoBox.class, User.class })
public class AdminRangeCommandTest {
private BentoBox plugin;
private CompositeCommand ac;
private UUID uuid;
private User user;
private IslandsManager im;
private PlayersManager pm;
private UUID notUUID;
/**
@ -52,7 +47,7 @@ public class AdminRangeCommandTest {
@Before
public void setUp() throws Exception {
// Set up plugin
plugin = mock(BentoBox.class);
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
// Command manager
@ -69,8 +64,8 @@ public class AdminRangeCommandTest {
// Sometimes use Mockito.withSettings().verboseLogging()
user = mock(User.class);
when(user.isOp()).thenReturn(false);
uuid = UUID.randomUUID();
notUUID = UUID.randomUUID();
UUID uuid = UUID.randomUUID();
UUID notUUID = UUID.randomUUID();
while(notUUID.equals(uuid)) {
notUUID = UUID.randomUUID();
}
@ -92,7 +87,7 @@ public class AdminRangeCommandTest {
// Player has island to begin with
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
@ -100,7 +95,7 @@ public class AdminRangeCommandTest {
when(plugin.getIslands()).thenReturn(im);
// Has team
pm = mock(PlayersManager.class);
PlayersManager pm = mock(PlayersManager.class);
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(plugin.getPlayers()).thenReturn(pm);
@ -112,12 +107,7 @@ public class AdminRangeCommandTest {
// Locales
LocalesManager lm = mock(LocalesManager.class);
Answer<String> answer = new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArgumentAt(1, String.class);
}};
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
when(plugin.getLocalesManager()).thenReturn(lm);
}

View File

@ -43,13 +43,8 @@ import world.bentobox.bentobox.managers.PlayersManager;
@PrepareForTest({Bukkit.class, BentoBox.class, User.class })
public class AdminRangeDisplayCommandTest {
private BentoBox plugin;
private CompositeCommand ac;
private UUID uuid;
private User user;
private IslandsManager im;
private PlayersManager pm;
private UUID notUUID;
/**
@ -58,7 +53,7 @@ public class AdminRangeDisplayCommandTest {
@Before
public void setUp() throws Exception {
// Set up plugin
plugin = mock(BentoBox.class);
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
// Command manager
@ -75,8 +70,8 @@ public class AdminRangeDisplayCommandTest {
// Sometimes use Mockito.withSettings().verboseLogging()
user = mock(User.class);
when(user.isOp()).thenReturn(false);
uuid = UUID.randomUUID();
notUUID = UUID.randomUUID();
UUID uuid = UUID.randomUUID();
UUID notUUID = UUID.randomUUID();
while(notUUID.equals(uuid)) {
notUUID = UUID.randomUUID();
}
@ -96,7 +91,7 @@ public class AdminRangeDisplayCommandTest {
// Player has island to begin with
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.isOwner(Mockito.any(),Mockito.any())).thenReturn(true);
@ -104,7 +99,7 @@ public class AdminRangeDisplayCommandTest {
when(plugin.getIslands()).thenReturn(im);
// Has team
pm = mock(PlayersManager.class);
PlayersManager pm = mock(PlayersManager.class);
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(plugin.getPlayers()).thenReturn(pm);
@ -116,12 +111,7 @@ public class AdminRangeDisplayCommandTest {
// Locales
LocalesManager lm = mock(LocalesManager.class);
Answer<String> answer = new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArgumentAt(1, String.class);
}};
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
when(plugin.getLocalesManager()).thenReturn(lm);
}

View File

@ -47,13 +47,11 @@ import world.bentobox.bentobox.managers.PlayersManager;
@PrepareForTest({Bukkit.class, BentoBox.class, User.class })
public class AdminRangeResetCommandTest {
private BentoBox plugin;
private CompositeCommand ac;
private UUID uuid;
private User user;
private IslandsManager im;
private PlayersManager pm;
private UUID notUUID;
/**
@ -62,7 +60,7 @@ public class AdminRangeResetCommandTest {
@Before
public void setUp() throws Exception {
// Set up plugin
plugin = mock(BentoBox.class);
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
// Command manager
@ -80,7 +78,7 @@ public class AdminRangeResetCommandTest {
user = mock(User.class);
when(user.isOp()).thenReturn(false);
uuid = UUID.randomUUID();
notUUID = UUID.randomUUID();
UUID notUUID = UUID.randomUUID();
while(notUUID.equals(uuid)) {
notUUID = UUID.randomUUID();
}
@ -124,13 +122,7 @@ public class AdminRangeResetCommandTest {
// Locales
LocalesManager lm = mock(LocalesManager.class);
Answer<String> answer = new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArgumentAt(1, String.class);
}
};
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
when(plugin.getLocalesManager()).thenReturn(lm);

View File

@ -47,13 +47,11 @@ import world.bentobox.bentobox.managers.PlayersManager;
@PrepareForTest({Bukkit.class, BentoBox.class, User.class })
public class AdminRangeSetCommandTest {
private BentoBox plugin;
private CompositeCommand ac;
private UUID uuid;
private User user;
private IslandsManager im;
private PlayersManager pm;
private UUID notUUID;
/**
@ -62,7 +60,7 @@ public class AdminRangeSetCommandTest {
@Before
public void setUp() throws Exception {
// Set up plugin
plugin = mock(BentoBox.class);
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
// Command manager
@ -80,7 +78,7 @@ public class AdminRangeSetCommandTest {
user = mock(User.class);
when(user.isOp()).thenReturn(false);
uuid = UUID.randomUUID();
notUUID = UUID.randomUUID();
UUID notUUID = UUID.randomUUID();
while(notUUID.equals(uuid)) {
notUUID = UUID.randomUUID();
}
@ -126,13 +124,7 @@ public class AdminRangeSetCommandTest {
// Locales
LocalesManager lm = mock(LocalesManager.class);
Answer<String> answer = new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArgumentAt(1, String.class);
}
};
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
when(plugin.getLocalesManager()).thenReturn(lm);

View File

@ -47,7 +47,6 @@ import world.bentobox.bentobox.managers.PlayersManager;
@PrepareForTest({Bukkit.class, BentoBox.class, User.class })
public class AdminTeamKickCommandTest {
private BentoBox plugin;
private CompositeCommand ac;
private UUID uuid;
private User user;
@ -61,7 +60,7 @@ public class AdminTeamKickCommandTest {
@Before
public void setUp() throws Exception {
// Set up plugin
plugin = mock(BentoBox.class);
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
// Command manager

View File

@ -8,16 +8,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
@ -149,7 +140,7 @@ public class IslandBanCommandTest {
@Test
public void testNoIsland() {
IslandBanCommand ibc = new IslandBanCommand(ic);
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.errors.no-island");
}
@ -157,7 +148,7 @@ public class IslandBanCommandTest {
public void testNotOwner() {
IslandBanCommand ibc = new IslandBanCommand(ic);
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.errors.not-leader");
}
@ -167,7 +158,7 @@ public class IslandBanCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(pm.getUUID(Mockito.anyString())).thenReturn(null);
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.errors.unknown-player");
}
@ -177,7 +168,7 @@ public class IslandBanCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(pm.getUUID(Mockito.anyString())).thenReturn(uuid);
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban-yourself");
}
@ -192,7 +183,7 @@ public class IslandBanCommandTest {
members.add(uuid);
members.add(teamMate);
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban-member");
}
@ -204,7 +195,7 @@ public class IslandBanCommandTest {
UUID bannedUser = UUID.randomUUID();
when(pm.getUUID(Mockito.anyString())).thenReturn(bannedUser);
when(island.isBanned(Mockito.eq(bannedUser))).thenReturn(true);
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("commands.island.ban.player-already-banned");
}
@ -220,7 +211,7 @@ public class IslandBanCommandTest {
when(opUser.isOp()).thenReturn(true);
when(opUser.isPlayer()).thenReturn(true);
when(User.getInstance(Mockito.any(UUID.class))).thenReturn(opUser);
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban");
}
@ -241,7 +232,7 @@ public class IslandBanCommandTest {
// Allow adding to ban list
when(island.addToBanList(Mockito.any())).thenReturn(true);
assertTrue(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertTrue(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.success");
Mockito.verify(targetUser).sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName());
}
@ -262,7 +253,7 @@ public class IslandBanCommandTest {
// Allow adding to ban list
when(island.addToBanList(Mockito.any())).thenReturn(true);
assertTrue(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertTrue(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.success");
Mockito.verify(targetUser).sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName());
}
@ -283,7 +274,7 @@ public class IslandBanCommandTest {
// Disallow adding to ban list - even cancelled
when(island.addToBanList(Mockito.any())).thenReturn(false);
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user, Mockito.never()).sendMessage("general.success");
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName());
}
@ -309,34 +300,13 @@ public class IslandBanCommandTest {
onlinePlayers.add(p);
}
when(island.isBanned(Mockito.any(UUID.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
return banned.contains(invocation.getArgumentAt(0, UUID.class));
}
});
when(island.isBanned(Mockito.any(UUID.class))).thenAnswer((Answer<Boolean>) invocation -> banned.contains(invocation.getArgumentAt(0, UUID.class)));
// Create the names
when(pm.getName(Mockito.any(UUID.class))).then(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return online.getOrDefault(invocation.getArgumentAt(0, UUID.class), "tastybento");
}
});
when(pm.getName(Mockito.any(UUID.class))).then((Answer<String>) invocation -> online.getOrDefault(invocation.getArgumentAt(0, UUID.class), "tastybento"));
// Return a set of online players
PowerMockito.mockStatic(Bukkit.class);
when(Bukkit.getOnlinePlayers()).then(new Answer<Set<Player>>() {
@Override
public Set<Player> answer(InvocationOnMock invocation) throws Throwable {
return onlinePlayers;
}
});
when(Bukkit.getOnlinePlayers()).then((Answer<Set<Player>>) invocation -> onlinePlayers);
IslandBanCommand ibc = new IslandBanCommand(ic);
// Set up the user
@ -344,14 +314,9 @@ public class IslandBanCommandTest {
when(user.getUniqueId()).thenReturn(UUID.randomUUID());
Player player = mock(Player.class);
// Player can see every other player except Ian
when(player.canSee(Mockito.any(Player.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
Player p = invocation.getArgumentAt(0, Player.class);
return !p.getName().equals("ian");
}
when(player.canSee(Mockito.any(Player.class))).thenAnswer((Answer<Boolean>) invocation -> {
Player p = invocation.getArgumentAt(0, Player.class);
return !p.getName().equals("ian");
});
when(user.getPlayer()).thenReturn(player);

View File

@ -8,13 +8,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -120,12 +114,12 @@ public class IslandBanlistCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandBanlistCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testWithArgs() {
IslandBanlistCommand iubc = new IslandBanlistCommand(ic);
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
// Verify show help
}
@ -152,21 +146,14 @@ public class IslandBanlistCommandTest {
String[] names = {"adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe"};
Set<UUID> banned = new HashSet<>();
Map<UUID, String> uuidToName = new HashMap<>();
for (int j = 0; j < names.length; j++) {
for (String name : names) {
UUID uuid = UUID.randomUUID();
banned.add(uuid);
uuidToName.put(uuid, names[j]);
uuidToName.put(uuid, name);
}
when(island.getBanned()).thenReturn(banned);
// Respond to name queries
when(pm.getName(Mockito.any(UUID.class))).then(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return uuidToName.getOrDefault(invocation.getArgumentAt(0, UUID.class), "tastybento");
}
});
when(pm.getName(Mockito.any(UUID.class))).then((Answer<String>) invocation -> uuidToName.getOrDefault(invocation.getArgumentAt(0, UUID.class), "tastybento"));
assertTrue(iubc.execute(user, iubc.getLabel(), new ArrayList<>()));
Mockito.verify(user).sendMessage("commands.island.banlist.the-following");
}

View File

@ -48,12 +48,9 @@ import world.bentobox.bentobox.util.Util;
@PrepareForTest({Bukkit.class, BentoBox.class, Util.class})
public class IslandGoCommandTest {
private CompositeCommand ic;
private UUID uuid;
private User user;
private IslandsManager im;
private PlayersManager pm;
private Island island;
private Player player;
/**
@ -76,11 +73,11 @@ public class IslandGoCommandTest {
when(plugin.getSettings()).thenReturn(s);
// Player
player = mock(Player.class);
Player player = mock(Player.class);
// Sometimes use Mockito.withSettings().verboseLogging()
user = mock(User.class);
when(user.isOp()).thenReturn(false);
uuid = UUID.randomUUID();
UUID uuid = UUID.randomUUID();
when(user.getUniqueId()).thenReturn(uuid);
when(user.getPlayer()).thenReturn(player);
when(user.getName()).thenReturn("tastybento");
@ -97,7 +94,7 @@ public class IslandGoCommandTest {
when(plugin.getIslands()).thenReturn(im);
// Has team
pm = mock(PlayersManager.class);
PlayersManager pm = mock(PlayersManager.class);
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(plugin.getPlayers()).thenReturn(pm);
@ -124,7 +121,7 @@ public class IslandGoCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandGoCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoArgsNoIsland() {
@ -136,7 +133,7 @@ public class IslandGoCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandGoCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoArgs() {
@ -146,7 +143,7 @@ public class IslandGoCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandGoCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoArgsMultipleHomes() {
@ -157,7 +154,7 @@ public class IslandGoCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandGoCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteArgs1MultipleHomes() {
@ -170,7 +167,7 @@ public class IslandGoCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandGoCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteArgs2MultipleHomes() {
@ -185,7 +182,7 @@ public class IslandGoCommandTest {
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandGoCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteArgsJunkMultipleHomes() {

View File

@ -123,7 +123,7 @@ public class IslandResetCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandResetCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
* @throws IOException
*/
@Test

View File

@ -8,15 +8,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -119,7 +111,7 @@ public class IslandUnbanCommandTest {
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.island.IslandUnbanCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
// Island ban command by itself
@ -142,7 +134,7 @@ public class IslandUnbanCommandTest {
@Test
public void testNoIsland() {
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.errors.no-island");
}
@ -150,7 +142,7 @@ public class IslandUnbanCommandTest {
public void testNotOwner() {
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.errors.not-leader");
}
@ -160,7 +152,7 @@ public class IslandUnbanCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(pm.getUUID(Mockito.anyString())).thenReturn(null);
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.errors.unknown-player");
}
@ -170,7 +162,7 @@ public class IslandUnbanCommandTest {
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
when(pm.getUUID(Mockito.anyString())).thenReturn(uuid);
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("commands.island.unban.cannot-unban-yourself");
}
@ -182,7 +174,7 @@ public class IslandUnbanCommandTest {
UUID bannedUser = UUID.randomUUID();
when(pm.getUUID(Mockito.anyString())).thenReturn(bannedUser);
when(island.isBanned(Mockito.eq(bannedUser))).thenReturn(false);
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("commands.island.unban.player-not-banned");
}
@ -205,7 +197,7 @@ public class IslandUnbanCommandTest {
// Allow removing from ban list
when(island.removeFromBanList(Mockito.any())).thenReturn(true);
assertTrue(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
assertTrue(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user).sendMessage("general.success");
Mockito.verify(targetUser).sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, user.getName());
}
@ -229,7 +221,7 @@ public class IslandUnbanCommandTest {
// Allow removing from ban list
when(island.removeFromBanList(Mockito.any())).thenReturn(false);
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
Mockito.verify(user, Mockito.never()).sendMessage("general.success");
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.unban.you-are-unbanned", "[owner]", user.getName());
}

View File

@ -120,7 +120,7 @@ public class IslandTeamInviteCommandTest {
}
/**
* Test method for {@link IslandTeamInviteCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoIsland() {
@ -131,7 +131,7 @@ public class IslandTeamInviteCommandTest {
}
/**
* Test method for {@link IslandTeamInviteCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNotTeamLeader() {
@ -142,7 +142,7 @@ public class IslandTeamInviteCommandTest {
}
/**
* Test method for {@link IslandTeamInviteCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoTarget() {
@ -152,7 +152,7 @@ public class IslandTeamInviteCommandTest {
}
/**
* Test method for {@link IslandTeamInviteCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteUnknownPlayer() {
@ -165,7 +165,7 @@ public class IslandTeamInviteCommandTest {
/**
* Test method for {@link IslandTeamInviteCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteOfflinePlayer() {
@ -180,7 +180,7 @@ public class IslandTeamInviteCommandTest {
}
/**
* Test method for {@link IslandTeamInviteCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteSamePlayer() {
@ -196,7 +196,7 @@ public class IslandTeamInviteCommandTest {
/**
* Test method for {@link IslandTeamInviteCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteDifferentPlayerInTeam() {
@ -212,7 +212,7 @@ public class IslandTeamInviteCommandTest {
}
/**
* Test method for {@link IslandTeamInviteCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteCoolDownActive() {

View File

@ -130,7 +130,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoTeam() {
@ -141,7 +141,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNotTeamLeader() {
@ -152,7 +152,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoTarget() {
@ -162,7 +162,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteUnknownPlayer() {
@ -174,7 +174,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteSamePlayer() {
@ -187,7 +187,7 @@ public class IslandTeamKickCommandTest {
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteDifferentPlayerNotInTeam() {
@ -200,7 +200,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoConfirmation() {
@ -220,7 +220,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteWithConfirmation() {
@ -240,7 +240,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteTestResets() {
@ -272,7 +272,7 @@ public class IslandTeamKickCommandTest {
}
/**
* Test method for {@link IslandTeamKickCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testCooldown() {

View File

@ -107,7 +107,7 @@ public class IslandTeamLeaveCommandTest {
}
/**
* Test method for {@link IslandTeamLeaveCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoTeam() {
@ -118,7 +118,7 @@ public class IslandTeamLeaveCommandTest {
}
/**
* Test method for {@link IslandTeamLeaveCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteInTeamLeader() {
@ -128,7 +128,7 @@ public class IslandTeamLeaveCommandTest {
}
/**
* Test method for {@link IslandTeamLeaveCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteNoConfirmation() {
@ -145,7 +145,7 @@ public class IslandTeamLeaveCommandTest {
}
/**
* Test method for {@link IslandTeamLeaveCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteWithConfirmation() {
@ -164,7 +164,7 @@ public class IslandTeamLeaveCommandTest {
}
/**
* Test method for {@link IslandTeamLeaveCommand#execute(world.bentobox.bentobox.api.user.User, java.util.List)}.
* Test method for .
*/
@Test
public void testExecuteTestResets() {

View File

@ -190,16 +190,11 @@ public class FlagTest {
User user = mock(User.class);
when(user.getUniqueId()).thenReturn(UUID.randomUUID());
Answer<String> answer = new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
StringBuilder sb = new StringBuilder();
Arrays.stream(invocation.getArguments()).forEach(sb::append);
sb.append("mock");
return sb.toString();
}
Answer<String> answer = invocation -> {
StringBuilder sb = new StringBuilder();
Arrays.stream(invocation.getArguments()).forEach(sb::append);
sb.append("mock");
return sb.toString();
};
when(user.getTranslation(Mockito.anyVararg())).thenAnswer(answer);
@ -207,7 +202,7 @@ public class FlagTest {
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
when(im.getIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(island);
Optional<Island> oL = Optional.ofNullable(island);
Optional<Island> oL = Optional.of(island);
when(im.getIslandAt(Mockito.any(Location.class))).thenReturn(oL);
when(plugin.getIslands()).thenReturn(im);

View File

@ -63,7 +63,7 @@ public class CycleClickTest {
private IslandWorldManager iwm;
/**
* @throws java.lang.Exception
* @throws java.lang.Exception - exception
*/
@Before
public void setUp() throws Exception {

View File

@ -9,6 +9,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;
@ -127,7 +128,7 @@ public class PanelItemBuilderTest {
@Test
public void testDescriptionString() {
PanelItemBuilder builder = new PanelItemBuilder();
List<String> test = Arrays.asList("test line 5");
List<String> test = Collections.singletonList("test line 5");
builder.description("test line 5");
PanelItem item = builder.build();
assertEquals(test, item.getDescription());

View File

@ -30,8 +30,6 @@ import world.bentobox.bentobox.managers.IslandWorldManager;
@PrepareForTest({Bukkit.class, BentoBox.class})
public class PlayersTest {
private IslandWorldManager s;
/**
* @throws java.lang.Exception
*/
@ -40,7 +38,7 @@ public class PlayersTest {
// Set up plugin
plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
s = mock(IslandWorldManager.class);
IslandWorldManager s = mock(IslandWorldManager.class);
when(s.getDeathsMax(Mockito.any())).thenReturn(3);
when(plugin.getIWM()).thenReturn(s);

View File

@ -74,14 +74,7 @@ public class BannedVisitorCommandsTest {
when(p.getName()).thenReturn(uuid.toString());
onlinePlayers.add(p);
}
when(server.getOnlinePlayers()).then(new Answer<Set<Player>>() {
@Override
public Set<Player> answer(InvocationOnMock invocation) throws Throwable {
return onlinePlayers;
}
});
when(server.getOnlinePlayers()).then((Answer<Set<Player>>) invocation -> onlinePlayers);
when(player.getServer()).thenReturn(server);
// Island manager

View File

@ -58,11 +58,9 @@ public class PanelListenerManagerTest {
private PanelListenerManager plm;
private UUID uuid;
private Panel panel;
private Panel wrongPanel;
private Inventory anotherInv;
private PanelListener pl;
private ClickHandler ch;
private Settings settings;
/**
* @throws java.lang.Exception
@ -73,7 +71,7 @@ public class PanelListenerManagerTest {
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
// Settings
settings = mock(Settings.class);
Settings settings = mock(Settings.class);
when(plugin.getSettings()).thenReturn(settings);
when(settings.isClosePanelOnClickOutside()).thenReturn(true);
@ -108,8 +106,8 @@ public class PanelListenerManagerTest {
when(panelItem.getClickHandler()).thenReturn(och);
map.put(0, panelItem);
when(panel.getItems()).thenReturn(map);
wrongPanel = mock(Panel.class);
Panel wrongPanel = mock(Panel.class);
anotherInv = mock(Inventory.class);
when(anotherInv.getName()).thenReturn("another_name");
when(wrongPanel.getInventory()).thenReturn(anotherInv);

View File

@ -69,8 +69,6 @@ public class ChestDamageListenerTest {
private static Location location;
private static BentoBox plugin;
private static IslandWorldManager iwm;
private static IslandsManager im;
private static World world;
@BeforeClass
@ -109,7 +107,7 @@ public class ChestDamageListenerTest {
// Worlds
iwm = mock(IslandWorldManager.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(iwm.inWorld(any())).thenReturn(true);
when(plugin.getIWM()).thenReturn(iwm);
@ -124,7 +122,7 @@ public class ChestDamageListenerTest {
// Fake players
Settings settings = mock(Settings.class);
Mockito.when(plugin.getSettings()).thenReturn(settings);
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<String>());
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<>());
// Users
//User user = mock(User.class);
@ -136,14 +134,7 @@ public class ChestDamageListenerTest {
LocalesManager lm = mock(LocalesManager.class);
when(plugin.getLocalesManager()).thenReturn(lm);
Answer<String> answer = new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return (String)Arrays.asList(invocation.getArguments()).get(1);
}
};
Answer<String> answer = invocation -> (String)Arrays.asList(invocation.getArguments()).get(1);
when(lm.get(any(), any())).thenAnswer(answer);
// Player name
@ -158,7 +149,7 @@ public class ChestDamageListenerTest {
when(ws.getWorldFlags()).thenReturn(worldFlags);
// Island manager
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im);
Island island = mock(Island.class);
Optional<Island> optional = Optional.of(island);

View File

@ -44,7 +44,6 @@ public class CleanSuperFlatListenerTest {
private Block block;
private Chunk chunk;
private IslandWorldManager iwm;
private BentoBox plugin;
/**
* @throws java.lang.Exception
@ -53,7 +52,7 @@ public class CleanSuperFlatListenerTest {
public void setUp() throws Exception {
// Set up plugin
plugin = mock(BentoBox.class);
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
when(plugin.isLoaded()).thenReturn(true);

View File

@ -52,11 +52,7 @@ import world.bentobox.bentobox.util.Util;
@PrepareForTest({BentoBox.class, Util.class, User.class })
public class EnderChestListenerTest {
private Island island;
private IslandsManager im;
private World world;
private Location inside;
private UUID uuid;
private Player player;
private IslandWorldManager iwm;
@ -70,17 +66,17 @@ public class EnderChestListenerTest {
world = mock(World.class);
// Owner
uuid = UUID.randomUUID();
UUID uuid1 = UUID.randomUUID();
// Island initialization
island = mock(Island.class);
when(island.getOwner()).thenReturn(uuid);
Island island = mock(Island.class);
when(island.getOwner()).thenReturn(uuid1);
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im);
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
inside = mock(Location.class);
Location inside = mock(Location.class);
when(inside.getWorld()).thenReturn(world);
Optional<Island> opIsland = Optional.ofNullable(island);
@ -116,12 +112,7 @@ public class EnderChestListenerTest {
// Locales - this returns the string that was requested for translation
LocalesManager lm = mock(LocalesManager.class);
when(plugin.getLocalesManager()).thenReturn(lm);
when(lm.get(any(), any())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArgumentAt(1, String.class);
}});
when(lm.get(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(1, String.class));
}

View File

@ -59,10 +59,7 @@ import world.bentobox.bentobox.util.Util;
@PrepareForTest( {BentoBox.class, Flags.class, Util.class, Bukkit.class} )
public class EndermanListenerTest {
private static Location location;
private static BentoBox plugin;
private static IslandWorldManager iwm;
private static IslandsManager im;
private static World world;
private static Enderman enderman;
private static Slime slime;
@ -71,7 +68,7 @@ public class EndermanListenerTest {
@Before
public void setUp() {
// Set up plugin
plugin = mock(BentoBox.class);
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
Server server = mock(Server.class);
@ -93,7 +90,7 @@ public class EndermanListenerTest {
when(itemFactory.getItemMeta(any())).thenReturn(skullMeta);
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
location = mock(Location.class);
Location location = mock(Location.class);
when(location.getWorld()).thenReturn(world);
when(location.getBlockX()).thenReturn(0);
when(location.getBlockY()).thenReturn(0);
@ -122,7 +119,7 @@ public class EndermanListenerTest {
// Fake players
Settings settings = mock(Settings.class);
Mockito.when(plugin.getSettings()).thenReturn(settings);
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<String>());
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<>());
// World Settings
WorldSettings ws = mock(WorldSettings.class);
@ -131,7 +128,7 @@ public class EndermanListenerTest {
when(ws.getWorldFlags()).thenReturn(worldFlags);
// Island manager
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im);
Island island = mock(Island.class);
Optional<Island> optional = Optional.of(island);
@ -207,7 +204,7 @@ public class EndermanListenerTest {
@Test
public void testOnNotEndermanDeath() {
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(slime, new ArrayList<ItemStack>());
EntityDeathEvent e = new EntityDeathEvent(slime, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
@ -220,7 +217,7 @@ public class EndermanListenerTest {
public void testOnEndermanDeathCarryAir() {
when(bd.getMaterial()).thenReturn(Material.AIR);
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<ItemStack>());
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
}
@ -232,7 +229,7 @@ public class EndermanListenerTest {
public void testOnEndermanDeathNotInWorld() {
when(iwm.inWorld(Mockito.any())).thenReturn(false);
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<ItemStack>());
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
@ -245,7 +242,7 @@ public class EndermanListenerTest {
public void testOnEndermanDeathNoFlag() {
Flags.ENDERMAN_DEATH_DROP.setSetting(world, false);
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<ItemStack>());
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world, Mockito.never()).dropItemNaturally(Mockito.any(), Mockito.any());
@ -257,7 +254,7 @@ public class EndermanListenerTest {
@Test
public void testOnEndermanDeath() {
EndermanListener listener = new EndermanListener();
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<ItemStack>());
EntityDeathEvent e = new EntityDeathEvent(enderman, new ArrayList<>());
listener.onEndermanDeath(e);
Mockito.verify(world).dropItemNaturally(Mockito.any(), Mockito.any());

View File

@ -51,15 +51,10 @@ public class EnterExitListenerTest {
private static final Integer X = 600;
private static final Integer Y = 120;
private static final Integer Z = 10000;
private UUID uuid;
private User user;
private IslandsManager im;
private Island island;
private World world;
private Location outside;
private Location inside;
private Notifier notifier;
private Location inside2;
private EnterExitListener listener;
private LocalesManager lm;
/**
@ -73,7 +68,7 @@ public class EnterExitListenerTest {
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
// World
world = mock(World.class);
World world = mock(World.class);
// Settings
Settings s = mock(Settings.class);
@ -85,13 +80,13 @@ public class EnterExitListenerTest {
user = mock(User.class);
User.setPlugin(plugin);
when(user.isOp()).thenReturn(false);
uuid = UUID.randomUUID();
UUID uuid = UUID.randomUUID();
when(user.getUniqueId()).thenReturn(uuid);
when(user.getPlayer()).thenReturn(p);
when(user.getName()).thenReturn("tastybento");
// No island for player to begin with (set it later in the tests)
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im);
// Locales
@ -100,7 +95,7 @@ public class EnterExitListenerTest {
when(lm.get(any(), any())).thenReturn("mock translation");
// Notifier
notifier = mock(Notifier.class);
Notifier notifier = mock(Notifier.class);
when(plugin.getNotifier()).thenReturn(notifier);
// Island initialization
@ -131,7 +126,7 @@ public class EnterExitListenerTest {
when(inside.getBlockZ()).thenReturn(Z);
when(inside.toVector()).thenReturn(new Vector(X + PROTECTION_RANGE - 1, Y, Z));
inside2 = mock(Location.class);
Location inside2 = mock(Location.class);
when(inside.getWorld()).thenReturn(world);
when(inside.getBlockX()).thenReturn(X + PROTECTION_RANGE - 2);
when(inside.getBlockY()).thenReturn(Y);

View File

@ -57,7 +57,6 @@ public class FireListenerTest {
private static Location location;
private static BentoBox plugin;
private static IslandWorldManager iwm;
@BeforeClass
public static void setUpClass() {
@ -95,7 +94,7 @@ public class FireListenerTest {
// Worlds
iwm = mock(IslandWorldManager.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(iwm.inWorld(any())).thenReturn(true);
when(plugin.getIWM()).thenReturn(iwm);
@ -110,7 +109,7 @@ public class FireListenerTest {
// Fake players
Settings settings = mock(Settings.class);
Mockito.when(plugin.getSettings()).thenReturn(settings);
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<String>());
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<>());
// Users
//User user = mock(User.class);

View File

@ -50,10 +50,7 @@ public class InvincibleVisitorsListenerTest {
private InvincibleVisitorsListener listener;
private Panel panel;
private User user;
private Flag flag;
private IslandsManager im;
private Island island;
private UUID uuid;
private List<String> ivSettings;
private Player player;
@ -86,13 +83,13 @@ public class InvincibleVisitorsListenerTest {
when(user.getPlayer()).thenReturn(player);
when(user.hasPermission(Mockito.anyString())).thenReturn(true);
when(user.getTranslation(Mockito.anyString())).thenReturn("panel");
uuid = UUID.randomUUID();
UUID uuid = UUID.randomUUID();
when(user.getUniqueId()).thenReturn(uuid);
PowerMockito.mockStatic(Util.class);
when(Util.getWorld(Mockito.any())).thenReturn(mock(World.class));
FlagsManager fm = mock(FlagsManager.class);
flag = mock(Flag.class);
Flag flag = mock(Flag.class);
when(flag.isSetForWorld(Mockito.any())).thenReturn(false);
PanelItem item = mock(PanelItem.class);
when(item.getItem()).thenReturn(mock(ItemStack.class));
@ -102,7 +99,7 @@ public class InvincibleVisitorsListenerTest {
// Island Manager
im = mock(IslandsManager.class);
island = mock(Island.class);
Island island = mock(Island.class);
when(island.getOwner()).thenReturn(uuid);
when(im.getIsland(Mockito.any(World.class), Mockito.any(User.class))).thenReturn(island);
// Visitor

View File

@ -60,22 +60,16 @@ import world.bentobox.bentobox.util.Util;
@PrepareForTest( {BentoBox.class, Flags.class, Util.class, Bukkit.class} )
public class ItemFrameListenerTest {
private static Location location;
private static BentoBox plugin;
private static IslandWorldManager iwm;
private static IslandsManager im;
private static World world;
private static Enderman enderman;
private static Slime slime;
@Before
public void setUp() {
// Set up plugin
plugin = mock(BentoBox.class);
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
Server server = mock(Server.class);
world = mock(World.class);
World world = mock(World.class);
when(server.getLogger()).thenReturn(Logger.getAnonymousLogger());
when(server.getWorld("world")).thenReturn(world);
when(server.getVersion()).thenReturn("BSB_Mocking");
@ -93,7 +87,7 @@ public class ItemFrameListenerTest {
when(itemFactory.getItemMeta(any())).thenReturn(skullMeta);
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
location = mock(Location.class);
Location location = mock(Location.class);
when(location.getWorld()).thenReturn(world);
when(location.getBlockX()).thenReturn(0);
when(location.getBlockY()).thenReturn(0);
@ -105,7 +99,7 @@ public class ItemFrameListenerTest {
// Worlds
iwm = mock(IslandWorldManager.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(iwm.inWorld(any())).thenReturn(true);
when(plugin.getIWM()).thenReturn(iwm);
@ -113,13 +107,13 @@ public class ItemFrameListenerTest {
enderman = mock(Enderman.class);
when(enderman.getLocation()).thenReturn(location);
when(enderman.getWorld()).thenReturn(world);
slime = mock(Slime.class);
Slime slime = mock(Slime.class);
when(slime.getLocation()).thenReturn(location);
// Fake players
Settings settings = mock(Settings.class);
Mockito.when(plugin.getSettings()).thenReturn(settings);
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<String>());
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<>());
// World Settings
WorldSettings ws = mock(WorldSettings.class);
@ -128,7 +122,7 @@ public class ItemFrameListenerTest {
when(ws.getWorldFlags()).thenReturn(worldFlags);
// Island manager
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im);
Island island = mock(Island.class);
Optional<Island> optional = Optional.of(island);

View File

@ -64,7 +64,6 @@ public class LockAndBanListenerTest {
private Notifier notifier;
private Location inside2;
private BukkitScheduler sch;
private Player player;
/**
* @throws java.lang.Exception
@ -92,7 +91,7 @@ public class LockAndBanListenerTest {
when(plugin.getSettings()).thenReturn(s);
// Player
player = mock(Player.class);
Player player = mock(Player.class);
// Sometimes use Mockito.withSettings().verboseLogging()
user = mock(User.class);
User.setPlugin(plugin);
@ -688,14 +687,7 @@ public class LockAndBanListenerTest {
when(player2.getUniqueId()).thenReturn(uuid2);
// Player 1 is not a member, player 2 is an island member
when(island.isAllowed(Mockito.any(User.class), Mockito.any())).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArgumentAt(0, User.class).getUniqueId().equals(uuid2);
}
});
when(island.isAllowed(Mockito.any(User.class), Mockito.any())).thenAnswer((Answer<Boolean>) invocation -> invocation.getArgumentAt(0, User.class).getUniqueId().equals(uuid2));
// Create vehicle and put two players in it. One is a member, the other is not
Vehicle vehicle = mock(Vehicle.class);

View File

@ -54,7 +54,6 @@ public class MobSpawnListenerTest {
private static Slime slime;
private static Cow cow;
private static IslandWorldManager iwm;
private static World world;
@BeforeClass
public static void setUpBeforeClass() {
@ -66,7 +65,7 @@ public class MobSpawnListenerTest {
when(plugin.getIslands()).thenReturn(im);
Server server = mock(Server.class);
world = mock(World.class);
World world = mock(World.class);
when(server.getLogger()).thenReturn(Logger.getAnonymousLogger());
when(server.getWorld("world")).thenReturn(world);
when(server.getVersion()).thenReturn("BSB_Mocking");

View File

@ -39,8 +39,6 @@ import world.bentobox.bentobox.util.Util;
public class OfflineRedstoneListenerTest {
private World world;
private UUID uuid;
private Island island;
private IslandsManager im;
private Location inside;
private Block block;
@ -54,10 +52,10 @@ public class OfflineRedstoneListenerTest {
// World
world = mock(World.class);
// Owner
uuid = UUID.randomUUID();
UUID uuid = UUID.randomUUID();
// Island initialization
island = mock(Island.class);
Island island = mock(Island.class);
when(island.getOwner()).thenReturn(uuid);
// Add members
Builder<UUID> set = new ImmutableSet.Builder<>();

View File

@ -10,14 +10,7 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -84,10 +77,7 @@ import world.bentobox.bentobox.util.Util;
public class PVPListenerTest {
private IslandWorldManager iwm;
private Panel panel;
private Flag flag;
private IslandsManager im;
private Settings s;
private Island island;
private Player player;
private Player player2;
@ -112,7 +102,7 @@ public class PVPListenerTest {
when(iwm.getIvSettings(Mockito.any())).thenReturn(new ArrayList<>());
when(plugin.getIWM()).thenReturn(iwm);
panel = mock(Panel.class);
Panel panel = mock(Panel.class);
when(panel.getInventory()).thenReturn(mock(Inventory.class));
// Sometimes use Mockito.withSettings().verboseLogging()
@ -143,7 +133,7 @@ public class PVPListenerTest {
when(Util.getWorld(Mockito.any())).thenReturn(mock(World.class));
FlagsManager fm = mock(FlagsManager.class);
flag = mock(Flag.class);
Flag flag = mock(Flag.class);
when(flag.isSetForWorld(Mockito.any())).thenReturn(false);
PanelItem item = mock(PanelItem.class);
when(item.getItem()).thenReturn(mock(ItemStack.class));
@ -162,18 +152,13 @@ public class PVPListenerTest {
when(plugin.getIslands()).thenReturn(im);
// Settings
s = mock(Settings.class);
Settings s = mock(Settings.class);
when(plugin.getSettings()).thenReturn(s);
// Locales - this returns the string that was requested for translation
LocalesManager lm = mock(LocalesManager.class);
when(plugin.getLocalesManager()).thenReturn(lm);
when(lm.get(any(), any())).thenAnswer(new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArgumentAt(1, String.class);
}});
when(lm.get(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(1, String.class));
// Create some entities
zombie = mock(Zombie.class);
@ -203,7 +188,7 @@ public class PVPListenerTest {
Entity damager = mock(Zombie.class);
Entity damagee = mock(Creeper.class);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
assertFalse(e.isCancelled());
@ -216,7 +201,7 @@ public class PVPListenerTest {
public void testOnEntityDamageSelfDamage() {
Entity damager = mock(Player.class);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damager, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
assertFalse(e.isCancelled());
@ -234,21 +219,21 @@ public class PVPListenerTest {
when(damager.getWorld()).thenReturn(world);
when(damagee.getWorld()).thenReturn(world);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
assertFalse(e.isCancelled());
// Different attack type
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
assertFalse(e.isCancelled());
// Wrong world
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
when(iwm.inWorld(Mockito.any())).thenReturn(false);
new PVPListener().onEntityDamage(e);
@ -275,13 +260,13 @@ public class PVPListenerTest {
// This player is on their island, i.e., not a visitor
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
assertFalse(e.isCancelled());
// Wrong world
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
when(iwm.inWorld(Mockito.any())).thenReturn(false);
new PVPListener().onEntityDamage(e);
@ -308,13 +293,13 @@ public class PVPListenerTest {
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
assertTrue(e.isCancelled());
// Wrong world
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
when(iwm.inWorld(Mockito.any())).thenReturn(false);
new PVPListener().onEntityDamage(e);
@ -341,7 +326,7 @@ public class PVPListenerTest {
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
// Damage is not entity attack
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.THORNS,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
assertFalse(e.isCancelled());
@ -367,13 +352,13 @@ public class PVPListenerTest {
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
assertFalse(e.isCancelled());
// Wrong world
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
when(iwm.inWorld(Mockito.any())).thenReturn(false);
new PVPListener().onEntityDamage(e);
@ -399,7 +384,7 @@ public class PVPListenerTest {
// No visitor protection
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
// PVP should be banned
@ -409,7 +394,7 @@ public class PVPListenerTest {
// Enable visitor protection
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
new PVPListener().onEntityDamage(e);
// visitor should be protected
assertTrue(e.isCancelled());
@ -424,7 +409,7 @@ public class PVPListenerTest {
// PVP is allowed
when(island.isAllowed(Mockito.any())).thenReturn(true);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
// PVP should be allowed
@ -434,7 +419,7 @@ public class PVPListenerTest {
// Enable visitor protection
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
new PVPListener().onEntityDamage(e);
// visitor should be protected
assertTrue(e.isCancelled());
@ -451,7 +436,7 @@ public class PVPListenerTest {
when(p.getShooter()).thenReturn(player);
when(p.getLocation()).thenReturn(loc);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
// PVP should be banned
@ -461,7 +446,7 @@ public class PVPListenerTest {
// Visitor protection
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
new PVPListener().onEntityDamage(e);
// visitor should be protected
assertTrue(e.isCancelled());
@ -479,7 +464,7 @@ public class PVPListenerTest {
when(p.getShooter()).thenReturn(player);
when(p.getLocation()).thenReturn(loc);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
// Self damage okay
@ -497,7 +482,7 @@ public class PVPListenerTest {
// PVP is allowed
when(island.isAllowed(Mockito.any())).thenReturn(true);
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
new PVPListener().onEntityDamage(e);
// PVP should be allowed
@ -507,7 +492,7 @@ public class PVPListenerTest {
// Enable visitor protection
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
new PVPListener().onEntityDamage(e);
// visitor should be protected
assertTrue(e.isCancelled());
@ -576,7 +561,7 @@ public class PVPListenerTest {
// Protect visitors
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
new PVPListener().onFishing(pfe);
// visitor should be protected
assertTrue(pfe.isCancelled());
@ -612,7 +597,7 @@ public class PVPListenerTest {
// Protect visitors
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
new PVPListener().onFishing(pfe);
// visitor should be protected
assertTrue(pfe.isCancelled());
@ -747,7 +732,7 @@ public class PVPListenerTest {
// Protect visitors
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
new PVPListener().onSplashPotionSplash(e);
// visitor should be protected
assertTrue(e.isCancelled());
@ -890,7 +875,7 @@ public class PVPListenerTest {
// Protect visitor
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
// See who it affects
AreaEffectCloudApplyEvent ae = new AreaEffectCloudApplyEvent(cloud, list);
@ -930,7 +915,7 @@ public class PVPListenerTest {
// Protect visitor
// This player is a visitor and any damage is not allowed
when(im.userIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
when(iwm.getIvSettings(Mockito.any())).thenReturn(Arrays.asList("ENTITY_ATTACK"));
when(iwm.getIvSettings(Mockito.any())).thenReturn(Collections.singletonList("ENTITY_ATTACK"));
// See who it affects
AreaEffectCloudApplyEvent ae = new AreaEffectCloudApplyEvent(cloud, list);

View File

@ -39,13 +39,9 @@ import world.bentobox.bentobox.util.Util;
public class PistonPushListenerTest {
private Island island;
private IslandsManager im;
private World world;
private Location inside;
private UUID uuid;
private Block block;
private List<Block> blocks;
private Block blockPushed;
@Before
public void setUp() throws Exception {
@ -57,17 +53,17 @@ public class PistonPushListenerTest {
world = mock(World.class);
// Owner
uuid = UUID.randomUUID();
UUID uuid = UUID.randomUUID();
// Island initialization
island = mock(Island.class);
when(island.getOwner()).thenReturn(uuid);
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im);
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
inside = mock(Location.class);
Location inside = mock(Location.class);
Optional<Island> opIsland = Optional.ofNullable(island);
when(im.getProtectedIslandAt(Mockito.eq(inside))).thenReturn(opIsland);
@ -76,8 +72,8 @@ public class PistonPushListenerTest {
block = mock(Block.class);
when(block.getWorld()).thenReturn(world);
when(block.getLocation()).thenReturn(inside);
blockPushed = mock(Block.class);
Block blockPushed = mock(Block.class);
when(block.getRelative(Mockito.any(BlockFace.class))).thenReturn(blockPushed);

View File

@ -40,11 +40,9 @@ import world.bentobox.bentobox.util.Util;
@PrepareForTest({BentoBox.class, Util.class })
public class RemoveMobsListenerTest {
private Island island;
private IslandsManager im;
private World world;
private Location inside;
private UUID uuid;
private Player player;
/**
@ -60,11 +58,11 @@ public class RemoveMobsListenerTest {
world = mock(World.class);
// Owner
uuid = UUID.randomUUID();
UUID uuid1 = UUID.randomUUID();
// Island initialization
island = mock(Island.class);
when(island.getOwner()).thenReturn(uuid);
Island island = mock(Island.class);
when(island.getOwner()).thenReturn(uuid1);
im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im);

View File

@ -70,8 +70,6 @@ public class TNTListenerTest {
private static Location location;
private static BentoBox plugin;
private static IslandWorldManager iwm;
private static IslandsManager im;
private static Notifier notifier;
@Before
@ -112,7 +110,7 @@ public class TNTListenerTest {
// Worlds
iwm = mock(IslandWorldManager.class);
IslandWorldManager iwm = mock(IslandWorldManager.class);
when(iwm.inWorld(any())).thenReturn(true);
when(plugin.getIWM()).thenReturn(iwm);
@ -127,7 +125,7 @@ public class TNTListenerTest {
// Fake players
Settings settings = mock(Settings.class);
Mockito.when(plugin.getSettings()).thenReturn(settings);
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<String>());
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<>());
// Users
//User user = mock(User.class);
@ -139,14 +137,7 @@ public class TNTListenerTest {
LocalesManager lm = mock(LocalesManager.class);
when(plugin.getLocalesManager()).thenReturn(lm);
Answer<String> answer = new Answer<String>() {
@Override
public String answer(InvocationOnMock invocation) throws Throwable {
return (String)Arrays.asList(invocation.getArguments()).get(1);
}
};
Answer<String> answer = invocation -> (String)Arrays.asList(invocation.getArguments()).get(1);
when(lm.get(any(), any())).thenAnswer(answer);
// Player name
@ -161,7 +152,7 @@ public class TNTListenerTest {
when(ws.getWorldFlags()).thenReturn(worldFlags);
// Island manager
im = mock(IslandsManager.class);
IslandsManager im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im);
Island island = mock(Island.class);
Optional<Island> optional = Optional.of(island);

View File

@ -97,13 +97,11 @@ public class FlagsManagerTest {
public void testRegisterDuplicateFlagIcons() {
FlagsManager fm = new FlagsManager(plugin);
// Change the ID to something random, but use every icon that is already used
Flags.values().forEach(dupe -> {
assertFalse(fm.registerFlag(new FlagBuilder()
.id(UUID.randomUUID().toString())
.icon(dupe.getIcon())
.listener(new BreakBlocksListener())
.build()));
});
Flags.values().forEach(dupe -> assertFalse(fm.registerFlag(new FlagBuilder()
.id(UUID.randomUUID().toString())
.icon(dupe.getIcon())
.listener(new BreakBlocksListener())
.build())));
}
@Test

View File

@ -68,7 +68,6 @@ public class IslandsManagerTest {
private static BentoBox plugin;
private UUID uuid;
private User user;
private Settings s;
private PlayersManager pm;
private Player player;
private static World world;
@ -77,7 +76,6 @@ public class IslandsManagerTest {
private Block ground;
private Block space2;
private Location location;
private BlockState blockState;
private IslandWorldManager iwm;
private IslandCache islandCache;
private Optional<Island> optionalIsland;
@ -98,7 +96,7 @@ public class IslandsManagerTest {
when(plugin.getCommandsManager()).thenReturn(cm);
// Settings
s = mock(Settings.class);
Settings s = mock(Settings.class);
when(s.getResetWait()).thenReturn(0L);
when(plugin.getSettings()).thenReturn(s);
@ -146,22 +144,14 @@ public class IslandsManagerTest {
when(space1.getType()).thenReturn(Material.AIR);
when(space2.getType()).thenReturn(Material.AIR);
// Neutral BlockState
blockState = mock(BlockState.class);
BlockState blockState = mock(BlockState.class);
when(ground.getState()).thenReturn(blockState);
BlockData bd = mock(BlockData.class);
when(blockState.getBlockData()).thenReturn(bd);
// Online players
// Return a set of online players
when(Bukkit.getOnlinePlayers()).then(new Answer<Set<Player>>() {
@Override
public Set<Player> answer(InvocationOnMock invocation) throws Throwable {
return new HashSet<>();
}
});
when(Bukkit.getOnlinePlayers()).then((Answer<Set<Player>>) invocation -> new HashSet<>());
// Worlds
iwm = mock(IslandWorldManager.class);
@ -717,7 +707,7 @@ public class IslandsManagerTest {
}
/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#userIsOnIsland(world.bentobox.bentobox.api.user.User)}.
* Test method for .
* @throws Exception
*/
@Test
@ -767,7 +757,7 @@ public class IslandsManagerTest {
}
/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#setIslandName(java.util.UUID, java.lang.String)}.
* Test method for .
*/
@Test
public void testSetIslandName() {
@ -791,7 +781,7 @@ public class IslandsManagerTest {
}
/**
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#setLeaveTeam(java.util.UUID)}.
* Test method for .
*/
@Test
public void testSetLeaveTeam() {

View File

@ -270,7 +270,7 @@ public class PlayersManagerTest {
}
/**
* Test method for {@link world.bentobox.bentobox.managers.PlayersManager#clearHomeLocations(java.util.UUID)}.
* Test method for .
*/
@Test
public void testClearHomeLocations() {
@ -326,7 +326,7 @@ public class PlayersManagerTest {
}
/**
* Test method for {@link world.bentobox.bentobox.managers.PlayersManager#getResets(java.util.UUID)}.
* Test method for .
*/
@Test
public void testGetSetResetsLeft() {

View File

@ -47,22 +47,18 @@ public class ItemParserTest {
when(itemFactory.getItemMeta(Mockito.eq(Material.TIPPED_ARROW))).thenReturn(potionMeta);
*/
bannerMeta = mock(BannerMeta.class);
when(itemFactory.getItemMeta(Mockito.any())).thenAnswer(new Answer<ItemMeta>() {
@Override
public ItemMeta answer(InvocationOnMock invocation) throws Throwable {
switch (invocation.getArgumentAt(0, Material.class)) {
case RED_BANNER:
case WHITE_BANNER:
return bannerMeta;
case POTION:
case SPLASH_POTION:
case LINGERING_POTION:
case TIPPED_ARROW:
return potionMeta;
default:
return mock(ItemMeta.class);
}
when(itemFactory.getItemMeta(Mockito.any())).thenAnswer((Answer<ItemMeta>) invocation -> {
switch (invocation.getArgumentAt(0, Material.class)) {
case RED_BANNER:
case WHITE_BANNER:
return bannerMeta;
case POTION:
case SPLASH_POTION:
case LINGERING_POTION:
case TIPPED_ARROW:
return potionMeta;
default:
return mock(ItemMeta.class);
}
});

View File

@ -36,7 +36,6 @@ public class UtilTest {
private World world;
private IslandWorldManager iwm;
private Location location;
private Server server;
/**
* @throws java.lang.Exception
@ -64,7 +63,7 @@ public class UtilTest {
when(location.getPitch()).thenReturn(20F);
PowerMockito.mockStatic(Bukkit.class);
server = mock(Server.class);
Server server = mock(Server.class);
when(Bukkit.getServer()).thenReturn(server);
when(server.getWorld(Mockito.anyString())).thenReturn(world);
}