use of org.bukkit.scheduler.BukkitTask in project AuthMeReloaded by AuthMe.
the class LimboPlayerTaskManagerTest method shouldCancelExistingTimeoutTask.
@Test
public void shouldCancelExistingTimeoutTask() {
// given
Player player = mock(Player.class);
LimboPlayer limboPlayer = new LimboPlayer(null, false, "", true, 0.3f, 0.1f);
BukkitTask existingTask = mock(BukkitTask.class);
limboPlayer.setTimeoutTask(existingTask);
given(settings.getProperty(RestrictionSettings.TIMEOUT)).willReturn(18);
BukkitTask bukkitTask = mock(BukkitTask.class);
given(bukkitService.runTaskLater(any(TimeoutTask.class), anyLong())).willReturn(bukkitTask);
// when
limboPlayerTaskManager.registerTimeoutTask(player, limboPlayer);
// then
verify(existingTask).cancel();
assertThat(limboPlayer.getTimeoutTask(), equalTo(bukkitTask));
// 18 * TICKS_PER_SECOND
verify(bukkitService).runTaskLater(any(TimeoutTask.class), eq(360L));
verify(messages).retrieveSingle(MessageKey.LOGIN_TIMEOUT_ERROR);
}
use of org.bukkit.scheduler.BukkitTask in project AuthMeReloaded by AuthMe.
the class BukkitServiceTest method shouldRunTaskAsynchronously.
@Test
public void shouldRunTaskAsynchronously() {
// given
Runnable task = () -> {
/* noop */
};
BukkitTask bukkitTask = mock(BukkitTask.class);
given(scheduler.runTaskAsynchronously(authMe, task)).willReturn(bukkitTask);
// when
BukkitTask resultingTask = bukkitService.runTaskAsynchronously(task);
// then
assertThat(resultingTask, equalTo(bukkitTask));
verify(scheduler, only()).runTaskAsynchronously(authMe, task);
}
use of org.bukkit.scheduler.BukkitTask in project AuthMeReloaded by AuthMe.
the class BukkitServiceTest method shouldRunTask.
@Test
public void shouldRunTask() {
// given
Runnable task = () -> {
/* noop */
};
BukkitTask bukkitTask = mock(BukkitTask.class);
given(scheduler.runTask(authMe, task)).willReturn(bukkitTask);
// when
BukkitTask resultingTask = bukkitService.runTask(task);
// then
assertThat(resultingTask, equalTo(bukkitTask));
verify(scheduler, only()).runTask(authMe, task);
}
use of org.bukkit.scheduler.BukkitTask in project AuthMeReloaded by AuthMe.
the class BukkitServiceTest method shouldRunTaskTimer.
@Test
public void shouldRunTaskTimer() {
// given
BukkitRunnable bukkitRunnable = mock(BukkitRunnable.class);
long delay = 20;
long period = 80;
BukkitTask bukkitTask = mock(BukkitTask.class);
given(bukkitRunnable.runTaskTimer(authMe, delay, period)).willReturn(bukkitTask);
// when
BukkitTask result = bukkitService.runTaskTimer(bukkitRunnable, delay, period);
// then
assertThat(result, equalTo(bukkitTask));
verify(bukkitRunnable).runTaskTimer(authMe, delay, period);
}
Aggregations