Replace AbstractSoneCommand with Kotlin version
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / fcp / GetPostCommandTest.kt
index e830daf..f8113af 100644 (file)
@@ -3,9 +3,9 @@ package net.pterodactylus.sone.fcp
 import freenet.support.SimpleFieldSet
 import net.pterodactylus.sone.core.Core
 import net.pterodactylus.sone.data.Sone
-import net.pterodactylus.sone.test.asOptional
 import net.pterodactylus.sone.test.mock
 import net.pterodactylus.sone.test.whenever
+import net.pterodactylus.sone.utils.asOptional
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.containsInAnyOrder
 import org.hamcrest.Matchers.equalTo
@@ -31,7 +31,7 @@ class GetPostCommandTest : SoneCommandTest() {
 
        @Before
        fun setupPostWithLikesAndReplies() {
-               whenever(core.getPost("ValidPostId")).thenReturn(post.asOptional())
+               whenever(core.getPost("ValidPostId")).thenReturn(post)
                whenever(core.getLikes(post)).thenReturn(setOf(sone1, sone2))
                val replies = listOf(postReply1, postReply2)
                whenever(core.getReplies("ValidPostId")).thenReturn(replies)
@@ -39,7 +39,7 @@ class GetPostCommandTest : SoneCommandTest() {
 
        @Test
        fun `command does not require write access`() {
-               assertThat(command.requiresWriteAccess(), equalTo(false))
+               assertThat(command.requiresWriteAccess, equalTo(false))
        }
 
        @Test
@@ -49,7 +49,7 @@ class GetPostCommandTest : SoneCommandTest() {
 
        @Test
        fun `request with invalid post parameter results in fcp exception`() {
-               parameters.putSingle("Post", "InvalidPostId")
+               parameters += "Post" to "InvalidPostId"
                executeCommandAndExpectFcpException()
        }
 
@@ -68,7 +68,7 @@ class GetPostCommandTest : SoneCommandTest() {
 
        @Test
        fun `request with valid post parameter returns post response`() {
-               parameters.putSingle("Post", "ValidPostId")
+               parameters += "Post" to "ValidPostId"
                val replyParameters = command.execute(parameters).replyParameters
                verifyPostWithLikes(replyParameters)
                assertThat(replyParameters["Post.Recipient"], nullValue())
@@ -77,8 +77,8 @@ class GetPostCommandTest : SoneCommandTest() {
 
        @Test
        fun `request with valid post parameter without replies returns post response without replies`() {
-               parameters.putSingle("Post", "ValidPostId")
-               parameters.putSingle("IncludeReplies", "false")
+               parameters += "Post" to "ValidPostId"
+               parameters += "IncludeReplies" to "false"
                val replyParameters = command.execute(parameters).replyParameters
                verifyPostWithLikes(replyParameters)
                assertThat(replyParameters["Post.Recipient"], nullValue())
@@ -87,7 +87,7 @@ class GetPostCommandTest : SoneCommandTest() {
 
        @Test
        fun `request with valid post parameter returns post response with recipient`() {
-               parameters.putSingle("Post", "ValidPostId")
+               parameters += "Post" to "ValidPostId"
                whenever(post.recipientId).thenReturn("Sone2".asOptional())
                val replyParameters = command.execute(parameters).replyParameters
                verifyPostWithLikes(replyParameters)
@@ -97,8 +97,8 @@ class GetPostCommandTest : SoneCommandTest() {
 
        @Test
        fun `request with valid post parameter without replies returns post response without replies but with recipient`() {
-               parameters.putSingle("Post", "ValidPostId")
-               parameters.putSingle("IncludeReplies", "false")
+               parameters += "Post" to "ValidPostId"
+               parameters += "IncludeReplies" to "false"
                whenever(post.recipientId).thenReturn("Sone2".asOptional())
                val replyParameters = command.execute(parameters).replyParameters
                verifyPostWithLikes(replyParameters)