From 24e7a91644d986f89494e94580095cfc103b23dc 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:27:45 +0100 Subject: [PATCH] Add test for DI constructability of UnlikeAjaxPage --- src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt | 4 +++- .../kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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()) + } + } -- 2.7.4