Add test for DI constructability of EditProfileFieldPage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 21 Jan 2018 07:58:46 +0000 (08:58 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 21 Jan 2018 07:58:46 +0000 (08:58 +0100)
src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt

index f3486d2..c9b7955 100644 (file)
@@ -6,11 +6,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
 
 /**
  * Page that lets the user edit the name of a profile field.
  */
-class EditProfileFieldPage(template: Template, webInterface: WebInterface) :
+class EditProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface) :
                LoggedInPage("editProfileField.html", template, "Page.EditProfileField.Title", webInterface) {
 
        override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
index b4acc7e..81d10c0 100644 (file)
@@ -1,10 +1,13 @@
 package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.data.Profile
+import net.pterodactylus.sone.test.getInstance
 import net.pterodactylus.sone.test.whenever
+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.Before
 import org.junit.Test
 import org.mockito.Mockito.never
@@ -93,4 +96,9 @@ class EditProfileFieldPageTest: WebPageTest(::EditProfileFieldPage) {
                assertThat(templateContext["duplicateFieldName"], equalTo<Any>(true))
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+               assertThat(baseInjector.getInstance<EditProfileFieldPage>(), notNullValue())
+       }
+
 }