From: David ‘Bombe’ Roden Date: Tue, 23 Jan 2018 20:49:28 +0000 (+0100) Subject: Add test for DI constructability of EditAlbumAjaxPage X-Git-Tag: v79^2~178 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9db5ef551b000dc6e9b6f6683a2cce3b8e2f5223;p=Sone.git Add test for DI constructability of EditAlbumAjaxPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt index 321ee7d..9cb3acf 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt @@ -6,11 +6,12 @@ import net.pterodactylus.sone.utils.ifTrue import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest +import javax.inject.Inject /** * Page that stores a user’s album modifications. */ -class EditAlbumAjaxPage(webInterface: WebInterface) : JsonPage("editAlbum.ajax", webInterface) { +class EditAlbumAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage("editAlbum.ajax", webInterface) { override fun createJsonObject(request: FreenetRequest) = request.parameters["album"]!! diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPageTest.kt index 098185b..1528d60 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPageTest.kt @@ -5,10 +5,13 @@ import net.pterodactylus.sone.data.Album.Modifier.AlbumTitleMustNotBeEmpty import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.data.impl.AlbumImpl import net.pterodactylus.sone.test.deepMock +import net.pterodactylus.sone.test.getInstance import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever +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 /** @@ -87,4 +90,9 @@ class EditAlbumAjaxPageTest : JsonPageTest("editAlbum.ajax", pageSupplier = ::Ed assertThat(json["description"]?.asText(), equalTo("foo KSK@foo.html link")) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }