diff --git a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/auth/ActiveCookieStoreTest.java b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/auth/ActiveCookieStoreTest.java index d0e3eca3f..f138eccbb 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/auth/ActiveCookieStoreTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/auth/ActiveCookieStoreTest.java @@ -28,7 +28,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import utilities.TestConstants; -import utilities.mocks.objects.TestRunnableFactory; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -46,9 +45,9 @@ class ActiveCookieStoreTest { when(dbSystem.getDatabase()).thenReturn(db); underTest = new ActiveCookieStore( - activeCookieExpiryCleanupTask, Mockito.mock(PlanConfig.class), + Mockito.mock(ActiveCookieExpiryCleanupTask.class), + Mockito.mock(PlanConfig.class), dbSystem, - new TestRunnableFactory(), Mockito.mock(Processing.class) ); user = new User(TestConstants.PLAYER_ONE_NAME, "console", null, PassEncryptUtil.createHash("testPass"), 0, WebUser.getPermissionsForLevel(0)); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/WebUserQueriesTest.java b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/WebUserQueriesTest.java index 1a05d7741..6422b96ea 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/WebUserQueriesTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/storage/database/queries/WebUserQueriesTest.java @@ -18,6 +18,7 @@ package com.djrapitops.plan.storage.database.queries; import com.djrapitops.plan.delivery.domain.WebUser; import com.djrapitops.plan.delivery.domain.auth.User; +import com.djrapitops.plan.delivery.webserver.auth.ActiveCookieExpiryCleanupTask; import com.djrapitops.plan.delivery.webserver.auth.ActiveCookieStore; import com.djrapitops.plan.processing.Processing; import com.djrapitops.plan.settings.config.PlanConfig; @@ -30,7 +31,6 @@ import com.djrapitops.plan.utilities.PassEncryptUtil; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import utilities.TestConstants; -import utilities.mocks.objects.TestRunnableFactory; import java.util.Collections; import java.util.Map; @@ -78,7 +78,7 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer { userIsRegistered(); User user = db().query(WebUserQueries.fetchUser(WEB_USERNAME)).orElseThrow(AssertionError::new); - ActiveCookieStore cookieStore = new ActiveCookieStore(activeCookieExpiryCleanupTask, Mockito.mock(PlanConfig.class), dbSystem(), new TestRunnableFactory(), Mockito.mock(Processing.class)); + ActiveCookieStore cookieStore = createActiveCookieStore(); String cookie = cookieStore.generateNewCookie(user); @@ -92,7 +92,7 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer { userIsRegistered(); User user = db().query(WebUserQueries.fetchUser(WEB_USERNAME)).orElseThrow(AssertionError::new); - ActiveCookieStore cookieStore = new ActiveCookieStore(activeCookieExpiryCleanupTask, Mockito.mock(PlanConfig.class), dbSystem(), new TestRunnableFactory(), Mockito.mock(Processing.class)); + ActiveCookieStore cookieStore = createActiveCookieStore(); String cookie = cookieStore.generateNewCookie(user); @@ -106,7 +106,7 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer { userIsRegistered(); User user = db().query(WebUserQueries.fetchUser(WEB_USERNAME)).orElseThrow(AssertionError::new); - ActiveCookieStore cookieStore = new ActiveCookieStore(activeCookieExpiryCleanupTask, Mockito.mock(PlanConfig.class), dbSystem(), new TestRunnableFactory(), Mockito.mock(Processing.class)); + ActiveCookieStore cookieStore = createActiveCookieStore(); String cookie = cookieStore.generateNewCookie(user); @@ -117,6 +117,15 @@ public interface WebUserQueriesTest extends DatabaseTestPreparer { assertTrue(db().query(WebUserQueries.fetchActiveCookies()).isEmpty()); } + private ActiveCookieStore createActiveCookieStore() { + return new ActiveCookieStore( + Mockito.mock(ActiveCookieExpiryCleanupTask.class), + Mockito.mock(PlanConfig.class), + dbSystem(), + Mockito.mock(Processing.class) + ); + } + @Test default void removeEverythingRemovesCookies() { activeCookieStoreSavesCookies();