🚚 Move new elements mock to test objects
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 1 Jul 2020 20:13:57 +0000 (22:13 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 1 Jul 2020 20:15:33 +0000 (22:15 +0200)
src/test/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt

index fb06e19..651d839 100644 (file)
@@ -38,10 +38,6 @@ class GetStatusAjaxPageTest: JsonPageTest("getStatus.ajax", requiresLogin = fals
 
        private val timeTextConverter = mock<TimeTextConverter>()
        private val l10nFilter = mock<L10nFilter>()
-       private val newElements = mock<NewElements>().apply {
-               whenever(newPosts).then { this@GetStatusAjaxPageTest.newPosts.values }
-               whenever(newReplies).then { this@GetStatusAjaxPageTest.newReplies.values }
-       }
        override var page: JsonPage = GetStatusAjaxPage(webInterface, elementLoader, newElements, timeTextConverter, l10nFilter, TimeZone.getTimeZone("UTC"))
 
        @Before
index e125c13..e8e660d 100644 (file)
@@ -25,6 +25,7 @@ import net.pterodactylus.sone.test.get
 import net.pterodactylus.sone.test.mock
 import net.pterodactylus.sone.test.whenever
 import net.pterodactylus.sone.utils.asOptional
+import net.pterodactylus.sone.web.NewElements
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.web.page.FreenetRequest
 import net.pterodactylus.util.notify.Notification
@@ -49,6 +50,7 @@ open class TestObjects {
        val preferences = Preferences(eventBus)
        val updateChecker = mock<UpdateChecker>()
        val elementLoader = mock<ElementLoader>()
+       val newElements = mock<NewElements>()
 
        val toadletContext = mock<ToadletContext>()
        val freenetRequest = mock<FreenetRequest>()
@@ -103,6 +105,9 @@ open class TestObjects {
                        linkedElements[it.getArgument(0)] ?: LinkedElement(it.getArgument(0), loading = true)
                }
 
+               whenever(newElements.newPosts).then { newPosts.values }
+               whenever(newElements.newReplies).then { newReplies.values }
+
                whenever(currentSone.options).thenReturn(DefaultSoneOptions())
                currentSone.mock("soneId", "Sone_Id", true, 1000, idle)