From: David ‘Bombe’ Roden Date: Sun, 21 Jan 2018 07:58:46 +0000 (+0100) Subject: Add test for DI constructability of EditProfileFieldPage X-Git-Tag: v79^2~213 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=10bfcce6b934c393c2535086ae0109e8f63f15fc;p=Sone.git Add test for DI constructability of EditProfileFieldPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt index f3486d2..c9b7955 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt @@ -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) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt index b4acc7e..81d10c0 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt @@ -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(true)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }