From: David ‘Bombe’ Roden Date: Sun, 28 Jun 2020 22:11:37 +0000 (+0200) Subject: 🚚 Rename test to match name of tested class X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a7f5b2eb88048f8264efafa5b19ffeae002385fc;p=Sone.git 🚚 Rename test to match name of tested class --- diff --git a/src/test/kotlin/net/pterodactylus/sone/notify/DefaultReplyVisibilityFilterTest.kt b/src/test/kotlin/net/pterodactylus/sone/notify/DefaultReplyVisibilityFilterTest.kt new file mode 100644 index 0000000..a34f522 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/notify/DefaultReplyVisibilityFilterTest.kt @@ -0,0 +1,64 @@ +package net.pterodactylus.sone.notify + +import com.google.inject.Guice +import net.pterodactylus.sone.test.createLocalSone +import net.pterodactylus.sone.test.createPost +import net.pterodactylus.sone.test.createPostReply +import net.pterodactylus.sone.test.verifySingletonInstance +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.junit.Test + +/** + * Unit test for [DefaultReplyVisibilityFilterTest]. + */ +class DefaultReplyVisibilityFilterTest { + + private val replyVisibilityFilter = DefaultReplyVisibilityFilter(showAllPosts) + private val localSone = createLocalSone() + private val post = createPost() + + @Test + fun `reply visibility filter is only created once`() { + val injector = Guice.createInjector() + injector.verifySingletonInstance() + } + + @Test + fun `reply is not visible if post is not visible`() { + val postReply = createPostReply(post = post) + val replyVisibilityFilter = DefaultReplyVisibilityFilter(showNoPosts) + assertThat(replyVisibilityFilter.isReplyVisible(null, postReply), equalTo(false)) + } + + @Test + fun `reply is not visible if post is not present`() { + val postReply = createPostReply(post = null) + assertThat(replyVisibilityFilter.isReplyVisible(null, postReply), equalTo(false)) + } + + @Test + fun `reply is not visible if it is from the future`() { + val postReply = createPostReply(post = post, time = System.currentTimeMillis() + 100000) + assertThat(replyVisibilityFilter.isReplyVisible(null, postReply), equalTo(false)) + } + + @Test + fun `reply is visible if it is not from the future`() { + val postReply = createPostReply(post = post) + assertThat(replyVisibilityFilter.isReplyVisible(null, postReply), equalTo(true)) + } + + @Test + fun `predicate correctly recognizes visible reply`() { + val postReply = createPostReply(post = post) + assertThat(replyVisibilityFilter.isVisible(localSone).invoke(postReply), equalTo(true)) + } + + @Test + fun `predicate correctly recognizes not visible reply`() { + val postReply = createPostReply(post = post, time = System.currentTimeMillis() + 100000) + assertThat(replyVisibilityFilter.isVisible(localSone).invoke(postReply), equalTo(false)) + } + +} diff --git a/src/test/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilterTest.kt b/src/test/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilterTest.kt deleted file mode 100644 index b9f3595..0000000 --- a/src/test/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilterTest.kt +++ /dev/null @@ -1,64 +0,0 @@ -package net.pterodactylus.sone.notify - -import com.google.inject.Guice -import net.pterodactylus.sone.test.createLocalSone -import net.pterodactylus.sone.test.createPost -import net.pterodactylus.sone.test.createPostReply -import net.pterodactylus.sone.test.verifySingletonInstance -import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.equalTo -import org.junit.Test - -/** - * Unit test for [ReplyVisibilityFilterTest]. - */ -class ReplyVisibilityFilterTest { - - private val replyVisibilityFilter = DefaultReplyVisibilityFilter(showAllPosts) - private val localSone = createLocalSone() - private val post = createPost() - - @Test - fun `reply visibility filter is only created once`() { - val injector = Guice.createInjector() - injector.verifySingletonInstance() - } - - @Test - fun `reply is not visible if post is not visible`() { - val postReply = createPostReply(post = post) - val replyVisibilityFilter = DefaultReplyVisibilityFilter(showNoPosts) - assertThat(replyVisibilityFilter.isReplyVisible(null, postReply), equalTo(false)) - } - - @Test - fun `reply is not visible if post is not present`() { - val postReply = createPostReply(post = null) - assertThat(replyVisibilityFilter.isReplyVisible(null, postReply), equalTo(false)) - } - - @Test - fun `reply is not visible if it is from the future`() { - val postReply = createPostReply(post = post, time = System.currentTimeMillis() + 100000) - assertThat(replyVisibilityFilter.isReplyVisible(null, postReply), equalTo(false)) - } - - @Test - fun `reply is visible if it is not from the future`() { - val postReply = createPostReply(post = post) - assertThat(replyVisibilityFilter.isReplyVisible(null, postReply), equalTo(true)) - } - - @Test - fun `predicate correctly recognizes visible reply`() { - val postReply = createPostReply(post = post) - assertThat(replyVisibilityFilter.isVisible(localSone).invoke(postReply), equalTo(true)) - } - - @Test - fun `predicate correctly recognizes not visible reply`() { - val postReply = createPostReply(post = post, time = System.currentTimeMillis() + 100000) - assertThat(replyVisibilityFilter.isVisible(localSone).invoke(postReply), equalTo(false)) - } - -}