From ea7ad5e87074576d17b7df74365a726bd95d7665 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 25 Jan 2018 19:24:47 +0100 Subject: [PATCH] Add test for DI constructability of TrustAjaxPage --- src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt | 4 +++- .../kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPageTest.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt index 1dfb058..ef806eb 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt @@ -5,13 +5,15 @@ import net.pterodactylus.sone.utils.let 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 trust a Sone. * * @see net.pterodactylus.sone.core.Core.trustSone */ -class TrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("trustSone.ajax", webInterface) { +class TrustAjaxPage @Inject constructor(webInterface: WebInterface) : + LoggedInJsonPage("trustSone.ajax", webInterface) { override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPageTest.kt index 64a66a3..b4fd212 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPageTest.kt @@ -1,9 +1,12 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock +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 @@ -36,4 +39,9 @@ class TrustAjaxPageTest : JsonPageTest("trustSone.ajax", requiresLogin = true, n assertThat(json["trustValue"]?.asInt(), equalTo(31)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + } -- 2.7.4