From c93d7aa1b5c647a07460e5724b04ecff2de90884 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 19 Jun 2017 23:45:32 +0200 Subject: [PATCH] Convert dismiss notification page test to use new web page test base --- .../pterodactylus/sone/web/pages/DismissNotificationPageTest.kt | 5 +---- src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt | 9 ++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt index 5ce0dcb..acb3d0a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt @@ -13,13 +13,10 @@ import org.mockito.Mockito.verify /** * Unit test for [DismissNotificationPage]. */ -class DismissNotificationPageTest: WebPageTest() { +class DismissNotificationPageTest: WebPageTest2(::DismissNotificationPage) { - private val page = DismissNotificationPage(template, webInterface) private val notification = mock() - override fun getPage() = page - @Test fun `page returns correct path`() { assertThat(page.path, equalTo("dismissNotification.html")) 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) } -- 2.7.4