Add test for DI constructability of GetPostAjaxPage
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / ajax / GetPostAjaxPage.kt
index 2b1deca..7f1ce6e 100644 (file)
@@ -3,24 +3,25 @@ package net.pterodactylus.sone.web.ajax
 import net.pterodactylus.sone.data.Post
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.jsonObject
-import net.pterodactylus.sone.utils.let
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.utils.render
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.web.page.FreenetRequest
 import net.pterodactylus.util.template.Template
+import javax.inject.Inject
 
 /**
  * This AJAX handler retrieves information and rendered representation of a [Post].
  */
-class GetPostAjaxPage(webInterface: WebInterface, private val postTemplate: Template) : LoggedInJsonPage("getPost.ajax", webInterface) {
+class GetPostAjaxPage @Inject constructor(webInterface: WebInterface, private val postTemplate: Template) :
+               LoggedInJsonPage("getPost.ajax", webInterface) {
 
-       override fun needsFormPassword() = false
+       override val needsFormPassword = false
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["post"]
-                                       .let(core::getPost)
-                                       .let { post ->
+                                       ?.let(core::getPost)
+                                       ?.let { post ->
                                                createSuccessJsonObject().
                                                                put("post", jsonObject(
                                                                                "id" to post.id,