From c73c1bc9d249ec18b5e7b6d938cdfeead68efec2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 18 Jun 2017 15:42:10 +0200 Subject: [PATCH] Convert view Sone page test to new web page test base --- .../kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt | 5 +---- src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt index 8776af7..e3259f5 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt @@ -12,13 +12,10 @@ import org.junit.Test /** * Unit test for [ViewPostPage]. */ -class ViewPostPageTest: WebPageTest() { +class ViewPostPageTest: WebPageTest2(::ViewPostPage) { - private val page = ViewPostPage(template, webInterface) private val post = mock() - override fun getPage() = page - @Test fun `page returns correct path`() { assertThat(page.path, equalTo("viewPost.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 6981f9f..40910fe 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt @@ -4,6 +4,7 @@ import com.google.common.eventbus.EventBus import freenet.clients.http.ToadletContext import freenet.support.api.HTTPRequest import net.pterodactylus.sone.core.Preferences +import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.deepMock import net.pterodactylus.sone.test.get @@ -41,6 +42,7 @@ abstract class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTempla private val toadletContext = deepMock() private val getRequestParameters = mutableMapOf>() private val allSones = mutableMapOf() + private val allPosts = mutableMapOf() private val translations = mutableMapOf() @Before @@ -48,6 +50,7 @@ abstract class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTempla whenever(core.preferences).thenReturn(preferences) whenever(core.sones).then { allSones.values } whenever(core.getSone(anyString())).then { allSones[it[0]].asOptional() } + whenever(core.getPost(anyString())).then { allPosts[it[0]].asOptional() } } @Before @@ -85,6 +88,10 @@ abstract class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTempla allSones[id] = sone } + fun addPost(id: String, post: Post) { + allPosts[id] = post + } + fun addTranslation(key: String, value: String) { translations[key] = value } -- 2.7.4