From: David ‘Bombe’ Roden Date: Thu, 25 Jan 2018 18:24:47 +0000 (+0100) Subject: Add test for DI constructability of TrustAjaxPage X-Git-Tag: v79^2~160 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ea7ad5e87074576d17b7df74365a726bd95d7665;p=Sone.git Add test for DI constructability of TrustAjaxPage --- 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()) + } + }