From 390526525d0e0483967ef564eabf85a6dbeb9835 Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Thu, 20 Jul 2023 11:34:18 -0600 Subject: [PATCH] Switch more test initialization to JUnit 5 annotations One significant improvement here is done by the custom @Territories annotation; it no longer initializes Territories on every test. This reduces total test time (wall clock) from 5.5 minutes to 3 minutes. Signed-off-by: Taylor Smock --- .../MapWithAISourceReaderTestIT.java | 12 ++++------ .../mapwithai/MapWithAIPluginTest.java | 17 +++++--------- .../plugins/mapwithai/UpdateProdTest.java | 7 ++---- .../actions/AddMapWithAILayerActionTest.java | 8 ++----- .../backend/DataConflationSenderTest.java | 8 ++----- .../DetectTaskingManagerUtilsTest.java | 12 ++++------ .../backend/DownloadListenerTest.java | 13 ++++------- .../backend/DownloadMapWithAITaskTest.java | 6 ++++- .../backend/GetDataRunnableTest.java | 4 +++- .../backend/MapWithAIActionTest.java | 18 +++++++-------- .../backend/MapWithAIAvailabilityTest.java | 13 +++-------- .../backend/MapWithAIDataUtilsTest.java | 12 +++++++--- .../mapwithai/backend/MapWithAILayerTest.java | 13 ++++++++--- .../backend/MapWithAIMoveActionTest.java | 17 +++++--------- .../backend/MapWithAIObjectTest.java | 12 ++++------ .../backend/MapWithAIRemoteControlTest.java | 22 ++++++++----------- .../backend/MapWithAIUploadHookTest.java | 17 +++++++------- .../backend/MergeDuplicateWaysActionTest.java | 12 ++++------ .../commands/AddNodeToWayCommandTest.java | 9 ++------ .../commands/ConnectedCommandTest.java | 13 ++--------- .../CreateConnectionsCommandTest.java | 13 +++-------- .../commands/DuplicateCommandTest.java | 13 ++--------- .../commands/MapWithAIAddComandTest.java | 14 +++++------- .../commands/MergeBuildingAddressTest.java | 13 ++--------- .../commands/MergeDuplicateWaysTest.java | 10 ++------- .../MovePrimitiveDataSetCommandTest.java | 10 ++------- .../AlreadyConflatedCommandTest.java | 6 ++--- .../conflation/MergeAddressBuildingsTest.java | 14 +++++------- .../cleanup/MissingConnectionTagsTest.java | 13 +++++------ .../mapwithai/PreConflatedDataUtilsTest.java | 6 ++--- .../ConnectingNodeInformationTestTest.java | 13 ++--------- .../tests/RoutingIslandsTestTest.java | 17 +++++--------- .../tests/StreetAddressOrderTest.java | 9 ++------ .../validation/tests/StubEndsTestTest.java | 9 ++------ .../mapwithai/gui/MapWithAIMenuTest.java | 13 ++++++----- .../MapWithAIDownloadSourceTypeTest.java | 10 ++------- .../preferences/MapWithAIPreferencesTest.java | 10 ++------- .../mapwithai/AddMapWithAIPanelTest.java | 15 +++++-------- .../MapWithAIDefaultLayerTableModelTest.java | 10 +++------ .../MapWithAIProvidersPanelTest.java | 10 +++------ .../io/mapwithai/ESRISourceReaderTest.java | 8 ++----- .../mapwithai/MapWithAISourceReaderTest.java | 12 ++++------ .../testutils/annotations/Territories.java | 6 +++++ .../mapwithai/tools/BlacklistUtilsTest.java | 6 ----- .../mapwithai/tools/MapPaintUtilsTest.java | 8 ++----- .../tools/MapWithAICopyProhibitTest.java | 10 ++++----- 46 files changed, 180 insertions(+), 343 deletions(-) diff --git a/src/test/integration/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReaderTestIT.java b/src/test/integration/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReaderTestIT.java index 3830e228..872977fc 100644 --- a/src/test/integration/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReaderTestIT.java +++ b/src/test/integration/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReaderTestIT.java @@ -11,16 +11,14 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIType; import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Integration test for {@link MapWithAISourceReader} @@ -29,12 +27,10 @@ */ @NoExceptions @BasicPreferences +@Projection +@Territories @Wiremock class MapWithAISourceReaderTestIT { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - public JOSMTestRules rule = new JOSMTestRules().territories().projection(); - @Test @Wiremock(false) void testDefaultSourceIT() throws IOException { diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPluginTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPluginTest.java index 9d35c886..3f375719 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPluginTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPluginTest.java @@ -18,37 +18,32 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; import org.openstreetmap.josm.plugins.PluginInformation; import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAIPreferences; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils; import org.openstreetmap.josm.spi.preferences.Config; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.testutils.mockers.WindowMocker; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - /** * Test class for {@link MapWithAIPlugin} * * @author Taylor Smock */ -@NoExceptions @BasicPreferences -@Wiremock +@Main @MapWithAISources +@NoExceptions +@Projection +@Wiremock class MapWithAIPluginTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules test = new MapWithAITestRules().main().projection(); - PluginInformation info; MapWithAIPlugin plugin; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/UpdateProdTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/UpdateProdTest.java index 1beca13d..e115477f 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/UpdateProdTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/UpdateProdTest.java @@ -9,10 +9,9 @@ import java.awt.GraphicsEnvironment; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.spi.preferences.Config; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.AssumeRevision; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; import org.openstreetmap.josm.testutils.mockers.OpenBrowserMocker; import org.openstreetmap.josm.testutils.mockers.WindowMocker; @@ -22,11 +21,9 @@ * * @author Taylor Smock */ +@AssumeRevision("Revision: 15000\n") @BasicPreferences class UpdateProdTest { - @RegisterExtension - JOSMTestRules rules = new JOSMTestRules().assumeRevision("Revision: 15000\n"); - @Test void testDoProd() { TestUtils.assumeWorkingJMockit(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/actions/AddMapWithAILayerActionTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/actions/AddMapWithAILayerActionTest.java index 42f47910..d85cb449 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/actions/AddMapWithAILayerActionTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/actions/AddMapWithAILayerActionTest.java @@ -27,7 +27,6 @@ import org.awaitility.Awaitility; import org.awaitility.Durations; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.DataSource; import org.openstreetmap.josm.data.osm.DataSet; @@ -39,11 +38,10 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIType; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.ImageProvider; import org.openstreetmap.josm.tools.Logging; @@ -63,10 +61,8 @@ @NoExceptions @BasicPreferences @MapWithAISources +@Projection class AddMapWithAILayerActionTest { - @RegisterExtension - static JOSMTestRules rule = new MapWithAITestRules().projection(); - @Test void testAddMapWithAILayerActionTest() { MapWithAIInfo info = MapWithAILayerInfo.getInstance().getLayers().stream() diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DataConflationSenderTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DataConflationSenderTest.java index 9dfb2505..f0fdc93b 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DataConflationSenderTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DataConflationSenderTest.java @@ -11,7 +11,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.function.ThrowingSupplier; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -24,9 +23,9 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIConflationCategory; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; import org.openstreetmap.josm.testutils.annotations.BasicWiremock; +import org.openstreetmap.josm.testutils.annotations.HTTP; import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; @@ -43,13 +42,10 @@ * @author Taylor Smock */ @BasicPreferences +@HTTP @Wiremock @MapWithAISources class DataConflationSenderTest { - // Needed for HTTP factory - @RegisterExtension - JOSMTestRules josmTestRules = new JOSMTestRules(); - @BasicWiremock WireMockServer wireMockServer; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DetectTaskingManagerUtilsTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DetectTaskingManagerUtilsTest.java index bc8803f8..3cb41263 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DetectTaskingManagerUtilsTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DetectTaskingManagerUtilsTest.java @@ -8,7 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.gpx.GpxData; @@ -16,23 +15,20 @@ import org.openstreetmap.josm.data.osm.BBox; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.layer.GpxLayer; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * @author Taylor Smock * */ @BasicPreferences +@Main +@Projection class DetectTaskingManagerUtilsTest { private static final String LAYER_NAME = "Task Boundaries"; - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new JOSMTestRules().main().projection(); - @Test void testHasTaskingManagerLayer() { assertFalse(DetectTaskingManagerUtils.hasTaskingManagerLayer(), "No TM layer exists yet"); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DownloadListenerTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DownloadListenerTest.java index 308b0196..be5d471a 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DownloadListenerTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DownloadListenerTest.java @@ -12,20 +12,17 @@ import org.awaitility.Awaitility; import org.awaitility.Durations; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.DataSource; import org.openstreetmap.josm.data.osm.DataSet; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.layer.OsmDataLayer; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Test class for {@link DownloadListener} @@ -36,11 +33,9 @@ @NoExceptions @Wiremock @MapWithAISources +@Projection +@Territories class DownloadListenerTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rule = new MapWithAITestRules().projection().territories(); - @Test void testDataSourceChange() { DataSet ds = new DataSet(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DownloadMapWithAITaskTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DownloadMapWithAITaskTest.java index bd76807e..5d4cdb21 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DownloadMapWithAITaskTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DownloadMapWithAITaskTest.java @@ -18,9 +18,11 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Projection; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -28,10 +30,12 @@ @MapWithAISources @NoExceptions @Wiremock +@Territories +@Projection class DownloadMapWithAITaskTest { @RegisterExtension @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rule = new MapWithAITestRules().fakeAPI().projection().territories(); + JOSMTestRules rule = new MapWithAITestRules().fakeAPI(); @Test void testDownloadOsmServerReaderDownloadParamsBoundsProgressMonitor() diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnableTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnableTest.java index f7ccdac2..c6e8dd2e 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnableTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnableTest.java @@ -33,6 +33,7 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.Geometry; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -44,11 +45,12 @@ */ @NoExceptions @MapWithAISources +@Projection @Territories class GetDataRunnableTest { @RegisterExtension @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules rule = new MapWithAITestRules().projection().fakeAPI(); + static JOSMTestRules rule = new MapWithAITestRules().fakeAPI(); @Test void testAddMissingElement() { diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIActionTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIActionTest.java index 642604c5..30f09b7c 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIActionTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIActionTest.java @@ -13,7 +13,7 @@ import org.awaitility.Durations; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.Timeout; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.DataSource; import org.openstreetmap.josm.data.coor.LatLon; @@ -22,28 +22,26 @@ import org.openstreetmap.josm.gui.Notification; import org.openstreetmap.josm.gui.layer.Layer; import org.openstreetmap.josm.gui.layer.OsmDataLayer; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.Territories; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - /** * Test class for {@link MapWithAIAction} * * @author Taylor Smock */ -@NoExceptions @BasicPreferences +@Main @MapWithAISources +@NoExceptions +@Projection +@org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories +@Timeout(10) class MapWithAIActionTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new MapWithAITestRules().main().projection().territories().timeout(100000); - private MapWithAIAction action; @BeforeEach diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailabilityTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailabilityTest.java index 4cb786be..5e635134 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailabilityTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailabilityTest.java @@ -12,33 +12,26 @@ import org.awaitility.Durations; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.Territories; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - /** * Test class for testing availability * * @author Taylor Smock */ -@Wiremock @MapWithAISources +@Projection @org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories +@Wiremock class MapWithAIAvailabilityTest { private DataAvailability instance; - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new MapWithAITestRules().projection(); - @BeforeEach void setUp() { instance = DataAvailability.getInstance(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtilsTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtilsTest.java index f89495c4..b4ff9013 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtilsTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtilsTest.java @@ -34,9 +34,12 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.Logging; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -46,17 +49,20 @@ * * @author Taylor Smock */ -@NoExceptions @BasicPreferences -@Wiremock +@Main @MapWithAISources +@NoExceptions +@Projection +@Territories +@Wiremock public class MapWithAIDataUtilsTest { /** This is the default MapWithAI URL */ private static final String DEFAULT_MAPWITHAI_API = "https://www.mapwith.ai/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&bbox={bbox}"; @RegisterExtension @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules test = new MapWithAITestRules().main().projection().fakeAPI().territories(); + static JOSMTestRules test = new MapWithAITestRules().fakeAPI(); /** * This gets data from MapWithAI. This test may fail if someone adds the data to diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAILayerTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAILayerTest.java index 56741eb7..f1c2ce61 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAILayerTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAILayerTest.java @@ -48,12 +48,14 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAIPluginMock; import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils; import org.openstreetmap.josm.spi.preferences.Config; import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; -import org.openstreetmap.josm.tools.Territories; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -63,12 +65,15 @@ * @author Taylor Smock */ @BasicPreferences +@Main @MapWithAISources +@Projection +@Territories(Territories.Initialize.ALL) @Wiremock class MapWithAILayerTest { @RegisterExtension @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules test = new MapWithAITestRules().main().projection().fakeAPI().territories(); + static JOSMTestRules test = new MapWithAITestRules().main().fakeAPI(); MapWithAILayer layer; @@ -76,7 +81,6 @@ class MapWithAILayerTest { static void beforeAll() { TestUtils.assumeWorkingJMockit(); new MapWithAIPluginMock(); - Territories.initialize(); // Required to avoid an NPE (see JOSM-19132) } @BeforeEach @@ -234,6 +238,9 @@ void testGetData() { void testGetMenuEntries() { Layer layer = MapWithAIDataUtils.getLayer(true); await().atMost(Durations.ONE_SECOND).until(() -> MapWithAIDataUtils.getLayer(false) != null); + if (!MainApplication.getLayerManager().containsLayer(layer)) { + MainApplication.getLayerManager().addLayer(layer); + } Action[] actions = layer.getMenuEntries(); assertTrue(actions.length > 0); assertEquals(ContinuousDownloadAction.class, layer.getMenuEntries()[actions.length - 3].getClass()); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIMoveActionTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIMoveActionTest.java index 3388c22e..fe2826cd 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIMoveActionTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIMoveActionTest.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.DeleteCommand; import org.openstreetmap.josm.data.UndoRedoHandler; @@ -34,24 +33,26 @@ import org.openstreetmap.josm.plugins.mapwithai.commands.ConnectedCommand; import org.openstreetmap.josm.plugins.mapwithai.commands.DuplicateCommand; import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAIPluginMock; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.MissingConnectionTagsMocker; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.LoggingHandler; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; import org.openstreetmap.josm.spi.preferences.Config; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.testutils.mockers.WindowMocker; import org.openstreetmap.josm.tools.Logging; -import org.openstreetmap.josm.tools.Territories; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import mockit.Mock; import mockit.MockUp; +@AssertionsInEDT @BasicPreferences +@Main @Projection +@org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories(Territories.Initialize.ALL) @Wiremock class MapWithAIMoveActionTest { private MapWithAIMoveAction moveAction; @@ -62,15 +63,9 @@ class MapWithAIMoveActionTest { private Node way1LastNode; private Node way2LastNode; - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new MapWithAITestRules().main().territories().assertionsInEDT(); - @BeforeAll static void beforeAll() { new MapWithAIPluginMock(); - // TODO remove with @Territories annotation - Territories.initialize(); } @BeforeEach diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIObjectTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIObjectTest.java index d2f7b4b8..23cac151 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIObjectTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIObjectTest.java @@ -15,7 +15,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.JOSMFixture; import org.openstreetmap.josm.data.UndoRedoHandler; import org.openstreetmap.josm.data.coor.LatLon; @@ -25,21 +24,18 @@ import org.openstreetmap.josm.gui.MapStatus; import org.openstreetmap.josm.gui.layer.OsmDataLayer; import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * @author Taylor Smock * */ @BasicPreferences +@Main +@Projection class MapWithAIObjectTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rule = new JOSMTestRules().main().projection(); - private MapWithAIObject mapWithAIObject; private MapStatus statusLine; private OsmDataLayer osmData; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControlTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControlTest.java index 4157477b..9bf31d86 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControlTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControlTest.java @@ -12,40 +12,36 @@ import org.awaitility.Durations; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.osm.BBox; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException; import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; +import org.openstreetmap.josm.testutils.annotations.ThreadSync; import org.openstreetmap.josm.tools.Utils; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - /** * Test class for {@link MapWithAIRemoteControl} * * @author Taylor Smock */ -@NoExceptions @BasicPreferences +@Main @MapWithAISources +@NoExceptions +@Projection +@Territories +@ThreadSync @Wiremock class MapWithAIRemoteControlTest { - /** - * Setup test. - */ - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules test = new MapWithAITestRules().main().projection().territories(); - private static MapWithAIRemoteControl newHandler(String url) throws RequestHandlerBadRequestException { final MapWithAIRemoteControl req = new MapWithAIRemoteControl(); if (url != null) { diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHookTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHookTest.java index 84caf23a..b9a064e0 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHookTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHookTest.java @@ -17,7 +17,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.coor.LatLon; @@ -32,26 +31,26 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo; import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAIPluginMock; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Test class for {@link MapWithAIUploadHook} * * @author Taylor Smock */ -@MapWithAISources @BasicPreferences +@Main +@MapWithAISources +@Projection +@Territories @Wiremock class MapWithAIUploadHookTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules test = new MapWithAITestRules().main().projection().territories(); + private PluginInformation info; private MapWithAILayer aiLayer; private Way way1; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MergeDuplicateWaysActionTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MergeDuplicateWaysActionTest.java index 453e04ac..e1107f42 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MergeDuplicateWaysActionTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MergeDuplicateWaysActionTest.java @@ -11,7 +11,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.data.UndoRedoHandler; import org.openstreetmap.josm.data.coor.LatLon; @@ -20,20 +19,17 @@ import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.layer.OsmDataLayer; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * @author Taylor Smock */ @BasicPreferences +@Main +@Projection class MergeDuplicateWaysActionTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rules = new JOSMTestRules().projection().main(); - MergeDuplicateWaysAction action; @BeforeEach diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/AddNodeToWayCommandTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/AddNodeToWayCommandTest.java index 8dc42d8c..9e5bbf98 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/AddNodeToWayCommandTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/AddNodeToWayCommandTest.java @@ -10,7 +10,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.DataSet; @@ -18,18 +17,14 @@ import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command; -import org.openstreetmap.josm.testutils.JOSMTestRules; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; @Command +@Projection class AddNodeToWayCommandTest { private Node toAdd; private Way way; private AddNodeToWayCommand command; - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new JOSMTestRules().projection(); @BeforeEach void setupArea() { diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/ConnectedCommandTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/ConnectedCommandTest.java index 29033454..35cc9b68 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/ConnectedCommandTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/ConnectedCommandTest.java @@ -9,7 +9,6 @@ import java.util.Collections; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.data.coor.LatLon; @@ -18,22 +17,14 @@ import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; -import org.openstreetmap.josm.testutils.JOSMTestRules; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Test class for {@link ConnectedCommand} */ @NoExceptions +@Projection class ConnectedCommandTest { - /** - * Setup test. - */ - @RegisterExtension - @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules rule = new JOSMTestRules().projection(); - @Test void testVariousConditions() { DataSet ds = new DataSet(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommandTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommandTest.java index cdaebcdc..652b138d 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommandTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommandTest.java @@ -13,7 +13,6 @@ import java.util.Objects; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.command.DeleteCommand; @@ -26,27 +25,21 @@ import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.layer.OsmDataLayer; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.LoggingHandler; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Tests for {@link CreateConnectionsCommand} * * @author Taylor Smock */ +@org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command @MapWithAISources +@Projection @Wiremock -@org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command class CreateConnectionsCommandTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules test = new MapWithAITestRules().projection(); - /** * Test method for * {@link CreateConnectionsCommand#createConnections(DataSet, Collection)}. diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/DuplicateCommandTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/DuplicateCommandTest.java index 89755c87..9c602785 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/DuplicateCommandTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/DuplicateCommandTest.java @@ -8,24 +8,15 @@ import java.util.Collections; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.command.DeleteCommand; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.DataSet; import org.openstreetmap.josm.data.osm.Node; -import org.openstreetmap.josm.testutils.JOSMTestRules; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; +@Projection class DuplicateCommandTest { - /** - * Setup test. - */ - @RegisterExtension - @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rule = new JOSMTestRules().projection(); - @Test void testVariousConditions() { DataSet ds = new DataSet(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddComandTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddComandTest.java index 04ce425c..d6d653b9 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddComandTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddComandTest.java @@ -20,7 +20,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.actions.SaveActionBase; import org.openstreetmap.josm.command.MoveCommand; @@ -35,7 +34,6 @@ import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.layer.OsmDataLayer; import org.openstreetmap.josm.gui.progress.NullProgressMonitor; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.MissingConnectionTagsMocker; import org.openstreetmap.josm.plugins.mapwithai.testutils.PleaseWaitDialogMocker; import org.openstreetmap.josm.plugins.mapwithai.testutils.SwingUtilitiesMocker; @@ -43,12 +41,13 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.testutils.mockers.WindowMocker; import org.openstreetmap.josm.tools.Logging; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import mockit.Mock; /** @@ -56,17 +55,16 @@ * * @author Taylor Smock */ +@AssertionsInEDT @BasicPreferences @Command +@Main @MapWithAISources +@Projection @Wiremock class MapWithAIAddComandTest { private final static String HIGHWAY_RESIDENTIAL = "highway=residential"; - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules test = new MapWithAITestRules().projection().assertionsInEDT().main(); - @BeforeEach void setUp() { // Required to avoid an NPE with AutoZoomHandler diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MergeBuildingAddressTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MergeBuildingAddressTest.java index 859f98b6..ac2fb9bf 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MergeBuildingAddressTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MergeBuildingAddressTest.java @@ -11,7 +11,6 @@ import java.util.Collections; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.command.DeleteCommand; @@ -21,21 +20,13 @@ import org.openstreetmap.josm.data.osm.Relation; import org.openstreetmap.josm.data.osm.RelationMember; import org.openstreetmap.josm.data.osm.Way; -import org.openstreetmap.josm.testutils.JOSMTestRules; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Test class for {@link MergeBuildingAddress} */ +@Projection class MergeBuildingAddressTest { - /** - * Setup test. - */ - @RegisterExtension - @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules rule = new JOSMTestRules().projection(); - @Test void testSingleAddress() { DataSet ds = new DataSet(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWaysTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWaysTest.java index 9e630dd7..b0cf4e34 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWaysTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWaysTest.java @@ -22,7 +22,6 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.data.coor.LatLon; @@ -30,20 +29,15 @@ import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.plugins.mapwithai.backend.GetDataRunnable; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.Pair; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - /** * @author Taylor Smock */ @org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command +@Projection class MergeDuplicateWaysTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new JOSMTestRules().projection(); - /** * Test method for {@link MergeDuplicateWays#removeCommonTags}. */ diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MovePrimitiveDataSetCommandTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MovePrimitiveDataSetCommandTest.java index 25c9baed..3338a487 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MovePrimitiveDataSetCommandTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MovePrimitiveDataSetCommandTest.java @@ -14,7 +14,6 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.MoveCommand; import org.openstreetmap.josm.data.UndoRedoHandler; @@ -24,16 +23,11 @@ import org.openstreetmap.josm.data.osm.OsmPrimitive; import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command; -import org.openstreetmap.josm.testutils.JOSMTestRules; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; @Command +@Projection class MovePrimitiveDataSetCommandTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new JOSMTestRules().projection(); - @Test void testMovePrimitives() { final Collection added = new ArrayList<>(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/AlreadyConflatedCommandTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/AlreadyConflatedCommandTest.java index ab4dd891..49df6305 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/AlreadyConflatedCommandTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/AlreadyConflatedCommandTest.java @@ -10,7 +10,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.data.coor.LatLon; @@ -21,12 +20,11 @@ import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.plugins.mapwithai.commands.AlreadyConflatedCommand; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.PreConflatedDataUtils; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.Projection; @org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command +@Projection class AlreadyConflatedCommandTest { - @RegisterExtension - JOSMTestRules rule = new JOSMTestRules().projection(); private AlreadyConflatedCommand alreadyConflatedCommand; @BeforeEach diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/MergeAddressBuildingsTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/MergeAddressBuildingsTest.java index d6067aa6..dc8984d4 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/MergeAddressBuildingsTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/MergeAddressBuildingsTest.java @@ -11,7 +11,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.command.DeleteCommand; @@ -25,18 +24,15 @@ import org.openstreetmap.josm.gui.layer.OsmDataLayer; import org.openstreetmap.josm.plugins.mapwithai.commands.MergeAddressBuildings; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.LoggingHandler; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - -@org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command @BasicPreferences +@org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command +@Main +@Projection class MergeAddressBuildingsTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules test = new JOSMTestRules().projection().main(); - private MergeAddressBuildings command; private DataSet ds; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/cleanup/MissingConnectionTagsTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/cleanup/MissingConnectionTagsTest.java index c0078632..9ff38a4b 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/cleanup/MissingConnectionTagsTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/cleanup/MissingConnectionTagsTest.java @@ -14,7 +14,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.command.Command; import org.openstreetmap.josm.data.coor.LatLon; @@ -28,24 +27,22 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.MissingConnectionTagsMocker; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.WoundedTest; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.testutils.mockers.WindowMocker; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - /** * Test class for {@link MissingConnectionTags} * * @author Taylor Smock */ -@NoExceptions @BasicPreferences @org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command +@Main +@NoExceptions +@Projection class MissingConnectionTagsTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules josmTestRules = new JOSMTestRules().projection().main(); private DataSet ds; private MissingConnectionTags missing; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/PreConflatedDataUtilsTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/PreConflatedDataUtilsTest.java index d23eff31..1952087b 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/PreConflatedDataUtilsTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/PreConflatedDataUtilsTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.DataSet; @@ -14,8 +13,8 @@ import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils; import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer; import org.openstreetmap.josm.spi.preferences.Config; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Test case for {@link PreConflatedDataUtils} @@ -24,9 +23,8 @@ * */ @BasicPreferences +@Projection class PreConflatedDataUtilsTest { - @RegisterExtension - JOSMTestRules rules = new JOSMTestRules().projection(); private DataSet ds; @BeforeEach diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/ConnectingNodeInformationTestTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/ConnectingNodeInformationTestTest.java index 1bc0f8ec..13f183d4 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/ConnectingNodeInformationTestTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/ConnectingNodeInformationTestTest.java @@ -6,7 +6,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.DataSet; @@ -15,18 +14,10 @@ import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.plugins.mapwithai.commands.ConnectedCommand; import org.openstreetmap.josm.plugins.mapwithai.commands.DuplicateCommand; -import org.openstreetmap.josm.testutils.JOSMTestRules; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; +@Projection class ConnectingNodeInformationTestTest { - /** - * Setup test. - */ - @RegisterExtension - @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rule = new JOSMTestRules().projection(); - @Test void testGetBadData() { DataSet ds = new DataSet(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/RoutingIslandsTestTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/RoutingIslandsTestTest.java index ee988a2b..8f5c9d37 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/RoutingIslandsTestTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/RoutingIslandsTestTest.java @@ -16,7 +16,7 @@ import java.util.stream.DoubleStream; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.Timeout; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.openstreetmap.josm.TestUtils; @@ -35,10 +35,8 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions; import org.openstreetmap.josm.plugins.mapwithai.tools.Access; import org.openstreetmap.josm.spi.preferences.Config; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Test class for {@link RoutingIslandsTest} @@ -46,17 +44,12 @@ * @author Taylor Smock * @since xxx */ -@NoExceptions @BasicPreferences +@NoExceptions @MapWithAISources +@Projection +@Timeout(30) class RoutingIslandsTestTest { - /** - * Setup test. - */ - @RegisterExtension - @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - static JOSMTestRules rule = new JOSMTestRules().projection().timeout(30000); - /** * Test method for {@link RoutingIslandsTest#RoutingIslandsTest()} and the * testing apparatus diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StreetAddressOrderTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StreetAddressOrderTest.java index 89906126..6dc505f6 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StreetAddressOrderTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StreetAddressOrderTest.java @@ -14,7 +14,6 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.data.coor.EastNorth; import org.openstreetmap.josm.data.coor.LatLon; @@ -27,16 +26,12 @@ import org.openstreetmap.josm.data.osm.Relation; import org.openstreetmap.josm.data.osm.RelationMember; import org.openstreetmap.josm.data.osm.Way; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.Geometry; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - +@Projection class StreetAddressOrderTest { private static final String ADDR_STREET = "addr:street"; - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new JOSMTestRules().projection(); @Test void testVisitWay() { diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StubEndsTestTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StubEndsTestTest.java index f9639dcb..dd2a3eb7 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StubEndsTestTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/data/validation/tests/StubEndsTestTest.java @@ -11,21 +11,16 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.data.coor.LatLon; import org.openstreetmap.josm.data.osm.DataSet; import org.openstreetmap.josm.data.osm.Node; import org.openstreetmap.josm.data.osm.Way; import org.openstreetmap.josm.gui.progress.NullProgressMonitor; -import org.openstreetmap.josm.testutils.JOSMTestRules; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; +@Projection class StubEndsTestTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new JOSMTestRules().projection(); private Way nonStaticWay; private Way staticWay; private StubEndsTest tester; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/MapWithAIMenuTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/MapWithAIMenuTest.java index 7175b27b..fc3bae93 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/MapWithAIMenuTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/MapWithAIMenuTest.java @@ -12,7 +12,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.actions.AutoScaleAction; import org.openstreetmap.josm.data.coor.LatLon; @@ -21,11 +20,12 @@ import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.gui.layer.OsmDataLayer; import org.openstreetmap.josm.plugins.mapwithai.actions.AddMapWithAILayerAction; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.Logging; /** @@ -35,11 +35,12 @@ * */ @BasicPreferences -@Wiremock +@Main @MapWithAISources +@Projection +@Territories +@Wiremock class MapWithAIMenuTest { - @RegisterExtension - static JOSMTestRules rule = new MapWithAITestRules().territories().projection().main(); private static MapWithAIMenu menu; @BeforeAll diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/download/MapWithAIDownloadSourceTypeTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/download/MapWithAIDownloadSourceTypeTest.java index 3ac7a00b..487e9051 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/download/MapWithAIDownloadSourceTypeTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/download/MapWithAIDownloadSourceTypeTest.java @@ -11,24 +11,18 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtilsTest; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Projection; @BasicPreferences +@Projection @Territories @Wiremock class MapWithAIDownloadSourceTypeTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rules = new JOSMTestRules().projection(); - /** * Check that we are appropriately checking that downloads are the correct size */ diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/MapWithAIPreferencesTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/MapWithAIPreferencesTest.java index d520c58f..06b1235c 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/MapWithAIPreferencesTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/MapWithAIPreferencesTest.java @@ -13,15 +13,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIPreferenceHelper; import org.openstreetmap.josm.plugins.mapwithai.testutils.ImageProviderMocker; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; - -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.openstreetmap.josm.testutils.annotations.Main; /** * Test class for {@link MapWithAIPreferences} @@ -29,12 +26,9 @@ * @author Taylor Smock */ @BasicPreferences +@Main @MapWithAISources class MapWithAIPreferencesTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules test = new JOSMTestRules().main(); - private MapWithAIPreferences preferences; /** diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/AddMapWithAIPanelTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/AddMapWithAIPanelTest.java index 0343530b..60496068 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/AddMapWithAIPanelTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/AddMapWithAIPanelTest.java @@ -10,30 +10,27 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.gui.widgets.JosmTextArea; import org.openstreetmap.josm.gui.widgets.JosmTextField; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.testutils.mockers.WindowMocker; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - /** * Test class for {@link AddMapWithAIPanel} * * @author Taylor Smock */ +@AssertionsInEDT @MapWithAISources +@Projection +@Territories @Wiremock class AddMapWithAIPanelTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rule = new MapWithAITestRules().territories().projection().assertionsInEDT(); - @Test void testAddMapWithAIPanel() throws ReflectiveOperationException { new WindowMocker(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/MapWithAIDefaultLayerTableModelTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/MapWithAIDefaultLayerTableModelTest.java index a1aa3c6e..a8849390 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/MapWithAIDefaultLayerTableModelTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/MapWithAIDefaultLayerTableModelTest.java @@ -12,25 +12,21 @@ import java.util.stream.IntStream; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.Projection; /** * Test class for {@link MapWithAIDefaultLayerTableModel} * * @author Taylor Smock */ -@Wiremock @MapWithAISources +@Projection +@Wiremock class MapWithAIDefaultLayerTableModelTest { - @RegisterExtension - JOSMTestRules rule = new MapWithAITestRules().projection(); - @Test void testGetRow() { List infos = MapWithAILayerInfo.getInstance().getAllDefaultLayers(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/MapWithAIProvidersPanelTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/MapWithAIProvidersPanelTest.java index adb4a6f0..559e9a00 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/MapWithAIProvidersPanelTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/gui/preferences/mapwithai/MapWithAIProvidersPanelTest.java @@ -15,15 +15,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo; import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.mapwithai.MapWithAIProvidersPanel.AreaListener; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.ListenerList; /** @@ -31,12 +29,10 @@ * * @author Taylor Smock */ -@Wiremock @MapWithAISources +@Projection +@Wiremock class MapWithAIProvidersPanelTest { - @RegisterExtension - JOSMTestRules rule = new MapWithAITestRules().projection(); - private MapWithAIProvidersPanel mapwithaiProvidersPanel; @BeforeEach diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/ESRISourceReaderTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/ESRISourceReaderTest.java index 424a9321..5d073546 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/ESRISourceReaderTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/ESRISourceReaderTest.java @@ -17,27 +17,23 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.gui.MainApplication; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIType; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicWiremock; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.tools.JosmRuntimeException; import com.github.tomakehurst.wiremock.WireMockServer; +@Projection @Wiremock class ESRISourceReaderTest { @BasicWiremock public WireMockServer wireMockServer; - @RegisterExtension - JOSMTestRules rule = new MapWithAITestRules().projection(); - @BeforeEach void setUp() { ESRISourceReader.SOURCE_CACHE.clear(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReaderTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReaderTest.java index 134411a0..1aaf7d2a 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReaderTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/io/mapwithai/MapWithAISourceReaderTest.java @@ -13,21 +13,17 @@ import java.util.List; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo; -import org.openstreetmap.josm.testutils.JOSMTestRules; +import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Territories; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Projection; import com.google.common.collect.ImmutableMap; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - @BasicPreferences +@Territories +@Projection class MapWithAISourceReaderTest { - @RegisterExtension - @SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") - JOSMTestRules rule = new JOSMTestRules().territories().projection(); - @Test void testParseSimple() { JsonObjectBuilder builder = Json.createObjectBuilder(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/testutils/annotations/Territories.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/testutils/annotations/Territories.java index 2ea0b73b..6229715e 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/testutils/annotations/Territories.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/testutils/annotations/Territories.java @@ -60,6 +60,8 @@ enum Initialize { * */ class TerritoriesExtension implements BeforeAllCallback, AfterAllCallback { + private static Initialize last = Initialize.NONE; + @Override public void afterAll(ExtensionContext context) throws Exception { synchronized (TerritoriesExtension.class) { @@ -74,6 +76,10 @@ public void beforeAll(ExtensionContext context) throws Exception { Territories.class); if (annotation.isPresent()) { Initialize current = annotation.get().value(); + if (current.ordinal() <= last.ordinal()) { + return; + } + last = current; // Avoid potential race conditions if tests are parallelized synchronized (TerritoriesExtension.class) { if (current == Initialize.INTERNAL) { diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/BlacklistUtilsTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/BlacklistUtilsTest.java index 8222221f..92c57ebc 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/BlacklistUtilsTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/BlacklistUtilsTest.java @@ -14,11 +14,9 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin; import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAIPluginMock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import com.github.tomakehurst.wiremock.WireMockServer; @@ -29,10 +27,6 @@ * */ class BlacklistUtilsTest { - - @RegisterExtension - static JOSMTestRules rules = new JOSMTestRules(); - private static WireMockServer wireMock; @BeforeAll diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/MapPaintUtilsTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/MapPaintUtilsTest.java index bef11e01..b9bfeefc 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/MapPaintUtilsTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/MapPaintUtilsTest.java @@ -11,7 +11,6 @@ import org.awaitility.Durations; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.data.osm.DataSet; import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; @@ -19,17 +18,14 @@ import org.openstreetmap.josm.gui.mappaint.StyleSource; import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; import org.openstreetmap.josm.io.CachedFile; -import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules; import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Projection; @BasicPreferences +@Projection @Wiremock class MapPaintUtilsTest { - @RegisterExtension - JOSMTestRules rule = new MapWithAITestRules().projection(); - @Test void testAddPaintStyle() { MapPaintUtils.removeMapWithAIPaintStyles(); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/MapWithAICopyProhibitTest.java b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/MapWithAICopyProhibitTest.java index 4ce7e477..284f5dfe 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/MapWithAICopyProhibitTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/mapwithai/tools/MapWithAICopyProhibitTest.java @@ -13,7 +13,6 @@ import java.util.logging.LogRecord; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; import org.openstreetmap.josm.TestUtils; import org.openstreetmap.josm.actions.CopyAction; import org.openstreetmap.josm.actions.PasteAction; @@ -25,8 +24,9 @@ import org.openstreetmap.josm.gui.layer.MainLayerManager; import org.openstreetmap.josm.gui.layer.OsmDataLayer; import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer; -import org.openstreetmap.josm.testutils.JOSMTestRules; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; +import org.openstreetmap.josm.testutils.annotations.Projection; import org.openstreetmap.josm.testutils.mockers.WindowMocker; import org.openstreetmap.josm.tools.Logging; @@ -39,6 +39,8 @@ * @author Taylor Smock */ @BasicPreferences +@Main +@Projection class MapWithAICopyProhibitTest { private static class BlacklistUtilsMock extends MockUp { @Mock @@ -47,10 +49,6 @@ public static boolean isBlacklisted() { } } - // preferences for nodes, main for actions, projection for mapview - @RegisterExtension - JOSMTestRules josmTestRules = new JOSMTestRules().main().projection(); - @Test void testDestroyable() { MapWithAICopyProhibit mapWithAICopyProhibit = new MapWithAICopyProhibit();