From: David ‘Bombe’ Roden Date: Thu, 25 Jan 2018 18:17:01 +0000 (+0100) Subject: Add test for DI constructability of GetTranslationAjaxPage X-Git-Tag: v79^2~165 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=ae78f11f111ddc964a36cc25ab6da413685d69a6 Add test for DI constructability of GetTranslationAjaxPage --- 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()) + } + }