Fixed IslandSethomeCommandTest

This commit is contained in:
Florian CUNY 2019-02-20 11:20:14 +01:00
parent f5bbe35bd8
commit fa1325bf14

View File

@ -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;
@ -49,6 +46,7 @@ public class IslandSethomeCommandTest {
private CompositeCommand ic; private CompositeCommand ic;
private User user; private User user;
private UUID uuid;
private IslandsManager im; private IslandsManager im;
private Island island; private Island island;
private IslandWorldManager iwm; private IslandWorldManager iwm;
@ -75,7 +73,7 @@ public class IslandSethomeCommandTest {
// Sometimes use Mockito.withSettings().verboseLogging() // Sometimes use Mockito.withSettings().verboseLogging()
user = mock(User.class); user = mock(User.class);
when(user.isOp()).thenReturn(false); when(user.isOp()).thenReturn(false);
UUID uuid = UUID.randomUUID(); 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.getName()).thenReturn("tastybento"); when(user.getName()).thenReturn("tastybento");
@ -125,8 +123,6 @@ public class IslandSethomeCommandTest {
PowerMockito.mockStatic(Util.class); PowerMockito.mockStatic(Util.class);
// 1 home for now // 1 home for now
when(user.getPermissionValue(Mockito.anyString(), Mockito.anyInt())).thenReturn(1); when(user.getPermissionValue(Mockito.anyString(), Mockito.anyInt())).thenReturn(1);
} }
/** /**
@ -153,6 +149,9 @@ public class IslandSethomeCommandTest {
*/ */
@Test @Test
public void testCanExecuteNoIsland() { public void testCanExecuteNoIsland() {
// Player doesn't have an island and doesn't have a team.
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
IslandSethomeCommand isc = new IslandSethomeCommand(ic); IslandSethomeCommand isc = new IslandSethomeCommand(ic);
assertFalse(isc.canExecute(user, "island", Collections.emptyList())); assertFalse(isc.canExecute(user, "island", Collections.emptyList()));
Mockito.verify(user).sendMessage("general.errors.no-island"); Mockito.verify(user).sendMessage("general.errors.no-island");