X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FWebPageTest.kt;h=d48f5fd342ffcaca96a04a0f2513ea09dc8b9a93;hp=d654b09850da47e935750cc0b9dbb7007bf124eb;hb=c28013c8a4bcb9776a1e2d82ffd6c4c8297ffb62;hpb=cd1f93dc057bdc6e89baeb41db0f749f2287224e diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt index d654b09..d48f5fd 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt @@ -1,7 +1,7 @@ package net.pterodactylus.sone.web.pages import com.google.common.eventbus.EventBus -import freenet.clients.http.ToadletContext +import freenet.clients.http.* import freenet.support.SimpleReadOnlyArrayBucket import freenet.support.api.HTTPRequest import freenet.support.api.HTTPUploadedFile @@ -51,14 +51,17 @@ open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePag val eventBus = mock() val preferences = Preferences(eventBus) val l10n = webInterface.l10n!! + val sessionManager = mock() val page by lazy { pageSupplier(template, webInterface) } val httpRequest = mock() val freenetRequest = mock() init { whenever(freenetRequest.l10n).thenReturn(l10n) + whenever(freenetRequest.sessionManager).thenReturn(sessionManager) whenever(freenetRequest.uri).thenReturn(mock()) } + val soneRequest by lazy { freenetRequest.toSoneRequest(core, webInterface) } val templateContext = TemplateContext() val toadletContext = deepMock() val responseContent = ByteArrayOutputStream() @@ -106,6 +109,7 @@ open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePag } private fun setupWebInterface() { + whenever(webInterface.sessionManager).thenReturn(sessionManager) whenever(webInterface.getCurrentSoneCreatingSession(eq(toadletContext))).thenReturn(currentSone) whenever(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(currentSone) whenever(webInterface.getCurrentSoneWithoutCreatingSession(eq(toadletContext))).thenReturn(currentSone)