From 6a03d8624a9b1872f6e3eeb259f5d49b4a5686a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 19 Jun 2017 11:00:55 +0200 Subject: [PATCH] Convert login page test to use new web page test base --- src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt | 6 +----- src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt index 274bdbf..e9fdb5c 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/LoginPageTest.kt @@ -19,14 +19,10 @@ import org.mockito.Mockito.verify /** * Unit test for [LoginPage]. */ -class LoginPageTest : WebPageTest() { - - private val page = LoginPage(template, webInterface) +class LoginPageTest: WebPageTest2(::LoginPage) { private val sones = listOf(createSone("Sone", "Test"), createSone("Test"), createSone("Sone")) - override fun getPage() = page - private fun createSone(vararg contexts: String) = mock().apply { whenever(id).thenReturn(hashCode().toString()) val identity = mock().apply { 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 08d00f9..bf328a7 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest2.kt @@ -9,6 +9,7 @@ import net.pterodactylus.sone.data.Image import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.PostReply import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.freenet.wot.OwnIdentity import net.pterodactylus.sone.test.deepMock import net.pterodactylus.sone.test.get import net.pterodactylus.sone.test.mock @@ -55,6 +56,7 @@ abstract class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTempla private val requestHeaders = mutableMapOf() private val getRequestParameters = mutableMapOf>() private val postRequestParameters = mutableMapOf() + private val ownIdentities = mutableSetOf() private val allSones = mutableMapOf() private val localSones = mutableMapOf() private val allPosts = mutableMapOf() @@ -67,6 +69,7 @@ abstract class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTempla @Before fun setupCore() { whenever(core.preferences).thenReturn(preferences) + whenever(core.identityManager.allOwnIdentities).then { ownIdentities } whenever(core.sones).then { allSones.values } whenever(core.getSone(anyString())).then { allSones[it[0]].asOptional() } whenever(core.localSones).then { localSones.values } @@ -147,6 +150,10 @@ abstract class WebPageTest2(pageSupplier: (Template, WebInterface) -> SoneTempla whenever(webInterface.getCurrentSoneWithoutCreatingSession(eq(toadletContext))).thenReturn(null) } + fun addOwnIdentity(ownIdentity: OwnIdentity) { + ownIdentities += ownIdentity + } + fun addSone(id: String, sone: Sone) { allSones[id] = sone } -- 2.7.4