Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed May 29, 2024
1 parent fdd30b4 commit cc4ca4e
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 107 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.30.0</version>
<version>2.43.0</version>
<configuration>
<java>
<eclipse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
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.maproulette.api.parsers;

import static org.junit.jupiter.api.Assertions.assertAll;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand All @@ -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);
Expand All @@ -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);
}
}
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.maproulette.data;

import static org.junit.jupiter.api.Assertions.assertAll;
Expand All @@ -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)));
}
}
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.maproulette.data;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
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.maproulette.gui;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
Expand All @@ -14,10 +15,12 @@ class MRGuiHelperTest {
void testGetInstructionTextMustache() {
final var task = assertDoesNotThrow(() -> TaskAPI.get(147197178));
final var instructions = MRGuiHelper.getInstructionText(task);
assertEquals("""
<html><ol>
<li>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.</li>
</ol>
</html>""", instructions);
assertEquals(
"""
<html><ol>
<li>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.</li>
</ol>
</html>""",
instructions);
}
}
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.maproulette.gui;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}

/**
Expand All @@ -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;
}
}
Loading

0 comments on commit cc4ca4e

Please sign in to comment.