Fix afk tracker tests

This commit is contained in:
Risto Lahtela 2022-01-31 21:05:47 +02:00
parent 96e0cd6856
commit 954ef59c0b
3 changed files with 15 additions and 1 deletions

View File

@ -16,6 +16,8 @@
*/
package com.djrapitops.plan.gathering.listeners;
import com.djrapitops.plan.gathering.cache.SessionCache;
import com.djrapitops.plan.gathering.domain.ActiveSession;
import com.djrapitops.plan.gathering.listeners.bukkit.BukkitAFKListener;
import com.djrapitops.plan.settings.config.PlanConfig;
import com.djrapitops.plan.settings.config.paths.TimeSettings;
@ -51,6 +53,9 @@ class BukkitAFKListenerTest {
when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(TimeUnit.MINUTES.toMillis(3));
errorLogger = Mockito.mock(ErrorLogger.class);
underTest = new BukkitAFKListener(config, errorLogger);
new SessionCache().cacheSession(TestConstants.PLAYER_ONE_UUID, new ActiveSession(null, null, 0, null, null));
new SessionCache().cacheSession(TestConstants.PLAYER_TWO_UUID, new ActiveSession(null, null, 0, null, null));
}
@AfterEach

View File

@ -16,6 +16,8 @@
*/
package com.djrapitops.plan.gathering.afk;
import com.djrapitops.plan.gathering.cache.SessionCache;
import com.djrapitops.plan.gathering.domain.ActiveSession;
import com.djrapitops.plan.settings.config.PlanConfig;
import com.djrapitops.plan.settings.config.paths.TimeSettings;
import org.junit.jupiter.api.BeforeEach;
@ -41,6 +43,8 @@ class AFKTrackerTest {
afkThreshold = TimeUnit.MINUTES.toMillis(1L);
when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(afkThreshold);
new SessionCache().cacheSession(playerUUID, new ActiveSession(playerUUID, null, 0, null, null));
underTest = new AFKTracker(config);
}
@ -72,7 +76,7 @@ class AFKTrackerTest {
@Test
void someOneIsNotEvenOnline() {
assertFalse(underTest.isAfk(playerUUID));
assertFalse(underTest.isAfk(TestConstants.PLAYER_TWO_UUID));
}
@Test

View File

@ -18,6 +18,8 @@ package com.djrapitops.plan.gathering.listeners;
import cn.nukkit.Player;
import cn.nukkit.event.player.PlayerMoveEvent;
import com.djrapitops.plan.gathering.cache.SessionCache;
import com.djrapitops.plan.gathering.domain.ActiveSession;
import com.djrapitops.plan.gathering.listeners.nukkit.NukkitAFKListener;
import com.djrapitops.plan.settings.config.PlanConfig;
import com.djrapitops.plan.settings.config.paths.TimeSettings;
@ -51,6 +53,9 @@ class NukkitAFKListenerTest {
when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(TimeUnit.MINUTES.toMillis(3));
errorLogger = Mockito.mock(ErrorLogger.class);
underTest = new NukkitAFKListener(config, errorLogger);
new SessionCache().cacheSession(TestConstants.PLAYER_ONE_UUID, new ActiveSession(null, null, 0, null, null));
new SessionCache().cacheSession(TestConstants.PLAYER_TWO_UUID, new ActiveSession(null, null, 0, null, null));
}
@AfterEach