🔀 Merge branch 'release/v82'
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / core / SoneComparisonTest.kt
1 package net.pterodactylus.sone.core
2
3 import net.pterodactylus.sone.data.*
4 import net.pterodactylus.sone.test.*
5 import org.hamcrest.MatcherAssert.*
6 import org.hamcrest.Matchers.*
7 import org.junit.*
8
9 class SoneComparsisonTest {
10
11         private val oldSone = mock<Sone>()
12         private val newSone = mock<Sone>()
13
14         private val oldPost = mock<Post>()
15         private val removedPost = mock<Post>()
16         private val newPost = mock<Post>()
17         private val oldPostReply = mock<PostReply>()
18         private val removedPostReply = mock<PostReply>()
19         private val newPostReply = mock<PostReply>()
20
21         init {
22                 whenever(oldSone.posts).thenReturn(listOf(oldPost, removedPost))
23                 whenever(newSone.posts).thenReturn(listOf(oldPost, newPost))
24                 whenever(oldSone.replies).thenReturn(setOf(oldPostReply, removedPostReply))
25                 whenever(newSone.replies).thenReturn(setOf(oldPostReply, newPostReply))
26         }
27
28         private val soneComparison = SoneComparison(oldSone, newSone)
29
30         @Test
31         fun `new posts are identified correctly`() {
32                 assertThat(soneComparison.newPosts, contains(newPost))
33         }
34
35         @Test
36         fun `removed posts are identified correctly`() {
37                 assertThat(soneComparison.removedPosts, contains(removedPost))
38         }
39
40         @Test
41         fun `new post replies are identified correctly`() {
42                 assertThat(soneComparison.newPostReplies, contains(newPostReply))
43         }
44
45         @Test
46         fun `removed post replies are identified correctly`() {
47                 assertThat(soneComparison.removedPostReplies, contains(removedPostReply))
48         }
49
50 }