From: David ‘Bombe’ Roden Date: Thu, 9 Jan 2020 21:12:31 +0000 (+0100) Subject: 🚚 Move post and reply mocks to correct file X-Git-Tag: v81^2~5^2~12 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6116ab8aa248eab6a4d800f991e749debc496df9;p=Sone.git 🚚 Move post and reply mocks to correct file --- diff --git a/src/test/kotlin/net/pterodactylus/sone/test/Mocks.kt b/src/test/kotlin/net/pterodactylus/sone/test/Mocks.kt index f469dd7..0bb8bc9 100644 --- a/src/test/kotlin/net/pterodactylus/sone/test/Mocks.kt +++ b/src/test/kotlin/net/pterodactylus/sone/test/Mocks.kt @@ -17,14 +17,42 @@ package net.pterodactylus.sone.test +import com.google.common.base.* import freenet.crypt.* import freenet.keys.* +import net.pterodactylus.sone.data.* import net.pterodactylus.sone.data.impl.* +import net.pterodactylus.sone.text.* import net.pterodactylus.sone.utils.* +val remoteSone1 = createRemoteSone() +val remoteSone2 = createRemoteSone() + +val localSone1 = createLocalSone() +val localSone2 = createLocalSone() + fun createId() = InsertableClientSSK.createRandom(DummyRandomSource(), "").uri.routingKey.asFreenetBase64 fun createLocalSone(id: String? = createId()) = object : IdOnlySone(id) { override fun isLocal() = true } fun createRemoteSone(id: String? = createId()) = IdOnlySone(id) + +fun createPost(text: String = "", sone: Sone = remoteSone1, known: Boolean = false): Post.EmptyPost { + return object : Post.EmptyPost("post-id") { + override fun getSone() = sone + override fun getText() = text + override fun isKnown() = known + } +} + +fun emptyPostReply(text: String = "", post: Post = createPost(), sone: Sone = remoteSone1, known: Boolean = false) = object : PostReply { + override val id = "reply-id" + override fun getSone() = sone + override fun getPostId() = post.id + override fun getPost(): Optional = Optional.of(post) + override fun getTime() = 1L + override fun getText() = text + override fun isKnown() = known + override fun setKnown(known: Boolean): PostReply = this +} diff --git a/src/test/kotlin/net/pterodactylus/sone/text/SoneMentionDetectorTest.kt b/src/test/kotlin/net/pterodactylus/sone/text/SoneMentionDetectorTest.kt index 24d2335..6ae437b 100644 --- a/src/test/kotlin/net/pterodactylus/sone/text/SoneMentionDetectorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/text/SoneMentionDetectorTest.kt @@ -17,8 +17,6 @@ package net.pterodactylus.sone.text -import com.google.common.base.* -import com.google.common.base.Optional.* import com.google.common.eventbus.* import net.pterodactylus.sone.core.event.* import net.pterodactylus.sone.data.* @@ -226,20 +224,6 @@ class SoneMentionDetectorTest { } -private val remoteSone1 = createRemoteSone() -private val remoteSone2 = createRemoteSone() - -private val localSone1 = createLocalSone() -private val localSone2 = createLocalSone() - -private fun createPost(text: String = "", sone: Sone = remoteSone1, known: Boolean = false): Post.EmptyPost { - return object : Post.EmptyPost("post-id") { - override fun getSone() = sone - override fun getText() = text - override fun isKnown() = known - } -} - private class TestSoneProvider : SoneProvider { override val sones: Collection get() = remoteSones + localSones @@ -268,14 +252,3 @@ private class TestPostReplyProvider : PostReplyProvider { override fun getReplies(postId: String) = postReplies[postId] ?: emptyList() } - -private fun emptyPostReply(text: String = "", post: Post = createPost(), sone: Sone = remoteSone1, known: Boolean = false) = object : PostReply { - override val id = "reply-id" - override fun getSone() = sone - override fun getPostId() = post.id - override fun getPost(): Optional = of(post) - override fun getTime() = 1L - override fun getText() = text - override fun isKnown() = known - override fun setKnown(known: Boolean): PostReply = this -}