diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/actions/IgnoreAction.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/actions/IgnoreAction.java index d2a0132..09dbd07 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/actions/IgnoreAction.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/actions/IgnoreAction.java @@ -38,7 +38,8 @@ public class IgnoreAction extends JosmAction { */ public IgnoreAction(IgnoreType type) { super(tr(type.getButtonText()), "dialogs/fix", tr(type.getButtonText()), - Shortcut.registerShortcut(/* NO-SHORTCUT */ "maproulette:ignore." + type.name().toLowerCase(Locale.ROOT), + Shortcut.registerShortcut( + /* NO-SHORTCUT */ "maproulette:ignore." + type.name().toLowerCase(Locale.ROOT), tr("MapRoulette: {0}", tr(type.getButtonText())), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false); this.type = type; diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/model/RecordUtils.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/model/RecordUtils.java index c3486bd..3cc1fb7 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/model/RecordUtils.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/model/RecordUtils.java @@ -30,8 +30,8 @@ static boolean equals(@Nonnull T first, @Nonnull T second) { final var type = component.getType(); final var firstObj = getField(first, component); final var secondObj = getField(second, component); - if ((type.isArray() && !arrayEquals(type, firstObj, secondObj)) || - (!type.isArray() && !Objects.equals(firstObj, secondObj))) { + if ((type.isArray() && !arrayEquals(type, firstObj, secondObj)) + || (!type.isArray() && !Objects.equals(firstObj, secondObj))) { return false; } } diff --git a/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/parsers/UserParser.java b/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/parsers/UserParser.java index d822c0d..f379a67 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/parsers/UserParser.java +++ b/src/main/java/org/openstreetmap/josm/plugins/maproulette/api/parsers/UserParser.java @@ -11,7 +11,8 @@ * A parser for user objects */ final class UserParser { - private UserParser() { /* Hide constructor */ } + private UserParser() { + /* Hide constructor */ } /** * Parse a {@link PointReview} object diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/TaskListPanelTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/TaskListPanelTest.java index 46c5fc2..e59a7d4 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/TaskListPanelTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/TaskListPanelTest.java @@ -11,8 +11,6 @@ import javax.swing.JMenuItem; import javax.swing.JTable; -import mockit.Mock; -import mockit.MockUp; import org.junit.jupiter.api.Test; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.osm.DataSet; @@ -22,10 +20,13 @@ import org.openstreetmap.josm.plugins.maproulette.actions.IgnoreAction; import org.openstreetmap.josm.plugins.maproulette.gui.task.list.TaskListPanel; import org.openstreetmap.josm.plugins.maproulette.util.LoggingHandler; -import org.openstreetmap.josm.plugins.maproulette.util.Main; import org.openstreetmap.josm.plugins.maproulette.util.MapRouletteConfig; +import org.openstreetmap.josm.testutils.annotations.Main; import org.openstreetmap.josm.testutils.annotations.Projection; +import mockit.Mock; +import mockit.MockUp; + /** * Test class for {@link TaskListPanel} */ diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/layer/MapRouletteClusteredPointLayerTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/layer/MapRouletteClusteredPointLayerTest.java index 49760c8..8b3f226 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/layer/MapRouletteClusteredPointLayerTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/layer/MapRouletteClusteredPointLayerTest.java @@ -9,8 +9,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import mockit.Mock; -import mockit.MockUp; import org.junit.jupiter.api.Test; import org.openstreetmap.josm.data.Bounds; import org.openstreetmap.josm.data.coor.LatLon; @@ -20,13 +18,16 @@ import org.openstreetmap.josm.gui.layer.OsmDataLayer; import org.openstreetmap.josm.plugins.maproulette.actions.IgnoreAction; import org.openstreetmap.josm.plugins.maproulette.api.model.Identifier; -import org.openstreetmap.josm.plugins.maproulette.gui.task.list.TaskListPanel; import org.openstreetmap.josm.plugins.maproulette.gui.TaskListPanelTest; -import org.openstreetmap.josm.plugins.maproulette.util.Main; +import org.openstreetmap.josm.plugins.maproulette.gui.task.list.TaskListPanel; import org.openstreetmap.josm.plugins.maproulette.util.MapRouletteConfig; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; import org.openstreetmap.josm.testutils.annotations.Projection; +import mockit.Mock; +import mockit.MockUp; + /** * Test class for {@link MapRouletteClusteredPointLayer} */ diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/io/upload/EarlyUploadHookTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/io/upload/EarlyUploadHookTest.java index 1bc61b8..aaef8bf 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/io/upload/EarlyUploadHookTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/io/upload/EarlyUploadHookTest.java @@ -34,10 +34,10 @@ import org.openstreetmap.josm.plugins.maproulette.gui.ModifiedObjects; import org.openstreetmap.josm.plugins.maproulette.gui.ModifiedTask; import org.openstreetmap.josm.plugins.maproulette.gui.layer.MapRouletteClusteredPointLayer; -import org.openstreetmap.josm.plugins.maproulette.util.Main; import org.openstreetmap.josm.plugins.maproulette.util.MapRouletteConfig; import org.openstreetmap.josm.spi.preferences.Config; import org.openstreetmap.josm.testutils.annotations.BasicPreferences; +import org.openstreetmap.josm.testutils.annotations.Main; import org.openstreetmap.josm.testutils.annotations.Projection; /** diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/Main.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/Main.java deleted file mode 100644 index a763e40..0000000 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/Main.java +++ /dev/null @@ -1,84 +0,0 @@ -// License: GPL. For details, see LICENSE file. -package org.openstreetmap.josm.plugins.maproulette.util; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.api.extension.BeforeEachCallback; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.openstreetmap.josm.JOSMFixture; -import org.openstreetmap.josm.TestUtils; -import org.openstreetmap.josm.gui.MainApplication; -import org.openstreetmap.josm.testutils.annotations.HTTP; -import org.openstreetmap.josm.testutils.annotations.LayerManager; -import org.openstreetmap.josm.testutils.mockers.WindowlessMapViewStateMocker; -import org.openstreetmap.josm.testutils.mockers.WindowlessNavigatableComponentMocker; - -/** - * The annotation for mocking map view and navigable components - * TODO Put this in JOSM core - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@HTTP -@LayerManager -@ExtendWith(Main.Extension.class) -public @interface Main { - /** - * If a specific mocker is required, use {@link org.junit.jupiter.api.extension.RegisterExtension}. - */ - class Extension implements BeforeEachCallback { - /** - * The mocker for the map view state - */ - private Runnable mapViewStateMockingRunnable = WindowlessMapViewStateMocker::new; - /** - * The mocker for navigable components - */ - private Runnable navigableComponentMockingRunnable = WindowlessNavigatableComponentMocker::new; - - /** - * Set the specific map view mocker - * - * @param mapViewStateMockingRunnable The new mocker - * @return this, for easy chaining - */ - public Extension setMapViewMocker(Runnable mapViewStateMockingRunnable) { - this.mapViewStateMockingRunnable = mapViewStateMockingRunnable; - return this; - } - - /** - * Set the navigable component mocker - * - * @param navigableComponentMockingRunnable The new mocker - * @return this, for easy chaining - */ - public Extension setNavigableComponentMocker(Runnable navigableComponentMockingRunnable) { - this.navigableComponentMockingRunnable = navigableComponentMockingRunnable; - return this; - } - - @Override - public void beforeEach(ExtensionContext context) { - TestUtils.assumeWorkingJMockit(); - // apply mockers to MapViewState and NavigableComponent whether we're headless or not - // as we generally don't create the josm main window even in non-headless mode. - if (this.mapViewStateMockingRunnable != null) { - this.mapViewStateMockingRunnable.run(); - } - if (this.navigableComponentMockingRunnable != null) { - this.navigableComponentMockingRunnable.run(); - } - - new MainApplication(); - JOSMFixture.initContentPane(); - JOSMFixture.initMainPanel(true); - JOSMFixture.initToolbar(); - JOSMFixture.initMainMenu(); - } - } -}