From: David ‘Bombe’ Roden Date: Sun, 21 Jan 2018 10:54:55 +0000 (+0100) Subject: Add test for DI constructability of BookmarkAjaxPage X-Git-Tag: v79^2~187 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=43feab5f45f23d734b641fe433d528a9e0133eaa;p=Sone.git Add test for DI constructability of BookmarkAjaxPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt index 35ac0e2..74fec61 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt @@ -4,11 +4,12 @@ import net.pterodactylus.sone.utils.emptyToNull import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest +import javax.inject.Inject /** * AJAX page that lets the user bookmark a post. */ -class BookmarkAjaxPage(webInterface: WebInterface) : JsonPage("bookmark.ajax", webInterface) { +class BookmarkAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage("bookmark.ajax", webInterface) { override val requiresLogin = false diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPageTest.kt index 17c334e..00de556 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPageTest.kt @@ -1,8 +1,11 @@ package net.pterodactylus.sone.web.ajax import net.pterodactylus.sone.data.Post +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 import org.mockito.ArgumentMatchers.any import org.mockito.Mockito.never @@ -39,4 +42,9 @@ class BookmarkAjaxPageTest : JsonPageTest("bookmark.ajax", requiresLogin = false verify(core).bookmarkPost(post) } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }