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