mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-21 20:22:45 +02:00
[Test] Fixed AFKListenerTest
This commit is contained in:
parent
1758832b8e
commit
29df1aca2b
|
@ -1,9 +1,12 @@
|
|||
package com.djrapitops.plan.system.listeners.bukkit;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plugin.logging.console.TestPluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ConsoleErrorLogger;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import utilities.TestConstants;
|
||||
|
@ -12,8 +15,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Test for {@link AFKListener}
|
||||
|
@ -22,23 +24,25 @@ import static org.mockito.Mockito.doReturn;
|
|||
*/
|
||||
public class AFKListenerTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
// Settings.AFK_THRESHOLD_MINUTES.setTemporaryValue(3);
|
||||
private AFKListener underTest;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
PlanConfig config = Mockito.mock(PlanConfig.class);
|
||||
when(config.getNumber(Settings.AFK_THRESHOLD_MINUTES)).thenReturn(3);
|
||||
underTest = new AFKListener(config, new ConsoleErrorLogger(new TestPluginLogger()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Requires AfkListener initialization")
|
||||
public void testAfkPermissionCallCaching() {
|
||||
AFKListener afkListener = new AFKListener(null, null);
|
||||
public void afkPermissionIsNotCalledMoreThanOnce() {
|
||||
Collection<Boolean> calls = new ArrayList<>();
|
||||
|
||||
Player player = mockPlayer(calls);
|
||||
PlayerMoveEvent event = mockMoveEvent(player);
|
||||
|
||||
afkListener.onMove(event);
|
||||
underTest.onMove(event);
|
||||
assertEquals(1, calls.size());
|
||||
afkListener.onMove(event);
|
||||
underTest.onMove(event);
|
||||
assertEquals(1, calls.size());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user