From 355e5656b51974303534146a3e401f3b73e4cea8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 2 Oct 2017 15:54:04 +0200 Subject: [PATCH] Refactoring: make id for local Sone optional --- .../kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt | 2 +- src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt | 4 ++-- .../kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPageTest.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt index 6b110ae..b192f84 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPageTest.kt @@ -49,7 +49,7 @@ class CreateReplyAjaxPageTest : JsonPageTest("createReply.ajax", pageSupplier = @Test fun `sender can be chosen from local sones`() { val sone = mock().apply { whenever(id).thenReturn("local-sone") } - addLocalSone("local-sone", sone) + addLocalSone(sone) val post = mock() addPost(post, "post-id") val reply = mock().apply { whenever(id).thenReturn("reply-id") } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt index c950a31..73dba5a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt @@ -195,8 +195,8 @@ abstract class JsonPageTest( remoteSones += (soneId ?: sone.id) to sone } - protected fun addLocalSone(id: String, sone: Sone) { - localSones += id to sone + protected fun addLocalSone(sone: Sone, id: String? = null) { + localSones[id ?: sone.id] = sone } protected fun addPost(post: Post, id: String? = null) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPageTest.kt index b63be51..61a0c40 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPageTest.kt @@ -21,7 +21,7 @@ class LockSoneAjaxPageTest : JsonPageTest("lockSone.ajax", requiresLogin = false @Test fun `request with valid sone id results in locked sone`() { val sone = mock() - addLocalSone("sone-id", sone) + addLocalSone(sone, "sone-id") addRequestParameter("sone", "sone-id") assertThat(json.isSuccess, equalTo(true)) verify(core).lockSone(sone) -- 2.7.4