From: David ‘Bombe’ Roden Date: Tue, 23 Jan 2018 20:54:41 +0000 (+0100) Subject: Add test for DI constructability of EditImageAjaxPage X-Git-Tag: v79^2~177 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d8d97caee86713d927c253486349e6cfab08fb82;p=Sone.git Add test for DI constructability of EditImageAjaxPage --- 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()) + } + }