Add test for DI constructability of EditProfileFieldAjaxPage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 23 Jan 2018 20:59:30 +0000 (21:59 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 23 Jan 2018 20:59:30 +0000 (21:59 +0100)
src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt
src/test/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPageTest.kt

index e48c92d..7e7581d 100644 (file)
@@ -5,11 +5,13 @@ import net.pterodactylus.sone.utils.ifFalse
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.web.page.FreenetRequest
+import javax.inject.Inject
 
 /**
  * AJAX page that lets the user rename a profile field.
  */
-class EditProfileFieldAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("editProfileField.ajax", webInterface) {
+class EditProfileFieldAjaxPage @Inject constructor(webInterface: WebInterface) :
+               LoggedInJsonPage("editProfileField.ajax", webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        currentSone.profile.let { profile ->
index 7eed9ac..6e00c29 100644 (file)
@@ -1,7 +1,10 @@
 package net.pterodactylus.sone.web.ajax
 
+import net.pterodactylus.sone.test.getInstance
+import net.pterodactylus.sone.web.baseInjector
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.equalTo
+import org.hamcrest.Matchers.notNullValue
 import org.junit.Test
 import org.mockito.Mockito.verify
 
@@ -43,4 +46,9 @@ class EditProfileFieldAjaxPageTest : JsonPageTest("editProfileField.ajax", pageS
                verify(currentSone).profile = profile
        }
 
+       @Test
+       fun `page can be created by dependency injection`() {
+           assertThat(baseInjector.getInstance<EditProfileFieldAjaxPage>(), notNullValue())
+       }
+
 }