Add test for DI constructability of CreatePostPage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 20 Jan 2018 11:07:13 +0000 (12:07 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 20 Jan 2018 11:07:13 +0000 (12:07 +0100)
src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/CreatePostPageTest.kt

index 31896f7..8a1268e 100644 (file)
@@ -8,11 +8,12 @@ import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.web.page.FreenetRequest
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
+import javax.inject.Inject
 
 /**
  * This page lets the user create a new [Post].
  */
-class CreatePostPage(template: Template, webInterface: WebInterface):
+class CreatePostPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("createPost.html", template, "Page.CreatePost.Title", webInterface) {
 
        override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
index 3b1cc8c..dccce87 100644 (file)
@@ -2,11 +2,14 @@ package net.pterodactylus.sone.web.pages
 
 import com.google.common.base.Optional.absent
 import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.test.getInstance
 import net.pterodactylus.sone.test.mock
 import net.pterodactylus.sone.utils.asOptional
+import net.pterodactylus.sone.web.baseInjector
 import net.pterodactylus.util.web.Method.POST
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.equalTo
+import org.hamcrest.Matchers.notNullValue
 import org.junit.Test
 import org.mockito.Mockito.verify
 
@@ -88,4 +91,9 @@ class CreatePostPageTest: WebPageTest(::CreatePostPage) {
                }
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<CreatePostPage>(), notNullValue())
+       }
+
 }