From ae78f11f111ddc964a36cc25ab6da413685d69a6 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:17:01 +0100 Subject: [PATCH] Add test for DI constructability of GetTranslationAjaxPage --- .../net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt | 4 +++- .../net/pterodactylus/sone/web/ajax/GetTranslationAjaxPageTest.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt index d260655..99429e4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt @@ -3,11 +3,13 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest +import javax.inject.Inject /** * Returns the translation for a given key as JSON object. */ -class GetTranslationAjaxPage(webInterface: WebInterface) : JsonPage("getTranslation.ajax", webInterface) { +class GetTranslationAjaxPage @Inject constructor(webInterface: WebInterface) : + JsonPage("getTranslation.ajax", webInterface) { override val needsFormPassword = false override val requiresLogin = false diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPageTest.kt index 0d58ca2..ebf4edd 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPageTest.kt @@ -1,7 +1,10 @@ package net.pterodactylus.sone.web.ajax +import net.pterodactylus.sone.test.getInstance +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 /** @@ -17,4 +20,9 @@ class GetTranslationAjaxPageTest : JsonPageTest("getTranslation.ajax", requiresL assertThat(json["value"]?.asText(), equalTo("bar")) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + } -- 2.7.4