Fixed EnterExitListener test class.

Added island.isOwned() mocking.
Added 2 test cases to handle unowned island testing.
This commit is contained in:
tastybento 2019-12-08 11:52:33 -08:00
parent 3e81b4a3cf
commit eb06b39b4a

View File

@ -136,6 +136,7 @@ public class EnterExitListenerTest {
when(island.getCenter()).thenReturn(loc);
when(island.getProtectionRange()).thenReturn(PROTECTION_RANGE);
when(island.getOwner()).thenReturn(uuid);
when(island.isOwned()).thenReturn(true);
when(im.getIsland(any(), any(UUID.class))).thenReturn(island);
@ -348,4 +349,31 @@ public class EnterExitListenerTest {
verify(pim).callEvent(any(IslandExitEvent.class));
}
/**
* Test method for {@link EnterExitListener#onTeleport(org.bukkit.event.player.PlayerTeleportEvent)}.
*/
@Test
public void testEnterIslandTeleportUnowned() {
when(island.isOwned()).thenReturn(false);
PlayerTeleportEvent e = new PlayerTeleportEvent(user.getPlayer(), anotherWorld, inside, TeleportCause.PLUGIN);
listener.onTeleport(e);
verify(notifier, never()).notify(any(User.class), anyString());
verify(pim).callEvent(any(IslandEnterEvent.class));
verify(pim, never()).callEvent(any(IslandExitEvent.class));
}
/**
* Test method for {@link EnterExitListener#onTeleport(org.bukkit.event.player.PlayerTeleportEvent)}.
*/
@Test
public void testExitIslandTeleportUnowned() {
when(island.isOwned()).thenReturn(false);
PlayerTeleportEvent e = new PlayerTeleportEvent(user.getPlayer(), inside, anotherWorld, TeleportCause.PLUGIN);
listener.onTeleport(e);
verify(notifier, never()).notify(any(User.class), anyString());
verify(pim, never()).callEvent(any(IslandEnterEvent.class));
verify(pim).callEvent(any(IslandExitEvent.class));
}
}