♻️ Extract page implementation for tests
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 3 Dec 2019 17:45:05 +0000 (18:45 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 11 Dec 2019 15:58:59 +0000 (16:58 +0100)
src/test/kotlin/net/pterodactylus/sone/test/TestPage.kt [new file with mode: 0644]
src/test/kotlin/net/pterodactylus/sone/web/PageToadletRegistryTest.kt

diff --git a/src/test/kotlin/net/pterodactylus/sone/test/TestPage.kt b/src/test/kotlin/net/pterodactylus/sone/test/TestPage.kt
new file mode 100644 (file)
index 0000000..762f789
--- /dev/null
@@ -0,0 +1,14 @@
+package net.pterodactylus.sone.test
+
+import net.pterodactylus.util.web.*
+
+/**
+ * Dummy implementation of a [Page].
+ */
+class TestPage<REQ : Request> : Page<REQ> {
+
+       override fun getPath() = ""
+       override fun isPrefixPage() = false
+       override fun handleRequest(freenetRequest: REQ, response: Response) = response
+
+}
index 739a0dd..2134661 100644 (file)
@@ -5,7 +5,6 @@ import freenet.clients.http.*
 import net.pterodactylus.sone.main.*
 import net.pterodactylus.sone.test.*
 import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.web.*
 import org.junit.*
 import org.junit.rules.*
 import org.mockito.Mockito.*
@@ -36,7 +35,7 @@ class PageToadletRegistryTest {
                verify(pageMaker).addNavigationCategory("/Sone/index.html", "Navigation.Menu.Sone.Name", "Navigation.Menu.Sone.Tooltip", sonePlugin)
        }
 
-       private val page = TestPage()
+       private val page = TestPage<FreenetRequest>()
 
        @Test
        fun `adding a page without menuname will add it correctly`() {
@@ -147,10 +146,4 @@ class PageToadletRegistryTest {
                                whenever(this.menuName).thenReturn(menuName)
                        }
 
-       private class TestPage : Page<FreenetRequest> {
-               override fun getPath() = ""
-               override fun isPrefixPage() = false
-               override fun handleRequest(freenetRequest: FreenetRequest, response: Response) = response
-       }
-
 }