From: David ‘Bombe’ Roden Date: Fri, 8 Mar 2024 14:43:42 +0000 (+0100) Subject: ♻️ Convert test for Chief O’Brian at Work to Kotlin X-Git-Tag: v2~10 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0e8ee257a2bbaf811d67ad46cc962dfbe82d2b62;p=rhynodge.git ♻️ Convert test for Chief O’Brian at Work to Kotlin --- diff --git a/src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java b/src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java deleted file mode 100644 index 041838d..0000000 --- a/src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.pterodactylus.rhynodge.filters.comics; - -import java.io.IOException; - -import net.pterodactylus.rhynodge.filters.ResourceLoader; - -import com.google.common.base.Optional; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; -import org.jsoup.nodes.Document; -import org.junit.Test; - -/** - * Unit test for {@link ChiefOBrienAtWorkComicFilter}. - * - * @author David ‘Bombe’ Roden - */ -public class ChiefOBrienAtWorkComicFilterTest { - - private final ChiefOBrienAtWorkComicFilter filter = new ChiefOBrienAtWorkComicFilter(); - private final Document document; - - public ChiefOBrienAtWorkComicFilterTest() throws IOException { - document = ResourceLoader.loadDocument(getClass(), "chief-obrien-at-work.html", "http://chiefobrienatwork.com/"); - } - - @Test - public void filterCanParseComics() { - MatcherAssert.assertThat(filter.extractImageUrls(document), Matchers.contains("http://41.media.tumblr.com/db92f4218b8a100f216863ce980e19a9/tumblr_njaewe7vNU1tjd8fao1_1280.jpg")); - } - - @Test - public void filterReturnsEmptyListForImageComments() { - MatcherAssert.assertThat(filter.extractImageComments(document), Matchers.empty()); - } - - @Test - public void filterCanParseComicTitles() { - MatcherAssert.assertThat(filter.extractTitle(document), Matchers.is(Optional.of("EPISODE 60: Being Human"))); - } - -} diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.kt new file mode 100644 index 0000000..61d5c31 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.kt @@ -0,0 +1,36 @@ +package net.pterodactylus.rhynodge.filters.comics + +import com.google.common.base.Optional +import net.pterodactylus.rhynodge.filters.ResourceLoader +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.contains +import org.hamcrest.Matchers.empty +import org.hamcrest.Matchers.equalTo +import org.jsoup.nodes.Document +import org.junit.Test + +/** + * Unit test for [ChiefOBrienAtWorkComicFilter]. + */ +class ChiefOBrienAtWorkComicFilterTest { + + @Test + fun `image url is parsed correctly`() { + assertThat(filter.extractImageUrls(document), contains("http://41.media.tumblr.com/db92f4218b8a100f216863ce980e19a9/tumblr_njaewe7vNU1tjd8fao1_1280.jpg")) + } + + @Test + fun `image comments are parsed correctly`() { + assertThat(filter.extractImageComments(document), empty()) + } + + @Test + fun `comic titles are parsed correctly`() { + assertThat(filter.extractTitle(document), equalTo(Optional.of("EPISODE 60: Being Human"))) + } + + private val filter = ChiefOBrienAtWorkComicFilter() + +} + +private val document: Document = ResourceLoader.loadDocument(ChiefOBrienAtWorkComicFilterTest::class.java, "chief-obrien-at-work.html", "http://chiefobrienatwork.com/")