Search in sources :

Example 1 with PlayerEvent

use of org.bukkit.event.player.PlayerEvent in project AuthMeReloaded by AuthMe.

the class ListenerServiceTest method shouldHandlePlayerEventWithNullPlayer.

@Test
public void shouldHandlePlayerEventWithNullPlayer() {
    // given
    PlayerEvent event = new TestPlayerEvent(null);
    // when
    boolean result = listenerService.shouldCancelEvent(event);
    // then
    assertThat(result, equalTo(false));
}
Also used : PlayerEvent(org.bukkit.event.player.PlayerEvent) Test(org.junit.Test)

Example 2 with PlayerEvent

use of org.bukkit.event.player.PlayerEvent in project AuthMeReloaded by AuthMe.

the class ListenerServiceTest method shouldHandlePlayerEvent.

@Test
public // This simply forwards to shouldCancelEvent(Player), so the rest is already tested
void shouldHandlePlayerEvent() {
    // given
    String playerName = "example";
    Player player = mockPlayerWithName(playerName);
    PlayerEvent event = new TestPlayerEvent(player);
    given(playerCache.isAuthenticated(playerName)).willReturn(true);
    // when
    boolean result = listenerService.shouldCancelEvent(event);
    // then
    assertThat(result, equalTo(false));
    verify(playerCache).isAuthenticated(playerName);
    verifyZeroInteractions(dataSource);
}
Also used : Player(org.bukkit.entity.Player) PlayerEvent(org.bukkit.event.player.PlayerEvent) Test(org.junit.Test)

Aggregations

PlayerEvent (org.bukkit.event.player.PlayerEvent)2 Test (org.junit.Test)2 Player (org.bukkit.entity.Player)1