♻️ Convert test for Chief O’Brian at Work to Kotlin
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 8 Mar 2024 14:43:42 +0000 (15:43 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 8 Mar 2024 14:43:42 +0000 (15:43 +0100)
src/test/java/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.java [deleted file]
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.kt [new file with mode: 0644]

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 (file)
index 041838d..0000000
+++ /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 <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-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 (file)
index 0000000..61d5c31
--- /dev/null
@@ -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/")