From: David ‘Bombe’ Roden Date: Mon, 19 Jun 2017 21:45:32 +0000 (+0200) Subject: Convert dismiss notification page test to use new web page test base X-Git-Tag: 0.9.7^2~127 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c93d7aa1b5c647a07460e5724b04ecff2de90884;p=Sone.git Convert dismiss notification page test to use new web page test base --- 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) }