X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FJsonPageTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FJsonPageTest.kt;h=d5314c5ae27862b9992ffea8a9fb45711a8f33bd;hp=60b262775af50d514c118e27d3c1f0c6527810ac;hb=c3407a682f9f81b27d0354e59fe9e3d3d6dffcd6;hpb=1a99ad0764b71eff7cde42f9c13f384948977b18 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 60b2627..d5314c5 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageTest.kt @@ -29,6 +29,7 @@ import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo import org.junit.Before import org.junit.Test +import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.anyString @@ -66,8 +67,10 @@ abstract class JsonPageTest( private val localSones = mutableMapOf() private val remoteSones = mutableMapOf() private val posts = mutableMapOf() + private val postLikes = mutableMapOf>() private val newPosts = mutableMapOf() private val replies = mutableMapOf() + private val replyLikes = mutableMapOf>() private val newReplies = mutableMapOf() private val linkedElements = mutableMapOf() private val notifications = mutableMapOf() @@ -92,6 +95,8 @@ abstract class JsonPageTest( whenever(core.getSone(anyString())).thenAnswer { (localSones + remoteSones)[it.getArgument(0)].asOptional() } whenever(core.getLocalSone(anyString())).thenAnswer { localSones[it[0]] } whenever(core.getPost(anyString())).thenAnswer { (posts + newPosts)[it[0]].asOptional() } + whenever(core.getLikes(any())).then { postLikes[it[0]] ?: emptySet() } + whenever(core.getLikes(any())).then { replyLikes[it[0]] ?: emptySet() } whenever(core.getPostReply(anyString())).then { replies[it[0]].asOptional() } whenever(core.getAlbum(anyString())).then { albums[it[0]] } whenever(core.getImage(anyString())).then { images[it[0]] } @@ -182,6 +187,14 @@ abstract class JsonPageTest( 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().apply { whenever(this.id).thenReturn(id)