From: David ‘Bombe’ Roden Date: Thu, 25 Jan 2018 18:03:35 +0000 (+0100) Subject: Add test for DI constructability of GetPostAjaxPage X-Git-Tag: v79^2~169 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=7afd66a21244e757b6b49ba96bb3989bc55a2abf;p=Sone.git Add test for DI constructability of GetPostAjaxPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt index d3ae4e9..7f1ce6e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt @@ -8,11 +8,13 @@ import net.pterodactylus.sone.utils.render import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import net.pterodactylus.util.template.Template +import javax.inject.Inject /** * This AJAX handler retrieves information and rendered representation of a [Post]. */ -class GetPostAjaxPage(webInterface: WebInterface, private val postTemplate: Template) : LoggedInJsonPage("getPost.ajax", webInterface) { +class GetPostAjaxPage @Inject constructor(webInterface: WebInterface, private val postTemplate: Template) : + LoggedInJsonPage("getPost.ajax", webInterface) { override val needsFormPassword = false diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPageTest.kt index 8d33542..130bdc2 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPageTest.kt @@ -2,13 +2,16 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.Sone +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import net.pterodactylus.sone.utils.asOptional import net.pterodactylus.sone.utils.asTemplate +import net.pterodactylus.sone.web.baseInjector import net.pterodactylus.util.template.ReflectionAccessor import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.notNullValue import org.junit.Test /** @@ -51,4 +54,9 @@ class GetPostAjaxPageTest : JsonPageTest("getPost.ajax", needsFormPassword = fal ).joinToString("\n"))) } + @Test + fun `page can be created dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }