use of org.bukkit.event.entity.EntityEvent in project AuthMeReloaded by AuthMe.
the class ListenerServiceTest method shouldAllowAuthenticatedPlayer.
@Test
public void shouldAllowAuthenticatedPlayer() {
// given
String playerName = "Bobby";
Player player = mockPlayerWithName(playerName);
given(playerCache.isAuthenticated(playerName)).willReturn(true);
EntityEvent event = mock(EntityEvent.class);
given(event.getEntity()).willReturn(player);
// when
boolean result = listenerService.shouldCancelEvent(event);
// then
assertThat(result, equalTo(false));
verify(playerCache).isAuthenticated(playerName);
verifyZeroInteractions(dataSource);
}
use of org.bukkit.event.entity.EntityEvent in project AuthMeReloaded by AuthMe.
the class ListenerServiceTest method shouldDenyUnLoggedPlayer.
@Test
public void shouldDenyUnLoggedPlayer() {
// given
String playerName = "Tester";
Player player = mockPlayerWithName(playerName);
given(playerCache.isAuthenticated(playerName)).willReturn(false);
EntityEvent event = mock(EntityEvent.class);
given(event.getEntity()).willReturn(player);
// when
boolean result = listenerService.shouldCancelEvent(event);
// then
assertThat(result, equalTo(true));
verify(playerCache).isAuthenticated(playerName);
// makes sure the setting is checked first = avoid unnecessary DB operation
verifyZeroInteractions(dataSource);
}
Aggregations