From a7f5b2eb88048f8264efafa5b19ffeae002385fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 29 Jun 2020 00:11:37 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=9A=9A=20Rename=20test=20to=20match=20name?= =?utf8?q?=20of=20tested=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../notify/DefaultReplyVisibilityFilterTest.kt | 64 ++++++++++++++++++++++ .../sone/notify/ReplyVisibilityFilterTest.kt | 64 ---------------------- 2 files changed, 64 insertions(+), 64 deletions(-) create mode 100644 src/test/kotlin/net/pterodactylus/sone/notify/DefaultReplyVisibilityFilterTest.kt delete mode 100644 src/test/kotlin/net/pterodactylus/sone/notify/ReplyVisibilityFilterTest.kt 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)) - } - -} -- 2.7.4