diff --git a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/JSErrorRegressionTest.java b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/JSErrorRegressionTest.java index 441877a73..1298e03c1 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/JSErrorRegressionTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/JSErrorRegressionTest.java @@ -107,7 +107,7 @@ class JSErrorRegressionTest { } private void assertNo500Error(WebDriver driver) { - assertFalse(driver.getPageSource().contains("500 Internal Error occurred"), driver.getPageSource()); + assertFalse(driver.getPageSource().contains("Error occurred"), driver.getPageSource()); } @Test diff --git a/Plan/common/src/test/java/com/djrapitops/plan/gathering/geolocation/GeolocationTest.java b/Plan/common/src/test/java/com/djrapitops/plan/gathering/geolocation/GeolocationTest.java index 7c9651d6f..b59ee96a0 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/gathering/geolocation/GeolocationTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/gathering/geolocation/GeolocationTest.java @@ -31,6 +31,7 @@ import org.junit.platform.runner.JUnitPlatform; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import utilities.mocks.objects.TestRunnableFactory; import java.io.File; import java.io.IOException; @@ -91,7 +92,7 @@ class GeolocationTest { assertTrue(config.isTrue(DataGatheringSettings.GEOLOCATIONS)); GeoLite2Geolocator geoLite2Geolocator = new GeoLite2Geolocator(files, config); - underTest = new GeolocationCache(new Locale(), config, geoLite2Geolocator, new IP2CGeolocator(), new TestPluginLogger()); + underTest = new GeolocationCache(new Locale(), config, geoLite2Geolocator, new IP2CGeolocator(), new TestPluginLogger(), TestRunnableFactory.forSameThread()); underTest.enable(); assertTrue(underTest.canGeolocate()); diff --git a/Plan/common/src/test/java/utilities/mocks/Mocker.java b/Plan/common/src/test/java/utilities/mocks/Mocker.java index 408857526..a11b5cee8 100644 --- a/Plan/common/src/test/java/utilities/mocks/Mocker.java +++ b/Plan/common/src/test/java/utilities/mocks/Mocker.java @@ -69,16 +69,28 @@ abstract class Mocker { "web/css/sb-admin-2.css", "web/js/color-selector.js", + "web/js/graphs.js", "web/js/network-values.js", + "web/js/pingTable.js", + "web/js/player-values.js", "web/js/sb-admin-2.js", "web/js/server-values.js", + "web/js/sessionAccordion.js", "web/js/xmlhttprequests.js", - "web/js/graphs.js", "web/vendor/bootstrap/js/bootstrap.bundle.min.js", + "web/vendor/datatables/jquery.dataTables.min.js", + "web/vendor/datatables/dataTables.bootstrap4.min.css", + "web/vendor/datatables/dataTables.bootstrap4.min.js", "web/vendor/jquery/jquery.min.js", "web/vendor/fullcalendar/fullcalendar.min.js", "web/vendor/fullcalendar/fullcalendar.min.css", + "web/vendor/highcharts/drilldown.js", + "web/vendor/highcharts/highcharts-more.js", + "web/vendor/highcharts/highstock.js", + "web/vendor/highcharts/map.js", + "web/vendor/highcharts/no-data-to-display.js", + "web/vendor/highcharts/world.js", "web/vendor/momentjs/moment.js" }) { withPluginFile(fileName); diff --git a/Plan/common/src/test/java/utilities/mocks/objects/TestRunnableFactory.java b/Plan/common/src/test/java/utilities/mocks/objects/TestRunnableFactory.java index 3d8bf1b64..c1cf0fa3f 100644 --- a/Plan/common/src/test/java/utilities/mocks/objects/TestRunnableFactory.java +++ b/Plan/common/src/test/java/utilities/mocks/objects/TestRunnableFactory.java @@ -18,8 +18,11 @@ package utilities.mocks.objects; import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.PluginRunnable; +import com.djrapitops.plugin.task.PluginTask; import com.djrapitops.plugin.task.RunnableFactory; +import org.mockito.Mockito; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; /** @@ -32,13 +35,42 @@ import static org.mockito.Mockito.mock; */ public class TestRunnableFactory extends RunnableFactory { + private boolean callOnSameThread; + + public TestRunnableFactory() { + this(false); + } + + private TestRunnableFactory(boolean callOnSameThread) { + this.callOnSameThread = callOnSameThread; + } + + public static RunnableFactory forSameThread() { + return new TestRunnableFactory(true); + } + @Override - protected PluginRunnable createNewRunnable(String name, AbsRunnable absRunnable, long l) { - return mock(PluginRunnable.class); + protected PluginRunnable createNewRunnable(String name, AbsRunnable runnable, long l) { + PluginRunnable mock = mock(PluginRunnable.class); + if (callOnSameThread) { + lenient().when(mock.runTask()).then(invocation -> run(runnable)); + lenient().when(mock.runTaskAsynchronously()).then(invocation -> run(runnable)); + lenient().when(mock.runTaskLater(Mockito.anyLong())).then(invocation -> run(runnable)); + lenient().when(mock.runTaskLaterAsynchronously(Mockito.anyLong())).then(invocation -> run(runnable)); + lenient().when(mock.runTaskTimer(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> run(runnable)); + lenient().when(mock.runTaskTimerAsynchronously(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> run(runnable)); + } + return mock; + } + + private PluginTask run(AbsRunnable runnable) { + runnable.run(); + return null; } @Override public void cancelAllKnownTasks() { /* Nothing to cancel, nothing is actually run. */ } + }