X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FCreatePostCommandTest.kt;h=29db41c480a00e3d41a8ba4c5759b395b0a32e9f;hp=6d2cc81975a5fe82c63df4c89458f5e30389006e;hb=5ab6ee01df9bac0c7bd5d27a6990dfdf60555d0f;hpb=914d5522692e7714ba5bdefb002fedc8e293f5fc diff --git a/src/test/kotlin/net/pterodactylus/sone/fcp/CreatePostCommandTest.kt b/src/test/kotlin/net/pterodactylus/sone/fcp/CreatePostCommandTest.kt index 6d2cc81..29db41c 100644 --- a/src/test/kotlin/net/pterodactylus/sone/fcp/CreatePostCommandTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/fcp/CreatePostCommandTest.kt @@ -1,6 +1,5 @@ package net.pterodactylus.sone.fcp -import com.google.common.base.Optional import com.google.common.base.Optional.absent import com.google.common.base.Optional.of import net.pterodactylus.sone.core.Core @@ -21,7 +20,7 @@ class CreatePostCommandTest : SoneCommandTest() { @Test fun `command requires write access`() { - assertThat(command.requiresWriteAccess(), equalTo(true)) + assertThat(command.requiresWriteAccess, equalTo(true)) } @Test @@ -46,16 +45,16 @@ class CreatePostCommandTest : SoneCommandTest() { @Test fun `request without text results in fcp exception`() { - parameters.putSingle("Sone", "LocalSoneId") - whenever(core.getSone("LocalSoneId")).thenReturn(Optional.of(localSone)) + parameters += "Sone" to "LocalSoneId" + whenever(core.getSone("LocalSoneId")).thenReturn(localSone) executeCommandAndExpectFcpException() } @Test fun `request with text creates post`() { - parameters.putSingle("Sone", "LocalSoneId") - parameters.putSingle("Text", "Test") - whenever(core.getSone("LocalSoneId")).thenReturn(of(localSone)) + parameters += "Sone" to "LocalSoneId" + parameters += "Text" to "Test" + whenever(core.getSone("LocalSoneId")).thenReturn(localSone) val post = mock().apply { whenever(id).thenReturn("PostId") } whenever(core.createPost(localSone, absent(), "Test")).thenReturn(post) val response = command.execute(parameters) @@ -65,19 +64,19 @@ class CreatePostCommandTest : SoneCommandTest() { @Test fun `request with invalid recipient results in fcp exception`() { - parameters.putSingle("Sone", "LocalSoneId") - parameters.putSingle("Text", "Test") - parameters.putSingle("Recipient", "InvalidSoneId") - whenever(core.getSone("LocalSoneId")).thenReturn(of(localSone)) + parameters += "Sone" to "LocalSoneId" + parameters += "Text" to "Test" + parameters += "Recipient" to "InvalidSoneId" + whenever(core.getSone("LocalSoneId")).thenReturn(localSone) executeCommandAndExpectFcpException() } @Test fun `request with recipient the same as the sender returns an error response`() { - parameters.putSingle("Sone", "LocalSoneId") - parameters.putSingle("Text", "Test") - parameters.putSingle("Recipient", "LocalSoneId") - whenever(core.getSone("LocalSoneId")).thenReturn(of(localSone)) + parameters += "Sone" to "LocalSoneId" + parameters += "Text" to "Test" + parameters += "Recipient" to "LocalSoneId" + whenever(core.getSone("LocalSoneId")).thenReturn(localSone) val response = command.execute(parameters) assertThat(response.replyParameters["Message"], equalTo("Error")) assertThat(response.replyParameters["ErrorMessage"], notNullValue()) @@ -85,11 +84,11 @@ class CreatePostCommandTest : SoneCommandTest() { @Test fun `request with text and recipient creates post`() { - parameters.putSingle("Sone", "LocalSoneId") - parameters.putSingle("Text", "Test") - parameters.putSingle("Recipient", "RemoteSoneId") - whenever(core.getSone("LocalSoneId")).thenReturn(of(localSone)) - whenever(core.getSone("RemoteSoneId")).thenReturn(of(remoteSone)) + parameters += "Sone" to "LocalSoneId" + parameters += "Text" to "Test" + parameters += "Recipient" to "RemoteSoneId" + whenever(core.getSone("LocalSoneId")).thenReturn(localSone) + whenever(core.getSone("RemoteSoneId")).thenReturn(remoteSone) val post = mock().apply { whenever(id).thenReturn("PostId") } whenever(core.createPost(localSone, of(remoteSone), "Test")).thenReturn(post) val response = command.execute(parameters)