Add test for DI constructability of UnlikeAjaxPage
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Jan 2018 18:27:45 +0000 (19:27 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Jan 2018 18:30:53 +0000 (19:30 +0100)
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt
src/test/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPageTest.kt

index b30829a..e2277c9 100644 (file)
@@ -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)
index 4661892..488aacd 100644 (file)
@@ -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<UnlikeAjaxPage>(), notNullValue())
+       }
+
 }