+ @Test
+ fun `detector does not emit event for reply without post`() {
+ val reply = emptyPostReply("text mentions sone://${localSone1.id} and sone://${localSone2.id}.", post = null)
+ eventBus.post(NewPostReplyFoundEvent(reply))
+ assertThat(caughtExceptions, emptyIterable())
+ assertThat(capturedFoundEvents, emptyIterable())
+ }
+
+ @Test
+ fun `detector does not emit removed event when a post without mention is removed`() {
+ val post = createPost()
+ eventBus.post(PostRemovedEvent(post))
+ assertThat(capturedRemovedEvents, emptyIterable())
+ }
+
+ @Test
+ fun `detector does emit removed event when post with mention is removed`() {
+ val post = createPost("sone://${localSone1.id}")
+ eventBus.post(NewPostFoundEvent(post))
+ eventBus.post(PostRemovedEvent(post))
+ assertThat(capturedRemovedEvents, contains(MentionOfLocalSoneRemovedEvent(post)))
+ }
+
+ @Test
+ fun `detector does not emit removed event when a post without mention is marked as known`() {
+ val post = createPost()
+ eventBus.post(MarkPostKnownEvent(post))
+ assertThat(capturedRemovedEvents, emptyIterable())
+ }
+
+ @Test
+ fun `detector does emit removed event when post with mention is marked as known`() {
+ val post = createPost("sone://${localSone1.id}")
+ eventBus.post(NewPostFoundEvent(post))
+ eventBus.post(MarkPostKnownEvent(post))
+ assertThat(capturedRemovedEvents, contains(MentionOfLocalSoneRemovedEvent(post)))
+ }
+
+ @Test
+ fun `detector does emit removed event when reply with mention is removed and no more mentions in that post exist`() {
+ val post = createPost()
+ val reply = emptyPostReply("sone://${localSone1.id}", post)
+ postReplyProvider.postReplies[post.id] = listOf(reply)
+ eventBus.post(NewPostReplyFoundEvent(reply))
+ eventBus.post(PostReplyRemovedEvent(reply))
+ assertThat(capturedRemovedEvents, contains(MentionOfLocalSoneRemovedEvent(post)))
+ }