From 210f03a3afc928e3bdba697957daa35bd8ffe4e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 22 Jan 2018 07:13:51 +0100 Subject: [PATCH] Add test for DI constructability of DistrustAjaxPage --- .../kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt | 4 +++- .../net/pterodactylus/sone/web/ajax/DistrustAjaxPageTest.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt index 4eadfde..10384df 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt @@ -6,13 +6,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 distrust a Sone. * * @see Core.distrustSone(Sone, Sone) */ -class DistrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("distrustSone.ajax", webInterface) { +class DistrustAjaxPage @Inject constructor(webInterface: WebInterface) : + LoggedInJsonPage("distrustSone.ajax", webInterface) { override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPageTest.kt index 78930e5..1cfa63e 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPageTest.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 @@ -42,4 +45,9 @@ class DistrustAjaxPageTest : JsonPageTest("distrustSone.ajax", pageSupplier = :: assertThat(json["trustValue"]?.asInt(), equalTo(-33)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + } -- 2.7.4