⬆️ Update to JUnit 5
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 9 Nov 2024 19:15:29 +0000 (20:15 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 9 Nov 2024 19:15:29 +0000 (20:15 +0100)
46 files changed:
build.gradle
src/test/java/net/pterodactylus/rhynodge/ReactionTest.java
src/test/java/net/pterodactylus/rhynodge/actions/EmailActionTest.java
src/test/java/net/pterodactylus/rhynodge/filters/BlacklistFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/ComicSiteFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/EpisodeFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/JsonFilterTest.kt
src/test/java/net/pterodactylus/rhynodge/filters/comics/AbstruseGooseComicFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/comics/CyanideAndHappinessComicFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/comics/GirlGeniusComicFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/comics/ScandinaviaAndTheWorldComicFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/torrents/KickAssTorrentsFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/torrents/PirateBayFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/torrents/TorrentHoundFilterTest.java
src/test/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilterTest.java
src/test/java/net/pterodactylus/rhynodge/states/StateManagerTest.java
src/test/java/net/pterodactylus/util/envopt/ParserTest.java
src/test/java/net/pterodactylus/util/envopt/SystemEnvironmentTest.java
src/test/java/net/pterodactylus/util/inject/ObjectBindingTest.java
src/test/kotlin/net/pterodactylus/rhynodge/engine/ReactionRunnerTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/SizeBlacklistFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/BusinessCatComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ChiefOBrienAtWorkComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ComicSiteFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/CtrlAltDelComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/DrugsAndWiresComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/HeldentageFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/LeastICouldDoComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/PoorlyDrawnLinesComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/QuestionableContentFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/SaturdayMorningBreakfastCerealComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/SinfestComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/SoggyCardboardComicFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/TheMonsterUnderTheBedFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/epicgames/EpicGamesFilterTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/epicgames/EpicGamesMergerTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/epicgames/FreeGamesStateTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieExtractorTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/MovieStateTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/filters/webpages/savoy/SavoyMergerTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/mergers/ComicMergerTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/mergers/LastStateMergerTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/queries/FallbackQueryTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/states/AbstractStateTest.kt
src/test/kotlin/net/pterodactylus/rhynodge/states/JsonStateTest.kt
src/test/kotlin/net/pterodactylus/util/exception/ExceptionsTest.kt

index 00dfc77..bd7bd42 100644 (file)
@@ -58,7 +58,8 @@ dependencies {
     implementation group: "org.jetbrains.kotlinx", name: "kotlinx-html-jvm", version: "0.11.0"
     implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
 
-    testImplementation group: "junit", name: "junit", version: "4.13.2"
+    testImplementation(platform("org.junit:junit-bom:5.11.3"))
+    testImplementation group: "org.junit.jupiter", name: "junit-jupiter-engine"
     testImplementation group: "org.hamcrest", name: "hamcrest", version: "2.2"
     testImplementation group: "org.mockito", name: "mockito-core", version: "5.11.0"
     testImplementation group: "com.spotify", name: "hamcrest-jackson", version: "1.3.2"
@@ -79,6 +80,7 @@ tasks.register('fatJar', Jar) {
 }
 
 tasks.named('test') {
+    useJUnitPlatform()
     jvmArgs += "--add-opens=java.base/java.lang=ALL-UNNAMED"
     jvmArgs += "--add-opens=java.base/java.util=ALL-UNNAMED"
 }
index c30013f..efb782e 100644 (file)
@@ -1,5 +1,7 @@
 package net.pterodactylus.rhynodge;
 
+import org.junit.jupiter.api.Test;
+
 import static java.util.Arrays.asList;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.contains;
@@ -7,8 +9,6 @@ import static org.hamcrest.Matchers.emptyIterable;
 import static org.hamcrest.Matchers.is;
 import static org.mockito.Mockito.mock;
 
-import org.junit.Test;
-
 /**
  * Unit test for {@link Reaction}.
  *
index a4dbb16..9fe5688 100644 (file)
@@ -13,8 +13,7 @@ import javax.mail.Transport;
 
 import net.pterodactylus.rhynodge.output.DefaultOutput;
 import net.pterodactylus.rhynodge.output.Output;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link EmailAction}.
index ed8e3a3..1e54d72 100644 (file)
@@ -28,8 +28,7 @@ import net.pterodactylus.rhynodge.State;
 import net.pterodactylus.rhynodge.states.FailedState;
 import net.pterodactylus.rhynodge.states.TorrentState;
 import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link BlacklistFilter}.
index deff04a..01c3f06 100644 (file)
@@ -6,6 +6,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.util.Collections;
 import java.util.List;
@@ -19,7 +20,7 @@ import net.pterodactylus.rhynodge.states.HtmlState;
 
 import com.google.common.base.Optional;
 import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link ComicSiteFilter}.
@@ -28,11 +29,11 @@ import org.junit.Test;
  */
 public class ComicSiteFilterTest {
 
-       @Test(expected = IllegalArgumentException.class)
+       @Test
        public void comicSiteFilterRequiresHtmlState() {
                State state = new FailedState();
                ComicSiteFilter comicSiteFilter = new TestComicSiteFilter(null, null, null);
-               comicSiteFilter.filter(state);
+               assertThrows(IllegalArgumentException.class, () -> comicSiteFilter.filter(state));
        }
 
        @Test
@@ -55,11 +56,11 @@ public class ComicSiteFilterTest {
                assertThat(comic.strips(), contains(new Strip("http://foo/url1.gif", "Comment 1"), new Strip("http://foo/url2.gif", "Comment 2"), new Strip("http://foo/url3.gif", "")));
        }
 
-       @Test(expected = IllegalStateException.class)
+       @Test
        public void illegalUrlThrowsException() {
                State state = new HtmlState("http://foo/^", null);
                ComicSiteFilter comicSiteFilter = new TestComicSiteFilter("Title", asList("url1.gif"), Collections.<String>emptyList());
-               comicSiteFilter.filter(state);
+               assertThrows(IllegalStateException.class, () -> comicSiteFilter.filter(state));
        }
 
        private static class TestComicSiteFilter extends ComicSiteFilter {
index 109e053..f2813e2 100644 (file)
@@ -2,6 +2,7 @@ package net.pterodactylus.rhynodge.filters;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import net.pterodactylus.rhynodge.State;
 import net.pterodactylus.rhynodge.states.EpisodeState;
@@ -9,8 +10,7 @@ import net.pterodactylus.rhynodge.states.FailedState;
 import net.pterodactylus.rhynodge.states.HtmlState;
 import net.pterodactylus.rhynodge.states.TorrentState;
 import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link EpisodeFilter}.
@@ -28,10 +28,10 @@ public class EpisodeFilterTest {
                assertThat(newState.success(), is(false));
        }
 
-       @Test(expected = IllegalStateException.class)
+       @Test
        public void episodeFilterRequiresATorrentState() {
                State state = new HtmlState("http://foo/", null);
-               episodeFilter.filter(state);
+               assertThrows(IllegalStateException.class, () -> episodeFilter.filter(state));
        }
 
        @Test
index a37990a..7e0f3ba 100644 (file)
@@ -6,7 +6,6 @@ import com.spotify.hamcrest.jackson.JsonMatchers.jsonNull
 import com.spotify.hamcrest.jackson.JsonMatchers.jsonObject
 import com.spotify.hamcrest.jackson.JsonMatchers.jsonText
 import net.pterodactylus.rhynodge.Filter
-import net.pterodactylus.rhynodge.states.AbstractState
 import net.pterodactylus.rhynodge.states.FailedState
 import net.pterodactylus.rhynodge.states.HttpState
 import net.pterodactylus.rhynodge.states.JsonState
@@ -14,9 +13,8 @@ import net.pterodactylus.rhynodge.states.StringState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
 import org.hamcrest.Matchers.instanceOf
-import org.junit.Assert
-import org.junit.Assert.assertThrows
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
 
 class JsonFilterTest {
 
@@ -58,7 +56,7 @@ class JsonFilterTest {
 
        @Test
        fun `json filter throws exception if given state is not an http state`() {
-               assertThrows(IllegalArgumentException::class.java) { filter.filter(StringState("foo")) }
+               assertThrows<IllegalArgumentException> { filter.filter(StringState("foo")) }
        }
 
        @Test
index f01e841..16be464 100644 (file)
@@ -29,7 +29,7 @@ import net.pterodactylus.rhynodge.filters.ResourceLoader;
 
 import com.google.common.base.Optional;
 import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link AbstruseGooseComicFilter}.
index bea429a..0b24697 100644 (file)
@@ -10,7 +10,7 @@ import net.pterodactylus.rhynodge.states.ComicState;
 import net.pterodactylus.rhynodge.states.HtmlState;
 
 import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link CyanideAndHappinessComicFilter}.
index a45f075..46b76d0 100644 (file)
@@ -11,7 +11,7 @@ import net.pterodactylus.rhynodge.states.ComicState;
 import net.pterodactylus.rhynodge.states.HtmlState;
 
 import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link GirlGeniusComicFilterTest}.
index 53461cb..8168539 100644 (file)
@@ -17,7 +17,7 @@ import org.hamcrest.Description;
 import org.hamcrest.Matcher;
 import org.hamcrest.TypeSafeDiagnosingMatcher;
 import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link ScandinaviaAndTheWorldComicFilterTest}.
index 73657bc..be2bfa9 100644 (file)
@@ -12,7 +12,7 @@ import org.hamcrest.TypeSafeDiagnosingMatcher;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link KickAssTorrentsFilter}.
index 11f7019..f95ffb7 100644 (file)
@@ -11,7 +11,7 @@ import net.pterodactylus.rhynodge.states.TorrentState;
 
 import org.hamcrest.Matchers;
 import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link PirateBayFilter}.
index 499999b..51feb42 100644 (file)
@@ -10,7 +10,7 @@ import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
index d7afc94..1d65308 100644 (file)
@@ -10,7 +10,7 @@ import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link TorrentzEuFilter}.
index da1bb90..639c8f7 100644 (file)
@@ -11,13 +11,12 @@ import net.pterodactylus.rhynodge.states.StateManager.StateDirectory;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.common.io.Files;
 import org.hamcrest.Matchers;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.base.Objects.equal;
 import static org.apache.log4j.Level.OFF;
 import static org.apache.log4j.Logger.getLogger;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -30,24 +29,21 @@ import static org.hamcrest.Matchers.is;
  */
 public class StateManagerTest {
 
-       @Rule
-       public TemporaryFolder tempFolder = new TemporaryFolder();
-       private final File statePath;
-       private final StateManager stateManager;
+       @TempDir private File tempFolder;
+       private StateManager stateManager;
 
-       @BeforeClass
+       @BeforeAll
        public static void deactivateLogging() {
                getLogger(StateManager.class).setLevel(OFF);
        }
 
-       public StateManagerTest() throws IOException {
-               tempFolder.create();
-               statePath = tempFolder.newFolder();
-               stateManager = new StateManager(StateDirectory.of(statePath.getPath()));
+       @BeforeEach
+       public void createStateManager() {
+               stateManager = new StateManager(StateDirectory.of(tempFolder.getPath()));
        }
 
        @Test
-       public void successStateCanBeRestored() {
+       public void successStateCanBeRestored(@TempDir File tempDir) throws IOException {
                TestState testState = new TestState();
                stateManager.saveState("test", testState);
                Optional<State> restoredState = stateManager.loadLastState("test");
@@ -68,14 +64,14 @@ public class StateManagerTest {
 
        @Test
        public void invalidJsonFileCanNotBeLoaded() throws IOException {
-               Files.write("not json", new File(statePath, "test.last.json"), UTF_8);
+               Files.write("not json", new File(tempFolder, "test.last.json"), UTF_8);
                Optional<State> restoredState = stateManager.loadLastState("test");
                assertThat(restoredState.isPresent(), is(false));
        }
 
        @Test
        public void jsonWithInvalidFieldsCanNotBeLoaded() throws IOException {
-               Files.write("{\"not\":\"json\"}", new File(statePath, "test.last.json"), UTF_8);
+               Files.write("{\"not\":\"json\"}", new File(tempFolder, "test.last.json"), UTF_8);
                Optional<State> restoredState = stateManager.loadLastState("test");
                assertThat(restoredState.isPresent(), is(false));
        }
@@ -84,7 +80,7 @@ public class StateManagerTest {
        public void unmappableStateCanBeSavedButNotLoaded() throws IOException {
                InvalidState invalidState = new InvalidState();
                stateManager.saveState("test", invalidState);
-               assertThat(new File(statePath, "test.last.json").exists(), is(false));
+               assertThat(new File(tempFolder, "test.last.json").exists(), is(false));
        }
 
        public static class TestState extends AbstractState {
index 5014b9d..0835fd4 100644 (file)
@@ -6,9 +6,11 @@ import net.pterodactylus.util.envopt.Parser.RequiredOptionIsMissing;
 
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 /**
  * Unit test for {@link Parser}.
  *
@@ -39,11 +41,10 @@ public class ParserTest {
                MatcherAssert.assertThat(finalTestOptions.getOptionOne(), Matchers.is("test"));
        }
 
-       @Test(expected = RequiredOptionIsMissing.class)
+       @Test
        public void parserThrowsIfRequiredOptionIsMissing() {
                Mockito.when(environment.getValue("foo")).thenReturn(Optional.empty());
-           RequiredTestOptions requiredTestOptions = parser.parseEnvironment(RequiredTestOptions::new);
-               requiredTestOptions.getOptionOne();
+               assertThrows(RequiredOptionIsMissing.class, () -> parser.parseEnvironment(RequiredTestOptions::new));
        }
 
        @Test
index ac9fe52..c21bba8 100644 (file)
@@ -6,7 +6,7 @@ import java.util.Optional;
 
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link SystemEnvironment}.
index df32585..273430a 100644 (file)
@@ -4,7 +4,7 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for {@link ObjectBinding}.
index 4dfd891..a7b6ddc 100644 (file)
@@ -13,7 +13,7 @@ import org.hamcrest.Matcher
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.equalTo
 import org.hamcrest.TypeSafeDiagnosingMatcher
-import org.junit.Test
+import org.junit.jupiter.api.Test
 import java.util.Optional
 import java.util.Optional.empty
 import java.util.Optional.of
index 4ab5430..393dc77 100644 (file)
@@ -3,11 +3,10 @@ package net.pterodactylus.rhynodge.filters
 import net.pterodactylus.rhynodge.states.FailedState
 import net.pterodactylus.rhynodge.states.TorrentState
 import net.pterodactylus.rhynodge.states.TorrentState.TorrentFile
-import org.hamcrest.MatcherAssert
 import org.hamcrest.MatcherAssert.assertThat
-import org.hamcrest.Matchers
+import org.hamcrest.Matchers.containsInAnyOrder
 import org.hamcrest.Matchers.equalTo
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 /**
  * Unit test for [SizeBlacklistFilter].
@@ -28,7 +27,7 @@ class SizeBlacklistFilterTest {
                                matchingTorrentFile1,
                                matchingTorrentFile2
                ))) as TorrentState
-               assertThat(filteredState.torrentFiles(), Matchers.containsInAnyOrder(
+               assertThat(filteredState.torrentFiles(), containsInAnyOrder(
                                notMatchingTorrentFile1,
                                notMatchingTorrentFile2
                ))
index df7bd8f..1956c82 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.rhynodge.states.ComicState
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 /**
  * Unit test for [BusinessCatComicFilter].
index d5a44b8..f252803 100644 (file)
@@ -7,7 +7,7 @@ import org.hamcrest.Matchers.contains
 import org.hamcrest.Matchers.empty
 import org.hamcrest.Matchers.equalTo
 import org.jsoup.nodes.Document
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 /**
  * Unit test for [ChiefOBrienAtWorkComicFilter].
index ce1a8e2..71f987d 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.rhynodge.states.ComicState.Comic
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.equalTo
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 abstract class ComicSiteFilterTest {
 
index e9817ed..d53e149 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.rhynodge.states.ComicState.Strip
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 /**
  * Unit test for [CtrlAltDelComicFilter].
index 1357209..3003434 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.rhynodge.states.ComicState.Strip
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 class DrugsAndWiresComicFilterTest {
 
index 8443a9d..0b39555 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.rhynodge.states.ComicState.Comic
 import net.pterodactylus.rhynodge.states.ComicState.Strip
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 /**
  * Unit test for [HeldentageFilter].
index 0d88973..a8fc14e 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.rhynodge.states.ComicState.Strip
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 /**
  * Unit test for [LeastICouldDoComicFilterTest].
index 4d31c13..5ae542f 100644 (file)
@@ -6,7 +6,7 @@ import net.pterodactylus.rhynodge.states.ComicState.Strip
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 class PoorlyDrawnLinesComicFilterTest {
 
index 39ae500..ba28c4c 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.rhynodge.states.ComicState.Strip
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 class QuestionableContentFilterTest {
 
index 45e97bf..35df42b 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.rhynodge.states.ComicState
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.*
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 /**
  * Unit test for [SaturdayMorningBreakfastCerealComicFilter].
index 92049ba..31084cf 100644 (file)
@@ -9,7 +9,7 @@ import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
 import org.hamcrest.Matchers.instanceOf
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 /**
  * Unit test for [SinfestComicFilter].
index b11f4eb..a18901e 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.rhynodge.states.ComicState.Strip
 import net.pterodactylus.rhynodge.states.HtmlState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 class SoggyCardboardComicFilterTest {
 
index df159c5..1495c5e 100644 (file)
@@ -1,11 +1,13 @@
 package net.pterodactylus.rhynodge.filters.comics
 
-import net.pterodactylus.rhynodge.filters.ResourceLoader.*
-import net.pterodactylus.rhynodge.states.*
-import net.pterodactylus.rhynodge.states.ComicState.*
-import org.hamcrest.MatcherAssert.*
-import org.hamcrest.Matchers.*
-import org.junit.*
+import net.pterodactylus.rhynodge.filters.ResourceLoader.loadDocument
+import net.pterodactylus.rhynodge.states.ComicState
+import net.pterodactylus.rhynodge.states.ComicState.Comic
+import net.pterodactylus.rhynodge.states.ComicState.Strip
+import net.pterodactylus.rhynodge.states.HtmlState
+import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.contains
+import org.junit.jupiter.api.Test
 
 class TheMonsterUnderTheBedFilterTest {
 
index 2d44796..08c0558 100644 (file)
@@ -7,8 +7,8 @@ import net.pterodactylus.rhynodge.states.JsonState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
 import org.hamcrest.Matchers.instanceOf
-import org.junit.Assert.assertThrows
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
 import java.time.Instant.parse
 
 class EpicGamesFilterTest {
@@ -20,7 +20,7 @@ class EpicGamesFilterTest {
 
        @Test
        fun `filter throws exception when given html state`() {
-               assertThrows(IllegalArgumentException::class.java) { filter.filter(HttpState("", 200, "", byteArrayOf())) }
+               assertThrows<IllegalArgumentException> { filter.filter(HttpState("", 200, "", byteArrayOf())) }
        }
 
        @Test
index 49ade1f..6b22ec3 100644 (file)
@@ -7,8 +7,8 @@ import org.hamcrest.Matchers.contains
 import org.hamcrest.Matchers.empty
 import org.hamcrest.Matchers.equalTo
 import org.hamcrest.Matchers.instanceOf
-import org.junit.Assert.assertThrows
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
 import java.time.Instant
 
 class EpicGamesMergerTest {
@@ -20,12 +20,12 @@ class EpicGamesMergerTest {
 
        @Test
        fun `merger throws exception if previous state is not a free games state`() {
-               assertThrows(IllegalArgumentException::class.java) { merger.mergeStates(TestState(), emptyState) }
+               assertThrows<IllegalArgumentException> { merger.mergeStates(TestState(), emptyState) }
        }
 
        @Test
        fun `merger throws exception if current state is not a free games state`() {
-               assertThrows(IllegalArgumentException::class.java) { merger.mergeStates(emptyState, TestState()) }
+               assertThrows<IllegalArgumentException> { merger.mergeStates(emptyState, TestState()) }
        }
 
        @Test
index 15679c7..d89eaa1 100644 (file)
@@ -5,7 +5,7 @@ import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
 import org.hamcrest.Matchers.equalTo
 import org.jsoup.Jsoup
-import org.junit.Test
+import org.junit.jupiter.api.Test
 import java.time.Instant
 import java.time.ZoneOffset
 
index 008c69c..4d16e33 100644 (file)
@@ -9,7 +9,7 @@ import org.hamcrest.Matchers.equalTo
 import org.hamcrest.Matchers.hasItems
 import org.hamcrest.TypeSafeDiagnosingMatcher
 import org.jsoup.Jsoup
-import org.junit.Test
+import org.junit.jupiter.api.Test
 import java.time.LocalDateTime
 
 /**
index bb2fa9b..6fb52cc 100644 (file)
@@ -11,7 +11,7 @@ import org.hamcrest.Matchers.not
 import org.jsoup.Jsoup
 import org.jsoup.nodes.Element
 import org.jsoup.nodes.TextNode
-import org.junit.Test
+import org.junit.jupiter.api.Test
 import java.time.LocalDateTime
 
 class MovieStateTest {
index cd2c7e0..b7ee7c8 100644 (file)
@@ -5,20 +5,20 @@ import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.containsInAnyOrder
 import org.hamcrest.Matchers.empty
 import org.hamcrest.Matchers.equalTo
-import org.junit.Assert.assertThrows
-import org.junit.Test
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
 import java.time.LocalDateTime
 
 class SavoyMergerTest {
 
        @Test
        fun `merger throws exception if first state is not a movie state`() {
-               assertThrows(IllegalArgumentException::class.java) { merger.mergeStates(TestState(), MovieState(emptySet())) }
+               assertThrows<IllegalArgumentException> { merger.mergeStates(TestState(), MovieState(emptySet())) }
        }
 
        @Test
        fun `merger throws exception if second state is not a movie state`() {
-               assertThrows(IllegalArgumentException::class.java) { merger.mergeStates(MovieState(emptySet()), TestState()) }
+               assertThrows<IllegalArgumentException> { merger.mergeStates(MovieState(emptySet()), TestState()) }
        }
 
        @Test
index 3f07181..e2afceb 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.rhynodge.states.ComicState
 import net.pterodactylus.rhynodge.states.ComicState.Comic
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.contains
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 class ComicMergerTest {
 
index 07d2bee..1118484 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.rhynodge.State
 import net.pterodactylus.rhynodge.states.StateManagerTest.TestState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.equalTo
-import org.junit.Test
+import org.junit.jupiter.api.Test
 
 class LastStateMergerTest {
 
index dd2a3c1..fe43511 100644 (file)
@@ -4,14 +4,12 @@ import net.pterodactylus.rhynodge.Query
 import net.pterodactylus.rhynodge.State
 import net.pterodactylus.rhynodge.states.AbstractState
 import net.pterodactylus.rhynodge.states.FailedState
-import net.pterodactylus.rhynodge.states.StateManagerTest
 import net.pterodactylus.rhynodge.states.StateManagerTest.TestState
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.`is`
 import org.hamcrest.Matchers.sameInstance
-import org.junit.Rule
-import org.junit.Test
-import org.junit.rules.ExpectedException
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
 import org.mockito.Mockito.`when`
 import org.mockito.Mockito.mock
 import org.mockito.Mockito.never
@@ -24,8 +22,6 @@ import org.mockito.Mockito.verify
  */
 class FallbackQueryTest {
 
-       @JvmField @Rule val expectedException = ExpectedException.none()!!
-
        private val firstQuery = mock(Query::class.java)
        private val secondQuery = mock(Query::class.java)
        private val thirdQuery = mock(Query::class.java)
@@ -90,8 +86,7 @@ class FallbackQueryTest {
 
        @Test
        fun `fallback query can not be created without queries`() {
-               expectedException.expect(IllegalArgumentException::class.java)
-               FallbackQuery()
+               assertThrows<IllegalArgumentException> { FallbackQuery() }
        }
 
 }
index 29d7386..d6362c3 100644 (file)
@@ -2,7 +2,7 @@ package net.pterodactylus.rhynodge.states
 
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.equalTo
-import org.junit.Test
+import org.junit.jupiter.api.Test
 import java.time.Clock
 import java.time.Instant.now
 import java.time.ZoneOffset.UTC
index b21095e..326c196 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.rhynodge.states
 import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
 import com.spotify.hamcrest.jackson.JsonMatchers.jsonObject
 import org.hamcrest.MatcherAssert.assertThat
-import org.junit.Test
+import org.junit.jupiter.api.Test
 import java.io.StringWriter
 
 class JsonStateTest {
index 151da89..65108a6 100644 (file)
@@ -2,7 +2,7 @@ package net.pterodactylus.util.exception
 
 import org.hamcrest.MatcherAssert
 import org.hamcrest.Matchers
-import org.junit.Test
+import org.junit.jupiter.api.Test
 import java.util.concurrent.atomic.AtomicBoolean
 import java.util.concurrent.atomic.AtomicReference