Add test for DI constructability of ViewPostPage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 21 Jan 2018 10:45:45 +0000 (11:45 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 21 Jan 2018 10:45:45 +0000 (11:45 +0100)
src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt

index d3f4540..763fc99 100644 (file)
@@ -8,11 +8,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
 
 /**
  * This page lets the user view a post and all its replies.
  */
-class ViewPostPage(template: Template, webInterface: WebInterface):
+class ViewPostPage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("viewPost.html", webInterface, template, "Page.ViewPost.Title") {
 
        override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
index b66f6cc..a4bd4b6 100644 (file)
@@ -2,10 +2,13 @@ package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.data.Post
 import net.pterodactylus.sone.data.Profile
+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.equalTo
+import org.hamcrest.Matchers.notNullValue
 import org.hamcrest.Matchers.nullValue
 import org.junit.Test
 
@@ -97,4 +100,9 @@ class ViewPostPageTest: WebPageTest(::ViewPostPage) {
                assertThat(page.getPageTitle(freenetRequest), equalTo("This is a text that … - First M. Last - view post title"))
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<ViewPostPage>(), notNullValue())
+       }
+
 }