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<Post> = Optional.of(post)
+ override fun getTime() = 1L
+ override fun getText() = text
+ override fun isKnown() = known
+ override fun setKnown(known: Boolean): PostReply = this
+}
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.*
}
-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<Sone> get() = remoteSones + localSones
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<Post> = of(post)
- override fun getTime() = 1L
- override fun getText() = text
- override fun isKnown() = known
- override fun setKnown(known: Boolean): PostReply = this
-}