Clean up some imports
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / web / pages / CreateReplyPageTest.kt
index 052620a..b7df1d1 100644 (file)
@@ -3,8 +3,6 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Post
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.test.mock
-import net.pterodactylus.sone.web.pages.WebPageTest
-import net.pterodactylus.sone.web.pages.CreateReplyPage
 import net.pterodactylus.util.web.Method.POST
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.equalTo
@@ -31,10 +29,10 @@ class CreateReplyPageTest: WebPageTest() {
 
        @Test
        fun `reply is created correctly`() {
-               request("", POST)
-               addHttpRequestParameter("returnPage", "return.html")
-               addHttpRequestParameter("post", "post-id")
-               addHttpRequestParameter("text", "new text")
+               setMethod(POST)
+               addHttpRequestPart("returnPage", "return.html")
+               addHttpRequestPart("post", "post-id")
+               addHttpRequestPart("text", "new text")
                val post = mock<Post>().apply { addPost("post-id", this) }
                verifyRedirect("return.html") {
                        verify(core).createReply(currentSone, post, "new text")
@@ -43,10 +41,10 @@ class CreateReplyPageTest: WebPageTest() {
 
        @Test
        fun `reply is filtered`() {
-               request("", POST)
-               addHttpRequestParameter("returnPage", "return.html")
-               addHttpRequestParameter("post", "post-id")
-               addHttpRequestParameter("text", "new http://localhost:12345/KSK@foo text")
+               setMethod(POST)
+               addHttpRequestPart("returnPage", "return.html")
+               addHttpRequestPart("post", "post-id")
+               addHttpRequestPart("text", "new http://localhost:12345/KSK@foo text")
                addHttpRequestHeader("Host", "localhost:12345")
                val post = mock<Post>().apply { addPost("post-id", this) }
                verifyRedirect("return.html") {
@@ -56,11 +54,11 @@ class CreateReplyPageTest: WebPageTest() {
 
        @Test
        fun `reply is created with correct sender`() {
-               request("", POST)
-               addHttpRequestParameter("returnPage", "return.html")
-               addHttpRequestParameter("post", "post-id")
-               addHttpRequestParameter("text", "new text")
-               addHttpRequestParameter("sender", "sender-id")
+               setMethod(POST)
+               addHttpRequestPart("returnPage", "return.html")
+               addHttpRequestPart("post", "post-id")
+               addHttpRequestPart("text", "new text")
+               addHttpRequestPart("sender", "sender-id")
                val sender = mock<Sone>().apply { addLocalSone("sender-id", this) }
                val post = mock<Post>().apply { addPost("post-id", this) }
                verifyRedirect("return.html") {
@@ -70,10 +68,10 @@ class CreateReplyPageTest: WebPageTest() {
 
        @Test
        fun `empty text sets parameters in template contexty`() {
-               request("", POST)
-               addHttpRequestParameter("returnPage", "return.html")
-               addHttpRequestParameter("post", "post-id")
-               addHttpRequestParameter("text", "  ")
+               setMethod(POST)
+               addHttpRequestPart("returnPage", "return.html")
+               addHttpRequestPart("post", "post-id")
+               addHttpRequestPart("text", "  ")
                page.processTemplate(freenetRequest, templateContext)
                assertThat(templateContext["errorTextEmpty"], equalTo<Any>(true))
                assertThat(templateContext["returnPage"], equalTo<Any>("return.html"))
@@ -83,22 +81,11 @@ class CreateReplyPageTest: WebPageTest() {
 
        @Test
        fun `user is redirected to no permissions page if post does not exist`() {
-               request("", POST)
-               addHttpRequestParameter("returnPage", "return.html")
-               addHttpRequestParameter("post", "post-id")
-               addHttpRequestParameter("text", "new text")
+               setMethod(POST)
+               addHttpRequestPart("returnPage", "return.html")
+               addHttpRequestPart("post", "post-id")
+               addHttpRequestPart("text", "new text")
                verifyRedirect("noPermission.html")
        }
 
-       @Test
-       fun `get request stores parameters in template context`() {
-               addHttpRequestParameter("returnPage", "return.html")
-               addHttpRequestParameter("post", "post-id")
-               addHttpRequestParameter("text", "new text")
-               page.processTemplate(freenetRequest, templateContext)
-               assertThat(templateContext["returnPage"], equalTo<Any>("return.html"))
-               assertThat(templateContext["postId"], equalTo<Any>("post-id"))
-               assertThat(templateContext["text"], equalTo<Any>("new text"))
-       }
-
 }