diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/ChallengeParserTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/ChallengeParserTest.java index 7fcaf5d..420e2a7 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/ChallengeParserTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/ChallengeParserTest.java @@ -28,13 +28,24 @@ void testChallenge15318() { final var expected = new Challenge(15318, "Add direction to Stop - USA Los Angeles Timezone", Instant.parse("2020-11-28T18:22:24.399Z"), Instant.parse("2023-01-24T14:21:34.897Z"), "This challenge will show every [highway=stop](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dstop) without [direction=*](https://wiki.openstreetmap.org/wiki/Key:direction). Your goal is to add tag \"direction\" with value: \"forward\", \"backward\" or \"both\" for every stop. Read article [highway=stop](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dstop) to know how to map.\n\n#### Overpass query\n[All my queries](https://wiki.openstreetmap.org/wiki/User:Binnette/OverpassQueries)\n\n#### About Binnette\n[Twitch](https://www.twitch.tv/binnettetv) - [Twitter](https://twitter.com/BinnetteBin) - [Wiki](https://wiki.openstreetmap.org/wiki/User:Binnette)", - false, "", new ChallengeGeneral(918586, 39866, "Add tag direction with value: \"forward\", \"backward\" or \"both\" for every stop. Read article [highway=stop](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dstop) to know how to map.\n\nEx: direction=forward / direction=backward / direction=both\n\nNote:\n- for this usecase iD editor is great and shows directions.\n- with iD to change direction, click on the node and press v (reverse shortcut).", 2, "Add direction=forward/backward/both to [highway=stop](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dstop).", true, false, 0, 1674515454, "Add tag direction to highway=stop - USA LA Timezone #maproulette", "", false, new long[0], false), - new ChallengeCreation("area[name=\"America/Los_Angeles Timezone\"]->.a;\nnode[\"highway\"=\"stop\"][!\"direction\"][!\"stop\"](area.a);\nway(bn)[\"highway\"][\"oneway\"!=\"yes\"];\nnode(w)[\"highway\"=\"stop\"][!\"direction\"];\nout skel;", "", "node"), + false, "", + new ChallengeGeneral(918586, 39866, + "Add tag direction with value: \"forward\", \"backward\" or \"both\" for every stop. Read article [highway=stop](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dstop) to know how to map.\n\nEx: direction=forward / direction=backward / direction=both\n\nNote:\n- for this usecase iD editor is great and shows directions.\n- with iD to change direction, click on the node and press v (reverse shortcut).", + 2, + "Add direction=forward/backward/both to [highway=stop](https://wiki.openstreetmap.org/wiki/Tag:highway%3Dstop).", + true, false, 0, 1674515454, "Add tag direction to highway=stop - USA LA Timezone #maproulette", + "", false, new long[0], false), + new ChallengeCreation( + "area[name=\"America/Los_Angeles Timezone\"]->.a;\nnode[\"highway\"=\"stop\"][!\"direction\"][!\"stop\"](area.a);\nway(bn)[\"highway\"][\"oneway\"!=\"yes\"];\nnode(w)[\"highway\"=\"stop\"][!\"direction\"];\nout skel;", + "", "node"), new ChallengePriority(Priority.LOW, "{}", "{}", "{}"), - new ChallengeExtra(19, 3, 19, -1, "", "", false, "", "", null, null, false, false, "[]", "", false, null), + new ChallengeExtra(19, 3, 19, -1, "", "", false, "", "", null, null, false, false, "[]", "", false, + null), 3, "Request timeout to overpass-api.de/178.63.48.217:80 after 120000 ms", Instant.parse("2022-07-23T07:13:38.609Z"), Instant.parse("2022-07-23T07:13:38.609Z"), - new Point(38.3241717215975, -120.521573627918), "{\"type\":\"Polygon\",\"coordinates\":[[[-124.586248289365,32.5435948864956],[-124.586248289365,48.9940324531592],[-114.103130987674,48.9940324531592],[-114.103130987674,32.5435948864956],[-124.586248289365,32.5435948864956]]]}", 4, 29734); + new Point(38.3241717215975, -120.521573627918), + "{\"type\":\"Polygon\",\"coordinates\":[[[-124.586248289365,32.5435948864956],[-124.586248289365,48.9940324531592],[-114.103130987674,48.9940324531592],[-114.103130987674,32.5435948864956],[-124.586248289365,32.5435948864956]]]}", + 4, 29734); assertRecordsEqual(expected, challenge); } } diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/ClusteredPointParserTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/ClusteredPointParserTest.java index 2369928..b238761 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/ClusteredPointParserTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/ClusteredPointParserTest.java @@ -23,18 +23,19 @@ class ClusteredPointParserTest { @Test void testTask136226437() throws IOException { - final var box = TaskAPI.box(-108.4962538, 39.082404, -108.4962538, 39.082404, - 1_000, 0, true, null, null, false, true, true); + final var box = TaskAPI.box(-108.4962538, 39.082404, -108.4962538, 39.082404, 1_000, 0, true, null, null, false, + true, true); assertEquals(1, box.length); final var photoMC = new PublicUser(11197, null, "Photo_MC", null, null); final var actual = box[0]; - final var expected = new ClusteredPoint(136226437L, -1L, "", "861207014_way_1", - 27887L, "United States | Polygon has self intersection", new Point(39.082404, -108.4962538), - "", "", Instant.parse("2023-01-31T19:28:24.909Z"), null, 2, TaskStatus.TOO_HARD, null, + final var expected = new ClusteredPoint(136226437L, -1L, "", "861207014_way_1", 27887L, + "United States | Polygon has self intersection", new Point(39.082404, -108.4962538), "", "", + Instant.parse("2023-01-31T19:28:24.909Z"), null, 2, TaskStatus.TOO_HARD, null, Instant.parse("2022-10-18T03:19:56.028Z"), 923162L, photoMC, new PointReview(1, photoMC, new PublicUser(9724, null, "Jenn_Bh", null, null), - Instant.parse("2022-10-18T07:09:14.455Z"), null, null, - null, Instant.parse("2022-10-18T07:08:52.469Z"), new long[0]), 0, null, false); + Instant.parse("2022-10-18T07:09:14.455Z"), null, null, null, + Instant.parse("2022-10-18T07:08:52.469Z"), new long[0]), + 0, null, false); assertRecordsEqual(expected, actual); } } diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/GeometryParserTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/GeometryParserTest.java index 6a70812..8e990fa 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/GeometryParserTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/GeometryParserTest.java @@ -1,3 +1,4 @@ +// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.maproulette.api.parsers; import static org.junit.jupiter.api.Assertions.assertAll; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/TaskParserTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/TaskParserTest.java index 962af9e..d6b6a0f 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/TaskParserTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/api/parsers/TaskParserTest.java @@ -37,22 +37,22 @@ class TaskParserTest { void testTaskParsing135045992() { final var task = assertDoesNotThrow(() -> TaskAPI.start(135045992)); final var expected = new Task(135045992, "way/131190351", Instant.parse("2022-08-06T15:23:36.531Z"), - Instant.parse("2022-08-06T15:23:36.531Z"), 24092, "", - new Point(36.0819446365856, -119.104608317353), task.geometries(), - new OSMChange(new ElementCreate[0], new ElementUpdate[]{ - new ElementUpdate(131190351L, OsmPrimitiveType.WAY, Integer.MIN_VALUE, new ElementTagChange( - Map.of("landuse", "farmland", "FMMP_modified", "yes"), new String[0] - )) - }), TaskStatus.CREATED, null, null, null, - new TaskReviewFields(null, null, null, null, null, - null, null, null, null, null), - 0, -1L, null, null, false, null, ""); + Instant.parse("2022-08-06T15:23:36.531Z"), 24092, "", new Point(36.0819446365856, -119.104608317353), + task.geometries(), + new OSMChange(new ElementCreate[0], + new ElementUpdate[] { new ElementUpdate(131190351L, OsmPrimitiveType.WAY, Integer.MIN_VALUE, + new ElementTagChange(Map.of("landuse", "farmland", "FMMP_modified", "yes"), + new String[0])) }), + TaskStatus.CREATED, null, null, null, + new TaskReviewFields(null, null, null, null, null, null, null, null, null, null), 0, -1L, null, null, + false, null, ""); assertRecordsEqual(expected, task); // Check geometries final var way = task.geometries().getWays().iterator().next(); assertAll("Tags were improperly parsed", () -> assertEquals("way/131190351", way.get("@id")), () -> assertEquals("28.9408234929", way.get("acres")), - () -> assertEquals("http://www.consrv.ca.gov/dlrp/fmmp/products/Pages/DownloadGISdata.aspx", way.get("source")), + () -> assertEquals("http://www.consrv.ca.gov/dlrp/fmmp/products/Pages/DownloadGISdata.aspx", + way.get("source")), () -> assertEquals("farmland", way.get("landuse")), () -> assertEquals("Tulare", way.get("addr:county")), () -> assertEquals("Farmland Mapping and Monitoring Program", way.get("attribution")), @@ -67,12 +67,11 @@ void testTaskParsing135045992() { @Test void testTaskParsing134808786() { final var task = assertDoesNotThrow(() -> TaskAPI.start(134808786)); - final var expected = new Task(134808786, "node/-103005", Instant.parse("2022-08-04T15:44:15.335Z"), Instant.parse("2022-08-04T15:44:15.335Z"), - 28467, "", new Point(43.3719671, -82.9782727), task.geometries(), - task.cooperativeWork(), TaskStatus.CREATED, null, null, null, - new TaskReviewFields(null, null, null, null, null, - null, null, null, null, null), - 0, -1L, null, null, false, null, ""); + final var expected = new Task(134808786, "node/-103005", Instant.parse("2022-08-04T15:44:15.335Z"), + Instant.parse("2022-08-04T15:44:15.335Z"), 28467, "", new Point(43.3719671, -82.9782727), + task.geometries(), task.cooperativeWork(), TaskStatus.CREATED, null, null, null, + new TaskReviewFields(null, null, null, null, null, null, null, null, null, null), 0, -1L, null, null, + false, null, ""); assertRecordsEqual(expected, task); final var actualData = expected.cooperativeWorkAsOsc(); assertNotNull(actualData); @@ -83,15 +82,20 @@ void testTaskParsing134808786() { final var node = ds.getNodes().iterator().next(); assertEquals(43.3719671, node.lat(), ILatLon.MAX_SERVER_PRECISION); assertEquals(-82.9782727, node.lon(), ILatLon.MAX_SERVER_PRECISION); - assertEquals(Map.of("gnis:feature_id", "624965", "name", "Duff Creek", "waterway", "stream"), - node.getKeys()); + assertEquals(Map.of("gnis:feature_id", "624965", "name", "Duff Creek", "waterway", "stream"), node.getKeys()); assertTrue(node.isNew()); } @Test void testTaskParsing136226437() { final var task = assertDoesNotThrow(() -> TaskAPI.start(136226437)); - final var expected = new Task(136226437L, "861207014_way_1", Instant.parse("2022-09-15T18:50:39.354Z"), Instant.parse("2022-10-18T03:19:56.028Z"), 27887, "", new Point(39.082404, -108.4962538), task.geometries(), task.cooperativeWork(), TaskStatus.TOO_HARD, Instant.parse("2022-10-18T03:19:56.028Z"), 923162L, 11197L, new TaskReviewFields(1, 11197L, 9724L, Instant.parse("2022-10-18T07:09:14.455Z"), null, null, null, Instant.parse("2022-10-18T07:08:52.469Z"), null, null), 0, -1L, null, null, false, null, ""); + final var expected = new Task(136226437L, "861207014_way_1", Instant.parse("2022-09-15T18:50:39.354Z"), + Instant.parse("2022-10-18T03:19:56.028Z"), 27887, "", new Point(39.082404, -108.4962538), + task.geometries(), task.cooperativeWork(), TaskStatus.TOO_HARD, + Instant.parse("2022-10-18T03:19:56.028Z"), 923162L, 11197L, + new TaskReviewFields(1, 11197L, 9724L, Instant.parse("2022-10-18T07:09:14.455Z"), null, null, null, + Instant.parse("2022-10-18T07:08:52.469Z"), null, null), + 0, -1L, null, null, false, null, ""); assertRecordsEqual(expected, task); } } diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/data/IgnoreListTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/data/IgnoreListTest.java index 1efc184..353387d 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/data/IgnoreListTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/data/IgnoreListTest.java @@ -1,3 +1,4 @@ +// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.maproulette.data; import static org.junit.jupiter.api.Assertions.assertAll; @@ -21,15 +22,10 @@ void testIgnores() { } IgnoreList.ignoreTask(15); IgnoreList.ignoreChallenge(15); - assertAll(() -> assertTrue(IgnoreList.isTaskIgnored(0)), - () -> assertTrue(IgnoreList.isChallengeIgnored(0)), - () -> assertTrue(IgnoreList.isTaskIgnored(9)), - () -> assertTrue(IgnoreList.isChallengeIgnored(9)), - () -> assertTrue(IgnoreList.isTaskIgnored(15)), - () -> assertTrue(IgnoreList.isChallengeIgnored(15)), - () -> assertTrue(IgnoreList.isTaskIgnored(20)), - () -> assertTrue(IgnoreList.isChallengeIgnored(20)), - () -> assertTrue(IgnoreList.isTaskIgnored(29)), - () -> assertTrue(IgnoreList.isChallengeIgnored(29))); + assertAll(() -> assertTrue(IgnoreList.isTaskIgnored(0)), () -> assertTrue(IgnoreList.isChallengeIgnored(0)), + () -> assertTrue(IgnoreList.isTaskIgnored(9)), () -> assertTrue(IgnoreList.isChallengeIgnored(9)), + () -> assertTrue(IgnoreList.isTaskIgnored(15)), () -> assertTrue(IgnoreList.isChallengeIgnored(15)), + () -> assertTrue(IgnoreList.isTaskIgnored(20)), () -> assertTrue(IgnoreList.isChallengeIgnored(20)), + () -> assertTrue(IgnoreList.isTaskIgnored(29)), () -> assertTrue(IgnoreList.isChallengeIgnored(29))); } } \ No newline at end of file diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/data/TaskPrimitivesTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/data/TaskPrimitivesTest.java index 7a5080b..a76567c 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/data/TaskPrimitivesTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/data/TaskPrimitivesTest.java @@ -1,3 +1,4 @@ +// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.maproulette.data; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/MRGuiHelperTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/MRGuiHelperTest.java index 9dc7b3c..48799bd 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/MRGuiHelperTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/gui/MRGuiHelperTest.java @@ -1,3 +1,4 @@ +// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.maproulette.gui; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ -14,10 +15,12 @@ class MRGuiHelperTest { void testGetInstructionTextMustache() { final var task = assertDoesNotThrow(() -> TaskAPI.get(147197178)); final var instructions = MRGuiHelper.getInstructionText(task); - assertEquals(""" -
    -
  1. Node 6318952236 has been tagged as a building indicating that it represents a building, but it is better to represent buildings with polygons or multipolygons. Please see if there is enough satellite imagery information to replace this node with a new polygon. If there is enough detail to draw this building as a polygon then add the polygon that represents the building and remove the building tag from this node or transfer the tags from this node to the new polygon, and then delete this node. See https://wiki.openstreetmap.org/wiki/Mapping_addresses_as_separate_nodes_or_by_adding_to_building_polygons.
  2. -
- """, instructions); + assertEquals( + """ +
    +
  1. Node 6318952236 has been tagged as a building indicating that it represents a building, but it is better to represent buildings with polygons or multipolygons. Please see if there is enough satellite imagery information to replace this node with a new polygon. If there is enough detail to draw this building as a polygon then add the polygon that represents the building and remove the building tag from this node or transfer the tags from this node to the new polygon, and then delete this node. See https://wiki.openstreetmap.org/wiki/Mapping_addresses_as_separate_nodes_or_by_adding_to_building_polygons.
  2. +
+ """, + instructions); } } \ No newline at end of file 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 e59a7d4..d94474d 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 @@ -1,3 +1,4 @@ +// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.maproulette.gui; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -43,13 +44,13 @@ public class TaskListPanelTest { * @param ignoreType The ignore action to use */ public static void fireIgnoreAction(TaskListPanel panel, IgnoreAction.IgnoreType ignoreType) { - final var table = ((JTable) ((JComponent) ((JComponent) ((JComponent) panel.getComponent(1 /* The scroll pane */)) - .getComponent(0 /* The viewport */)).getComponent(0 /* A panel */)) - .getComponent(2 /* The table */)); + final var table = ((JTable) ((JComponent) ((JComponent) ((JComponent) panel + .getComponent(1 /* The scroll pane */)).getComponent(0 /* The viewport */)) + .getComponent(0 /* A panel */)).getComponent(2 /* The table */)); final var menu = table.getComponentPopupMenu(); final var menuItem = (JMenuItem) switch (ignoreType) { - case IGNORE_TASK -> menu.getComponent(1); - case IGNORE_CHALLENGE -> menu.getComponent(2); + case IGNORE_TASK -> menu.getComponent(1); + case IGNORE_CHALLENGE -> menu.getComponent(2); }; menu.setInvoker(table); final var action = menuItem.getAction(); @@ -70,9 +71,11 @@ public Bounds getLatLonBoundsBox() { } }; action.actionPerformed(null); - MainApplication.worker.submit(() -> { /* Sync thread */ }).get(); + MainApplication.worker.submit(() -> { + /* Sync thread */ }).get(); action.actionPerformed(null); - MainApplication.worker.submit(() -> { /* Sync thread */ }).get(); + MainApplication.worker.submit(() -> { + /* Sync thread */ }).get(); } /** @@ -83,9 +86,9 @@ public Bounds getLatLonBoundsBox() { */ public static Action getDownloadAction(TaskListPanel taskListPanel) { final var action = ((JButton) ((JComponent) ((JComponent) taskListPanel.getComponent(2 /* The side buttons */)) - .getComponent(0 /* A singular JPanel */)) - .getComponent(0 /* The download button */)).getAction(); - assertEquals("org.openstreetmap.josm.plugins.maproulette.gui.task.list.TaskListPanel$DownloadDataAction", action.getClass().getName()); + .getComponent(0 /* A singular JPanel */)).getComponent(0 /* The download button */)).getAction(); + assertEquals("org.openstreetmap.josm.plugins.maproulette.gui.task.list.TaskListPanel$DownloadDataAction", + action.getClass().getName()); return action; } } \ No newline at end of file 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 8b3f226..2d069c7 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 @@ -1,3 +1,4 @@ +// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.maproulette.gui.layer; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -53,7 +54,8 @@ public Bounds getLatLonBoundsBox() { try { MainApplication.getMap().addToggleDialog(panel); TaskListPanelTest.getDownloadAction(panel).actionPerformed(null); - MainApplication.worker.submit(() -> { /* Sync thread */ }).get(5, TimeUnit.SECONDS); + MainApplication.worker.submit(() -> { + /* Sync thread */ }).get(5, TimeUnit.SECONDS); final var layers = MainApplication.getLayerManager().getLayersOfType(MapRouletteClusteredPointLayer.class); assertEquals(1, layers.size()); final var layer = layers.get(0); @@ -68,7 +70,8 @@ public Bounds getLatLonBoundsBox() { // Now what happens with shift events? layer.mouseClicked(generateMouseEvent(true, 36.0778797, -119.1075725)); assertEquals(2, panel.getSelected().size()); - assertTrue(panel.getSelected().stream().mapToLong(Identifier::id).allMatch(id -> id == 133361784L || id == 133361785L)); + assertTrue(panel.getSelected().stream().mapToLong(Identifier::id) + .allMatch(id -> id == 133361784L || id == 133361785L)); assertEquals(2, panel.getSelected().stream().mapToLong(Identifier::id).distinct().count()); // Now, let us hide the challenge for the objects we have selected TaskListPanelTest.fireIgnoreAction(panel, IgnoreAction.IgnoreType.IGNORE_CHALLENGE); @@ -88,7 +91,7 @@ private static MouseEvent generateMouseEvent(boolean shift, double lat, double l final var ll = new LatLon(lat, lon); mv.zoomTo(ll); final var point = mv.getPoint(ll); - return new MouseEvent(MainApplication.getMap(), UUID.randomUUID().hashCode(), - System.currentTimeMillis(), shift ? MouseEvent.SHIFT_DOWN_MASK : 0, point.x, point.y, 1, false, MouseEvent.BUTTON1); + return new MouseEvent(MainApplication.getMap(), UUID.randomUUID().hashCode(), System.currentTimeMillis(), + shift ? MouseEvent.SHIFT_DOWN_MASK : 0, point.x, point.y, 1, false, MouseEvent.BUTTON1); } } \ No newline at end of file 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 aaef8bf..76d740a 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 @@ -1,3 +1,4 @@ +// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.maproulette.io.upload; import static org.junit.jupiter.api.Assertions.assertAll; @@ -56,7 +57,7 @@ void setUp() { } @ParameterizedTest - @ValueSource(strings = {"9494185766_node_4", "9494185766", "node/9494185766", "node 9494185766@4"}) + @ValueSource(strings = { "9494185766_node_4", "9494185766", "node/9494185766", "node 9494185766@4" }) void testRegexParsing(String title) { final var ds = new DataSet(); final var node = TestUtils.newNode(""); @@ -66,12 +67,11 @@ void testRegexParsing(String title) { ds.addPrimitive(node); final var apiDataSet = new APIDataSet(ds); MainApplication.getLayerManager().addLayer(new OsmDataLayer(ds, "testRegexParsing", null)); - final var mrLayer = new MapRouletteClusteredPointLayer(new Bounds(0, 0, 0, 0), Collections.singleton( - new ClusteredPoint(132279499L, 0L, "null", title, 0L, "parentName", new Point(0, 0), - "bounding", "blurb", Instant.EPOCH, Difficulty.NORMAL, 2, TaskStatus.CREATED, null, - Instant.EPOCH, 0L, new PublicUser(0L, null, "someone", Instant.EPOCH, null), - new PointReview(null, null, null, null, null, null, null, null, null), 0, null, false) - )); + final var mrLayer = new MapRouletteClusteredPointLayer(new Bounds(0, 0, 0, 0), + Collections.singleton(new ClusteredPoint(132279499L, 0L, "null", title, 0L, "parentName", + new Point(0, 0), "bounding", "blurb", Instant.EPOCH, Difficulty.NORMAL, 2, TaskStatus.CREATED, + null, Instant.EPOCH, 0L, new PublicUser(0L, null, "someone", Instant.EPOCH, null), + new PointReview(null, null, null, null, null, null, null, null, null), 0, null, false))); MainApplication.getLayerManager().addLayer(mrLayer); Config.getPref().putInt("message." + EarlyUploadHook.PREF_CHECK_IF_FINISHED + ".value", 0); Config.getPref().putBoolean("message." + EarlyUploadHook.PREF_CHECK_IF_FINISHED, false); @@ -87,7 +87,9 @@ void testRegexParsing(String title) { @Test void testManyClosedTasks() { for (int i = 100_000_000; i < 100_000_050; i++) { - ModifiedObjects.addModifiedTask(new ModifiedTask(new Task(i, "", null, null, 15318, null, null, null, null, null, null, null, null, null, 0, null, null, null, false, null, null), TaskStatus.FIXED, null, null, null, null)); + ModifiedObjects.addModifiedTask( + new ModifiedTask(new Task(i, "", null, null, 15318, null, null, null, null, null, null, null, null, + null, 0, null, null, null, false, null, null), TaskStatus.FIXED, null, null, null, null)); } final var map = new HashMap(); hook.modifyChangesetTags(map); diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/markdown/SelectParserTest.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/markdown/SelectParserTest.java index c849e2b..bd46d7d 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/markdown/SelectParserTest.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/markdown/SelectParserTest.java @@ -1,3 +1,4 @@ +// License: GPL. For details, see LICENSE file. package org.openstreetmap.josm.plugins.maproulette.markdown; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -29,14 +30,14 @@ void setup() { static List testSelect() { final var renderSelect = "\n\n"; final var markdownSelect = "[select \" \" values=\"One,Two,Three\"]"; - return Arrays.asList( - Arguments.of("

" + renderSelect + "

\n", markdownSelect), + return Arrays.asList(Arguments.of("

" + renderSelect + "

\n", markdownSelect), Arguments.of("

Matching: " + renderSelect + "

\n", "Matching: " + markdownSelect), Arguments.of("

" + renderSelect + " values

\n", markdownSelect + " values"), - Arguments.of("

Matching: " + renderSelect + " values

\n", "Matching: " + markdownSelect + " values"), - Arguments.of("

\n\n

\n", - "[select \" \" name=\"Test Name\" values=\"One,Two,Three\"]") - ); + Arguments.of("

Matching: " + renderSelect + " values

\n", + "Matching: " + markdownSelect + " values"), + Arguments.of( + "

\n\n

\n", + "[select \" \" name=\"Test Name\" values=\"One,Two,Three\"]")); } @ParameterizedTest diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/LoggingHandler.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/LoggingHandler.java index df33f62..3b278a7 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/LoggingHandler.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/LoggingHandler.java @@ -35,7 +35,7 @@ */ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD}) +@Target({ ElementType.TYPE, ElementType.METHOD }) @ExtendWith(LoggingHandler.LoggingHandlerImplementation.class) public @interface LoggingHandler { /** @@ -52,11 +52,14 @@ class LoggingHandlerImplementation implements BeforeEachCallback, AfterEachCallb @Override public void afterEach(ExtensionContext context) { - MainApplication.worker.submit(() -> { /* Sync thread */ }); - GuiHelper.runInEDTAndWait(() -> { /* Sync thread */ }); - final int failLevel = AnnotationSupport.findAnnotation(context.getElement(), LoggingHandler.class).map(LoggingHandler::value) - .orElse(AnnotationSupport.findAnnotation(context.getClass(), LoggingHandler.class).map(LoggingHandler::value) - .orElse(1000)); + MainApplication.worker.submit(() -> { + /* Sync thread */ }); + GuiHelper.runInEDTAndWait(() -> { + /* Sync thread */ }); + final int failLevel = AnnotationSupport.findAnnotation(context.getElement(), LoggingHandler.class) + .map(LoggingHandler::value) + .orElse(AnnotationSupport.findAnnotation(context.getClass(), LoggingHandler.class) + .map(LoggingHandler::value).orElse(1000)); ExtensionContext.Store store = context.getStore(ExtensionContext.Namespace.create(LoggingHandler.class)); TestHandler testHandler = store.get(TestHandler.class, TestHandler.class); Logging.getLogger().removeHandler(testHandler); @@ -64,9 +67,9 @@ public void afterEach(ExtensionContext context) { for (Handler handler : handlers) { Logging.getLogger().addHandler(handler); } - assertAll(testHandler.getRecords().stream() - .filter(logRecord -> logRecord.getLevel().intValue() >= failLevel) - .map(logRecord -> fail(logRecord.getMessage(), logRecord.getThrown()))); + assertAll( + testHandler.getRecords().stream().filter(logRecord -> logRecord.getLevel().intValue() >= failLevel) + .map(logRecord -> fail(logRecord.getMessage(), logRecord.getThrown()))); testHandler.clearRecords(); } @@ -81,8 +84,8 @@ public void beforeEach(ExtensionContext context) { store.put(TestHandler.class, testHandler); Logging.getLogger().addHandler(testHandler); // Ensure that exceptions thrown in the EDT are logged -- they weren't in testing - GuiHelper.runInEDTAndWaitWithException(() -> - Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Logging.error(throwable))); + GuiHelper.runInEDTAndWaitWithException(() -> Thread.currentThread() + .setUncaughtExceptionHandler((thread, throwable) -> Logging.error(throwable))); } @Override @@ -134,4 +137,3 @@ public void close() throws SecurityException { } } } - diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/MapRouletteConfig.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/MapRouletteConfig.java index 5520ce0..df1c68b 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/MapRouletteConfig.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/MapRouletteConfig.java @@ -57,9 +57,9 @@ public Extension() { @Override protected void onBeforeEach(WireMockRuntimeInfo wireMockRuntimeInfo) { - org.openstreetmap.josm.plugins.maproulette.config.MapRouletteConfig.setInstance( - new org.openstreetmap.josm.plugins.maproulette.config.MapRouletteConfig(wireMockRuntimeInfo.getHttpBaseUrl() + "/api/v2") - ); + org.openstreetmap.josm.plugins.maproulette.config.MapRouletteConfig + .setInstance(new org.openstreetmap.josm.plugins.maproulette.config.MapRouletteConfig( + wireMockRuntimeInfo.getHttpBaseUrl() + "/api/v2")); Config.getPref().put("osm-server.url", wireMockRuntimeInfo.getHttpBaseUrl() + "/api"); } @@ -85,14 +85,17 @@ protected void onAfterEach(WireMockRuntimeInfo wireMockRuntimeInfo) { class MapRouletteExtension extends ResponseDefinitionTransformer { @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, FileSource files, Parameters parameters) { + public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, FileSource files, + Parameters parameters) { if (request.getUrl().startsWith("/api/v2/task/") && request.getUrl().matches("/api/v2/task/\\d+")) { final var file = files.getTextFileNamed(request.getUrl().substring(1) + "/start"); if (file != null) { - final var builder = responseDefinition.wasConfigured() ? ResponseDefinitionBuilder.like(responseDefinition) : ResponseDefinitionBuilder.responseDefinition(); - return builder - .withStatus(HTTP_OK) - .withResponseBody(Body.ofBinaryOrText(file.readContents(), new ContentTypeHeader("application/json"))) + final var builder = responseDefinition.wasConfigured() + ? ResponseDefinitionBuilder.like(responseDefinition) + : ResponseDefinitionBuilder.responseDefinition(); + return builder.withStatus(HTTP_OK) + .withResponseBody( + Body.ofBinaryOrText(file.readContents(), new ContentTypeHeader("application/json"))) .build(); } } diff --git a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/RecordAssertion.java b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/RecordAssertion.java index b0249ef..d777a50 100644 --- a/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/RecordAssertion.java +++ b/src/test/unit/org/openstreetmap/josm/plugins/maproulette/util/RecordAssertion.java @@ -55,35 +55,47 @@ public static void assertRecordsEqual(T expected, T actual, S final var actualObj = method.invoke(actual); if (expectedObj instanceof Record && actualObj instanceof Record && expectedObj.getClass().equals(actualObj.getClass())) { - executableList.add(() -> assertRecordsEqual((Record) expectedObj, (Record) actualObj, component.getName())); + executableList.add( + () -> assertRecordsEqual((Record) expectedObj, (Record) actualObj, component.getName())); } else if (expectedObj instanceof Object[] expectedArray && actualObj instanceof Object[] actualArray) { - if (expectedObj.getClass().getComponentType().isRecord() && expectedObj.getClass().equals(actualObj.getClass())) { - executableList.add(() -> assertEquals(expectedArray.length, actualArray.length, component.getName())); + if (expectedObj.getClass().getComponentType().isRecord() + && expectedObj.getClass().equals(actualObj.getClass())) { + executableList + .add(() -> assertEquals(expectedArray.length, actualArray.length, component.getName())); if (expectedArray.length == actualArray.length) { for (int i = 0; i < expectedArray.length; i++) { final var index = i; - executableList.add(() -> assertRecordsEqual((Record) expectedArray[index], (Record) actualArray[index], component.getName())); + executableList.add(() -> assertRecordsEqual((Record) expectedArray[index], + (Record) actualArray[index], component.getName())); } } } else { executableList.add(() -> assertArrayEquals(expectedArray, actualArray, component.getName())); } } else if (expectedObj instanceof long[] && actualObj instanceof long[]) { - executableList.add(() -> assertArrayEquals((long[]) expectedObj, (long[]) actualObj, component.getName())); + executableList.add( + () -> assertArrayEquals((long[]) expectedObj, (long[]) actualObj, component.getName())); } else if (expectedObj instanceof int[] && actualObj instanceof int[]) { - executableList.add(() -> assertArrayEquals((int[]) expectedObj, (int[]) actualObj, component.getName())); + executableList + .add(() -> assertArrayEquals((int[]) expectedObj, (int[]) actualObj, component.getName())); } else if (expectedObj instanceof short[] && actualObj instanceof short[]) { - executableList.add(() -> assertArrayEquals((short[]) expectedObj, (short[]) actualObj, component.getName())); + executableList.add( + () -> assertArrayEquals((short[]) expectedObj, (short[]) actualObj, component.getName())); } else if (expectedObj instanceof char[] && actualObj instanceof char[]) { - executableList.add(() -> assertArrayEquals((char[]) expectedObj, (char[]) actualObj, component.getName())); + executableList.add( + () -> assertArrayEquals((char[]) expectedObj, (char[]) actualObj, component.getName())); } else if (expectedObj instanceof byte[] && actualObj instanceof byte[]) { - executableList.add(() -> assertArrayEquals((byte[]) expectedObj, (byte[]) actualObj, component.getName())); + executableList.add( + () -> assertArrayEquals((byte[]) expectedObj, (byte[]) actualObj, component.getName())); } else if (expectedObj instanceof boolean[] && actualObj instanceof boolean[]) { - executableList.add(() -> assertArrayEquals((boolean[]) expectedObj, (boolean[]) actualObj, component.getName())); + executableList.add(() -> assertArrayEquals((boolean[]) expectedObj, (boolean[]) actualObj, + component.getName())); } else if (expectedObj instanceof double[] && actualObj instanceof double[]) { - executableList.add(() -> assertArrayEquals((double[]) expectedObj, (double[]) actualObj, component.getName())); + executableList.add( + () -> assertArrayEquals((double[]) expectedObj, (double[]) actualObj, component.getName())); } else if (expectedObj instanceof float[] && actualObj instanceof float[]) { - executableList.add(() -> assertArrayEquals((float[]) expectedObj, (float[]) actualObj, component.getName())); + executableList.add( + () -> assertArrayEquals((float[]) expectedObj, (float[]) actualObj, component.getName())); } else { executableList.add(() -> assertEquals(expectedObj, actualObj, component.getName())); }