X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FCreatePostCommandTest.kt;h=6d2cc81975a5fe82c63df4c89458f5e30389006e;hb=914d5522692e7714ba5bdefb002fedc8e293f5fc;hp=75e238e9e1d1d155a56e8153bad8cce07cae1fb7;hpb=00c0f66598af0a462cb367fbf1ad67512878cf5e;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/fcp/CreatePostCommandTest.kt b/src/test/kotlin/net/pterodactylus/sone/fcp/CreatePostCommandTest.kt index 75e238e..6d2cc81 100644 --- a/src/test/kotlin/net/pterodactylus/sone/fcp/CreatePostCommandTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/fcp/CreatePostCommandTest.kt @@ -5,7 +5,6 @@ import com.google.common.base.Optional.absent import com.google.common.base.Optional.of import net.pterodactylus.sone.core.Core import net.pterodactylus.sone.data.Post -import net.pterodactylus.sone.freenet.fcp.FcpException import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import org.hamcrest.MatcherAssert.assertThat @@ -49,8 +48,7 @@ class CreatePostCommandTest : SoneCommandTest() { fun `request without text results in fcp exception`() { parameters.putSingle("Sone", "LocalSoneId") whenever(core.getSone("LocalSoneId")).thenReturn(Optional.of(localSone)) - expectedException.expect(FcpException::class.java) - command.execute(parameters, null, null) + executeCommandAndExpectFcpException() } @Test @@ -60,7 +58,7 @@ class CreatePostCommandTest : SoneCommandTest() { whenever(core.getSone("LocalSoneId")).thenReturn(of(localSone)) val post = mock().apply { whenever(id).thenReturn("PostId") } whenever(core.createPost(localSone, absent(), "Test")).thenReturn(post) - val response = command.execute(parameters, null, null) + val response = command.execute(parameters) assertThat(response.replyParameters.get("Message"), equalTo("PostCreated")) assertThat(response.replyParameters.get("Post"), equalTo("PostId")) } @@ -71,8 +69,7 @@ class CreatePostCommandTest : SoneCommandTest() { parameters.putSingle("Text", "Test") parameters.putSingle("Recipient", "InvalidSoneId") whenever(core.getSone("LocalSoneId")).thenReturn(of(localSone)) - expectedException.expect(FcpException::class.java) - command.execute(parameters, null, null) + executeCommandAndExpectFcpException() } @Test @@ -81,7 +78,7 @@ class CreatePostCommandTest : SoneCommandTest() { parameters.putSingle("Text", "Test") parameters.putSingle("Recipient", "LocalSoneId") whenever(core.getSone("LocalSoneId")).thenReturn(of(localSone)) - val response = command.execute(parameters, null, null) + val response = command.execute(parameters) assertThat(response.replyParameters["Message"], equalTo("Error")) assertThat(response.replyParameters["ErrorMessage"], notNullValue()) } @@ -95,7 +92,7 @@ class CreatePostCommandTest : SoneCommandTest() { whenever(core.getSone("RemoteSoneId")).thenReturn(of(remoteSone)) val post = mock().apply { whenever(id).thenReturn("PostId") } whenever(core.createPost(localSone, of(remoteSone), "Test")).thenReturn(post) - val response = command.execute(parameters, null, null) + val response = command.execute(parameters) assertThat(response.replyParameters.get("Message"), equalTo("PostCreated")) assertThat(response.replyParameters.get("Post"), equalTo("PostId")) }