From: David ‘Bombe’ Roden Date: Mon, 2 Oct 2017 13:54:04 +0000 (+0200) Subject: Refactoring: make id for local Sone optional X-Git-Tag: 0.9.7^2~35 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=355e5656b51974303534146a3e401f3b73e4cea8;p=Sone.git Refactoring: make id for local Sone optional --- 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)