- protected fun addNewPost(id: String, soneId: String, time: Long, recipientId: String? = null) {
- newPosts[id] = mock<Post>().apply {
- whenever(this.id).thenReturn(id)
- val sone = mock<Sone>().apply { whenever(this.id).thenReturn(soneId) }
- whenever(this.sone).thenReturn(sone)
- whenever(this.time).thenReturn(time)
- whenever(this.recipientId).thenReturn(recipientId.asOptional())
- }
+ protected fun addSone(sone: Sone, soneId: String? = null) {
+ remoteSones += (soneId ?: sone.id) to sone
+ }
+
+ protected fun addLocalSone(id: String, sone: Sone) {
+ localSones += id to sone
+ }
+
+ protected fun addPost(post: Post, id: String? = null) {
+ posts[id ?: post.id] = post
+ }
+
+ protected fun addLikes(post: Post, vararg sones: Sone) {
+ postLikes[post] = setOf(*sones)
+ }
+
+ protected fun addLikes(reply: PostReply, vararg sones: Sone) {
+ replyLikes[reply] = setOf(*sones)
+ }
+
+ protected fun addNewPost(id: String, soneId: String, time: Long, recipientId: String? = null) =
+ mock<Post>().apply {
+ whenever(this.id).thenReturn(id)
+ val sone = mock<Sone>().apply { whenever(this.id).thenReturn(soneId) }
+ whenever(this.sone).thenReturn(sone)
+ whenever(this.time).thenReturn(time)
+ whenever(this.recipientId).thenReturn(recipientId.asOptional())
+ }.also { newPosts[id] = it }
+
+ protected fun addReply(reply: PostReply, id: String? = null) {
+ replies[id ?: reply.id] = reply