From d8d97caee86713d927c253486349e6cfab08fb82 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:54:41 +0100 Subject: [PATCH] Add test for DI constructability of EditImageAjaxPage --- .../net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt | 3 ++- .../pterodactylus/sone/web/ajax/EditImageAjaxPageTest.kt | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt index dbeb2d2..b0ce048 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt @@ -10,11 +10,12 @@ import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.TemplateContext +import javax.inject.Inject /** * Page that stores a user’s image modifications. */ -class EditImageAjaxPage(webInterface: WebInterface, +class EditImageAjaxPage @Inject constructor(webInterface: WebInterface, private val parserFilter: ParserFilter, private val shortenFilter: ShortenFilter, private val renderFilter: RenderFilter) : JsonPage("editImage.ajax", webInterface) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPageTest.kt index dad6c02..26436a3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPageTest.kt @@ -8,10 +8,14 @@ import net.pterodactylus.sone.template.ParserFilter import net.pterodactylus.sone.template.RenderFilter import net.pterodactylus.sone.template.ShortenFilter import net.pterodactylus.sone.test.argumentCaptor +import net.pterodactylus.sone.test.getInstance +import net.pterodactylus.sone.test.isProvidedByMock import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever +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.ArgumentMatchers.any import org.mockito.ArgumentMatchers.eq @@ -113,4 +117,13 @@ class EditImageAjaxPageTest : JsonPageTest("editImage.ajax") { assertThat(parameterCaptor.value["sone"], equalTo(sone)) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.createChildInjector( + ParserFilter::class.isProvidedByMock(), + ShortenFilter::class.isProvidedByMock(), + RenderFilter::class.isProvidedByMock() + ).getInstance(), notNullValue()) + } + } -- 2.7.4