From a14502d1d27732bda4180937574cf0e221b5045d Mon Sep 17 00:00:00 2001 From: Taylor Smock Date: Wed, 11 Dec 2019 16:33:33 -0700 Subject: [PATCH] Formatting fixes Signed-off-by: Taylor Smock --- .../plugins/mapwithai/MapWithAIPlugin.java | 2 +- .../mapwithai/ReplacementPreferenceTable.java | 2 +- .../josm/plugins/mapwithai/UpdateProd.java | 3 +-- .../BoundingBoxMapWithAIDownloader.java | 8 +++---- .../backend/MapWithAIAvailability.java | 7 +++--- .../mapwithai/backend/MapWithAIDataUtils.java | 24 +++++++++---------- .../backend/MapWithAIPreferenceHelper.java | 2 +- .../backend/MapWithAIRemoteControl.java | 9 +++---- .../backend/MapWithAIUploadHook.java | 9 ++++--- .../mapwithai/backend/OsmReaderCustom.java | 23 ++++++++++-------- .../conflation/AbstractConflationCommand.java | 1 + .../commands/conflation/ConnectedCommand.java | 2 +- .../conflation/MergeAddressBuildings.java | 8 +++---- .../commands/CreateConnectionsCommand.java | 2 +- .../commands/MapWithAIAddCommand.java | 10 ++++---- .../commands/MergeDuplicateWays.java | 2 +- .../frontend/MapWithAIDownloadReader.java | 4 +--- .../mapwithai/MapWithAIPluginTest.java | 4 ++-- .../plugins/mapwithai/UpdateProdTest.java | 6 ++--- .../DetectTaskingManagerUtilsTest.java | 5 ++-- .../backend/GetDataRunnableTest.java | 4 ++-- .../backend/MapWithAIActionTest.java | 2 +- .../backend/MapWithAIAvailabilityTest.java | 4 ++-- .../backend/MapWithAIMoveActionTest.java | 6 ++--- .../backend/MapWithAIRemoteControlTest.java | 23 +++++++++--------- .../backend/MapWithAIUploadHookTest.java | 4 ++-- .../commands/MapWithAIAddComandTest.java | 4 ++-- .../conflation/MergeAddressBuildingsTest.java | 2 +- .../frontend/MapWithAIDownloadReaderTest.java | 2 +- 29 files changed, 90 insertions(+), 94 deletions(-) diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPlugin.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPlugin.java index b933fb9..d903a74 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPlugin.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPlugin.java @@ -146,7 +146,7 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable { } MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).stream() - .forEach(layer -> MainApplication.getLayerManager().removeLayer(layer)); + .forEach(layer -> MainApplication.getLayerManager().removeLayer(layer)); if (!Config.getPref().getBoolean(PAINTSTYLE_PREEXISTS)) { MapWithAIDataUtils.removeMapWithAIPaintStyles(); diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/ReplacementPreferenceTable.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/ReplacementPreferenceTable.java index 42dc5f5..c1580bd 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/ReplacementPreferenceTable.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/ReplacementPreferenceTable.java @@ -52,7 +52,7 @@ public class ReplacementPreferenceTable extends PreferencesTable { return askAddSetting(gui, p) ? new PrefEntry(tkey.getText(), new StringSetting(tValue.getText()), new StringSetting(null), false) - : null; + : null; } private static boolean askAddSetting(JComponent gui, JPanel p) { diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/UpdateProd.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/UpdateProd.java index ecdedfa..d956b60 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/UpdateProd.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/UpdateProd.java @@ -30,8 +30,7 @@ public final class UpdateProd { public static boolean doProd(int nextMinVersion) { if (nextMinVersion > Version.getInstance().getVersion()) { int doUpdate = ConditionalOptionPaneUtil.showOptionDialog( - MapWithAIPlugin.NAME.concat(".ignore_next_version"), - MainApplication.getMainFrame(), + MapWithAIPlugin.NAME.concat(".ignore_next_version"), MainApplication.getMainFrame(), tr("Please update JOSM -- {0} {1} is the last {0} version to support JOSM {2}", MapWithAIPlugin.NAME, MapWithAIPlugin.getVersionInfo(), Integer.toString(Version.getInstance().getVersion())), diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/BoundingBoxMapWithAIDownloader.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/BoundingBoxMapWithAIDownloader.java index a8509c2..0e9da39 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/BoundingBoxMapWithAIDownloader.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/BoundingBoxMapWithAIDownloader.java @@ -34,11 +34,9 @@ public class BoundingBoxMapWithAIDownloader extends BoundingBoxDownloader { @Override protected DataSet parseDataSet(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException { DataSet ds = OsmReaderCustom.parseDataSet(source, progressMonitor, true); - GetDataRunnable.addMapWithAISourceTag(ds, - MapWithAIPreferenceHelper.getMapWithAIUrl().stream() - .filter(map -> map.getOrDefault("url", "no-url").equals(url)) - .map(map -> map.getOrDefault("source", MapWithAIPlugin.NAME)).findFirst() - .orElse(MapWithAIPlugin.NAME)); + GetDataRunnable.addMapWithAISourceTag(ds, MapWithAIPreferenceHelper.getMapWithAIUrl().stream() + .filter(map -> map.getOrDefault("url", "no-url").equals(url)) + .map(map -> map.getOrDefault("source", MapWithAIPlugin.NAME)).findFirst().orElse(MapWithAIPlugin.NAME)); GetDataRunnable.cleanup(ds, downloadArea); return ds; } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailability.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailability.java index 941a74c..b120647 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailability.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailability.java @@ -75,8 +75,8 @@ public final class MapWithAIAvailability { cachedRapidReleases.setMaxAge(604_800); parser.next(); final Stream> entries = parser.getObjectStream(); - final Optional> objects = entries - .filter(entry -> "objects".equals(entry.getKey())).findFirst(); + final Optional> objects = entries.filter(entry -> "objects".equals(entry.getKey())) + .findFirst(); if (objects.isPresent()) { final JsonObject value = objects.get().getValue().asJsonObject(); if (value != null) { @@ -120,8 +120,7 @@ public final class MapWithAIAvailability { .orElse(Optional.ofNullable(countryLoop.get("ISO3166-2")).orElse("")); if ("".equals(key)) { Logging.error("{0}: {1} does not have a \"ISO3166-1:alpha2\" or \"ISO3166-2\" key. {2}", - MapWithAIPlugin.NAME, - countryLoop, countryLoop.getInterestingTags()); + MapWithAIPlugin.NAME, countryLoop, countryLoop.getInterestingTags()); } else { Logging.trace("{0}: {1} has a country code of {2}", MapWithAIPlugin.NAME, countryLoop.get("name:en"), key); diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java index 39fbda9..e12dd2f 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIDataUtils.java @@ -69,7 +69,7 @@ public final class MapWithAIDataUtils { "https://gitlab.com/smocktaylor/rapid/raw/master/src/resources/styles/standard/rapid.mapcss", "resource://styles/standard/mapwithai.mapcss"); new ArrayList<>(MapPaintStyles.getStyles().getStyleSources()).parallelStream() - .filter(style -> oldUrls.contains(style.url)).forEach(MapPaintStyles::removeStyle); + .filter(style -> oldUrls.contains(style.url)).forEach(MapPaintStyles::removeStyle); if (!checkIfMapWithAIPaintStyleExists()) { final MapCSSStyleSource style = new MapCSSStyleSource(paintStyleResourceUrl, MapWithAIPlugin.NAME, @@ -91,8 +91,8 @@ public final class MapWithAIDataUtils { */ public static void removeMapWithAIPaintStyles() { new ArrayList<>(MapPaintStyles.getStyles().getStyleSources()).parallelStream() - .filter(source -> paintStyleResourceUrl.equals(source.url)) - .forEach(style -> SwingUtilities.invokeLater(() -> MapPaintStyles.removeStyle(style))); + .filter(source -> paintStyleResourceUrl.equals(source.url)) + .forEach(style -> SwingUtilities.invokeLater(() -> MapPaintStyles.removeStyle(style))); } /** @@ -172,15 +172,15 @@ public final class MapWithAIDataUtils { } else { final Notification noUrls = MapWithAIPreferenceHelper.getMapWithAIURLs().isEmpty() ? new Notification(tr("There are no defined URLs. To get the defaults, restart JOSM")) - : new Notification(tr("No URLS are enabled")); - noUrls.setDuration(Notification.TIME_DEFAULT); - noUrls.setIcon(JOptionPane.INFORMATION_MESSAGE); - noUrls.setHelpTopic(ht("Plugin/MapWithAI#Preferences")); - if (SwingUtilities.isEventDispatchThread()) { - noUrls.show(); - } else { - SwingUtilities.invokeLater(noUrls::show); - } + : new Notification(tr("No URLS are enabled")); + noUrls.setDuration(Notification.TIME_DEFAULT); + noUrls.setIcon(JOptionPane.INFORMATION_MESSAGE); + noUrls.setHelpTopic(ht("Plugin/MapWithAI#Preferences")); + if (SwingUtilities.isEventDispatchThread()) { + noUrls.show(); + } else { + SwingUtilities.invokeLater(noUrls::show); + } } return dataSet; } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIPreferenceHelper.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIPreferenceHelper.java index 7c9048a..8577bf7 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIPreferenceHelper.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIPreferenceHelper.java @@ -55,7 +55,7 @@ public final class MapWithAIPreferenceHelper { return (layer != null) && (layer.getMapWithAIUrl() != null) ? getMapWithAIURLs().parallelStream().filter(map -> layer.getMapWithAIUrl().equals(map.get(URL_STRING))) .collect(Collectors.toList()) - : getMapWithAIURLs().stream() + : getMapWithAIURLs().stream() .filter(map -> Boolean.valueOf(map.getOrDefault(ENABLED_STRING, Boolean.FALSE.toString()))) .collect(Collectors.toList()); } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControl.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControl.java index 794b642..78defc2 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControl.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControl.java @@ -87,8 +87,9 @@ public class MapWithAIRemoteControl extends RequestHandler.RawURLParseRequestHan @Override protected void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException { if (crop != null && crop.isInWorld()) { - MainApplication.getLayerManager().addLayer(new GpxLayer( - DetectTaskingManagerUtils.createTaskingManagerGpxData(crop), DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA)); + MainApplication.getLayerManager() + .addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(crop), + DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA)); } final MapWithAILayer layer = MapWithAIDataUtils.getLayer(true); @@ -120,7 +121,7 @@ public class MapWithAIRemoteControl extends RequestHandler.RawURLParseRequestHan final String br = "
"; final StringBuilder sb = new StringBuilder(); sb.append(tr("Remote Control has been asked to load data from the API.")).append(" (").append(url).append(')') - .append(br).append(tr("{0} will ", MapWithAIPlugin.NAME)); + .append(br).append(tr("{0} will ", MapWithAIPlugin.NAME)); if (Boolean.FALSE.equals(switchLayer)) { sb.append(tr("not ")); } @@ -162,6 +163,6 @@ public class MapWithAIRemoteControl extends RequestHandler.RawURLParseRequestHan "/mapwithai?url=https://www.facebook.com/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&bbox={bbox}", "/mapwithai?bbox=-108.4625421,39.0621223,-108.4594728,39.0633059&max_obj=1", "/mapwithai?bbox=-108.4625421,39.0621223,-108.4594728,39.0633059&switch_layer=false", - "/mapwithai?crop_bbox=-108.4625421,39.0621223,-108.4594728,39.0633059" }; + "/mapwithai?crop_bbox=-108.4625421,39.0621223,-108.4594728,39.0633059" }; } } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHook.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHook.java index 4d24db8..216235a 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHook.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHook.java @@ -38,11 +38,10 @@ public class MapWithAIUploadHook implements UploadHook, Destroyable { if (MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream().anyMatch( map -> !MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API.equalsIgnoreCase(map.get("url")))) { sb.append(";url=") - .append(String.join(";url=", - MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream() - .filter(map -> map.containsKey("url")).map(map -> map.get("url")) - .filter(url -> !MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API.equalsIgnoreCase(url)) - .collect(Collectors.toList()))); + .append(String.join(";url=", MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream() + .filter(map -> map.containsKey("url")).map(map -> map.get("url")) + .filter(url -> !MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API.equalsIgnoreCase(url)) + .collect(Collectors.toList()))); } tags.put("mapwithai:options", sb.toString()); } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/OsmReaderCustom.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/OsmReaderCustom.java index f169923..a939eed 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/OsmReaderCustom.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/OsmReaderCustom.java @@ -14,11 +14,12 @@ import org.openstreetmap.josm.io.OsmReader; import org.openstreetmap.josm.tools.Logging; /** - * Parser for the Osm API (XML output). Read from an input stream and construct a dataset out of it. + * Parser for the Osm API (XML output). Read from an input stream and construct + * a dataset out of it. * - * For each xml element, there is a dedicated method. - * The XMLStreamReader cursor points to the start of the element, when the method is - * entered, and it must point to the end of the same element, when it is exited. + * For each xml element, there is a dedicated method. The XMLStreamReader cursor + * points to the start of the element, when the method is entered, and it must + * point to the end of the same element, when it is exited. */ public class OsmReaderCustom extends OsmReader { protected OsmReaderCustom(boolean convertUnknownToTags) { @@ -50,18 +51,20 @@ public class OsmReaderCustom extends OsmReader { /** * Parse the given input source and return the dataset. * - * @param source the source input stream. Must not be null. - * @param progressMonitor the progress monitor. If null, {@link NullProgressMonitor#INSTANCE} is assumed - * @param convertUnknownToTags true if unknown xml attributes should be kept as tags + * @param source the source input stream. Must not be null. + * @param progressMonitor the progress monitor. If null, + * {@link NullProgressMonitor#INSTANCE} is assumed + * @param convertUnknownToTags true if unknown xml attributes should be kept as + * tags * * @return the dataset with the parsed data - * @throws IllegalDataException if an error was found while parsing the data from the source + * @throws IllegalDataException if an error was found while parsing the data + * from the source * @throws IllegalArgumentException if source is null * @since xxx */ public static DataSet parseDataSet(InputStream source, ProgressMonitor progressMonitor, - boolean convertUnknownToTags) - throws IllegalDataException { + boolean convertUnknownToTags) throws IllegalDataException { return new OsmReaderCustom(convertUnknownToTags).doParseDataSet(source, progressMonitor); } } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/AbstractConflationCommand.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/AbstractConflationCommand.java index a693690..a2651a5 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/AbstractConflationCommand.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/AbstractConflationCommand.java @@ -27,6 +27,7 @@ import org.openstreetmap.josm.tools.Pair; public abstract class AbstractConflationCommand extends Command { Collection possiblyAffectedPrimitives; + public AbstractConflationCommand(DataSet data) { super(data); } diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/ConnectedCommand.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/ConnectedCommand.java index 6a8e757..2afb1a5 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/ConnectedCommand.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/ConnectedCommand.java @@ -87,7 +87,7 @@ public class ConnectedCommand extends AbstractConflationCommand { public Command getRealCommand() { final List commands = new ArrayList<>(); possiblyAffectedPrimitives.stream().filter(Node.class::isInstance).map(Node.class::cast) - .forEach(node -> commands.addAll(connectedCommand(getAffectedDataSet(), node))); + .forEach(node -> commands.addAll(connectedCommand(getAffectedDataSet(), node))); Command returnCommand = null; if (!commands.isEmpty()) { returnCommand = new SequenceCommand(getDescriptionText(), commands); diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/MergeAddressBuildings.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/MergeAddressBuildings.java index ede97f8..2e24ea6 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/MergeAddressBuildings.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/commands/conflation/MergeAddressBuildings.java @@ -47,12 +47,12 @@ public class MergeAddressBuildings extends AbstractConflationCommand { List commands = new ArrayList<>(); if (MapWithAIPreferenceHelper.isMergeBuildingAddress()) { possiblyAffectedPrimitives.stream().filter(Way.class::isInstance).map(Way.class::cast) - .filter(way -> way.hasKey(BUILDING_KEY)).filter(Way::isClosed) - .forEach(way -> commands.addAll(mergeAddressBuilding(getAffectedDataSet(), way))); + .filter(way -> way.hasKey(BUILDING_KEY)).filter(Way::isClosed) + .forEach(way -> commands.addAll(mergeAddressBuilding(getAffectedDataSet(), way))); possiblyAffectedPrimitives.stream().filter(Relation.class::isInstance).map(Relation.class::cast) - .filter(rel -> rel.hasKey(BUILDING_KEY)).filter(Relation::isMultipolygon) - .forEach(rel -> commands.addAll(mergeAddressBuilding(getAffectedDataSet(), rel))); + .filter(rel -> rel.hasKey(BUILDING_KEY)).filter(Relation::isMultipolygon) + .forEach(rel -> commands.addAll(mergeAddressBuilding(getAffectedDataSet(), rel))); } Command returnCommand = null; diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommand.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommand.java index 4f4a51a..b2d4631 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommand.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/CreateConnectionsCommand.java @@ -81,7 +81,7 @@ public class CreateConnectionsCommand extends Command { } final Collection tPrimitives = new TreeSet<>(); abstractCommand.getInterestedTypes() - .forEach(clazz -> tPrimitives.addAll(Utils.filteredCollection(realPrimitives, clazz))); + .forEach(clazz -> tPrimitives.addAll(Utils.filteredCollection(realPrimitives, clazz))); final Command actualCommand = abstractCommand.getCommand(tPrimitives.stream() .filter(prim -> prim.hasKey(abstractCommand.getKey())).collect(Collectors.toList())); diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddCommand.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddCommand.java index f903a8b..3aa1ad8 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddCommand.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddCommand.java @@ -41,7 +41,8 @@ public class MapWithAIAddCommand extends Command implements Runnable { * @param editLayer The OSM layer * @param selection The primitives to add from MapWithAI */ - public MapWithAIAddCommand(MapWithAILayer mapWithAILayer, OsmDataLayer editLayer, Collection selection) { + public MapWithAIAddCommand(MapWithAILayer mapWithAILayer, OsmDataLayer editLayer, + Collection selection) { this(mapWithAILayer.getDataSet(), editLayer.getDataSet(), selection); lock = mapWithAILayer.getLock(); } @@ -76,8 +77,8 @@ public class MapWithAIAddCommand extends Command implements Runnable { @Override public void run() { if (mapWithAI.equals(editable)) { - Logging.error("{0}: DataSet mapWithAI ({1}) should not be the same as DataSet editable ({2})", MapWithAIPlugin.NAME, - mapWithAI, editable); + Logging.error("{0}: DataSet mapWithAI ({1}) should not be the same as DataSet editable ({2})", + MapWithAIPlugin.NAME, mapWithAI, editable); throw new IllegalArgumentException(); } synchronized (this) { @@ -91,7 +92,8 @@ public class MapWithAIAddCommand extends Command implements Runnable { final Command movePrimitivesCommand = new MovePrimitiveDataSetCommand(editable, mapWithAI, primitives); final Command createConnectionsCommand = createConnections(editable, allPrimitives); - command = new SequenceCommand(getDescriptionText(), movePrimitivesCommand, createConnectionsCommand); + command = new SequenceCommand(getDescriptionText(), movePrimitivesCommand, + createConnectionsCommand); } command.executeCommand(); } finally { diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java index 964173f..aad6c26 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/commands/MergeDuplicateWays.java @@ -113,7 +113,7 @@ public class MergeDuplicateWays extends Command { public static void filterDataSet(DataSet dataSet, List commands, Bounds bound) { final List ways = new ArrayList<>( (bound == null ? dataSet.getWays() : dataSet.searchWays(bound.toBBox())).parallelStream() - .filter(prim -> !prim.isIncomplete() && !prim.isDeleted()).collect(Collectors.toList())); + .filter(prim -> !prim.isIncomplete() && !prim.isDeleted()).collect(Collectors.toList())); for (int i = 0; i < ways.size(); i++) { final Way way1 = ways.get(i); final Collection nearbyWays = dataSet.searchWays(way1.getBBox()).parallelStream() diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/frontend/MapWithAIDownloadReader.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/frontend/MapWithAIDownloadReader.java index 84ad2f0..cb50629 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/frontend/MapWithAIDownloadReader.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/frontend/MapWithAIDownloadReader.java @@ -41,7 +41,6 @@ import org.openstreetmap.josm.tools.ImageProvider; public class MapWithAIDownloadReader implements DownloadSource { - @Override public AbstractDownloadSourcePanel createPanel(DownloadDialog dialog) { return new MapWithAIDownloadPanel(this); @@ -65,8 +64,7 @@ public class MapWithAIDownloadReader implements DownloadSource parameters = DataUrl.readJsonStringArraySimple(urlInformation.get("parameters")) - .parallelStream() - .filter(JsonObject.class::isInstance).map(JsonObject.class::cast) + .parallelStream().filter(JsonObject.class::isInstance).map(JsonObject.class::cast) .filter(map -> map.getBoolean("enabled", false)).filter(map -> map.containsKey("parameter")) .map(map -> map.getString("parameter")).collect(Collectors.toList()); if (!parameters.isEmpty()) { diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPluginTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPluginTest.java index f52b665..2c55996 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPluginTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/MapWithAIPluginTest.java @@ -88,10 +88,10 @@ public class MapWithAIPluginTest { plugin.destroy(); Assert.assertEquals(dataMenuSize, dataMenu.getMenuComponentCount()); Awaitility.await().atMost(Durations.FIVE_SECONDS) - .until(() -> existed == MapWithAIDataUtils.checkIfMapWithAIPaintStyleExists()); + .until(() -> existed == MapWithAIDataUtils.checkIfMapWithAIPaintStyleExists()); Assert.assertEquals(Config.getPref().getBoolean(MapWithAIPlugin.PAINTSTYLE_PREEXISTS) ? 1 : 0, MapPaintStyles.getStyles().getStyleSources().parallelStream() - .filter(source -> source.url != null && source.name.contains("MapWithAI")).count()); + .filter(source -> source.url != null && source.name.contains("MapWithAI")).count()); } for (int i = 0; i < 3; i++) { diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/UpdateProdTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/UpdateProdTest.java index 9fa300a..a45c011 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/UpdateProdTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/UpdateProdTest.java @@ -29,11 +29,9 @@ public class UpdateProdTest { String booleanKey = "message.".concat(MapWithAIPlugin.NAME.concat(".ignore_next_version")); String intKey = "message.".concat(MapWithAIPlugin.NAME.concat(".ignore_next_version")).concat(".value"); // "message.MapWithAI.ignore_next_version.value"; Config.getPref().putBoolean(booleanKey, false); - Config.getPref().putInt(intKey, - JOptionPane.YES_OPTION); + Config.getPref().putInt(intKey, JOptionPane.YES_OPTION); assertTrue(UpdateProd.doProd(Integer.MAX_VALUE)); - Config.getPref().putInt(intKey, - JOptionPane.NO_OPTION); + Config.getPref().putInt(intKey, JOptionPane.NO_OPTION); assertTrue(UpdateProd.doProd(Integer.MAX_VALUE)); assertFalse(UpdateProd.doProd(0)); } diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DetectTaskingManagerUtilsTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DetectTaskingManagerUtilsTest.java index 7f69d36..0d1f881 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DetectTaskingManagerUtilsTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/DetectTaskingManagerUtilsTest.java @@ -65,8 +65,9 @@ public class DetectTaskingManagerUtilsTest { Assert.assertFalse(DetectTaskingManagerUtils.hasTaskingManagerLayer()); final BBox bbox = new BBox(0, 0, 1, 1); - MainApplication.getLayerManager().addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox), - DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA)); + MainApplication.getLayerManager() + .addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox), + DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA)); Assert.assertTrue(DetectTaskingManagerUtils.hasTaskingManagerLayer()); Assert.assertTrue(DetectTaskingManagerUtils.getTaskingManagerBBox().bounds(bbox)); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnableTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnableTest.java index 3dc1e9d..b046aa4 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnableTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/GetDataRunnableTest.java @@ -115,8 +115,8 @@ public class GetDataRunnableTest { @Test public void testRegressionTicket46() { DataSet ds = new DataSet(); - new GetDataRunnable(Arrays.asList(new BBox(-5.7400005, 34.4524384, -5.6686014, 34.5513153)), ds, - null).fork().join(); + new GetDataRunnable(Arrays.asList(new BBox(-5.7400005, 34.4524384, -5.6686014, 34.5513153)), ds, null).fork() + .join(); assertNotNull(ds); assertFalse(ds.isEmpty()); assertFalse(ds.allNonDeletedPrimitives().isEmpty()); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIActionTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIActionTest.java index 203cd6b..1eaa367 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIActionTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIActionTest.java @@ -53,7 +53,7 @@ public class MapWithAIActionTest { MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(), "temporary", null)); action.actionPerformed(null); Awaitility.await().atMost(Durations.TEN_SECONDS) - .until(() -> 1 == MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).size()); + .until(() -> 1 == MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).size()); assertEquals(1, MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).size()); assertSame(MapWithAIDataUtils.getLayer(false), MainApplication.getLayerManager().getActiveLayer()); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailabilityTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailabilityTest.java index d04fea6..d649795 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailabilityTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIAvailabilityTest.java @@ -31,8 +31,8 @@ public class MapWithAIAvailabilityTest { @Before public void setUp() { wireMock.start(); - MapWithAIAvailability.setReleaseUrl(wireMock.baseUrl() - + "/facebookmicrosites/Open-Mapping-At-Facebook/master/data/rapid_releases.geojson"); + MapWithAIAvailability.setReleaseUrl( + wireMock.baseUrl() + "/facebookmicrosites/Open-Mapping-At-Facebook/master/data/rapid_releases.geojson"); Territories.initialize(); instance = MapWithAIAvailability.getInstance(); LatLon temp = new LatLon(40, -100); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIMoveActionTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIMoveActionTest.java index eb7bca6..496a388 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIMoveActionTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIMoveActionTest.java @@ -35,8 +35,7 @@ public class MapWithAIMoveActionTest { moveAction = new MapWithAIMoveAction(); final DataSet osmData = new DataSet(); mapWithAIData = new DataSet(); - way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), - new Node(new LatLon(0.1, 0.1))); + way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0.1, 0.1))); way2 = TestUtils.newWay("highway=residential", new Node(new LatLon(-0.1, -0.1)), new Node(new LatLon(0.1, 0.1))); way1.getNodes().forEach(node -> mapWithAIData.addPrimitive(node)); @@ -45,8 +44,7 @@ public class MapWithAIMoveActionTest { mapWithAIData.addPrimitive(way1); osmLayer = new OsmDataLayer(osmData, "osm", null); - final MapWithAILayer mapWithAILayer = new MapWithAILayer(mapWithAIData, "MapWithAI", - null); + final MapWithAILayer mapWithAILayer = new MapWithAILayer(mapWithAIData, "MapWithAI", null); MainApplication.getLayerManager().addLayer(osmLayer); MainApplication.getLayerManager().addLayer(mapWithAILayer); MainApplication.getLayerManager().setActiveLayer(mapWithAILayer); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControlTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControlTest.java index 8235a4f..d349570 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControlTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIRemoteControlTest.java @@ -52,13 +52,11 @@ public class MapWithAIRemoteControlTest { @Before public void setUp() { wireMock.start(); - MapWithAIPreferenceHelper.setMapWithAIURLs(MapWithAIPreferenceHelper.getMapWithAIURLs().stream() - .map(map -> { - map.put("url", - map.getOrDefault("url", MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API) - .replace("https://www.facebook.com", wireMock.baseUrl())); - return map; - }).collect(Collectors.toList())); + MapWithAIPreferenceHelper.setMapWithAIURLs(MapWithAIPreferenceHelper.getMapWithAIURLs().stream().map(map -> { + map.put("url", map.getOrDefault("url", MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API) + .replace("https://www.facebook.com", wireMock.baseUrl())); + return map; + }).collect(Collectors.toList())); } @After @@ -76,6 +74,7 @@ public class MapWithAIRemoteControlTest { /** * Unit test for bad request - invalid URL. + * * @throws Exception if any error occurs */ @Test @@ -134,9 +133,8 @@ public class MapWithAIRemoteControlTest { thrown.expect(RequestHandlerBadRequestException.class); thrown.expectMessage("NumberFormatException (For input string: \"BAD_VALUE\")"); - newHandler( - "http://127.0.0.1:8111/mapwithai?bbox=" + getTestBBox().toStringCSV(",") + "&max_obj=BAD_VALUE") - .handle(); + newHandler("http://127.0.0.1:8111/mapwithai?bbox=" + getTestBBox().toStringCSV(",") + "&max_obj=BAD_VALUE") + .handle(); } @Test @@ -146,8 +144,9 @@ public class MapWithAIRemoteControlTest { assertFalse(MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).isEmpty()); await().atMost(Durations.TEN_SECONDS) - .until(() -> !MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().isEmpty()); - final BBox added = MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().iterator().next().toBBox(); + .until(() -> !MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().isEmpty()); + final BBox added = MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().iterator().next() + .toBBox(); assertTrue(temp.bounds(added)); MainApplication.getLayerManager().removeLayer(MapWithAIDataUtils.getLayer(false)); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHookTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHookTest.java index fec768f..322e495 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHookTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIUploadHookTest.java @@ -104,8 +104,8 @@ public class MapWithAIUploadHookTest { BBox tBBox = new BBox(1, 0, 0, 1); MainApplication.getLayerManager() - .addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(tBBox), - DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA)); + .addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(tBBox), + DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA)); tags.clear(); hook.modifyChangesetTags(tags); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddComandTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddComandTest.java index 66f8055..790d5fc 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddComandTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/MapWithAIAddComandTest.java @@ -102,8 +102,8 @@ public class MapWithAIAddComandTest { new Node(new LatLon(0.05, 0.2))); way2.firstNode().put("conn", "w".concat(Long.toString(way1.getUniqueId())).concat(",n") - .concat(Long.toString(way1.firstNode().getUniqueId())).concat(",n") - .concat(Long.toString(way1.lastNode().getUniqueId()))); + .concat(Long.toString(way1.firstNode().getUniqueId())).concat(",n") + .concat(Long.toString(way1.lastNode().getUniqueId()))); way1.getNodes().forEach(node -> ds1.addPrimitive(node)); way2.getNodes().forEach(node -> ds1.addPrimitive(node)); ds1.addPrimitive(way2); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/MergeAddressBuildingsTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/MergeAddressBuildingsTest.java index f95a91f..0939f07 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/MergeAddressBuildingsTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/commands/conflation/MergeAddressBuildingsTest.java @@ -59,7 +59,7 @@ public class MergeAddressBuildingsTest { Node address = TestUtils.newNode("addr:street=None addr:housenumber=2"); building.getNodes().forEach(ds::addPrimitive); MainApplication.getLayerManager() - .addLayer(new OsmDataLayer(ds, "required for ReplaceGeometry in utilsplugin2", null)); + .addLayer(new OsmDataLayer(ds, "required for ReplaceGeometry in utilsplugin2", null)); ds.addPrimitive(building); ds.addPrimitive(address); diff --git a/test/unit/org/openstreetmap/josm/plugins/mapwithai/frontend/MapWithAIDownloadReaderTest.java b/test/unit/org/openstreetmap/josm/plugins/mapwithai/frontend/MapWithAIDownloadReaderTest.java index bc135bb..0b14fa8 100644 --- a/test/unit/org/openstreetmap/josm/plugins/mapwithai/frontend/MapWithAIDownloadReaderTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/mapwithai/frontend/MapWithAIDownloadReaderTest.java @@ -79,7 +79,7 @@ public class MapWithAIDownloadReaderTest { Awaitility.await().atMost(Durations.TEN_SECONDS).until(() -> MapWithAIDataUtils.getLayer(false) != null); assertNotNull(MapWithAIDataUtils.getLayer(false)); Awaitility.await().atMost(Durations.TEN_SECONDS) - .until(() -> !MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().isEmpty()); + .until(() -> !MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().isEmpty()); assertFalse(MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().isEmpty()); assertTrue(settings.getDownloadBounds().get().toBBox().bboxIsFunctionallyEqual( MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().get(0).toBBox(), 0.0001));