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

index 932827e..196b0b4 100644 (file)
@@ -5,11 +5,12 @@ import net.pterodactylus.sone.web.page.FreenetPage
 import net.pterodactylus.sone.web.page.FreenetRequest
 import net.pterodactylus.util.web.Response
 import java.net.URI
+import javax.inject.Inject
 
 /**
  * Page that delivers a {@link TemporaryImage} to the browser.
  */
-class GetImagePage(webInterface: WebInterface): FreenetPage {
+class GetImagePage @Inject constructor(webInterface: WebInterface): FreenetPage {
 
        private val core = webInterface.core
 
index b5efeac..ec0cd99 100644 (file)
@@ -1,9 +1,12 @@
 package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.data.TemporaryImage
+import net.pterodactylus.sone.test.getInstance
+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
 
 /**
@@ -59,4 +62,9 @@ class GetImagePageTest {
                ))
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<GetImagePage>(), notNullValue())
+       }
+
 }