From 393926e1a012b28b05e946d6ac68310b3548f6f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 23 Jan 2018 21:59:30 +0100 Subject: [PATCH] Add test for DI constructability of EditProfileFieldAjaxPage --- .../net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt | 4 +++- .../pterodactylus/sone/web/ajax/EditProfileFieldAjaxPageTest.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt index e48c92d..7e7581d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt @@ -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 -> diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPageTest.kt index 7eed9ac..6e00c29 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPageTest.kt @@ -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(), notNullValue()) + } + } -- 2.7.4