mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-24 17:11:30 +01:00
Fixed AdminPurgeCommand test class.
Added mock for island.isOwned() and island.isUnowned() methods.
This commit is contained in:
parent
eb06b39b4a
commit
a42da35174
@ -1,6 +1,3 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package world.bentobox.bentobox.api.commands.admin.purge;
|
package world.bentobox.bentobox.api.commands.admin.purge;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@ -91,11 +88,13 @@ public class AdminPurgeCommandTest {
|
|||||||
when(im.getIslands()).thenReturn(Collections.emptyList());
|
when(im.getIslands()).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
// IWM
|
// IWM
|
||||||
|
|
||||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||||
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock");
|
||||||
when(plugin.getIWM()).thenReturn(iwm);
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
|
|
||||||
|
// Island
|
||||||
|
when(island.isOwned()).thenReturn(true); // Default owned
|
||||||
|
|
||||||
// Command
|
// Command
|
||||||
apc = new AdminPurgeCommand(ac);
|
apc = new AdminPurgeCommand(ac);
|
||||||
}
|
}
|
||||||
@ -206,6 +205,8 @@ public class AdminPurgeCommandTest {
|
|||||||
when(island.getPurgeProtected()).thenReturn(false);
|
when(island.getPurgeProtected()).thenReturn(false);
|
||||||
when(island.getWorld()).thenReturn(world);
|
when(island.getWorld()).thenReturn(world);
|
||||||
when(island.getOwner()).thenReturn(null);
|
when(island.getOwner()).thenReturn(null);
|
||||||
|
when(island.isUnowned()).thenReturn(true);
|
||||||
|
when(island.isOwned()).thenReturn(false);
|
||||||
when(im.getIslands()).thenReturn(Collections.singleton(island));
|
when(im.getIslands()).thenReturn(Collections.singleton(island));
|
||||||
assertTrue(apc.execute(user, "protect", Collections.singletonList("10")));
|
assertTrue(apc.execute(user, "protect", Collections.singletonList("10")));
|
||||||
verify(user).sendMessage(eq("commands.admin.purge.purgable-islands"), eq("[number]"), eq("0"));
|
verify(user).sendMessage(eq("commands.admin.purge.purgable-islands"), eq("[number]"), eq("0"));
|
||||||
@ -256,6 +257,7 @@ public class AdminPurgeCommandTest {
|
|||||||
when(island.getPurgeProtected()).thenReturn(false);
|
when(island.getPurgeProtected()).thenReturn(false);
|
||||||
when(island.getWorld()).thenReturn(world);
|
when(island.getWorld()).thenReturn(world);
|
||||||
when(island.getOwner()).thenReturn(UUID.randomUUID());
|
when(island.getOwner()).thenReturn(UUID.randomUUID());
|
||||||
|
when(island.isOwned()).thenReturn(true);
|
||||||
Map<UUID, Integer> team = new HashMap<>();
|
Map<UUID, Integer> team = new HashMap<>();
|
||||||
team.put(UUID.randomUUID(), RanksManager.OWNER_RANK);
|
team.put(UUID.randomUUID(), RanksManager.OWNER_RANK);
|
||||||
when(island.getMembers()).thenReturn(team);
|
when(island.getMembers()).thenReturn(team);
|
||||||
|
Loading…
Reference in New Issue
Block a user