kopia lustrzana https://github.com/JOSM/MapWithAI
Fix some unit tests
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
9e80b4fa63
commit
fea93b59ad
|
@ -139,6 +139,7 @@ spotless {
|
||||||
|
|
||||||
josm {
|
josm {
|
||||||
manifest {
|
manifest {
|
||||||
|
oldVersionDownloadLink 16220, "v1.4.1", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.4.1/mapwithai.jar")
|
||||||
oldVersionDownloadLink 15820, "v1.3.7", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.3.7/mapwithai.jar")
|
oldVersionDownloadLink 15820, "v1.3.7", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.3.7/mapwithai.jar")
|
||||||
oldVersionDownloadLink 15737, "v1.2.3", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.2.3/mapwithai.jar")
|
oldVersionDownloadLink 15737, "v1.2.3", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.2.3/mapwithai.jar")
|
||||||
oldVersionDownloadLink 15609, "v1.1.8", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.1.8/mapwithai.jar")
|
oldVersionDownloadLink 15609, "v1.1.8", new URL("https://gokaart.gitlab.io/JOSM_MapWithAI/dist/v1.1.8/mapwithai.jar")
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# The minimum JOSM version this plugin is compatible with (can be any numeric version
|
# The minimum JOSM version this plugin is compatible with (can be any numeric version
|
||||||
plugin.main.version = 16220
|
plugin.main.version = 16284
|
||||||
# The JOSM version this plugin is currently compiled against
|
# The JOSM version this plugin is currently compiled against
|
||||||
# Please make sure this version is available at https://josm.openstreetmap.de/download
|
# Please make sure this version is available at https://josm.openstreetmap.de/download
|
||||||
# The special values "latest" and "tested" are also possible here, but not recommended.
|
# The special values "latest" and "tested" are also possible here, but not recommended.
|
||||||
plugin.compile.version = 16220
|
plugin.compile.version = 16284
|
||||||
plugin.canloadatruntime = true
|
plugin.canloadatruntime = true
|
||||||
plugin.author = Taylor Smock <incoming+gokaart/JOSM_MapWithAI@incoming.gitlab.com>
|
plugin.author = Taylor Smock <incoming+gokaart/JOSM_MapWithAI@incoming.gitlab.com>
|
||||||
plugin.class = org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin
|
plugin.class = org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.json.Json;
|
import javax.json.Json;
|
||||||
import javax.json.JsonException;
|
import javax.json.JsonException;
|
||||||
|
@ -22,6 +23,8 @@ import javax.json.stream.JsonParser;
|
||||||
import org.openstreetmap.josm.data.coor.LatLon;
|
import org.openstreetmap.josm.data.coor.LatLon;
|
||||||
import org.openstreetmap.josm.data.osm.BBox;
|
import org.openstreetmap.josm.data.osm.BBox;
|
||||||
import org.openstreetmap.josm.io.CachedFile;
|
import org.openstreetmap.josm.io.CachedFile;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
||||||
import org.openstreetmap.josm.tools.Logging;
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
import org.openstreetmap.josm.tools.Territories;
|
import org.openstreetmap.josm.tools.Territories;
|
||||||
import org.openstreetmap.josm.tools.Utils;
|
import org.openstreetmap.josm.tools.Utils;
|
||||||
|
@ -235,15 +238,17 @@ public class DataAvailability {
|
||||||
* @return List of terms of use urls
|
* @return List of terms of use urls
|
||||||
*/
|
*/
|
||||||
public static final List<String> getTermsOfUse() {
|
public static final List<String> getTermsOfUse() {
|
||||||
return DATA_SOURCES.stream().map(clazz -> {
|
return Stream.concat(MapWithAILayerInfo.instance.getLayers().stream().map(MapWithAIInfo::getTermsOfUseURL),
|
||||||
try {
|
DATA_SOURCES.stream().map(clazz -> {
|
||||||
return clazz.getConstructor().newInstance().getTermsOfUseUrl();
|
try {
|
||||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
return clazz.getConstructor().newInstance().getTermsOfUseUrl();
|
||||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||||
Logging.debug(e);
|
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
}
|
Logging.debug(e);
|
||||||
return "";
|
}
|
||||||
}).filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty()).collect(Collectors.toList());
|
return "";
|
||||||
|
})).filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty())
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,15 +257,17 @@ public class DataAvailability {
|
||||||
* @return List of privacy policy urls
|
* @return List of privacy policy urls
|
||||||
*/
|
*/
|
||||||
public static final List<String> getPrivacyPolicy() {
|
public static final List<String> getPrivacyPolicy() {
|
||||||
return DATA_SOURCES.stream().map(clazz -> {
|
return Stream.concat(MapWithAILayerInfo.instance.getLayers().stream().map(MapWithAIInfo::getPrivacyPolicyURL),
|
||||||
try {
|
DATA_SOURCES.stream().map(clazz -> {
|
||||||
return clazz.getConstructor().newInstance().getPrivacyPolicyUrl();
|
try {
|
||||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
return clazz.getConstructor().newInstance().getPrivacyPolicyUrl();
|
||||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
|
||||||
Logging.debug(e);
|
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||||
}
|
Logging.debug(e);
|
||||||
return "";
|
}
|
||||||
}).filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty()).collect(Collectors.toList());
|
return "";
|
||||||
|
})).filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty()).distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class MapWithAISourceReader implements Closeable {
|
||||||
info.setDefaultEntry(values.getBoolean("default", false));
|
info.setDefaultEntry(values.getBoolean("default", false));
|
||||||
info.setParameters(values.getJsonArray("parameters"));
|
info.setParameters(values.getJsonArray("parameters"));
|
||||||
if (values.containsKey("terms_of_use_url")) {
|
if (values.containsKey("terms_of_use_url")) {
|
||||||
info.setTermsOfUseText(values.getString("terms_of_use_url"));
|
info.setTermsOfUseURL(values.getString("terms_of_use_url"));
|
||||||
}
|
}
|
||||||
if (values.containsKey("privacy_policy_url")) {
|
if (values.containsKey("privacy_policy_url")) {
|
||||||
info.setPrivacyPolicyURL(values.getString("privacy_policy_url"));
|
info.setPrivacyPolicyURL(values.getString("privacy_policy_url"));
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,28 +0,0 @@
|
||||||
{
|
|
||||||
"id" : "2aac807a-9c8c-4713-a806-9f2451600f2b",
|
|
||||||
"name" : "maps_ml_roads",
|
|
||||||
"request" : {
|
|
||||||
"url" : "/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&bbox=-108.5715723,39.0734162,-108.5707107,39.0738791&crop_bbox=-108.5711561,39.0735205,-108.5708568,39.0736682&result_type=road_building_vector_xml",
|
|
||||||
"method" : "GET"
|
|
||||||
},
|
|
||||||
"response" : {
|
|
||||||
"status" : 200,
|
|
||||||
"body" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<osm generator=\"NS_ROADS_SERVICE\" version=\"0.6\"><bounds maxlat=\"39.0738691\" maxlon=\"-108.57072358101\" minlat=\"39.0734262\" minlon=\"-108.57155941899\"/><node id=\"-2976339053870190188\" lon=\"-108.5708568\" lat=\"39.073597910501\" visible=\"true\"/><way id=\"-4444230471161502073\" orig_id=\"-1203473873173507\" visible=\"true\" action=\"modify\"><tag k=\"highway\" v=\"residential\"/><tag k=\"source\" v=\"digitalglobe\"/><nd ref=\"-710999622096597555\"/><nd ref=\"-373066400259132\"/><nd ref=\"-2976339053870190188\"/></way><node action=\"modify\" id=\"-710999622096597555\" lat=\"39.0736112\" lon=\"-108.5710852\" visible=\"true\"><tag k=\"dupe\" v=\"n6815623346\"/></node><node action=\"modify\" id=\"-373066400259132\" lat=\"39.0735933\" lon=\"-108.5709927\" visible=\"true\"/></osm>\n",
|
|
||||||
"headers" : {
|
|
||||||
"Content-Type" : "text/xml; charset=UTF-8",
|
|
||||||
"Strict-Transport-Security" : "max-age=15552000; preload",
|
|
||||||
"Vary" : "Accept-Encoding",
|
|
||||||
"X-Content-Type-Options" : "nosniff",
|
|
||||||
"X-Frame-Options" : "DENY",
|
|
||||||
"X-XSS-Protection" : "0",
|
|
||||||
"Access-Control-Allow-Origin" : "https://mapwith.ai",
|
|
||||||
"X-FB-Debug" : "pAVoB1d1AQr2FejyueTMcu+w/Dz6gRkTSWM8vHG9Is5MwRmNnY97YHiWDtoDigLbkHsoKHQtAWaRwWI+47NZKw==",
|
|
||||||
"Date" : "Thu, 05 Dec 2019 14:25:09 GMT",
|
|
||||||
"Alt-Svc" : "h3-23=\":443\"; ma=3600",
|
|
||||||
"Connection" : "keep-alive"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"uuid" : "2aac807a-9c8c-4713-a806-9f2451600f2b",
|
|
||||||
"persistent" : true,
|
|
||||||
"insertionIndex" : 3
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,28 +0,0 @@
|
||||||
{
|
|
||||||
"id" : "5547df42-8d64-4a75-8a27-d598b4de5968",
|
|
||||||
"name" : "maps_ml_roads",
|
|
||||||
"request" : {
|
|
||||||
"url" : "/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&bbox=-108.5715723,39.0734162,-108.5707107,39.0738791",
|
|
||||||
"method" : "GET"
|
|
||||||
},
|
|
||||||
"response" : {
|
|
||||||
"status" : 200,
|
|
||||||
"body" : "<?xml version=\"1.0\"?>\n<osm attribution=\"http://www.openstreetmap.org/copyright\" copyright=\"OpenStreetMap and contributors\" generator=\"fb_conflation_service\" version=\"0.6\">\n <bounds maxlat=\"39.0738691\" maxlon=\"-108.57072358101\" minlat=\"39.0734262\" minlon=\"-108.57155941899\"/>\n <node action=\"modify\" id=\"-3625810361941368501\" lat=\"39.0736017\" lon=\"-108.5707451\" visible=\"true\">\n <tag k=\"conn\" v=\"w626760817,n5917002841,n5917002155\"/>\n </node>\n <node action=\"modify\" id=\"-373066400259132\" lat=\"39.0735933\" lon=\"-108.5709927\" visible=\"true\"/>\n <way action=\"modify\" id=\"-4444230471161502072\" orig_id=\"-1203473873173507\" visible=\"true\">\n <nd ref=\"-710999622096597555\"/>\n <nd ref=\"-373066400259132\"/>\n <nd ref=\"-3625810361941368501\"/>\n <tag k=\"highway\" v=\"residential\"/>\n <tag k=\"source\" v=\"digitalglobe\"/>\n </way>\n <node action=\"modify\" id=\"-710999622096597555\" lat=\"39.0736112\" lon=\"-108.5710852\" visible=\"true\">\n <tag k=\"dupe\" v=\"n6815623346\"/>\n </node>\n <node action=\"modify\" id=\"-2406517166226748\" lat=\"39.0736540\" lon=\"-108.5718322\" visible=\"true\">\n <tag k=\"dupe\" v=\"n5907055578\"/>\n </node>\n <node action=\"modify\" id=\"-2406517166226748\" lat=\"39.0736540\" lon=\"-108.5718322\" visible=\"true\">\n <tag k=\"dupe\" v=\"n6815623345\"/>\n </node>\n <way action=\"modify\" id=\"-4444230471161502073\" orig_id=\"-1203473873173507\" visible=\"true\">\n <nd ref=\"-2406517166226748\"/>\n <nd ref=\"-2406517166226748\"/>\n <tag k=\"highway\" v=\"service\"/>\n <tag k=\"source\" v=\"digitalglobe\"/>\n </way>\n</osm>\n",
|
|
||||||
"headers" : {
|
|
||||||
"Content-Type" : "text/xml; charset=UTF-8",
|
|
||||||
"Strict-Transport-Security" : "max-age=15552000; preload",
|
|
||||||
"Vary" : "Accept-Encoding",
|
|
||||||
"X-Content-Type-Options" : "nosniff",
|
|
||||||
"X-Frame-Options" : "DENY",
|
|
||||||
"X-XSS-Protection" : "0",
|
|
||||||
"Access-Control-Allow-Origin" : "https://mapwith.ai",
|
|
||||||
"X-FB-Debug" : "PO3X3PMMLb3HV54QiTBVn22/bnfz0ZqWTjvT4wBDXxjrZCbSWSX8/uGfQ7ItzmBiQQJ0ytFBpHWmvZm48YWdUQ==",
|
|
||||||
"Date" : "Wed, 18 Dec 2019 20:28:03 GMT",
|
|
||||||
"Alt-Svc" : "h3-24=\":443\"; ma=3600",
|
|
||||||
"Connection" : "keep-alive"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"uuid" : "5547df42-8d64-4a75-8a27-d598b4de5968",
|
|
||||||
"persistent" : true,
|
|
||||||
"insertionIndex" : 18
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai;
|
package org.openstreetmap.josm.plugins.mapwithai;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@ -16,7 +15,6 @@ import javax.swing.JMenu;
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -25,11 +23,10 @@ import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
|
||||||
import org.openstreetmap.josm.plugins.PluginInformation;
|
import org.openstreetmap.josm.plugins.PluginInformation;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAIPreferences;
|
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAIPreferences;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,30 +35,21 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
public class MapWithAIPluginTest {
|
public class MapWithAIPluginTest {
|
||||||
@Rule
|
@Rule
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules test = new JOSMTestRules().preferences().main();
|
public JOSMTestRules test = new MapWithAITestRules().wiremock().preferences().main();
|
||||||
|
|
||||||
public PluginInformation info;
|
public PluginInformation info;
|
||||||
public MapWithAIPlugin plugin;
|
public MapWithAIPlugin plugin;
|
||||||
|
|
||||||
private static final String VERSION = "no-such-version";
|
private static final String VERSION = "no-such-version";
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws java.lang.Exception
|
* @throws java.lang.Exception
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
wireMock.start();
|
|
||||||
final InputStream in = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
|
final InputStream in = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
|
||||||
info = new PluginInformation(in, "MapWithAI", null);
|
info = new PluginInformation(in, "MapWithAI", null);
|
||||||
info.localversion = VERSION;
|
info.localversion = VERSION;
|
||||||
MapWithAIDataUtils.setPaintStyleUrl(
|
|
||||||
MapWithAIDataUtils.getPaintStyleUrl().replace(Config.getUrls().getJOSMWebsite(), wireMock.baseUrl()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,9 +13,9 @@ import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.TestUtils;
|
import org.openstreetmap.josm.TestUtils;
|
||||||
import org.openstreetmap.josm.data.Version;
|
import org.openstreetmap.josm.data.Version;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.testutils.OpenBrowserMocker;
|
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
import org.openstreetmap.josm.testutils.mockers.OpenBrowserMocker;
|
||||||
import org.openstreetmap.josm.testutils.mockers.WindowMocker;
|
import org.openstreetmap.josm.testutils.mockers.WindowMocker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
@ -12,34 +11,17 @@ import java.net.URL;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.actions.downloadtasks.DownloadParams;
|
import org.openstreetmap.josm.actions.downloadtasks.DownloadParams;
|
||||||
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAILayerInfoTest;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
public class DownloadMapWithAITaskTest {
|
public class DownloadMapWithAITaskTest {
|
||||||
@Rule
|
@Rule
|
||||||
public JOSMTestRules rule = new JOSMTestRules().preferences().fakeAPI().projection().territories();
|
public JOSMTestRules rule = new MapWithAITestRules().wiremock().preferences().fakeAPI().projection().territories();
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
wireMock.start();
|
|
||||||
MapWithAILayerInfoTest.setupMapWithAILayerInfo(wireMock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
MapWithAILayerInfoTest.resetMapWithAILayerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDownloadOsmServerReaderDownloadParamsBoundsProgressMonitor()
|
public void testDownloadOsmServerReaderDownloadParamsBoundsProgressMonitor()
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
@ -15,8 +14,6 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.TestUtils;
|
import org.openstreetmap.josm.TestUtils;
|
||||||
|
@ -29,7 +26,7 @@ import org.openstreetmap.josm.data.osm.WaySegment;
|
||||||
import org.openstreetmap.josm.data.projection.ProjectionRegistry;
|
import org.openstreetmap.josm.data.projection.ProjectionRegistry;
|
||||||
import org.openstreetmap.josm.gui.MainApplication;
|
import org.openstreetmap.josm.gui.MainApplication;
|
||||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAILayerInfoTest;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
import org.openstreetmap.josm.tools.Geometry;
|
import org.openstreetmap.josm.tools.Geometry;
|
||||||
|
|
||||||
|
@ -37,21 +34,7 @@ import com.github.tomakehurst.wiremock.WireMockServer;
|
||||||
|
|
||||||
public class GetDataRunnableTest {
|
public class GetDataRunnableTest {
|
||||||
@Rule
|
@Rule
|
||||||
public JOSMTestRules rule = new JOSMTestRules().projection().fakeAPI().territories();
|
public JOSMTestRules rule = new MapWithAITestRules().wiremock().projection().fakeAPI().territories();
|
||||||
|
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
wireMock.start();
|
|
||||||
MapWithAILayerInfoTest.setupMapWithAILayerInfo(wireMock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
MapWithAILayerInfoTest.resetMapWithAILayerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDefaultMapWithAIAPIForTest(WireMockServer wireMock, String url) {
|
public static String getDefaultMapWithAIAPIForTest(WireMockServer wireMock, String url) {
|
||||||
return getDefaultMapWithAIAPIForTest(wireMock, url, "https://www.mapwith.ai");
|
return getDefaultMapWithAIAPIForTest(wireMock, url, "https://www.mapwith.ai");
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.awaitility.Awaitility.await;
|
import static org.awaitility.Awaitility.await;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
@ -13,7 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -25,36 +23,26 @@ import org.openstreetmap.josm.gui.MainApplication;
|
||||||
import org.openstreetmap.josm.gui.Notification;
|
import org.openstreetmap.josm.gui.Notification;
|
||||||
import org.openstreetmap.josm.gui.layer.Layer;
|
import org.openstreetmap.josm.gui.layer.Layer;
|
||||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
import org.openstreetmap.josm.tools.Territories;
|
import org.openstreetmap.josm.tools.Territories;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
public class MapWithAIActionTest {
|
public class MapWithAIActionTest {
|
||||||
@Rule
|
@Rule
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules test = new JOSMTestRules().main().projection().territories().timeout(100000);
|
public JOSMTestRules test = new MapWithAITestRules().wiremock().main().projection().territories().timeout(100000);
|
||||||
|
|
||||||
private MapWithAIAction action;
|
private MapWithAIAction action;
|
||||||
|
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
action = new MapWithAIAction();
|
action = new MapWithAIAction();
|
||||||
wireMock.start(); // This is required to avoid failing a test in MapWithAIAvailabilityTest
|
|
||||||
DataAvailability.setReleaseUrl(wireMock.baseUrl() + "/JOSM_MapWithAI/json/sources.json");
|
|
||||||
LatLon temp = new LatLon(40, -100);
|
LatLon temp = new LatLon(40, -100);
|
||||||
await().atMost(Durations.TEN_SECONDS).until(() -> Territories.isIso3166Code("US", temp));
|
await().atMost(Durations.TEN_SECONDS).until(() -> Territories.isIso3166Code("US", temp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnabled() {
|
public void testEnabled() {
|
||||||
assertFalse(action.isEnabled());
|
assertFalse(action.isEnabled());
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.awaitility.Awaitility.await;
|
import static org.awaitility.Awaitility.await;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
@ -11,19 +10,16 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.data.coor.LatLon;
|
import org.openstreetmap.josm.data.coor.LatLon;
|
||||||
import org.openstreetmap.josm.data.osm.BBox;
|
import org.openstreetmap.josm.data.osm.BBox;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAILayerInfoTest;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
import org.openstreetmap.josm.tools.Territories;
|
import org.openstreetmap.josm.tools.Territories;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
public class MapWithAIAvailabilityTest {
|
public class MapWithAIAvailabilityTest {
|
||||||
|
@ -31,25 +27,15 @@ public class MapWithAIAvailabilityTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules test = new JOSMTestRules().projection().territories();
|
public JOSMTestRules test = new MapWithAITestRules().wiremock().projection().territories();
|
||||||
|
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
wireMock.start();
|
|
||||||
MapWithAILayerInfoTest.setupMapWithAILayerInfo(wireMock);
|
|
||||||
instance = DataAvailability.getInstance();
|
instance = DataAvailability.getInstance();
|
||||||
LatLon temp = new LatLon(40, -100);
|
LatLon temp = new LatLon(40, -100);
|
||||||
await().atMost(Durations.TEN_SECONDS).until(() -> Territories.isIso3166Code("US", temp));
|
await().atMost(Durations.TEN_SECONDS).until(() -> Territories.isIso3166Code("US", temp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
MapWithAILayerInfoTest.resetMapWithAILayerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasDataBBox() {
|
public void testHasDataBBox() {
|
||||||
assertFalse(instance.hasData(new BBox(0, 0, 0.1, 0.1)), "There shouldn't be data in the ocean");
|
assertFalse(instance.hasData(new BBox(0, 0, 0.1, 0.1)), "There shouldn't be data in the ocean");
|
||||||
|
@ -71,10 +57,10 @@ public class MapWithAIAvailabilityTest {
|
||||||
"The US should have highway data");
|
"The US should have highway data");
|
||||||
assertTrue(DataAvailability.getDataTypes(new LatLon(40, -100)).getOrDefault("building", false),
|
assertTrue(DataAvailability.getDataTypes(new LatLon(40, -100)).getOrDefault("building", false),
|
||||||
"The US should have building data");
|
"The US should have building data");
|
||||||
assertFalse(DataAvailability.getDataTypes(new LatLon(71.67, -42.85)).getOrDefault("highway", false),
|
assertFalse(DataAvailability.getDataTypes(new LatLon(39.1, 125.7)).getOrDefault("highway", false),
|
||||||
"Denmark should not have highway data");
|
"North Korea should not have highway data");
|
||||||
assertFalse(DataAvailability.getDataTypes(new LatLon(71.67, -42.85)).getOrDefault("building", false),
|
assertFalse(DataAvailability.getDataTypes(new LatLon(39.1, 125.7)).getOrDefault("building", false),
|
||||||
"Denmark does not have building data");
|
"North Korea does not have building data");
|
||||||
assertTrue(DataAvailability.getDataTypes(new LatLon(19.433333, -99.133333)).getOrDefault("highway", false),
|
assertTrue(DataAvailability.getDataTypes(new LatLon(19.433333, -99.133333)).getOrDefault("highway", false),
|
||||||
"Mexico has highway data");
|
"Mexico has highway data");
|
||||||
assertFalse(DataAvailability.getDataTypes(new LatLon(19.433333, -99.133333)).getOrDefault("building", false),
|
assertFalse(DataAvailability.getDataTypes(new LatLon(19.433333, -99.133333)).getOrDefault("building", false),
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
@ -17,8 +16,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.TestUtils;
|
import org.openstreetmap.josm.TestUtils;
|
||||||
|
@ -36,36 +33,17 @@ import org.openstreetmap.josm.gui.layer.GpxLayer;
|
||||||
import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
|
import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
|
||||||
import org.openstreetmap.josm.gui.mappaint.StyleSource;
|
import org.openstreetmap.josm.gui.mappaint.StyleSource;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAILayerInfoTest;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
import org.openstreetmap.josm.tools.Logging;
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
public class MapWithAIDataUtilsTest {
|
public class MapWithAIDataUtilsTest {
|
||||||
@Rule
|
@Rule
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules test = new JOSMTestRules().preferences().main().projection().fakeAPI().territories();
|
public JOSMTestRules test = new MapWithAITestRules().sources().wiremock().preferences().main().projection()
|
||||||
|
.fakeAPI().territories();
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
wireMock.start();
|
|
||||||
|
|
||||||
MapWithAILayerInfoTest.resetMapWithAILayerInfo();
|
|
||||||
MapWithAIDataUtils.setPaintStyleUrl(
|
|
||||||
MapWithAIDataUtils.getPaintStyleUrl().replace(Config.getUrls().getJOSMWebsite(), wireMock.baseUrl()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
MapWithAILayerInfoTest.resetMapWithAILayerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This gets data from MapWithAI. This test may fail if someone adds the data to
|
* This gets data from MapWithAI. This test may fail if someone adds the data to
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.awaitility.Awaitility.await;
|
import static org.awaitility.Awaitility.await;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
@ -24,7 +23,6 @@ import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -46,12 +44,10 @@ import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer.ContinuousDownloadAction;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer.ContinuousDownloadAction;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
|
import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAILayerInfoTest;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,25 +57,16 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
public class MapWithAILayerTest {
|
public class MapWithAILayerTest {
|
||||||
@Rule
|
@Rule
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules test = new JOSMTestRules().preferences().main().projection().fakeAPI().territories();
|
public JOSMTestRules test = new MapWithAITestRules().wiremock().preferences().main().projection().fakeAPI()
|
||||||
|
.territories();
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
MapWithAILayer layer;
|
MapWithAILayer layer;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
wireMock.start();
|
|
||||||
MapWithAILayerInfoTest.setupMapWithAILayerInfo(wireMock);
|
|
||||||
layer = new MapWithAILayer(new DataSet(), "test", null);
|
layer = new MapWithAILayer(new DataSet(), "test", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
MapWithAILayerInfoTest.resetMapWithAILayerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSource() {
|
public void testGetSource() {
|
||||||
assertNull(layer.getChangesetSourceTag(), "The source tag should be null");
|
assertNull(layer.getChangesetSourceTag(), "The source tag should be null");
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.awaitility.Awaitility.await;
|
import static org.awaitility.Awaitility.await;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
@ -11,8 +10,6 @@ import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
@ -21,12 +18,10 @@ import org.openstreetmap.josm.gui.MainApplication;
|
||||||
import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
|
import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAILayerInfoTest;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
import org.openstreetmap.josm.tools.Utils;
|
import org.openstreetmap.josm.tools.Utils;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,21 +41,7 @@ public class MapWithAIRemoteControlTest {
|
||||||
*/
|
*/
|
||||||
@Rule
|
@Rule
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules test = new JOSMTestRules().main().projection().territories();
|
public JOSMTestRules test = new MapWithAITestRules().wiremock().main().projection().territories();
|
||||||
|
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
wireMock.start();
|
|
||||||
MapWithAILayerInfoTest.setupMapWithAILayerInfo(wireMock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
MapWithAILayerInfoTest.resetMapWithAILayerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MapWithAIRemoteControl newHandler(String url) throws RequestHandlerBadRequestException {
|
private static MapWithAIRemoteControl newHandler(String url) throws RequestHandlerBadRequestException {
|
||||||
final MapWithAIRemoteControl req = new MapWithAIRemoteControl();
|
final MapWithAIRemoteControl req = new MapWithAIRemoteControl();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
@ -12,8 +11,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.TestUtils;
|
import org.openstreetmap.josm.TestUtils;
|
||||||
|
@ -29,11 +26,9 @@ import org.openstreetmap.josm.gui.MainApplication;
|
||||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.ConnectedCommand;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.ConnectedCommand;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.DuplicateCommand;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.DuplicateCommand;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,20 +39,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
public class CreateConnectionsCommandTest {
|
public class CreateConnectionsCommandTest {
|
||||||
@Rule
|
@Rule
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules test = new JOSMTestRules().projection();
|
public JOSMTestRules test = new MapWithAITestRules().wiremock().projection();
|
||||||
|
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
wireMock.start();
|
|
||||||
Config.getPref().put("osm-server.url", wireMock.baseUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for
|
* Test method for
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
package org.openstreetmap.josm.plugins.mapwithai.commands;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
@ -15,8 +14,6 @@ import java.util.Collections;
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.TestUtils;
|
import org.openstreetmap.josm.TestUtils;
|
||||||
|
@ -33,11 +30,9 @@ import org.openstreetmap.josm.data.validation.tests.SharpAngles;
|
||||||
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
||||||
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.ConnectedCommand;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.ConnectedCommand;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
public class MapWithAIAddComandTest {
|
public class MapWithAIAddComandTest {
|
||||||
|
@ -45,20 +40,7 @@ public class MapWithAIAddComandTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules test = new JOSMTestRules().projection();
|
public JOSMTestRules test = new MapWithAITestRules().wiremock().projection();
|
||||||
|
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
wireMock.start();
|
|
||||||
Config.getPref().put("osm-server.url", wireMock.baseUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMoveCollection() {
|
public void testMoveCollection() {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.frontend;
|
package org.openstreetmap.josm.plugins.mapwithai.frontend;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
@ -10,8 +9,6 @@ import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.data.Bounds;
|
import org.openstreetmap.josm.data.Bounds;
|
||||||
|
@ -19,28 +16,12 @@ import org.openstreetmap.josm.gui.download.DownloadSettings;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIPreferenceHelper;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIPreferenceHelper;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAILayerInfoTest;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
public class MapWithAIDownloadReaderTest {
|
public class MapWithAIDownloadReaderTest {
|
||||||
@Rule
|
@Rule
|
||||||
public JOSMTestRules rules = new JOSMTestRules().projection().territories();
|
public JOSMTestRules rules = new MapWithAITestRules().wiremock().projection().territories();
|
||||||
|
|
||||||
WireMockServer wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
wireMock.start();
|
|
||||||
MapWithAILayerInfoTest.setupMapWithAILayerInfo(wireMock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
wireMock.stop();
|
|
||||||
MapWithAILayerInfoTest.resetMapWithAILayerInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetLabel() {
|
public void testGetLabel() {
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.gui.preferences;
|
|
||||||
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.GetDataRunnableTest;
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is currently (mostly) a utils class. It should be expanded to tests,
|
|
||||||
* sometime.
|
|
||||||
*
|
|
||||||
* @author Taylor Smock
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class MapWithAILayerInfoTest {
|
|
||||||
public static void setupMapWithAILayerInfo(WireMockServer wireMock) {
|
|
||||||
synchronized (MapWithAILayerInfoTest.class) {
|
|
||||||
resetMapWithAILayerInfo();
|
|
||||||
MapWithAILayerInfo.instance.getLayers().stream()
|
|
||||||
.forEach(i -> i.setUrl(GetDataRunnableTest.getDefaultMapWithAIAPIForTest(wireMock, i.getUrl())));
|
|
||||||
MapWithAILayerInfo.instance.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetMapWithAILayerInfo() {
|
|
||||||
synchronized (MapWithAILayerInfoTest.class) {
|
|
||||||
MapWithAILayerInfo.instance.clear();
|
|
||||||
MapWithAILayerInfo.instance.getDefaultLayers().stream().filter(MapWithAIInfo::isDefaultEntry)
|
|
||||||
.forEach(MapWithAILayerInfo.instance::add);
|
|
||||||
MapWithAILayerInfo.instance.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
// License: GPL. For details, see LICENSE file.
|
||||||
|
package org.openstreetmap.josm.plugins.mapwithai.testutils;
|
||||||
|
|
||||||
|
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.junit.runners.model.InitializationError;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.backend.DataAvailability;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.backend.GetDataRunnableTest;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
||||||
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
|
|
||||||
|
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||||
|
|
||||||
|
public class MapWithAITestRules extends JOSMTestRules {
|
||||||
|
|
||||||
|
private boolean sources;
|
||||||
|
private boolean wiremock;
|
||||||
|
private WireMockServer wireMock;
|
||||||
|
|
||||||
|
public MapWithAITestRules sources() {
|
||||||
|
this.sources = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapWithAITestRules wiremock() {
|
||||||
|
this.wiremock = true;
|
||||||
|
super.territories();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up before running a test
|
||||||
|
*
|
||||||
|
* @throws InitializationError If an error occurred while creating the
|
||||||
|
* required environment.
|
||||||
|
* @throws ReflectiveOperationException if a reflective access error occurs
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void before() throws InitializationError, ReflectiveOperationException {
|
||||||
|
super.before();
|
||||||
|
Logging.getLogger().setFilter(record -> record.getLevel().intValue() >= Level.WARNING.intValue()
|
||||||
|
|| record.getSourceClassName().startsWith("org.openstreetmap.josm.plugins.mapwithai"));
|
||||||
|
if (sources) {
|
||||||
|
MapWithAILayerInfo.instance.load(false);
|
||||||
|
}
|
||||||
|
if (wiremock) {
|
||||||
|
wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock"));
|
||||||
|
wireMock.start();
|
||||||
|
resetMapWithAILayerInfo();
|
||||||
|
setupMapWithAILayerInfo(wireMock);
|
||||||
|
MapWithAIDataUtils.setPaintStyleUrl(MapWithAIDataUtils.getPaintStyleUrl()
|
||||||
|
.replace(Config.getUrls().getJOSMWebsite(), wireMock.baseUrl()));
|
||||||
|
DataAvailability.setReleaseUrl(wireMock.baseUrl() + "/JOSM_MapWithAI/json/sources.json");
|
||||||
|
Config.getPref().put("osm-server.url", wireMock.baseUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void after() {
|
||||||
|
if (wiremock) {
|
||||||
|
wireMock.stop();
|
||||||
|
resetMapWithAILayerInfo();
|
||||||
|
DataAvailability.setReleaseUrl(DataAvailability.DEFAULT_SERVER_URL);
|
||||||
|
Config.getPref().put("osm-server.url", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setupMapWithAILayerInfo(WireMockServer wireMock) {
|
||||||
|
synchronized (MapWithAITestRules.class) {
|
||||||
|
resetMapWithAILayerInfo();
|
||||||
|
MapWithAILayerInfo.instance.getLayers().stream()
|
||||||
|
.forEach(i -> i.setUrl(GetDataRunnableTest.getDefaultMapWithAIAPIForTest(wireMock, i.getUrl())));
|
||||||
|
MapWithAILayerInfo.instance.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void resetMapWithAILayerInfo() {
|
||||||
|
synchronized (MapWithAITestRules.class) {
|
||||||
|
MapWithAILayerInfo.instance.clear();
|
||||||
|
MapWithAILayerInfo.instance.getDefaultLayers().stream().filter(MapWithAIInfo::isDefaultEntry)
|
||||||
|
.forEach(MapWithAILayerInfo.instance::add);
|
||||||
|
MapWithAILayerInfo.instance.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,25 +0,0 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.testutils;
|
|
||||||
|
|
||||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.openstreetmap.josm.tools.CheckParameterUtil;
|
|
||||||
import org.openstreetmap.josm.tools.Logging;
|
|
||||||
import org.openstreetmap.josm.tools.OpenBrowser;
|
|
||||||
|
|
||||||
import mockit.Mock;
|
|
||||||
import mockit.MockUp;
|
|
||||||
|
|
||||||
/** TODO Remove if #18766 is merged */
|
|
||||||
public class OpenBrowserMocker extends MockUp<OpenBrowser> {
|
|
||||||
@Mock
|
|
||||||
public static String displayUrl(URI uri) {
|
|
||||||
CheckParameterUtil.ensureParameterNotNull(uri, "uri");
|
|
||||||
|
|
||||||
Logging.debug(tr("Opening URL: {0}", uri));
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
Ładowanie…
Reference in New Issue