X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FTestObjects.kt;h=e8e660d9c7606384e8ddfb761c345d26f5c2bf9b;hb=fe880bd95f2f1bb155e890a9ffd2dc2abc86cb37;hp=f9025330e52f23c62ad58cd05b775045f1f4e7d1;hpb=faf66247a34f64946990a985d2ea3003465969cb;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt index f902533..e8e660d 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TestObjects.kt @@ -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() val elementLoader = mock() + val newElements = mock() val toadletContext = mock() val freenetRequest = mock() @@ -80,15 +82,11 @@ open class TestObjects { init { whenever(webInterface.templateContextFactory).thenReturn(TemplateContextFactory()) - whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext), ArgumentMatchers.anyBoolean())).thenReturn(currentSone) - whenever(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(currentSone) - whenever(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(currentSone) + whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext))).thenReturn(currentSone) whenever(webInterface.core).thenReturn(core) whenever(webInterface.formPassword).then { formPassword } whenever(webInterface.getNotifications(currentSone)).thenAnswer { notifications.values } whenever(webInterface.getNotification(ArgumentMatchers.anyString())).then { notifications[it[0]].asOptional() } - whenever(webInterface.getNewPosts(currentSone)).thenAnswer { newPosts.values } - whenever(webInterface.getNewReplies(currentSone)).thenAnswer { newReplies.values } whenever(webInterface.translation).thenReturn(translation) whenever(core.preferences).thenReturn(preferences) @@ -107,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) @@ -139,9 +140,7 @@ open class TestObjects { } protected fun unsetCurrentSone() { - whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext), ArgumentMatchers.anyBoolean())).thenReturn(null) - whenever(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(null) - whenever(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(null) + whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext))).thenReturn(null) } protected fun postRequest() {