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