Skip to content

Commit

Permalink
Update tests to avoid JOSMTestRules
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Nov 2, 2023
1 parent 9d196a0 commit 1e5815c
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,16 @@
import java.util.Date;
import java.util.stream.Stream;

import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import org.openstreetmap.josm.plugins.datepicker.IDatePicker;
import org.openstreetmap.josm.testutils.JOSMTestRules;

/**
* Test method for date implementations.
* The {@link #getDatePickers} method should be updated when new date pickers are implemented.
*/
class GenericDateImplementationTest {
@RegisterExtension
static JOSMTestRules rules = new JOSMTestRules();

static Stream<Arguments> getDatePickers() {
Calendar minCalendar = Calendar.getInstance();
minCalendar.setTime(new Date(Long.MIN_VALUE));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.mapillary;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -7,7 +8,6 @@
import javax.swing.JPopupMenu;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.openstreetmap.josm.data.coor.LatLon;
Expand All @@ -26,24 +26,25 @@
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryImageUtils;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryKeys;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryMapFeatureUtils;
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.Main;
import org.openstreetmap.josm.testutils.annotations.Projection;

/**
* Test class for {@link MapillaryKeyListener}
*
* @author Taylor Smock
*/
@BasicPreferences
@BasicWiremock // TODO remove when it is inheritable (see #21139)
@MapillaryURLWireMock
@BasicWiremock
@Main
@MapillaryLayerAnnotation
@MapillaryURLWireMock
@Projection
class MapillaryKeyListenerTest {
/** This is the JOSM standard component count. Update as needed. */
private static final int TAG_MENU_COMPONENT_COUNT = 15;
@RegisterExtension
static JOSMTestRules josmTestRules = new JOSMTestRules().main().projection();

@Test
void testListenerNoSpuriousActions() throws ReflectiveOperationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
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.mapillary.gui.layer.PointObjectLayer;
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryURLWireMock;
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryURLWireMockErrors;
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;

@BasicPreferences
@Main
@MapillaryURLWireMock
@Projection
class MapObjectLayerActionTest {

@RegisterExtension
static JOSMTestRules rules = new JOSMTestRules().main().projection();

@Test
@MapillaryURLWireMockErrors
void testAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,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.TestUtils;
import org.openstreetmap.josm.data.cache.ICachedLoaderListener;
import org.openstreetmap.josm.data.coor.LatLon;
Expand All @@ -34,19 +33,18 @@
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryURLWireMockErrors;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryImageUtils;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillarySequenceUtils;
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;

@AwaitThreadFinish
@BasicPreferences
@Main
@MapillaryCaches
@MapillaryURLWireMock
@Projection
class MapillaryCacheTest {

@RegisterExtension
static JOSMTestRules rules = new JOSMTestRules().main().projection();

@Test
void test() throws ExecutionException, InterruptedException, TimeoutException {
// Use 135511895288847 since that is an image we have real information for
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.mapillary.data.mapillary;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -9,24 +10,23 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.command.Command;
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.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.AssumeRevision;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.annotations.Projection;

/**
* Test class for {@link AdditionalInstructions}
*
* @author Taylor Smock
*/
@BasicPreferences
@Projection
class AdditionalInstructionsTest {
@RegisterExtension
static JOSMTestRules josmTestRules = new JOSMTestRules().projection();
private DataSet dataSet;

@BeforeEach
Expand Down Expand Up @@ -55,13 +55,13 @@ void testApplyNull() {
assertNull(this.snapToRoad.apply(node));
}

@JOSMTestRules.OverrideAssumeRevision("18108\n")
@AssumeRevision("18108\n")
@Test
void testApplyHighway() {
this.applyHighwayCommon();
}

@JOSMTestRules.OverrideAssumeRevision("18109\n")
@AssumeRevision("18109\n")
@Test
void testApplyHighway18109() {
this.applyHighwayCommon();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,22 @@

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.openstreetmap.josm.actions.ExpertToggleAction;
import org.openstreetmap.josm.plugins.mapillary.gui.DeveloperToggleAction;
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.ObjectDetectionsAnnotation;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.annotations.TaggingPresets;

/**
* Test class for {@link ObjectDetections}
*/
@BasicPreferences
@ObjectDetectionsAnnotation
@TaggingPresets
class ObjectDetectionsTest {
@RegisterExtension
static JOSMTestRules rule = new JOSMTestRules().presets();
static Field osmKey;

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.openstreetmap.josm.data.Bounds;
Expand Down Expand Up @@ -52,15 +51,16 @@
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryKeys;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryMapFeatureUtils;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryProperties;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.Main;
import org.openstreetmap.josm.testutils.annotations.Projection;

/**
* Test class for {@link DataMouseListener}
*/
@Main
@MapillaryURLWireMock
@Projection
class DataMouseListenerTest {
@RegisterExtension
static JOSMTestRules josmTestRules = new JOSMTestRules().main().projection();

private DataMouseListener dataMouseListener;
private OsmDataLayer osmDataLayer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -34,16 +33,13 @@
import org.openstreetmap.josm.data.preferences.StringProperty;
import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryProperties;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.annotations.Main;
import org.openstreetmap.josm.tools.I18n;

@BasicPreferences
@Main
class MapillaryPreferenceSettingTest {

@RegisterExtension
static JOSMTestRules rules = new JOSMTestRules().main();

@Test
void testAddGui() {
PreferenceTabbedPane tabs = new PreferenceTabbedPane();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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.gui.jmapviewer.interfaces.TileSource;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.imagery.ImageryInfo;
Expand All @@ -40,18 +39,17 @@
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryURLWireMockErrors;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryImageUtils;
import org.openstreetmap.josm.plugins.mapillary.utils.api.JsonImageDetailsDecoderTest;
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;

@BasicPreferences
@Main
@MapillaryLayerAnnotation
@MapillaryURLWireMock
@MapillaryURLWireMockErrors
@Projection
class MapillaryLayerTest {

@RegisterExtension
static JOSMTestRules rules = new JOSMTestRules().main().projection();

private static Layer getDummyLayer() {
return ImageryLayer.create(new ImageryInfo("dummy", "https://example.org"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
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.junit.jupiter.api.Timeout;
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.mapillary.testutils.annotations.AwaitThreadFinish;
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryLayerAnnotation;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryKeys;
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.ImageProvider.ImageSizes;

@BasicPreferences
@AwaitThreadFinish
@BasicPreferences
@Main
@MapillaryLayerAnnotation
@Projection
@Timeout(20)
class PointObjectLayerTest {

@RegisterExtension
static JOSMTestRules rules = new JOSMTestRules().timeout(20000).projection().main();

private PointObjectLayer instance;

private static WireMockServer wmRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand All @@ -30,8 +29,9 @@
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryLayerAnnotation;
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryURLWireMock;
import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryImageUtils;
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;

/**
* Test class for {@link MapillaryRemoteControl}
Expand All @@ -40,13 +40,11 @@
*/
@AwaitThreadFinish
@BasicPreferences
@MapillaryURLWireMock
@Main
@MapillaryLayerAnnotation
@MapillaryURLWireMock
@Projection
class MapillaryRemoteControlTest {
// Needed for layer clearing. And Main.
@RegisterExtension
static JOSMTestRules josmTestRules = new JOSMTestRules().main().projection();

@Test
void testGetMandatoryParams() {
assertEquals(0, new MapillaryRemoteControl().getMandatoryParams().length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,16 @@
import java.util.stream.Stream;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.openstreetmap.josm.plugins.mapillary.data.mapillary.ObjectDetections;
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryCaches;
import org.openstreetmap.josm.plugins.mapillary.testutils.annotations.MapillaryURLWireMock;
import org.openstreetmap.josm.testutils.JOSMTestRules;

@MapillaryURLWireMock
@MapillaryCaches
class ImageDetectionTest {
@RegisterExtension
static JOSMTestRules josmTestRules = new JOSMTestRules();

@Test
void testBasics() {
ImageDetection<Path2D.Double> id = new ImageDetection<>(new Path2D.Double(), 1, 2, "value");
Expand Down
Loading

0 comments on commit 1e5815c

Please sign in to comment.