Add test for DI constructability of ImageBrowserPage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 21 Jan 2018 08:05:04 +0000 (09:05 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 21 Jan 2018 08:05:04 +0000 (09:05 +0100)
src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt

index bf1ed2a..6bbde00 100644 (file)
@@ -9,11 +9,12 @@ import net.pterodactylus.sone.web.page.FreenetRequest
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import java.net.URI
+import javax.inject.Inject
 
 /**
  * The image browser page is the entry page for the image management.
  */
-class ImageBrowserPage(template: Template, webInterface: WebInterface):
+class ImageBrowserPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface) {
 
        override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
index 4d0b2c7..c306b3e 100644 (file)
@@ -3,11 +3,14 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Album
 import net.pterodactylus.sone.data.Image
 import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.test.getInstance
 import net.pterodactylus.sone.test.mock
 import net.pterodactylus.sone.test.whenever
+import net.pterodactylus.sone.web.baseInjector
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
 import org.hamcrest.Matchers.equalTo
+import org.hamcrest.Matchers.notNullValue
 import org.junit.Test
 
 /**
@@ -133,4 +136,9 @@ class ImageBrowserPageTest: WebPageTest(::ImageBrowserPage) {
            assertThat(page.isLinkExcepted(null), equalTo(true))
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<ImageBrowserPage>(), notNullValue())
+       }
+
 }