From d587892df2d260522b0f188e92e2ef9bf724bf21 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 20 Aug 2018 11:44:21 +0300 Subject: [PATCH] Fixed tests --- .../plan/data/container/Session.java | 22 ++++++++++++------- .../plan/system/cache/SessionCacheTest.java | 10 +++++---- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java index 4a6fb62c4..7a83447c0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/container/Session.java @@ -182,14 +182,8 @@ public class Session extends DataContainer implements DateHolder { getValue(SessionKeys.END).orElse(-1L).equals(session.getValue(SessionKeys.END).orElse(-1L)) && mobKills == session.mobKills && deaths == session.deaths && - Objects.equals( - getValue(SessionKeys.WORLD_TIMES).orElse(null), - session.getValue(SessionKeys.WORLD_TIMES).orElse(null) - ) && - Objects.equals( - getValue(SessionKeys.PLAYER_KILLS).orElse(new ArrayList<>()), - session.getValue(SessionKeys.PLAYER_KILLS).orElse(new ArrayList<>()) - ); + Objects.equals(playerKills, session.playerKills) && + Objects.equals(worldTimes, session.worldTimes); } @Override @@ -252,4 +246,16 @@ public class Session extends DataContainer implements DateHolder { return theWorld + " (" + Formatters.percentage().apply(quotient) + ")"; } + + @Override + public String toString() { + return "Session{" + + "sessionStart=" + sessionStart + + ", worldTimes=" + worldTimes + + ", playerKills=" + playerKills + + ", mobKills=" + mobKills + + ", deaths=" + deaths + + ", afkTime=" + afkTime + + '}'; + } } diff --git a/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java b/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java index 65eda615b..7316387ab 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/cache/SessionCacheTest.java @@ -1,10 +1,7 @@ package com.djrapitops.plan.system.cache; import com.djrapitops.plan.data.container.Session; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; +import org.junit.*; import org.junit.rules.TemporaryFolder; import utilities.TestConstants; import utilities.mocks.SystemMockUtil; @@ -36,6 +33,11 @@ public class SessionCacheTest { sessionCache.cacheSession(uuid, session); } + @After + public void tearDown() { + SessionCache.clear(); + } + @Test public void testAtomity() { SessionCache reloaded = new SessionCache(null);