X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FWebPageTest2.kt;h=5682b11f9825ac02229e7f7481c7db33648022b1;hp=69ac20ab0ffc11bd4eb76086aead0ec1176c14c3;hb=c93d7aa1b5c647a07460e5724b04ecff2de90884;hpb=1d435ca72d40b7e737791fb966386cdb78566efa diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt index 69ac20a..5682b11 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt @@ -20,6 +20,7 @@ import net.pterodactylus.sone.utils.asOptional import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException +import net.pterodactylus.util.notify.Notification import net.pterodactylus.util.template.Template import net.pterodactylus.util.template.TemplateContext import net.pterodactylus.util.web.Method @@ -69,6 +70,7 @@ open class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTemplatePa private val perPostReplies = mutableMapOf() private val allAlbums = mutableMapOf() private val allImages = mutableMapOf() + private val notifications = mutableMapOf() private val translations = mutableMapOf() init { @@ -99,7 +101,8 @@ open class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTemplatePa whenever(webInterface.getCurrentSoneCreatingSession(eq(toadletContext))).thenReturn(currentSone) whenever(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(currentSone) whenever(webInterface.getCurrentSoneWithoutCreatingSession(eq(toadletContext))).thenReturn(currentSone) - whenever(webInterface.getNotifications(currentSone)).thenReturn(emptyList()) + whenever(webInterface.getNotifications(currentSone)).then { notifications.values } + whenever(webInterface.getNotification(anyString())).then { notifications[it[0]].asOptional() } } private fun setupHttpRequest() { @@ -192,6 +195,10 @@ open class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTemplatePa translations[key] = value } + fun addNotification(id: String, notification: Notification) { + notifications[id] = notification + } + fun addTemporaryImage(id: String, temporaryImage: TemporaryImage) { whenever(core.getTemporaryImage(id)).thenReturn(temporaryImage) }