use of org.bukkit.event.entity.EntityEvent in project AuthMeReloaded by AuthMe.
the class ListenerServiceTest method shouldAllowNpcPlayer.
@Test
public void shouldAllowNpcPlayer() {
// given
String playerName = "other_npc";
Player player = mockPlayerWithName(playerName);
EntityEvent event = mock(EntityEvent.class);
given(event.getEntity()).willReturn(player);
given(pluginHookService.isNpc(player)).willReturn(true);
// when
boolean result = listenerService.shouldCancelEvent(event);
// then
assertThat(result, equalTo(false));
verify(pluginHookService).isNpc(player);
}
use of org.bukkit.event.entity.EntityEvent in project AuthMeReloaded by AuthMe.
the class ListenerServiceTest method shouldHandleEntityEventWithNonPlayerEntity.
@Test
public void shouldHandleEntityEventWithNonPlayerEntity() {
// given
EntityEvent event = mock(EntityEvent.class);
given(event.getEntity()).willReturn(mock(Entity.class));
// when
boolean result = listenerService.shouldCancelEvent(event);
// then
assertThat(result, equalTo(false));
}
use of org.bukkit.event.entity.EntityEvent in project AuthMeReloaded by AuthMe.
the class ListenerServiceTest method shouldAllowUnrestrictedName.
@Test
public void shouldAllowUnrestrictedName() {
// given
String playerName = "Npc2";
Player player = mockPlayerWithName(playerName);
EntityEvent event = mock(EntityEvent.class);
given(event.getEntity()).willReturn(player);
given(validationService.isUnrestricted(playerName)).willReturn(true);
// when
boolean result = listenerService.shouldCancelEvent(event);
// then
assertThat(result, equalTo(false));
verifyZeroInteractions(dataSource);
}
use of org.bukkit.event.entity.EntityEvent in project AuthMeReloaded by AuthMe.
the class ListenerServiceTest method shouldAllowUnloggedPlayerForOptionalRegistration.
@Test
public void shouldAllowUnloggedPlayerForOptionalRegistration() {
// given
String playerName = "myPlayer1";
Player player = mockPlayerWithName(playerName);
given(playerCache.isAuthenticated(playerName)).willReturn(false);
given(settings.getProperty(RegistrationSettings.FORCE)).willReturn(false);
EntityEvent event = mock(EntityEvent.class);
given(event.getEntity()).willReturn(player);
listenerService.reload(settings);
// when
boolean result = listenerService.shouldCancelEvent(event);
// then
assertThat(result, equalTo(false));
verify(playerCache).isAuthenticated(playerName);
verify(dataSource).isAuthAvailable(playerName);
}
use of org.bukkit.event.entity.EntityEvent in project AuthMeReloaded by AuthMe.
the class ListenerServiceTest method shouldHandleEventWithNullEntity.
@Test
public void shouldHandleEventWithNullEntity() {
// given
EntityEvent event = mock(EntityEvent.class);
given(event.getEntity()).willReturn(null);
// when
boolean result = listenerService.shouldCancelEvent(event);
// then
assertThat(result, equalTo(false));
}
Aggregations