Add test for DI constructability of GetReplyAjaxPage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Jan 2018 18:06:04 +0000 (19:06 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Jan 2018 18:30:52 +0000 (19:30 +0100)
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt
src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt

index c6cfc2f..119a622 100644 (file)
@@ -8,11 +8,13 @@ import net.pterodactylus.sone.utils.render
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.web.page.FreenetRequest
 import net.pterodactylus.util.template.Template
+import javax.inject.Inject
 
 /**
  * This AJAX page returns the details of a reply.
  */
-class GetReplyAjaxPage(webInterface: WebInterface, private val template: Template) : LoggedInJsonPage("getReply.ajax", webInterface) {
+class GetReplyAjaxPage @Inject constructor(webInterface: WebInterface, private val template: Template) :
+               LoggedInJsonPage("getReply.ajax", webInterface) {
 
        override val needsFormPassword = false
 
index 6af8776..6010e9f 100644 (file)
@@ -2,12 +2,15 @@ package net.pterodactylus.sone.web.ajax
 
 import net.pterodactylus.sone.data.PostReply
 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.utils.asTemplate
+import net.pterodactylus.sone.web.baseInjector
 import net.pterodactylus.util.template.ReflectionAccessor
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.equalTo
+import org.hamcrest.Matchers.notNullValue
 import org.junit.Test
 
 /**
@@ -49,4 +52,9 @@ class GetReplyAjaxPageTest : JsonPageTest("getReply.ajax", needsFormPassword = f
                ).joinToString("\n")))
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<GetReplyAjaxPage>(), notNullValue())
+       }
+
 }