mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-09 17:01:51 +01:00
Switched to latest Mockito and PowerMockito libs. WIP
This commit is contained in:
parent
113f065609
commit
be673fa527
8
pom.xml
8
pom.xml
@ -66,7 +66,7 @@
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<!-- Non-minecraft related dependencies -->
|
||||
<powermock.version>1.7.4</powermock.version>
|
||||
<powermock.version>2.0.2</powermock.version>
|
||||
<mongodb.version>3.8.0</mongodb.version>
|
||||
<!-- More visible way how to change dependency versions -->
|
||||
<spigot.version>1.13.2-R0.1-SNAPSHOT</spigot.version>
|
||||
@ -189,8 +189,8 @@
|
||||
<!-- Mockito (Unit testing) -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.10.19</version>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -201,7 +201,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito</artifactId>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>${powermock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
@ -6,7 +6,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -41,7 +41,6 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
@ -117,7 +116,7 @@ public class TestBentoBox {
|
||||
visitorToIsland = mock(Player.class);
|
||||
Mockito.when(player.hasPermission(Mockito.anyString())).thenReturn(true);
|
||||
User.getInstance(player);
|
||||
when(Bukkit.getPlayer(Mockito.any(UUID.class))).thenReturn(player);
|
||||
when(Bukkit.getPlayer(any(UUID.class))).thenReturn(player);
|
||||
|
||||
location = mock(Location.class);
|
||||
Mockito.when(location.getWorld()).thenReturn(world);
|
||||
@ -146,9 +145,9 @@ public class TestBentoBox {
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(true);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
when(Util.getWorld(Mockito.any())).thenReturn(world);
|
||||
when(Util.getWorld(any())).thenReturn(world);
|
||||
// We want the read tabLimit call here
|
||||
when(Util.tabLimit(Mockito.any(), Mockito.anyString())).thenCallRealMethod();
|
||||
when(Util.tabLimit(any(), Mockito.anyString())).thenCallRealMethod();
|
||||
|
||||
// Islands
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
@ -162,8 +161,8 @@ public class TestBentoBox {
|
||||
members.put(OWNER_UUID, RanksManager.OWNER_RANK);
|
||||
members.put(MEMBER_UUID, RanksManager.MEMBER_RANK);
|
||||
island.setMembers(members);
|
||||
Mockito.when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getProtectedIslandAt(Mockito.any())).thenReturn(Optional.of(island));
|
||||
Mockito.when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
when(im.getProtectedIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
Settings settings = mock(Settings.class);
|
||||
Mockito.when(plugin.getSettings()).thenReturn(settings);
|
||||
|
@ -107,7 +107,7 @@ public class AdminSetspawnCommandTest {
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenReturn("mock translation");
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
// Return the reference (USE THIS IN THE FUTURE)
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(0, String.class));
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
|
||||
// Plugin Manager
|
||||
Server server = mock(Server.class);
|
||||
|
@ -120,7 +120,7 @@ public class AdminTeleportCommandTest {
|
||||
|
||||
@Override
|
||||
public String answer(InvocationOnMock invocation) throws Throwable {
|
||||
return invocation.getArgumentAt(0, String.class);
|
||||
return invocation.getArgument(0, String.class);
|
||||
}});
|
||||
|
||||
// Island location
|
||||
|
@ -101,7 +101,7 @@ public class AdminRangeCommandTest {
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgument(1, String.class);
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
|
||||
|
@ -103,9 +103,9 @@ public class AdminRangeDisplayCommandTest {
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
Answer<String> answer = invocation -> invocation.getArgument(1, String.class);
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,7 @@ public class AdminRangeResetCommandTest {
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgument(1, String.class);
|
||||
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
|
@ -119,7 +119,7 @@ public class AdminRangeSetCommandTest {
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgument(1, String.class);
|
||||
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer );
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
|
@ -1,6 +1,3 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package world.bentobox.bentobox.api.commands.island;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@ -8,6 +5,9 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -73,8 +73,8 @@ public class CustomIslandMultiHomeHelpTest {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getPlayer()).thenReturn(player);
|
||||
when(user.hasPermission(Mockito.anyString())).thenReturn(true);
|
||||
when(user.getTranslation(Mockito.anyVararg())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(0, String.class));
|
||||
when(user.hasPermission(anyString())).thenReturn(true);
|
||||
when(user.getTranslation(any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
User.setPlugin(plugin);
|
||||
// Set up user already
|
||||
User.getInstance(player);
|
||||
@ -90,10 +90,10 @@ public class CustomIslandMultiHomeHelpTest {
|
||||
|
||||
// No island for player to begin with (set it later in the tests)
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
||||
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
||||
when(im.hasIsland(any(), Mockito.eq(uuid))).thenReturn(false);
|
||||
when(im.isOwner(any(), Mockito.eq(uuid))).thenReturn(false);
|
||||
// Has team
|
||||
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||
when(im.inTeam(any(), Mockito.eq(uuid))).thenReturn(true);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
|
||||
|
||||
@ -107,7 +107,7 @@ public class CustomIslandMultiHomeHelpTest {
|
||||
|
||||
// IWM friendly name
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(iwm.getFriendlyName(Mockito.any())).thenReturn("BSkyBlock");
|
||||
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Command
|
||||
@ -166,7 +166,7 @@ public class CustomIslandMultiHomeHelpTest {
|
||||
@Test
|
||||
public void testExecuteUserStringListOfString() {
|
||||
assertTrue(ch.execute(user, "", Collections.emptyList()));
|
||||
Mockito.verify(user).sendMessage(
|
||||
verify(user).sendMessage(
|
||||
"commands.help.syntax",
|
||||
"[usage]",
|
||||
"",
|
||||
@ -184,7 +184,7 @@ public class CustomIslandMultiHomeHelpTest {
|
||||
public void testExecuteUserStringListOfStringMaxHomes() {
|
||||
when(user.getPermissionValue(Mockito.anyString(), Mockito.anyInt())).thenReturn(20);
|
||||
assertTrue(ch.execute(user, "", Collections.emptyList()));
|
||||
Mockito.verify(user).sendMessage(
|
||||
verify(user).sendMessage(
|
||||
"commands.help.syntax",
|
||||
"[usage]",
|
||||
"",
|
||||
|
@ -146,10 +146,10 @@ public class IslandBanCommandTest {
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(invocation -> invocation.getArgumentAt(1, String.class));
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(invocation -> invocation.getArgument(1, String.class));
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
PlaceholdersManager phm = mock(PlaceholdersManager.class);
|
||||
when(phm.replacePlaceholders(any(), any())).thenAnswer(invocation -> invocation.getArgumentAt(1, String.class));
|
||||
when(phm.replacePlaceholders(any(), any())).thenAnswer(invocation -> invocation.getArgument(1, String.class));
|
||||
// Placeholder manager
|
||||
when(plugin.getPlaceholdersManager()).thenReturn(phm);
|
||||
|
||||
@ -348,9 +348,9 @@ public class IslandBanCommandTest {
|
||||
onlinePlayers.add(p);
|
||||
}
|
||||
|
||||
when(island.isBanned(any(UUID.class))).thenAnswer((Answer<Boolean>) invocation -> banned.contains(invocation.getArgumentAt(0, UUID.class)));
|
||||
when(island.isBanned(any(UUID.class))).thenAnswer((Answer<Boolean>) invocation -> banned.contains(invocation.getArgument(0, UUID.class)));
|
||||
// Create the names
|
||||
when(pm.getName(any(UUID.class))).then((Answer<String>) invocation -> online.getOrDefault(invocation.getArgumentAt(0, UUID.class), "tastybento"));
|
||||
when(pm.getName(any(UUID.class))).then((Answer<String>) invocation -> online.getOrDefault(invocation.getArgument(0, UUID.class), "tastybento"));
|
||||
|
||||
// Return a set of online players
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
@ -362,7 +362,7 @@ public class IslandBanCommandTest {
|
||||
Player player = mock(Player.class);
|
||||
// Player can see every other player except Ian
|
||||
when(player.canSee(any(Player.class))).thenAnswer((Answer<Boolean>) invocation -> {
|
||||
Player p = invocation.getArgumentAt(0, Player.class);
|
||||
Player p = invocation.getArgument(0, Player.class);
|
||||
return !p.getName().equals("ian");
|
||||
});
|
||||
when(user.getPlayer()).thenReturn(player);
|
||||
|
@ -155,7 +155,7 @@ public class IslandBanlistCommandTest {
|
||||
}
|
||||
when(island.getBanned()).thenReturn(banned);
|
||||
// Respond to name queries
|
||||
when(pm.getName(Mockito.any(UUID.class))).then((Answer<String>) invocation -> uuidToName.getOrDefault(invocation.getArgumentAt(0, UUID.class), "tastybento"));
|
||||
when(pm.getName(Mockito.any(UUID.class))).then((Answer<String>) invocation -> uuidToName.getOrDefault(invocation.getArgument(0, UUID.class), "tastybento"));
|
||||
assertTrue(iubc.execute(user, iubc.getLabel(), new ArrayList<>()));
|
||||
Mockito.verify(user).sendMessage("commands.island.banlist.the-following");
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class IslandCreateCommandTest {
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getPlayer()).thenReturn(player);
|
||||
when(user.hasPermission(Mockito.anyString())).thenReturn(true);
|
||||
when(user.getTranslation(Mockito.anyVararg())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(0, String.class));
|
||||
when(user.getTranslation(Mockito.anyVararg())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
User.setPlugin(plugin);
|
||||
// Set up user already
|
||||
User.getInstance(player);
|
||||
|
@ -141,7 +141,7 @@ public class IslandExpelCommandTest {
|
||||
when(island.getWorld()).thenReturn(mock(World.class));
|
||||
|
||||
// Locales
|
||||
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgument(1, String.class);
|
||||
when(lm.get(Mockito.any(User.class), Mockito.anyString())).thenAnswer(answer);
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
|
||||
|
@ -161,11 +161,11 @@ public class IslandGoCommandTest {
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(1, String.class));
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
// Return the same string
|
||||
PlaceholdersManager phm = mock(PlaceholdersManager.class);
|
||||
when(phm.replacePlaceholders(any(), anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(1, String.class));
|
||||
when(phm.replacePlaceholders(any(), anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||
when(plugin.getPlaceholdersManager()).thenReturn(phm);
|
||||
|
||||
// Notifier
|
||||
|
@ -78,7 +78,7 @@ public class IslandSethomeCommandTest {
|
||||
when(user.getPlayer()).thenReturn(player);
|
||||
when(user.getName()).thenReturn("tastybento");
|
||||
when(user.getWorld()).thenReturn(mock(World.class));
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer(i -> i.getArgumentAt(0, String.class));
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer(i -> i.getArgument(0, String.class));
|
||||
|
||||
// Parent command has no aliases
|
||||
ic = mock(CompositeCommand.class);
|
||||
|
@ -133,7 +133,7 @@ public class IslandTeamCoopCommandTest {
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
PlaceholdersManager phm = mock(PlaceholdersManager.class);
|
||||
when(phm.replacePlaceholders(any(), any())).thenAnswer(invocation -> invocation.getArgumentAt(1, String.class));
|
||||
when(phm.replacePlaceholders(any(), any())).thenAnswer(invocation -> invocation.getArgument(1, String.class));
|
||||
// Placeholder manager
|
||||
when(plugin.getPlaceholdersManager()).thenReturn(phm);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class FlagTest {
|
||||
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
// Return world
|
||||
when(Util.getWorld(Mockito.any())).thenAnswer((Answer<World>) invocation -> invocation.getArgumentAt(0, World.class));
|
||||
when(Util.getWorld(Mockito.any())).thenAnswer((Answer<World>) invocation -> invocation.getArgument(0, World.class));
|
||||
|
||||
// World Settings
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
@ -366,7 +366,7 @@ public class FlagTest {
|
||||
PanelItem pi = f.toPanelItem(plugin, user, island, false);
|
||||
|
||||
verify(user).getTranslation(Mockito.eq("protection.flags.flagID.name"));
|
||||
verify(user).getTranslation(Mockito.eq("protection.panel.flag-item.name-layout"), Mockito.anyVararg());
|
||||
verify(user).getTranslation(Mockito.eq("protection.panel.flag-item.name-layout"), any());
|
||||
|
||||
assertEquals(Material.ACACIA_PLANKS, pi.getItem().getType());
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class UserTest {
|
||||
PlaceholdersManager placeholdersManager = mock(PlaceholdersManager.class);
|
||||
when(plugin.getPlaceholdersManager()).thenReturn(placeholdersManager);
|
||||
// This will just return the value of the second argument of replacePlaceholders. i.e., it won't change anything
|
||||
when(placeholdersManager.replacePlaceholders(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(1, String.class));
|
||||
when(placeholdersManager.replacePlaceholders(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(1, String.class));
|
||||
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class BentoBoxReloadCommandTest {
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
// User
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(0, String.class));
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
|
||||
// Panels
|
||||
PowerMockito.mockStatic(PanelListenerManager.class);
|
||||
|
@ -2,7 +2,7 @@ package world.bentobox.bentobox.listeners.flags.protection;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -30,7 +30,6 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
@ -150,7 +149,7 @@ public class FireListenerTest {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
Island island = mock(Island.class);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
// Block on fire
|
||||
Block block = mock(Block.class);
|
||||
@ -178,7 +177,7 @@ public class FireListenerTest {
|
||||
assertFalse(listener.checkFire(e, location, Flags.FLINT_AND_STEEL));
|
||||
|
||||
// Check with no island
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
// Fire is not allowed, so should be cancelled
|
||||
Flags.FLINT_AND_STEEL.setDefaultSetting(false);
|
||||
assertTrue(listener.checkFire(e, location, Flags.FLINT_AND_STEEL));
|
||||
@ -193,7 +192,7 @@ public class FireListenerTest {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
Island island = mock(Island.class);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
// Block on fire
|
||||
Block block = mock(Block.class);
|
||||
@ -222,7 +221,7 @@ public class FireListenerTest {
|
||||
|
||||
// Check with no island
|
||||
e = new BlockBurnEvent(block, block);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
// Fire is not allowed, so should be cancelled
|
||||
Flags.FIRE_BURNING.setDefaultSetting(false);
|
||||
listener.onBlockBurn(e);
|
||||
@ -238,7 +237,7 @@ public class FireListenerTest {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
Island island = mock(Island.class);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
// Block on fire spread
|
||||
|
||||
@ -271,7 +270,7 @@ public class FireListenerTest {
|
||||
assertFalse(listener.onBlockSpread(e));
|
||||
|
||||
// Check with no island
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
// Fire spread is not allowed, so should be cancelled
|
||||
Flags.FIRE_SPREAD.setDefaultSetting(false);
|
||||
assertTrue(listener.onBlockSpread(e));
|
||||
@ -286,7 +285,7 @@ public class FireListenerTest {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
Island island = mock(Island.class);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
// Block on fire spread
|
||||
|
||||
@ -323,7 +322,7 @@ public class FireListenerTest {
|
||||
assertFalse(listener.onBlockIgnite(e));
|
||||
|
||||
// Check with no island
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
// Fire spread is not allowed, so should be cancelled
|
||||
Flags.FIRE_IGNITE.setDefaultSetting(false);
|
||||
assertTrue(listener.onBlockIgnite(e));
|
||||
|
@ -143,7 +143,7 @@ public class HurtingListenerTest {
|
||||
// Locales
|
||||
lm = mock(LocalesManager.class);
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgument(1, String.class);
|
||||
when(lm.get(Mockito.any(), Mockito.any())).thenAnswer(answer);
|
||||
|
||||
// Placeholders
|
||||
|
@ -695,7 +695,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((Answer<Boolean>) invocation -> invocation.getArgumentAt(0, User.class).getUniqueId().equals(uuid2));
|
||||
when(island.isAllowed(Mockito.any(User.class), Mockito.any())).thenAnswer((Answer<Boolean>) invocation -> invocation.getArgument(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);
|
||||
|
@ -2,7 +2,7 @@ package world.bentobox.bentobox.listeners.flags.protection;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -41,7 +41,6 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
@ -219,7 +218,7 @@ public class TNTListenerTest {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
Island island = mock(Island.class);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
when(im.getProtectedIslandAt(Mockito.any())).thenReturn(Optional.of(island));
|
||||
|
||||
// Block on fire
|
||||
|
@ -2,7 +2,7 @@ package world.bentobox.bentobox.listeners.flags.settings;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -28,7 +28,6 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
@ -142,7 +141,7 @@ public class MobSpawnListenerTest {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
Island island = mock(Island.class);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
// Set up entity
|
||||
LivingEntity entity = mock(LivingEntity.class);
|
||||
@ -168,7 +167,7 @@ public class MobSpawnListenerTest {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
Island island = mock(Island.class);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
// Block mobs
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(false);
|
||||
@ -214,7 +213,7 @@ public class MobSpawnListenerTest {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
Island island = mock(Island.class);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.of(island));
|
||||
|
||||
// Allow mobs
|
||||
when(island.isAllowed(Mockito.any())).thenReturn(true);
|
||||
@ -250,7 +249,7 @@ public class MobSpawnListenerTest {
|
||||
public void testOnNaturalMonsterSpawnBlockedNoIsland() {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
|
||||
// Block mobs
|
||||
Flags.MONSTER_SPAWN.setDefaultSetting(false);
|
||||
@ -278,7 +277,7 @@ public class MobSpawnListenerTest {
|
||||
public void testOnNaturalMobSpawnUnBlockedNoIsland() {
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
when(im.getIslandAt(Matchers.any())).thenReturn(Optional.empty());
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
|
||||
// Block mobs
|
||||
Flags.MONSTER_SPAWN.setDefaultSetting(true);
|
||||
|
@ -171,7 +171,7 @@ public class PVPListenerTest {
|
||||
// Locales - this returns the string that was requested for translation
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
Answer<String> answer = (Answer<String>) invocation -> invocation.getArgumentAt(1, String.class);
|
||||
Answer<String> answer = (Answer<String>) invocation -> invocation.getArgument(1, String.class);
|
||||
when(lm.get(any(), any())).thenAnswer(answer);
|
||||
|
||||
// Placeholders
|
||||
|
@ -2,9 +2,12 @@ package world.bentobox.bentobox.listeners.flags.worldsettings;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -82,24 +85,24 @@ public class EnderChestListenerTest {
|
||||
|
||||
IslandsManager im = mock(IslandsManager.class);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(island);
|
||||
|
||||
Location inside = mock(Location.class);
|
||||
when(inside.getWorld()).thenReturn(world);
|
||||
|
||||
Optional<Island> opIsland = Optional.ofNullable(island);
|
||||
when(im.getProtectedIslandAt(Mockito.eq(inside))).thenReturn(opIsland);
|
||||
when(im.getProtectedIslandAt(eq(inside))).thenReturn(opIsland);
|
||||
// On island
|
||||
when(im.locationIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
when(im.locationIsOnIsland(any(), any())).thenReturn(true);
|
||||
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
when(Util.getWorld(Mockito.any())).thenReturn(world);
|
||||
when(Util.getWorld(any())).thenReturn(world);
|
||||
|
||||
// World Settings
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
WorldSettings ws = mock(WorldSettings.class);
|
||||
when(iwm.getWorldSettings(Mockito.any())).thenReturn(ws);
|
||||
when(iwm.getWorldSettings(any())).thenReturn(ws);
|
||||
Map<String, Boolean> worldFlags = new HashMap<>();
|
||||
when(ws.getWorldFlags()).thenReturn(worldFlags);
|
||||
// By default everything is in world
|
||||
@ -116,7 +119,7 @@ public class EnderChestListenerTest {
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
when(player.isOp()).thenReturn(false);
|
||||
// No special perms
|
||||
when(player.hasPermission(Mockito.anyString())).thenReturn(false);
|
||||
when(player.hasPermission(anyString())).thenReturn(false);
|
||||
when(player.getWorld()).thenReturn(world);
|
||||
User.setPlugin(plugin);
|
||||
User.getInstance(player);
|
||||
@ -124,7 +127,7 @@ public class EnderChestListenerTest {
|
||||
// Locales - this returns the string that was requested for translation
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
Answer<String> answer = invocation -> invocation.getArgumentAt(1, String.class);
|
||||
Answer<String> answer = invocation -> invocation.getArgument(1, String.class);
|
||||
when(lm.get(any(), any())).thenAnswer(answer);
|
||||
|
||||
// Placeholders
|
||||
@ -144,7 +147,7 @@ public class EnderChestListenerTest {
|
||||
when(clickedBlock.getLocation()).thenReturn(inside);
|
||||
when(clickedBlock.getType()).thenReturn(Material.ENDER_CHEST);
|
||||
// Addon
|
||||
when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty());
|
||||
when(iwm.getAddon(any())).thenReturn(Optional.empty());
|
||||
|
||||
Settings settings = mock(Settings.class);
|
||||
// Fake players
|
||||
@ -192,7 +195,7 @@ public class EnderChestListenerTest {
|
||||
BlockFace clickedBlockFace = BlockFace.EAST;
|
||||
PlayerInteractEvent e = new PlayerInteractEvent(player, action, item, clickedBlock, clickedBlockFace);
|
||||
// Has bypass perm
|
||||
when(player.hasPermission(Mockito.anyString())).thenReturn(true);
|
||||
when(player.hasPermission(anyString())).thenReturn(true);
|
||||
new BlockInteractionListener().onPlayerInteract(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
@ -206,7 +209,7 @@ public class EnderChestListenerTest {
|
||||
BlockInteractionListener bil = new BlockInteractionListener();
|
||||
bil.onPlayerInteract(e);
|
||||
assertFalse(e.isCancelled());
|
||||
Mockito.verify(notifier, Mockito.never()).notify(Mockito.anyObject(), Mockito.anyString());
|
||||
verify(notifier, Mockito.never()).notify(any(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -217,7 +220,7 @@ public class EnderChestListenerTest {
|
||||
Flags.ENDER_CHEST.setSetting(world, false);
|
||||
new BlockInteractionListener().onPlayerInteract(e);
|
||||
assertTrue(e.isCancelled());
|
||||
Mockito.verify(notifier).notify(Mockito.any(User.class), Mockito.eq("protection.world-protected"));
|
||||
verify(notifier).notify(any(User.class), eq("protection.world-protected"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1,8 +1,12 @@
|
||||
package world.bentobox.bentobox.listeners.flags.worldsettings;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -20,7 +24,6 @@ import org.bukkit.util.Vector;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
@ -123,7 +126,7 @@ public class EnterExitListenerTest {
|
||||
when(island.getProtectionRange()).thenReturn(PROTECTION_RANGE);
|
||||
when(island.getOwner()).thenReturn(uuid);
|
||||
|
||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(island);
|
||||
|
||||
// Common from to's
|
||||
outside = mock(Location.class);
|
||||
@ -148,9 +151,9 @@ public class EnterExitListenerTest {
|
||||
when(inside.toVector()).thenReturn(new Vector(X + PROTECTION_RANGE -2, Y, Z));
|
||||
|
||||
Optional<Island> opIsland = Optional.ofNullable(island);
|
||||
when(im.getProtectedIslandAt(Mockito.eq(inside))).thenReturn(opIsland);
|
||||
when(im.getProtectedIslandAt(Mockito.eq(inside2))).thenReturn(opIsland);
|
||||
when(im.getProtectedIslandAt(Mockito.eq(outside))).thenReturn(Optional.empty());
|
||||
when(im.getProtectedIslandAt(eq(inside))).thenReturn(opIsland);
|
||||
when(im.getProtectedIslandAt(eq(inside2))).thenReturn(opIsland);
|
||||
when(im.getProtectedIslandAt(eq(outside))).thenReturn(Optional.empty());
|
||||
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
@ -160,23 +163,23 @@ public class EnterExitListenerTest {
|
||||
|
||||
// Player's manager
|
||||
PlayersManager pm = mock(PlayersManager.class);
|
||||
when(pm.getName(Mockito.any())).thenReturn("tastybento");
|
||||
when(pm.getName(any())).thenReturn("tastybento");
|
||||
when(plugin.getPlayers()).thenReturn(pm);
|
||||
|
||||
// Listener
|
||||
listener = new EnterExitListener();
|
||||
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
when(Util.getWorld(Mockito.any())).thenReturn(world);
|
||||
when(Util.getWorld(any())).thenReturn(world);
|
||||
|
||||
// World Settings
|
||||
WorldSettings ws = mock(WorldSettings.class);
|
||||
when(iwm.getWorldSettings(Mockito.any())).thenReturn(ws);
|
||||
when(iwm.getWorldSettings(any())).thenReturn(ws);
|
||||
Map<String, Boolean> worldFlags = new HashMap<>();
|
||||
when(ws.getWorldFlags()).thenReturn(worldFlags);
|
||||
|
||||
// Addon
|
||||
when(iwm.getAddon(Mockito.any())).thenReturn(Optional.empty());
|
||||
when(iwm.getAddon(any())).thenReturn(Optional.empty());
|
||||
|
||||
// Flags
|
||||
Flags.ENTER_EXIT_MESSAGES.setSetting(world, true);
|
||||
@ -190,7 +193,7 @@ public class EnterExitListenerTest {
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(user.getPlayer(), inside, inside);
|
||||
listener.onMove(e);
|
||||
// Moving in the island should result in no messages to the user
|
||||
Mockito.verify(user, Mockito.never()).sendMessage(Mockito.anyVararg());
|
||||
verify(user, never()).sendMessage(any());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,7 +204,7 @@ public class EnterExitListenerTest {
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(user.getPlayer(), outside, outside);
|
||||
listener.onMove(e);
|
||||
// Moving outside the island should result in no messages to the user
|
||||
Mockito.verify(user, Mockito.never()).sendMessage(Mockito.anyVararg());
|
||||
verify(user, never()).sendMessage(any());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,9 +216,9 @@ public class EnterExitListenerTest {
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(user.getPlayer(), outside, inside);
|
||||
listener.onMove(e);
|
||||
// Moving into the island should show a message
|
||||
Mockito.verify(lm).get(Mockito.any(), Mockito.eq("protection.flags.ENTER_EXIT_MESSAGES.now-entering"));
|
||||
verify(lm).get(any(), eq("protection.flags.ENTER_EXIT_MESSAGES.now-entering"));
|
||||
// The island owner needs to be checked
|
||||
Mockito.verify(island).getOwner();
|
||||
verify(island).getOwner();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,10 +230,10 @@ public class EnterExitListenerTest {
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(user.getPlayer(), outside, inside);
|
||||
listener.onMove(e);
|
||||
// Moving into the island should show a message
|
||||
Mockito.verify(lm).get(Mockito.any(), Mockito.eq("protection.flags.ENTER_EXIT_MESSAGES.now-entering"));
|
||||
verify(lm).get(any(), eq("protection.flags.ENTER_EXIT_MESSAGES.now-entering"));
|
||||
// No owner check
|
||||
Mockito.verify(island).getOwner();
|
||||
Mockito.verify(island, Mockito.times(2)).getName();
|
||||
verify(island).getOwner();
|
||||
verify(island, times(2)).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -242,9 +245,9 @@ public class EnterExitListenerTest {
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(user.getPlayer(), inside, outside);
|
||||
listener.onMove(e);
|
||||
// Moving into the island should show a message
|
||||
Mockito.verify(lm).get(Mockito.any(), Mockito.eq("protection.flags.ENTER_EXIT_MESSAGES.now-leaving"));
|
||||
verify(lm).get(any(), eq("protection.flags.ENTER_EXIT_MESSAGES.now-leaving"));
|
||||
// The island owner needs to be checked
|
||||
Mockito.verify(island).getOwner();
|
||||
verify(island).getOwner();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,10 +259,10 @@ public class EnterExitListenerTest {
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(user.getPlayer(), inside, outside);
|
||||
listener.onMove(e);
|
||||
// Moving into the island should show a message
|
||||
Mockito.verify(lm).get(Mockito.any(), Mockito.eq("protection.flags.ENTER_EXIT_MESSAGES.now-leaving"));
|
||||
verify(lm).get(any(), eq("protection.flags.ENTER_EXIT_MESSAGES.now-leaving"));
|
||||
// No owner check
|
||||
Mockito.verify(island).getOwner();
|
||||
Mockito.verify(island, Mockito.times(2)).getName();
|
||||
verify(island).getOwner();
|
||||
verify(island, times(2)).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,6 +277,6 @@ public class EnterExitListenerTest {
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(user.getPlayer(), inside, outside);
|
||||
listener.onMove(e);
|
||||
// No messages should be sent
|
||||
Mockito.verify(user, Mockito.never()).sendMessage(Mockito.anyVararg());
|
||||
verify(user, never()).sendMessage(any());
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public class BlueprintsManagerTest {
|
||||
|
||||
@Override
|
||||
public BukkitTask answer(InvocationOnMock invocation) throws Throwable {
|
||||
invocation.getArgumentAt(1,Runnable.class).run();
|
||||
invocation.getArgument(1,Runnable.class).run();
|
||||
verify(plugin).logError(eq("There is no blueprint folder for addon name"));
|
||||
verify(plugin).logError(eq("No blueprint bundles found! Creating a default one."));
|
||||
File blueprints = new File(dataFolder, BlueprintsManager.FOLDER_NAME);
|
||||
@ -263,7 +263,7 @@ public class BlueprintsManagerTest {
|
||||
|
||||
@Override
|
||||
public BukkitTask answer(InvocationOnMock invocation) throws Throwable {
|
||||
invocation.getArgumentAt(1,Runnable.class).run();
|
||||
invocation.getArgument(1,Runnable.class).run();
|
||||
verify(plugin).logError(eq("No blueprint bundles found! Creating a default one."));
|
||||
return task;
|
||||
}});
|
||||
@ -304,7 +304,7 @@ public class BlueprintsManagerTest {
|
||||
|
||||
@Override
|
||||
public BukkitTask answer(InvocationOnMock invocation) throws Throwable {
|
||||
invocation.getArgumentAt(1,Runnable.class).run();
|
||||
invocation.getArgument(1,Runnable.class).run();
|
||||
return task;
|
||||
}});
|
||||
BlueprintsManager bpm = new BlueprintsManager(plugin);
|
||||
@ -361,7 +361,7 @@ public class BlueprintsManagerTest {
|
||||
|
||||
@Override
|
||||
public BukkitTask answer(InvocationOnMock invocation) throws Throwable {
|
||||
invocation.getArgumentAt(1,Runnable.class).run();
|
||||
invocation.getArgument(1,Runnable.class).run();
|
||||
File d = new File(blueprints, "bundle.json");
|
||||
assertTrue(d.exists());
|
||||
return task;
|
||||
@ -405,7 +405,7 @@ public class BlueprintsManagerTest {
|
||||
|
||||
@Override
|
||||
public BukkitTask answer(InvocationOnMock invocation) throws Throwable {
|
||||
invocation.getArgumentAt(1,Runnable.class).run();
|
||||
invocation.getArgument(1,Runnable.class).run();
|
||||
// Verify
|
||||
times++;
|
||||
if (times > 2) {
|
||||
@ -627,7 +627,7 @@ public class BlueprintsManagerTest {
|
||||
|
||||
@Override
|
||||
public BukkitTask answer(InvocationOnMock invocation) throws Throwable {
|
||||
invocation.getArgumentAt(1,Runnable.class).run();
|
||||
invocation.getArgument(1,Runnable.class).run();
|
||||
|
||||
// Verify
|
||||
assertFalse(d.exists());
|
||||
|
@ -1,7 +1,8 @@
|
||||
package world.bentobox.bentobox.panels;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@ -99,8 +100,8 @@ public class IslandCreationPanelTest {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getPlayer()).thenReturn(player);
|
||||
when(user.hasPermission(Mockito.anyString())).thenReturn(true);
|
||||
when(user.getTranslation(Mockito.anyVararg())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(0, String.class));
|
||||
when(user.hasPermission(anyString())).thenReturn(true);
|
||||
when(user.getTranslation(any())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
User.setPlugin(plugin);
|
||||
// Set up user already
|
||||
User.getInstance(player);
|
||||
|
@ -47,7 +47,7 @@ public class ItemParserTest {
|
||||
*/
|
||||
bannerMeta = mock(BannerMeta.class);
|
||||
when(itemFactory.getItemMeta(Mockito.any())).thenAnswer((Answer<ItemMeta>) invocation -> {
|
||||
switch (invocation.getArgumentAt(0, Material.class)) {
|
||||
switch (invocation.getArgument(0, Material.class)) {
|
||||
case RED_BANNER:
|
||||
case WHITE_BANNER:
|
||||
return bannerMeta;
|
||||
|
Loading…
Reference in New Issue
Block a user