From: David ‘Bombe’ Roden Date: Thu, 25 Jan 2018 18:27:45 +0000 (+0100) Subject: Add test for DI constructability of UnlikeAjaxPage X-Git-Tag: v79^2~157 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=24e7a91644d986f89494e94580095cfc103b23dc;p=Sone.git Add test for DI constructability of UnlikeAjaxPage --- diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt index b30829a..e2277c9 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt @@ -5,11 +5,13 @@ 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 unlike a [net.pterodactylus.sone.data.Post]. */ -class UnlikeAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("unlike.ajax", webInterface) { +class UnlikeAjaxPage @Inject constructor(webInterface: WebInterface) : + LoggedInJsonPage("unlike.ajax", webInterface) { override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = when (request.parameters["type"]) { "post" -> request.processEntity("post", currentSone::removeLikedPostId) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt index 4661892..488aacd 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.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 import org.mockito.Mockito.verify @@ -52,4 +55,9 @@ class UnlikeAjaxPageTest : JsonPageTest("unlike.ajax", pageSupplier = ::UnlikeAj verify(core).touchConfiguration() } + @Test + fun `page can be created by dependency injection`() { + assertThat(baseInjector.getInstance(), notNullValue()) + } + }