From e28b0a9dd851f52f8e09a49f97eac5c1a26ecf48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 21 Jan 2018 09:00:04 +0100 Subject: [PATCH] Add test for DI constructability of EditProfilePage --- .../kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt | 3 ++- .../kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt index 95c40c8..f1805cf 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt @@ -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 edit her profile. */ -class EditProfilePage(template: Template, webInterface: WebInterface) : +class EditProfilePage @Inject constructor(template: Template, webInterface: WebInterface) : LoggedInPage("editProfile.html", template, "Page.EditProfile.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt index b4e6570..999a720 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt @@ -2,8 +2,10 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Image 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 net.pterodactylus.util.web.Method.POST import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains @@ -218,4 +220,9 @@ class EditProfilePageTest: WebPageTest(::EditProfilePage) { verifyRedirect("editProfileField.html?field=${firstField.id}") } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + } -- 2.7.4