X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FCreateReplyCommandTest.kt;h=1cd53a512487dabc8a54e3f1132540ceda75ff84;hp=6d39083e0ab433a73e1cb8d25b7d5d25bfd2e73c;hb=5ab6ee01df9bac0c7bd5d27a6990dfdf60555d0f;hpb=92adeef899fe2798c0952a6585463448cbf56c94 diff --git a/src/test/kotlin/net/pterodactylus/sone/fcp/CreateReplyCommandTest.kt b/src/test/kotlin/net/pterodactylus/sone/fcp/CreateReplyCommandTest.kt index 6d39083..1cd53a5 100644 --- a/src/test/kotlin/net/pterodactylus/sone/fcp/CreateReplyCommandTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/fcp/CreateReplyCommandTest.kt @@ -4,7 +4,6 @@ import com.google.common.base.Optional.of import net.pterodactylus.sone.core.Core import net.pterodactylus.sone.data.Post import net.pterodactylus.sone.data.PostReply -import net.pterodactylus.sone.freenet.fcp.FcpException import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import org.hamcrest.MatcherAssert.assertThat @@ -22,7 +21,7 @@ class CreateReplyCommandTest : SoneCommandTest() { @Test fun `command requires write access`() { - assertThat(command.requiresWriteAccess(), equalTo(true)) + assertThat(command.requiresWriteAccess, equalTo(true)) } @Test @@ -46,46 +45,43 @@ class CreateReplyCommandTest : SoneCommandTest() { } private fun addValidLocalSoneParameter() { - parameters.putSingle("Sone", "LocalSoneId") - whenever(core.getSone("LocalSoneId")).thenReturn(of(localSone)) + parameters += "Sone" to "LocalSoneId" + whenever(core.getSone("LocalSoneId")).thenReturn(localSone) } @Test fun `request without post parameter results in fcp exception`() { addValidLocalSoneParameter() - expectedException.expect(FcpException::class.java) - command.execute(parameters, null, null) + executeCommandAndExpectFcpException() } @Test fun `request with invalid post parameter results in fcp exception`() { addValidLocalSoneParameter() - parameters.putSingle("Post", "InvalidPostId") - expectedException.expect(FcpException::class.java) - command.execute(parameters, null, null) + parameters += "Post" to "InvalidPostId" + executeCommandAndExpectFcpException() } private fun addValidPostParameter() { - parameters.putSingle("Post", "ValidPostId") - whenever(core.getPost("ValidPostId")).thenReturn(of(post)) + parameters += "Post" to "ValidPostId" + whenever(core.getPost("ValidPostId")).thenReturn(post) } @Test fun `request without text results in fcp exception`() { addValidLocalSoneParameter() addValidPostParameter() - expectedException.expect(FcpException::class.java) - command.execute(parameters, null, null) + executeCommandAndExpectFcpException() } @Test fun `complete request creates reply`() { addValidLocalSoneParameter() addValidPostParameter() - parameters.putSingle("Text", "Test") + parameters += "Text" to "Test" val postReply = mock().apply { whenever(id).thenReturn("ReplyId") } whenever(core.createReply(localSone, post, "Test")).thenReturn(postReply) - val response = command.execute(parameters, null, null) + val response = command.execute(parameters) assertThat(response.replyParameters["Message"], equalTo("ReplyCreated")) assertThat(response.replyParameters["Reply"], equalTo("ReplyId")) }