From: David ‘Bombe’ Roden Date: Thu, 25 Jan 2018 18:29:53 +0000 (+0100) Subject: Add test for DI constructability of UntrustAjaxPage X-Git-Tag: v79^2~155 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=06a56ce130d602cb7ff019d599226c115dbe41c8;p=Sone.git Add test for DI constructability of UntrustAjaxPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt index 8418cd3..95dca17 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt @@ -4,11 +4,13 @@ import net.pterodactylus.sone.data.Sone 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 [untrust][net.pterodactylus.sone.core.Core.untrustSone] a [Sone]. */ -class UntrustAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("untrustSone.ajax", webInterface) { +class UntrustAjaxPage @Inject constructor(webInterface: WebInterface) : + LoggedInJsonPage("untrustSone.ajax", webInterface) { override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = request.parameters["sone"] diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPageTest.kt index f2de48d..6421c09 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPageTest.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.hamcrest.Matchers.nullValue import org.junit.Test import org.mockito.Mockito.verify @@ -42,4 +45,9 @@ class UntrustAjaxPageTest : JsonPageTest("untrustSone.ajax", pageSupplier = ::Un assertThat(json["trustValue"], nullValue()) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }