From 7afd66a21244e757b6b49ba96bb3989bc55a2abf Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 25 Jan 2018 19:03:35 +0100 Subject: [PATCH] Add test for DI constructability of GetPostAjaxPage --- .../kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt | 4 +++- .../kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPageTest.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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()) + } + } -- 2.7.4