From 548e98afbe5696f0a05a6ac4aff8029cba1f7875 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:06:04 +0100 Subject: [PATCH] Add test for DI constructability of GetReplyAjaxPage --- .../kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt | 4 +++- .../net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt index c6cfc2f..119a622 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.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 page returns the details of a reply. */ -class GetReplyAjaxPage(webInterface: WebInterface, private val template: Template) : LoggedInJsonPage("getReply.ajax", webInterface) { +class GetReplyAjaxPage @Inject constructor(webInterface: WebInterface, private val template: Template) : + LoggedInJsonPage("getReply.ajax", webInterface) { override val needsFormPassword = false diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt index 6af8776..6010e9f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPageTest.kt @@ -2,12 +2,15 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.data.PostReply 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.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 /** @@ -49,4 +52,9 @@ class GetReplyAjaxPageTest : JsonPageTest("getReply.ajax", needsFormPassword = f ).joinToString("\n"))) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + } -- 2.7.4