kopia lustrzana https://github.com/JOSM/MapWithAI
rodzic
8c80790127
commit
99f4de5dd4
|
@ -3,6 +3,9 @@ package org.openstreetmap.josm.plugins.mapwithai;
|
||||||
|
|
||||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
|
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -11,9 +14,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.swing.JMenu;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
|
|
||||||
import org.openstreetmap.josm.actions.JosmAction;
|
import org.openstreetmap.josm.actions.JosmAction;
|
||||||
import org.openstreetmap.josm.actions.PreferencesAction;
|
import org.openstreetmap.josm.actions.PreferencesAction;
|
||||||
import org.openstreetmap.josm.data.validation.OsmValidator;
|
import org.openstreetmap.josm.data.validation.OsmValidator;
|
||||||
|
@ -47,6 +47,8 @@ import org.openstreetmap.josm.plugins.mapwithai.gui.MapWithAIMenu;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.download.MapWithAIDownloadOptions;
|
import org.openstreetmap.josm.plugins.mapwithai.gui.download.MapWithAIDownloadOptions;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.download.MapWithAIDownloadSourceType;
|
import org.openstreetmap.josm.plugins.mapwithai.gui.download.MapWithAIDownloadSourceType;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAIPreferences;
|
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAIPreferences;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIUrls;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils;
|
import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.tools.MapWithAICopyProhibit;
|
import org.openstreetmap.josm.plugins.mapwithai.tools.MapWithAICopyProhibit;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
|
@ -81,6 +83,8 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
|
||||||
public MapWithAIPlugin(PluginInformation info) {
|
public MapWithAIPlugin(PluginInformation info) {
|
||||||
super(info);
|
super(info);
|
||||||
|
|
||||||
|
MapWithAIConfig.setUrlsProvider(MapWithAIUrls.getInstance());
|
||||||
|
|
||||||
preferenceSetting = new MapWithAIPreferences();
|
preferenceSetting = new MapWithAIPreferences();
|
||||||
|
|
||||||
// Add MapWithAI specific menu
|
// Add MapWithAI specific menu
|
||||||
|
|
|
@ -24,15 +24,12 @@ import org.openstreetmap.josm.data.coor.LatLon;
|
||||||
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.MapWithAIInfo;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig;
|
||||||
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;
|
||||||
|
|
||||||
public class DataAvailability {
|
public class DataAvailability {
|
||||||
/** The default server URL */
|
|
||||||
public static final String DEFAULT_SERVER_URL = "https://gokaart.gitlab.io/JOSM_MapWithAI/json/sources.json";
|
|
||||||
/** This points to a list of default sources that can be used with MapWithAI */
|
|
||||||
private static String defaultServerUrl = DEFAULT_SERVER_URL;
|
|
||||||
/** A map of tag -> message of possible data types */
|
/** A map of tag -> message of possible data types */
|
||||||
static final Map<String, String> POSSIBLE_DATA_POINTS = new TreeMap<>();
|
static final Map<String, String> POSSIBLE_DATA_POINTS = new TreeMap<>();
|
||||||
|
|
||||||
|
@ -51,16 +48,14 @@ public class DataAvailability {
|
||||||
*/
|
*/
|
||||||
private static final List<Class<? extends DataAvailability>> DATA_SOURCES = new ArrayList<>();
|
private static final List<Class<? extends DataAvailability>> DATA_SOURCES = new ArrayList<>();
|
||||||
|
|
||||||
|
private static DataAvailability instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of countries to a map of available types
|
* A map of countries to a map of available types
|
||||||
* ({@code Map<Country, Map<Type, IsAvailable>>}
|
* ({@code Map<Country, Map<Type, IsAvailable>>}
|
||||||
*/
|
*/
|
||||||
static final Map<String, Map<String, Boolean>> COUNTRIES = new HashMap<>();
|
static final Map<String, Map<String, Boolean>> COUNTRIES = new HashMap<>();
|
||||||
|
|
||||||
private static class InstanceHelper {
|
|
||||||
static DataAvailability instance = new DataAvailability();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DataAvailability() {
|
protected DataAvailability() {
|
||||||
if (DataAvailability.class.equals(this.getClass())) {
|
if (DataAvailability.class.equals(this.getClass())) {
|
||||||
initialize();
|
initialize();
|
||||||
|
@ -71,7 +66,7 @@ public class DataAvailability {
|
||||||
* Initialize the class
|
* Initialize the class
|
||||||
*/
|
*/
|
||||||
private static void initialize() {
|
private static void initialize() {
|
||||||
try (CachedFile jsonFile = new CachedFile(defaultServerUrl);
|
try (CachedFile jsonFile = new CachedFile(MapWithAIConfig.getUrls().getMapWithAISourcesJson());
|
||||||
JsonParser jsonParser = Json.createParser(jsonFile.getContentReader());) {
|
JsonParser jsonParser = Json.createParser(jsonFile.getContentReader());) {
|
||||||
jsonFile.setMaxAge(SEVEN_DAYS_IN_SECONDS);
|
jsonFile.setMaxAge(SEVEN_DAYS_IN_SECONDS);
|
||||||
jsonParser.next();
|
jsonParser.next();
|
||||||
|
@ -162,11 +157,11 @@ public class DataAvailability {
|
||||||
* @return the unique instance
|
* @return the unique instance
|
||||||
*/
|
*/
|
||||||
public static DataAvailability getInstance() {
|
public static DataAvailability getInstance() {
|
||||||
if (InstanceHelper.instance == null || COUNTRIES.isEmpty()
|
if (instance == null || COUNTRIES.isEmpty()
|
||||||
|| MapWithAIPreferenceHelper.getMapWithAIUrl().isEmpty()) {
|
|| MapWithAIPreferenceHelper.getMapWithAIUrl().isEmpty()) {
|
||||||
InstanceHelper.instance = new DataAvailability();
|
instance = new DataAvailability();
|
||||||
}
|
}
|
||||||
return InstanceHelper.instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -248,7 +243,7 @@ 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 List<String> getTermsOfUse() {
|
||||||
return Stream.concat(MapWithAILayerInfo.getInstance().getLayers().stream().map(MapWithAIInfo::getTermsOfUseURL),
|
return Stream.concat(MapWithAILayerInfo.getInstance().getLayers().stream().map(MapWithAIInfo::getTermsOfUseURL),
|
||||||
DATA_SOURCES.stream().map(clazz -> {
|
DATA_SOURCES.stream().map(clazz -> {
|
||||||
try {
|
try {
|
||||||
|
@ -267,7 +262,7 @@ public class DataAvailability {
|
||||||
*
|
*
|
||||||
* @return List of privacy policy urls
|
* @return List of privacy policy urls
|
||||||
*/
|
*/
|
||||||
public static final List<String> getPrivacyPolicy() {
|
public static List<String> getPrivacyPolicy() {
|
||||||
return Stream
|
return Stream
|
||||||
.concat(MapWithAILayerInfo.getInstance().getLayers().stream().map(MapWithAIInfo::getPrivacyPolicyURL),
|
.concat(MapWithAILayerInfo.getInstance().getLayers().stream().map(MapWithAIInfo::getPrivacyPolicyURL),
|
||||||
DATA_SOURCES.stream().map(clazz -> {
|
DATA_SOURCES.stream().map(clazz -> {
|
||||||
|
@ -282,22 +277,4 @@ public class DataAvailability {
|
||||||
.filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty()).distinct()
|
.filter(Objects::nonNull).filter(str -> !Utils.removeWhiteSpaces(str).isEmpty()).distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the URL to use to get MapWithAI information (`sources.json`)
|
|
||||||
*
|
|
||||||
* @param url The URL which serves MapWithAI servers
|
|
||||||
*/
|
|
||||||
public static void setReleaseUrl(String url) {
|
|
||||||
defaultServerUrl = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the URL for the `sources.json`.
|
|
||||||
*
|
|
||||||
* @return The URL which serves MapWithAI servers
|
|
||||||
*/
|
|
||||||
public static String getReleaseUrl() {
|
|
||||||
return defaultServerUrl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,10 +97,13 @@ public class DataConflationSender implements RunnableFuture<DataSet> {
|
||||||
.append(protocolVersion.getProtocol()).append('/').append(protocolVersion.getMajor()).append('.')
|
.append(protocolVersion.getProtocol()).append('/').append(protocolVersion.getMajor()).append('.')
|
||||||
.append(protocolVersion.getMinor()).append(' ').append(response.getStatusLine().getStatusCode())
|
.append(protocolVersion.getMinor()).append(' ').append(response.getStatusLine().getStatusCode())
|
||||||
.toString());
|
.toString());
|
||||||
this.done = true;
|
|
||||||
} catch (IOException | UnsupportedOperationException | IllegalDataException e) {
|
} catch (IOException | UnsupportedOperationException | IllegalDataException e) {
|
||||||
Logging.error(e);
|
Logging.error(e);
|
||||||
}
|
}
|
||||||
|
this.done = true;
|
||||||
|
synchronized (this) {
|
||||||
|
this.notifyAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,6 +116,9 @@ public class DataConflationSender implements RunnableFuture<DataSet> {
|
||||||
}
|
}
|
||||||
this.done = true;
|
this.done = true;
|
||||||
this.cancelled = true;
|
this.cancelled = true;
|
||||||
|
synchronized (this) {
|
||||||
|
this.notifyAll();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +134,10 @@ public class DataConflationSender implements RunnableFuture<DataSet> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSet get() throws InterruptedException, ExecutionException {
|
public DataSet get() throws InterruptedException, ExecutionException {
|
||||||
|
synchronized (this) {
|
||||||
while (!isDone()) {
|
while (!isDone()) {
|
||||||
Thread.sleep(100);
|
this.wait(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this.conflatedData;
|
return this.conflatedData;
|
||||||
}
|
}
|
||||||
|
@ -139,10 +147,12 @@ public class DataConflationSender implements RunnableFuture<DataSet> {
|
||||||
long realtime = unit.toMillis(timeout);
|
long realtime = unit.toMillis(timeout);
|
||||||
long waitTime = realtime > MAX_POLLS ? realtime / MAX_POLLS : 1;
|
long waitTime = realtime > MAX_POLLS ? realtime / MAX_POLLS : 1;
|
||||||
long timeWaited = 0;
|
long timeWaited = 0;
|
||||||
|
synchronized (this) {
|
||||||
while (!isDone()) {
|
while (!isDone()) {
|
||||||
Thread.sleep(waitTime);
|
this.wait(waitTime);
|
||||||
timeWaited += waitTime;
|
timeWaited += waitTime;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!isDone() && timeWaited > realtime) {
|
if (!isDone() && timeWaited > realtime) {
|
||||||
throw new TimeoutException();
|
throw new TimeoutException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,20 +10,20 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.io.mapwithai.ConflationSourceReader;
|
import org.openstreetmap.josm.plugins.mapwithai.io.mapwithai.ConflationSourceReader;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig;
|
||||||
import org.openstreetmap.josm.tools.Logging;
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
|
|
||||||
public final class MapWithAIConflationCategory {
|
public final class MapWithAIConflationCategory {
|
||||||
private static final Map<MapWithAICategory, List<String>> CONFLATION_URLS = new EnumMap<>(MapWithAICategory.class);
|
private static final Map<MapWithAICategory, List<String>> CONFLATION_URLS = new EnumMap<>(MapWithAICategory.class);
|
||||||
private static final String EMPTY_URL = "";
|
private static final String EMPTY_URL = "";
|
||||||
private static final String DEFAULT_CONFLATION_JSON = "https://gokaart.gitlab.io/JOSM_MapWithAI/json/conflation_servers.json";
|
|
||||||
private static String conflationJson = DEFAULT_CONFLATION_JSON;
|
|
||||||
static {
|
static {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize() {
|
public static void initialize() {
|
||||||
CONFLATION_URLS.clear();
|
CONFLATION_URLS.clear();
|
||||||
try (ConflationSourceReader reader = new ConflationSourceReader(conflationJson)) {
|
try (ConflationSourceReader reader = new ConflationSourceReader(
|
||||||
|
MapWithAIConfig.getUrls().getConflationServerJson())) {
|
||||||
reader.parse().ifPresent(CONFLATION_URLS::putAll);
|
reader.parse().ifPresent(CONFLATION_URLS::putAll);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logging.error(e);
|
Logging.error(e);
|
||||||
|
@ -54,30 +54,4 @@ public final class MapWithAIConflationCategory {
|
||||||
Collection<String> list = CONFLATION_URLS.computeIfAbsent(category, i -> new ArrayList<>(1));
|
Collection<String> list = CONFLATION_URLS.computeIfAbsent(category, i -> new ArrayList<>(1));
|
||||||
list.add(url);
|
list.add(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the URL to use to get conflation servers
|
|
||||||
*
|
|
||||||
* @param url The URL to use
|
|
||||||
*/
|
|
||||||
public static void setConflationJsonLocation(String url) {
|
|
||||||
conflationJson = url;
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the conflation json location to the default location
|
|
||||||
*/
|
|
||||||
public static void resetConflationJsonLocation() {
|
|
||||||
setConflationJsonLocation(DEFAULT_CONFLATION_JSON);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current conflation json location
|
|
||||||
*
|
|
||||||
* @return The URL that is used to build conflation information
|
|
||||||
*/
|
|
||||||
public static String getConflationJsonLocation() {
|
|
||||||
return conflationJson;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,8 @@ package org.openstreetmap.josm.plugins.mapwithai.data.mapwithai;
|
||||||
|
|
||||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -24,6 +20,9 @@ import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo;
|
import org.openstreetmap.gui.jmapviewer.tilesources.TileSourceInfo;
|
||||||
import org.openstreetmap.josm.actions.ExpertToggleAction;
|
import org.openstreetmap.josm.actions.ExpertToggleAction;
|
||||||
import org.openstreetmap.josm.data.Preferences;
|
import org.openstreetmap.josm.data.Preferences;
|
||||||
|
@ -37,6 +36,7 @@ import org.openstreetmap.josm.io.imagery.ImageryReader;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo.MapWithAIPreferenceEntry;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo.MapWithAIPreferenceEntry;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.io.mapwithai.ESRISourceReader;
|
import org.openstreetmap.josm.plugins.mapwithai.io.mapwithai.ESRISourceReader;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.io.mapwithai.MapWithAISourceReader;
|
import org.openstreetmap.josm.plugins.mapwithai.io.mapwithai.MapWithAISourceReader;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig;
|
||||||
import org.openstreetmap.josm.spi.preferences.Config;
|
import org.openstreetmap.josm.spi.preferences.Config;
|
||||||
import org.openstreetmap.josm.tools.ListenerList;
|
import org.openstreetmap.josm.tools.ListenerList;
|
||||||
import org.openstreetmap.josm.tools.Logging;
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
|
@ -68,15 +68,15 @@ public class MapWithAILayerInfo {
|
||||||
/** The prefix for configuration of the MapWithAI sources */
|
/** The prefix for configuration of the MapWithAI sources */
|
||||||
public static final String CONFIG_PREFIX = "mapwithai.sources.";
|
public static final String CONFIG_PREFIX = "mapwithai.sources.";
|
||||||
|
|
||||||
private static final String[] DEFAULT_LAYER_SITES = {
|
|
||||||
"https://gokaart.gitlab.io/JOSM_MapWithAI/json/sources.json" };
|
|
||||||
|
|
||||||
/** Unique instance -- MUST be after DEFAULT_LAYER_SITES */
|
/** Unique instance -- MUST be after DEFAULT_LAYER_SITES */
|
||||||
private static MapWithAILayerInfo instance;
|
private static MapWithAILayerInfo instance;
|
||||||
|
|
||||||
public static MapWithAILayerInfo getInstance() {
|
public static MapWithAILayerInfo getInstance() {
|
||||||
|
if (instance != null) {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
final AtomicBoolean finished = new AtomicBoolean();
|
final AtomicBoolean finished = new AtomicBoolean();
|
||||||
synchronized (DEFAULT_LAYER_SITES) {
|
synchronized (MapWithAILayerInfo.class) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new MapWithAILayerInfo(() -> {
|
instance = new MapWithAILayerInfo(() -> {
|
||||||
synchronized (finished) {
|
synchronized (finished) {
|
||||||
|
@ -111,7 +111,8 @@ public class MapWithAILayerInfo {
|
||||||
* @since 7434
|
* @since 7434
|
||||||
*/
|
*/
|
||||||
public static Collection<String> getImageryLayersSites() {
|
public static Collection<String> getImageryLayersSites() {
|
||||||
return Config.getPref().getList(CONFIG_PREFIX + "layers.sites", Arrays.asList(DEFAULT_LAYER_SITES));
|
return Config.getPref().getList(CONFIG_PREFIX + "layers.sites",
|
||||||
|
Collections.singletonList(MapWithAIConfig.getUrls().getMapWithAISourcesJson()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,8 +123,12 @@ public class MapWithAILayerInfo {
|
||||||
* {@link org.openstreetmap.josm.spi.preferences.IPreferences#putList}
|
* {@link org.openstreetmap.josm.spi.preferences.IPreferences#putList}
|
||||||
*/
|
*/
|
||||||
public static boolean setImageryLayersSites(Collection<String> sites) {
|
public static boolean setImageryLayersSites(Collection<String> sites) {
|
||||||
|
if (sites == null || sites.isEmpty()) {
|
||||||
|
return Config.getPref().put(CONFIG_PREFIX + "layers.sites", null);
|
||||||
|
} else {
|
||||||
return Config.getPref().putList(CONFIG_PREFIX + "layers.sites", new ArrayList<>(sites));
|
return Config.getPref().putList(CONFIG_PREFIX + "layers.sites", new ArrayList<>(sites));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private MapWithAILayerInfo(FinishListener listener) {
|
private MapWithAILayerInfo(FinishListener listener) {
|
||||||
load(false, listener);
|
load(false, listener);
|
||||||
|
|
|
@ -210,9 +210,11 @@ public class ESRISourceReader {
|
||||||
@Nullable
|
@Nullable
|
||||||
private static String getJsonString(@Nonnull final String url, final long defaultMaxAge, final boolean fastFail) {
|
private static String getJsonString(@Nonnull final String url, final long defaultMaxAge, final boolean fastFail) {
|
||||||
String jsonString = SOURCE_CACHE.get(url);
|
String jsonString = SOURCE_CACHE.get(url);
|
||||||
|
if (Config.getPref() != null) {
|
||||||
// TODO FIXME remove sometime after January 2022 (give it a chance to cleanup
|
// TODO FIXME remove sometime after January 2022 (give it a chance to cleanup
|
||||||
// directories)
|
// directories)
|
||||||
CachedFile.cleanup(url);
|
CachedFile.cleanup(url);
|
||||||
|
}
|
||||||
if (jsonString == null) {
|
if (jsonString == null) {
|
||||||
synchronized (SOURCE_CACHE) {
|
synchronized (SOURCE_CACHE) {
|
||||||
jsonString = SOURCE_CACHE.get(url);
|
jsonString = SOURCE_CACHE.get(url);
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
// License: GPL. For details, see LICENSE file.
|
||||||
|
package org.openstreetmap.josm.plugins.mapwithai.spi.preferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for a provider of certain URLs. Modelled after
|
||||||
|
* {@link org.openstreetmap.josm.spi.preferences.IUrls}.
|
||||||
|
*
|
||||||
|
* @author Taylor Smock
|
||||||
|
*/
|
||||||
|
public interface IMapWithAIUrls {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the conflation server json URL
|
||||||
|
*
|
||||||
|
* @return The URL with additional conflation servers
|
||||||
|
*/
|
||||||
|
String getConflationServerJson();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the URL for MapWithAI sources
|
||||||
|
*
|
||||||
|
* @return The URL with source information
|
||||||
|
*/
|
||||||
|
String getMapWithAISourcesJson();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the URL for the MapWithAI paintstyle
|
||||||
|
*
|
||||||
|
* @return The URL to use to get the paint style
|
||||||
|
*/
|
||||||
|
String getMapWithAIPaintStyle();
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
// License: GPL. For details, see LICENSE file.
|
||||||
|
package org.openstreetmap.josm.plugins.mapwithai.spi.preferences;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to hold the global preferences objects. Modeled after
|
||||||
|
* {@link org.openstreetmap.josm.spi.preferences.Config}.
|
||||||
|
*
|
||||||
|
* @author Taylor Smock
|
||||||
|
*/
|
||||||
|
public class MapWithAIConfig {
|
||||||
|
private static IMapWithAIUrls urls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get class that provides the value of certain URLs
|
||||||
|
*
|
||||||
|
* @return the global {@link IMapWithAIUrls} instance
|
||||||
|
*/
|
||||||
|
public static IMapWithAIUrls getUrls() {
|
||||||
|
return urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install the global URLs provider.
|
||||||
|
*
|
||||||
|
* @param urls the global URLs provider instance to set (must not be null)
|
||||||
|
*/
|
||||||
|
public static void setUrlsProvider(IMapWithAIUrls urls) {
|
||||||
|
MapWithAIConfig.urls = Objects.requireNonNull(urls);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
// License: GPL. For details, see LICENSE file.
|
||||||
|
package org.openstreetmap.josm.plugins.mapwithai.spi.preferences;
|
||||||
|
|
||||||
|
public class MapWithAIUrls implements IMapWithAIUrls {
|
||||||
|
/** The default url for additional conflation servers */
|
||||||
|
private static final String DEFAULT_CONFLATION_JSON = "https://gokaart.gitlab.io/JOSM_MapWithAI/json/conflation_servers.json";
|
||||||
|
/** The default URL for the MapWithAI sources */
|
||||||
|
private static final String DEFAULT_MAPWITHAI_SOURCES_JSON = "https://gokaart.gitlab.io/JOSM_MapWithAI/json/sources.json";
|
||||||
|
/** The default url for the MapWithAI paint style */
|
||||||
|
private static final String DEFAULT_PAINT_STYLE_RESOURCE_URL = "https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1";
|
||||||
|
|
||||||
|
private static class InstanceHolder {
|
||||||
|
static final MapWithAIUrls INSTANCE = new MapWithAIUrls();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the unique instance.
|
||||||
|
*
|
||||||
|
* @return the unique instance
|
||||||
|
*/
|
||||||
|
public static MapWithAIUrls getInstance() {
|
||||||
|
return MapWithAIUrls.InstanceHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getConflationServerJson() {
|
||||||
|
return DEFAULT_CONFLATION_JSON;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMapWithAISourcesJson() {
|
||||||
|
return DEFAULT_MAPWITHAI_SOURCES_JSON;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMapWithAIPaintStyle() {
|
||||||
|
return DEFAULT_PAINT_STYLE_RESOURCE_URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MapWithAIUrls() {
|
||||||
|
// Hide the constructor
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,14 +38,12 @@ import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
|
||||||
import org.openstreetmap.josm.gui.util.GuiHelper;
|
import org.openstreetmap.josm.gui.util.GuiHelper;
|
||||||
import org.openstreetmap.josm.io.CachedFile;
|
import org.openstreetmap.josm.io.CachedFile;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig;
|
||||||
import org.openstreetmap.josm.tools.ColorHelper;
|
import org.openstreetmap.josm.tools.ColorHelper;
|
||||||
import org.openstreetmap.josm.tools.Logging;
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
|
|
||||||
public final class MapPaintUtils {
|
public final class MapPaintUtils {
|
||||||
/** The default url for the MapWithAI paint style */
|
/** The default url for the MapWithAI paint style */
|
||||||
public static final String DEFAULT_PAINT_STYLE_RESOURCE_URL = "https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1";
|
|
||||||
|
|
||||||
private static String paintStyleResourceUrl = DEFAULT_PAINT_STYLE_RESOURCE_URL;
|
|
||||||
private static final Pattern TEST_PATTERN = Pattern
|
private static final Pattern TEST_PATTERN = Pattern
|
||||||
.compile("^https?:\\/\\/(www\\.)?localhost[:0-9]*\\/josmfile\\?page=Styles\\/MapWithAI&zip=1$");
|
.compile("^https?:\\/\\/(www\\.)?localhost[:0-9]*\\/josmfile\\?page=Styles\\/MapWithAI&zip=1$");
|
||||||
|
|
||||||
|
@ -95,8 +93,8 @@ public final class MapPaintUtils {
|
||||||
.forEach(MapPaintStyles::removeStyle);
|
.forEach(MapPaintStyles::removeStyle);
|
||||||
|
|
||||||
if (!checkIfMapWithAIPaintStyleExists()) {
|
if (!checkIfMapWithAIPaintStyleExists()) {
|
||||||
final MapCSSStyleSource style = new MapCSSStyleSource(paintStyleResourceUrl, MapWithAIPlugin.NAME,
|
final MapCSSStyleSource style = new MapCSSStyleSource(MapWithAIConfig.getUrls().getMapWithAIPaintStyle(),
|
||||||
"MapWithAI");
|
MapWithAIPlugin.NAME, "MapWithAI");
|
||||||
return MapPaintStyles.addStyle(style);
|
return MapPaintStyles.addStyle(style);
|
||||||
}
|
}
|
||||||
return getMapWithAIPaintStyle();
|
return getMapWithAIPaintStyle();
|
||||||
|
@ -104,7 +102,8 @@ public final class MapPaintUtils {
|
||||||
|
|
||||||
public static synchronized boolean checkIfMapWithAIPaintStyleExists() {
|
public static synchronized boolean checkIfMapWithAIPaintStyleExists() {
|
||||||
return MapPaintStyles.getStyles().getStyleSources().parallelStream().filter(MapCSSStyleSource.class::isInstance)
|
return MapPaintStyles.getStyles().getStyleSources().parallelStream().filter(MapCSSStyleSource.class::isInstance)
|
||||||
.map(MapCSSStyleSource.class::cast).anyMatch(source -> paintStyleResourceUrl.equals(source.url)
|
.map(MapCSSStyleSource.class::cast)
|
||||||
|
.anyMatch(source -> MapWithAIConfig.getUrls().getMapWithAIPaintStyle().equals(source.url)
|
||||||
|| TEST_PATTERN.matcher(source.url).matches());
|
|| TEST_PATTERN.matcher(source.url).matches());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +113,8 @@ public final class MapPaintUtils {
|
||||||
public static synchronized void removeMapWithAIPaintStyles() {
|
public static synchronized void removeMapWithAIPaintStyles() {
|
||||||
// WebStart has issues with streams and EDT permissions. Don't use streams.
|
// WebStart has issues with streams and EDT permissions. Don't use streams.
|
||||||
for (StyleSource style : new ArrayList<>(MapPaintStyles.getStyles().getStyleSources())) {
|
for (StyleSource style : new ArrayList<>(MapPaintStyles.getStyles().getStyleSources())) {
|
||||||
if (paintStyleResourceUrl.equals(style.url) || TEST_PATTERN.matcher(style.url).matches()) {
|
if (MapWithAIConfig.getUrls().getMapWithAIPaintStyle().equals(style.url)
|
||||||
|
|| TEST_PATTERN.matcher(style.url).matches()) {
|
||||||
GuiHelper.runInEDT(() -> MapPaintStyles.removeStyle(style));
|
GuiHelper.runInEDT(() -> MapPaintStyles.removeStyle(style));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,29 +126,12 @@ public final class MapPaintUtils {
|
||||||
* @return get the MapWithAI Paint style
|
* @return get the MapWithAI Paint style
|
||||||
*/
|
*/
|
||||||
public static synchronized StyleSource getMapWithAIPaintStyle() {
|
public static synchronized StyleSource getMapWithAIPaintStyle() {
|
||||||
return MapPaintStyles.getStyles().getStyleSources().parallelStream().filter(
|
return MapPaintStyles.getStyles().getStyleSources().parallelStream()
|
||||||
source -> paintStyleResourceUrl.equals(source.url) || TEST_PATTERN.matcher(source.url).matches())
|
.filter(source -> MapWithAIConfig.getUrls().getMapWithAIPaintStyle().equals(source.url)
|
||||||
|
|| TEST_PATTERN.matcher(source.url).matches())
|
||||||
.findAny().orElse(null);
|
.findAny().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the URL for the MapWithAI paint style
|
|
||||||
*
|
|
||||||
* @param paintUrl The paint style for MapWithAI
|
|
||||||
*/
|
|
||||||
public static synchronized void setPaintStyleUrl(String paintUrl) {
|
|
||||||
paintStyleResourceUrl = paintUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the url for the paint style for MapWithAI
|
|
||||||
*
|
|
||||||
* @return The url for the paint style
|
|
||||||
*/
|
|
||||||
public static synchronized String getPaintStyleUrl() {
|
|
||||||
return paintStyleResourceUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add sources to the paint style
|
* Add sources to the paint style
|
||||||
*
|
*
|
||||||
|
|
|
@ -12,10 +12,11 @@ import java.util.List;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.DataAvailability;
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIType;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIType;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
||||||
|
|
||||||
|
@ -28,15 +29,17 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
*/
|
*/
|
||||||
@NoExceptions
|
@NoExceptions
|
||||||
@BasicPreferences
|
@BasicPreferences
|
||||||
|
@Wiremock
|
||||||
class MapWithAISourceReaderTestIT {
|
class MapWithAISourceReaderTestIT {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
public JOSMTestRules rule = new JOSMTestRules().territories().projection();
|
public JOSMTestRules rule = new JOSMTestRules().territories().projection();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Wiremock(false)
|
||||||
void testDefaultSourceIT() throws IOException {
|
void testDefaultSourceIT() throws IOException {
|
||||||
DataAvailability.setReleaseUrl(DataAvailability.DEFAULT_SERVER_URL);
|
try (MapWithAISourceReader source = new MapWithAISourceReader(
|
||||||
try (MapWithAISourceReader source = new MapWithAISourceReader(DataAvailability.getReleaseUrl())) {
|
MapWithAIConfig.getUrls().getMapWithAISourcesJson())) {
|
||||||
List<MapWithAIInfo> infoList = source.parse().orElse(Collections.emptyList());
|
List<MapWithAIInfo> infoList = source.parse().orElse(Collections.emptyList());
|
||||||
assertFalse(infoList.isEmpty(), "There should be viable sources");
|
assertFalse(infoList.isEmpty(), "There should be viable sources");
|
||||||
for (MapWithAIType type : Arrays.asList(MapWithAIType.FACEBOOK, MapWithAIType.THIRD_PARTY)) {
|
for (MapWithAIType type : Arrays.asList(MapWithAIType.FACEBOOK, MapWithAIType.THIRD_PARTY)) {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -23,6 +22,8 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
|
||||||
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 edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for testing availability
|
* Test class for testing availability
|
||||||
*
|
*
|
||||||
|
@ -60,7 +61,7 @@ class MapWithAIAvailabilityTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testgetDataLatLon() {
|
void testGetDataLatLon() {
|
||||||
assertTrue(DataAvailability.getDataTypes(new LatLon(0, 0)).isEmpty(), "There should not be data in the ocean");
|
assertTrue(DataAvailability.getDataTypes(new LatLon(0, 0)).isEmpty(), "There should not be data in the ocean");
|
||||||
assertTrue(DataAvailability.getDataTypes(new LatLon(40, -100)).getOrDefault("highway", false),
|
assertTrue(DataAvailability.getDataTypes(new LatLon(40, -100)).getOrDefault("highway", false),
|
||||||
"The US should have highway data");
|
"The US should have highway data");
|
||||||
|
@ -81,7 +82,7 @@ class MapWithAIAvailabilityTest {
|
||||||
new ArrayList<>(MapWithAILayerInfo.getInstance().getLayers())
|
new ArrayList<>(MapWithAILayerInfo.getInstance().getLayers())
|
||||||
.forEach(i -> MapWithAILayerInfo.getInstance().remove(i));
|
.forEach(i -> MapWithAILayerInfo.getInstance().remove(i));
|
||||||
DataAvailability.getInstance();
|
DataAvailability.getInstance();
|
||||||
testgetDataLatLon();
|
testGetDataLatLon();
|
||||||
MapWithAILayerInfo.getInstance().getLayers().forEach(i -> MapWithAILayerInfo.getInstance().remove(i));
|
MapWithAILayerInfo.getInstance().getLayers().forEach(i -> MapWithAILayerInfo.getInstance().remove(i));
|
||||||
DataAvailability.getInstance();
|
DataAvailability.getInstance();
|
||||||
testHasDataLatLon();
|
testHasDataLatLon();
|
||||||
|
|
|
@ -10,15 +10,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.openstreetmap.josm.data.Bounds;
|
import org.openstreetmap.josm.data.Bounds;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtilsTest;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtilsTest;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
@BasicPreferences
|
@BasicPreferences
|
||||||
|
@Wiremock
|
||||||
class MapWithAIDownloadSourceTypeTest {
|
class MapWithAIDownloadSourceTypeTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
||||||
|
|
|
@ -6,12 +6,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
@ -22,6 +21,8 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAIS
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
||||||
|
|
||||||
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for {@link MapWithAIPreferences}
|
* Test class for {@link MapWithAIPreferences}
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,78 +1,24 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.testutils;
|
package org.openstreetmap.josm.plugins.mapwithai.testutils;
|
||||||
|
|
||||||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import java.lang.Thread.UncaughtExceptionHandler;
|
import java.lang.Thread.UncaughtExceptionHandler;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
import com.github.tomakehurst.wiremock.common.FileSource;
|
|
||||||
import com.github.tomakehurst.wiremock.extension.Parameters;
|
|
||||||
import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
|
|
||||||
import com.github.tomakehurst.wiremock.http.Request;
|
|
||||||
import com.github.tomakehurst.wiremock.http.Response;
|
|
||||||
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
|
|
||||||
import mockit.integration.TestRunnerDecorator;
|
|
||||||
import org.junit.runners.model.InitializationError;
|
import org.junit.runners.model.InitializationError;
|
||||||
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
|
||||||
import org.openstreetmap.josm.gui.util.GuiHelper;
|
|
||||||
import org.openstreetmap.josm.io.OsmApi;
|
|
||||||
import org.openstreetmap.josm.io.OsmApiInitializationException;
|
|
||||||
import org.openstreetmap.josm.io.OsmTransferCanceledException;
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.DataAvailability;
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIConflationCategory;
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils;
|
|
||||||
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 mockit.integration.TestRunnerDecorator;
|
||||||
|
|
||||||
public class MapWithAITestRules extends JOSMTestRules {
|
public class MapWithAITestRules extends JOSMTestRules {
|
||||||
|
|
||||||
private boolean wiremock;
|
|
||||||
private static WireMockServer wireMock;
|
|
||||||
private static final List<Object> wireMockUsers = Collections.synchronizedList(new ArrayList<>());
|
|
||||||
private boolean workerExceptions = true;
|
private boolean workerExceptions = true;
|
||||||
private UncaughtExceptionHandler currentExceptionHandler;
|
private UncaughtExceptionHandler currentExceptionHandler;
|
||||||
private String currentReleaseUrl;
|
|
||||||
private Collection<String> sourceSites;
|
|
||||||
private boolean territories;
|
|
||||||
|
|
||||||
public MapWithAITestRules() {
|
public MapWithAITestRules() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MapWithAITestRules territories() {
|
|
||||||
this.territories = true;
|
|
||||||
super.territories();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use
|
|
||||||
* {@link org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock}
|
|
||||||
* instead
|
|
||||||
* @return this, for easy chaining
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public MapWithAITestRules wiremock() {
|
|
||||||
this.wiremock = true;
|
|
||||||
territories();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapWithAITestRules noWorkerExceptions() {
|
public MapWithAITestRules noWorkerExceptions() {
|
||||||
this.workerExceptions = false;
|
this.workerExceptions = false;
|
||||||
return this;
|
return this;
|
||||||
|
@ -92,39 +38,6 @@ public class MapWithAITestRules extends JOSMTestRules {
|
||||||
Logging.getLogger().setFilter(record -> record.getLevel().intValue() >= Level.WARNING.intValue()
|
Logging.getLogger().setFilter(record -> record.getLevel().intValue() >= Level.WARNING.intValue()
|
||||||
|| record.getSourceClassName().startsWith("org.openstreetmap.josm.plugins.mapwithai"));
|
|| record.getSourceClassName().startsWith("org.openstreetmap.josm.plugins.mapwithai"));
|
||||||
|
|
||||||
synchronized (wireMockUsers) {
|
|
||||||
if (wiremock && wireMock == null) {
|
|
||||||
wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock")
|
|
||||||
.extensions(new WireMockUrlTransformer()).dynamicPort());
|
|
||||||
wireMock.start();
|
|
||||||
}
|
|
||||||
// Sometimes this is called twice, the second time resetting the config but not
|
|
||||||
// resetting the urls.
|
|
||||||
if (wiremock && wireMock != null) {
|
|
||||||
MapPaintUtils.setPaintStyleUrl(replaceUrl(wireMock, MapPaintUtils.getPaintStyleUrl()));
|
|
||||||
// Avoid cases where tests could write the wiremock url to some fields.
|
|
||||||
if (currentReleaseUrl == null) {
|
|
||||||
currentReleaseUrl = DataAvailability.getReleaseUrl();
|
|
||||||
}
|
|
||||||
DataAvailability.setReleaseUrl(replaceUrl(wireMock, DataAvailability.getReleaseUrl()));
|
|
||||||
Config.getPref().put("osm-server.url", wireMock.baseUrl());
|
|
||||||
// Avoid cases where tests could write the wiremock url to some fields.
|
|
||||||
if (sourceSites == null) {
|
|
||||||
sourceSites = MapWithAILayerInfo.getImageryLayersSites();
|
|
||||||
}
|
|
||||||
MapWithAILayerInfo.setImageryLayersSites(sourceSites.stream().map(t -> replaceUrl(wireMock, t))
|
|
||||||
.filter(Objects::nonNull).collect(Collectors.toList()));
|
|
||||||
MapWithAIConflationCategory.setConflationJsonLocation(
|
|
||||||
replaceUrl(wireMock, MapWithAIConflationCategory.getConflationJsonLocation()));
|
|
||||||
try {
|
|
||||||
OsmApi.getOsmApi().initialize(NullProgressMonitor.INSTANCE);
|
|
||||||
} catch (OsmTransferCanceledException | OsmApiInitializationException e) {
|
|
||||||
Logging.error(e);
|
|
||||||
}
|
|
||||||
wireMockUsers.add(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (workerExceptions) {
|
if (workerExceptions) {
|
||||||
currentExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
currentExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
|
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
|
||||||
|
@ -137,86 +50,10 @@ public class MapWithAITestRules extends JOSMTestRules {
|
||||||
@Override
|
@Override
|
||||||
protected void after() throws ReflectiveOperationException {
|
protected void after() throws ReflectiveOperationException {
|
||||||
super.after();
|
super.after();
|
||||||
synchronized (wireMockUsers) {
|
|
||||||
wireMockUsers.remove(this);
|
|
||||||
if (wiremock && wireMockUsers.isEmpty()) {
|
|
||||||
MapPaintUtils.removeMapWithAIPaintStyles();
|
|
||||||
// Run in EDT to avoid stopping wiremock server before wiremock requests finish.
|
|
||||||
GuiHelper.runInEDTAndWait(wireMock::stop);
|
|
||||||
List<LoggedRequest> requests = wireMock.findUnmatchedRequests().getRequests();
|
|
||||||
wireMock = null;
|
|
||||||
requests.forEach(r -> Logging.error(r.getAbsoluteUrl()));
|
|
||||||
assertTrue(requests.isEmpty());
|
|
||||||
Config.getPref().put("osm-server.url", null);
|
|
||||||
// Avoid cases where tests could write the wiremock url to some fields.
|
|
||||||
if (currentReleaseUrl != null) {
|
|
||||||
DataAvailability.setReleaseUrl(currentReleaseUrl);
|
|
||||||
currentReleaseUrl = null;
|
|
||||||
}
|
|
||||||
if (sourceSites != null) {
|
|
||||||
MapWithAILayerInfo.setImageryLayersSites(sourceSites);
|
|
||||||
sourceSites = null;
|
|
||||||
}
|
|
||||||
MapWithAIConflationCategory.resetConflationJsonLocation();
|
|
||||||
resetMapWithAILayerInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (workerExceptions) {
|
if (workerExceptions) {
|
||||||
Thread.setDefaultUncaughtExceptionHandler(currentExceptionHandler);
|
Thread.setDefaultUncaughtExceptionHandler(currentExceptionHandler);
|
||||||
}
|
}
|
||||||
TestRunnerDecorator.cleanUpAllMocks();
|
TestRunnerDecorator.cleanUpAllMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetMapWithAILayerInfo() {
|
|
||||||
if (territories) {
|
|
||||||
synchronized (MapWithAILayerInfo.class) {
|
|
||||||
MapWithAILayerInfo.getInstance().clear();
|
|
||||||
MapWithAILayerInfo.getInstance().getDefaultLayers().stream().filter(MapWithAIInfo::isDefaultEntry)
|
|
||||||
.forEach(MapWithAILayerInfo.getInstance()::add);
|
|
||||||
MapWithAILayerInfo.getInstance().save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace URL servers with wiremock
|
|
||||||
*
|
|
||||||
* @param wireMockServer The wiremock to point to
|
|
||||||
* @param url The URL to fix
|
|
||||||
* @return A url that points at the wiremock server
|
|
||||||
*/
|
|
||||||
private static String replaceUrl(WireMockServer wireMockServer, String url) {
|
|
||||||
try {
|
|
||||||
URL temp = new URL(url);
|
|
||||||
return wireMockServer.baseUrl() + temp.getFile();
|
|
||||||
} catch (MalformedURLException error) {
|
|
||||||
Logging.error(error);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace URL's with the wiremock URL
|
|
||||||
*
|
|
||||||
* @author Taylor Smock
|
|
||||||
*/
|
|
||||||
private static class WireMockUrlTransformer extends ResponseTransformer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Convert urls in responses to wiremock url";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Response transform(Request request, Response response, FileSource files, Parameters parameters) {
|
|
||||||
if (wireMock != null && !request.getUrl().endsWith("/capabilities")
|
|
||||||
&& !response.getHeaders().getContentTypeHeader().mimeTypePart().contains("application/zip")) {
|
|
||||||
String origBody = response.getBodyAsString();
|
|
||||||
String newBody = origBody.replaceAll("https?:\\/\\/.*?\\/", wireMock.baseUrl() + "/");
|
|
||||||
return Response.Builder.like(response).but().body(newBody).build();
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,8 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.util.Collections;
|
import java.util.Optional;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
|
@ -18,7 +16,11 @@ import org.openstreetmap.josm.plugins.mapwithai.backend.DataAvailability;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIConflationCategory;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIConflationCategory;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.IMapWithAIUrls;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig;
|
||||||
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIUrls;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils;
|
import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils;
|
||||||
|
import org.openstreetmap.josm.testutils.annotations.AnnotationUtils;
|
||||||
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
||||||
import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
|
import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
|
||||||
import org.openstreetmap.josm.testutils.annotations.HTTP;
|
import org.openstreetmap.josm.testutils.annotations.HTTP;
|
||||||
|
@ -39,9 +41,7 @@ import com.github.tomakehurst.wiremock.http.Response;
|
||||||
@Target({ ElementType.PARAMETER, ElementType.TYPE, ElementType.METHOD })
|
@Target({ ElementType.PARAMETER, ElementType.TYPE, ElementType.METHOD })
|
||||||
@BasicPreferences
|
@BasicPreferences
|
||||||
@HTTP
|
@HTTP
|
||||||
@ExtendWith(Wiremock.DataAvailabilityExtension.class)
|
@ExtendWith(Wiremock.TestMapWithAIUrls.class)
|
||||||
@ExtendWith(Wiremock.MapPaintUtilsExtension.class)
|
|
||||||
@ExtendWith(Wiremock.MapWithAIConflationCategoryExtension.class)
|
|
||||||
@BasicWiremock(value = "test/resources/wiremock", responseTransformers = Wiremock.WireMockUrlTransformer.class)
|
@BasicWiremock(value = "test/resources/wiremock", responseTransformers = Wiremock.WireMockUrlTransformer.class)
|
||||||
public @interface Wiremock {
|
public @interface Wiremock {
|
||||||
/**
|
/**
|
||||||
|
@ -97,27 +97,6 @@ public @interface Wiremock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for {@link MapPaintUtils}
|
|
||||||
*/
|
|
||||||
class MapPaintUtilsExtension extends WiremockExtension {
|
|
||||||
@Override
|
|
||||||
public void afterAll(ExtensionContext context) throws Exception {
|
|
||||||
try {
|
|
||||||
super.afterAll(context);
|
|
||||||
} finally {
|
|
||||||
MapPaintUtils.removeMapWithAIPaintStyles();
|
|
||||||
MapPaintUtils.setPaintStyleUrl("https://invalid.url/josmfile?page=Styles/MapWithAI&zip=1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeAll(ExtensionContext context) throws Exception {
|
|
||||||
super.beforeAll(context);
|
|
||||||
MapPaintUtils.setPaintStyleUrl(replaceUrl(getWiremock(context), MapPaintUtils.getPaintStyleUrl()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension for {@link MapWithAILayerInfo}
|
* Extension for {@link MapWithAILayerInfo}
|
||||||
*/
|
*/
|
||||||
|
@ -127,8 +106,6 @@ public @interface Wiremock {
|
||||||
try {
|
try {
|
||||||
super.afterAll(context);
|
super.afterAll(context);
|
||||||
} finally {
|
} finally {
|
||||||
MapWithAILayerInfo.setImageryLayersSites(
|
|
||||||
Collections.singleton("https://invalid.url/JOSM_MapWithAI/json/sources.json"));
|
|
||||||
resetMapWithAILayerInfo();
|
resetMapWithAILayerInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,9 +113,7 @@ public @interface Wiremock {
|
||||||
@Override
|
@Override
|
||||||
public void beforeAll(ExtensionContext context) throws Exception {
|
public void beforeAll(ExtensionContext context) throws Exception {
|
||||||
super.beforeAll(context);
|
super.beforeAll(context);
|
||||||
MapWithAILayerInfo.setImageryLayersSites(
|
MapWithAILayerInfo.setImageryLayersSites(null);
|
||||||
MapWithAILayerInfo.getImageryLayersSites().stream().map(t -> replaceUrl(getWiremock(context), t))
|
|
||||||
.filter(Objects::nonNull).collect(Collectors.toList()));
|
|
||||||
AtomicBoolean finished = new AtomicBoolean();
|
AtomicBoolean finished = new AtomicBoolean();
|
||||||
MapWithAILayerInfo.getInstance().clear();
|
MapWithAILayerInfo.getInstance().clear();
|
||||||
MapWithAILayerInfo.getInstance().load(false, () -> finished.set(true));
|
MapWithAILayerInfo.getInstance().load(false, () -> finished.set(true));
|
||||||
|
@ -158,45 +133,78 @@ public @interface Wiremock {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
class TestMapWithAIUrls extends WiremockExtension implements IMapWithAIUrls {
|
||||||
* Extension for {@link DataAvailability}
|
ExtensionContext context;
|
||||||
*/
|
private static boolean conflationServerInitialized;
|
||||||
class DataAvailabilityExtension extends WiremockExtension {
|
|
||||||
@Override
|
@Override
|
||||||
public void afterAll(ExtensionContext context) throws Exception {
|
public String getConflationServerJson() {
|
||||||
try {
|
conflationServerInitialized = true;
|
||||||
super.afterAll(context);
|
return replaceUrl(getWiremock(this.context), MapWithAIUrls.getInstance().getConflationServerJson());
|
||||||
} finally {
|
|
||||||
DataAvailability.setReleaseUrl("https://invalid.url/JOSM_MapWithAI/json/sources.json");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMapWithAISourcesJson() {
|
||||||
|
return replaceUrl(getWiremock(this.context), MapWithAIUrls.getInstance().getMapWithAISourcesJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMapWithAIPaintStyle() {
|
||||||
|
return replaceUrl(getWiremock(this.context), MapWithAIUrls.getInstance().getMapWithAIPaintStyle());
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void beforeAll(ExtensionContext context) throws Exception {
|
public void beforeAll(ExtensionContext context) throws Exception {
|
||||||
super.beforeAll(context);
|
super.beforeAll(context);
|
||||||
DataAvailability.setReleaseUrl(replaceUrl(getWiremock(context), DataAvailability.getReleaseUrl()));
|
final Optional<Wiremock> annotation = AnnotationUtils.findFirstParentAnnotation(context, Wiremock.class);
|
||||||
|
this.context = context;
|
||||||
|
if (Boolean.FALSE.equals(annotation.map(Wiremock::value).orElse(Boolean.TRUE))) {
|
||||||
|
MapWithAIConfig.setUrlsProvider(MapWithAIUrls.getInstance());
|
||||||
|
} else {
|
||||||
|
MapWithAIConfig.setUrlsProvider(this);
|
||||||
}
|
}
|
||||||
|
if (conflationServerInitialized) {
|
||||||
|
MapWithAIConflationCategory.initialize();
|
||||||
|
}
|
||||||
|
AnnotationUtils.resetStaticClass(DataAvailability.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeEach(ExtensionContext context) throws Exception {
|
||||||
|
final Optional<Wiremock> annotation = AnnotationUtils.findFirstParentAnnotation(context, Wiremock.class);
|
||||||
|
if (annotation.isPresent()) {
|
||||||
|
this.beforeAll(context);
|
||||||
|
}
|
||||||
|
super.beforeEach(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension for {@link MapWithAIConflationCategory}
|
|
||||||
*/
|
|
||||||
class MapWithAIConflationCategoryExtension extends WiremockExtension {
|
|
||||||
@Override
|
@Override
|
||||||
public void afterAll(ExtensionContext context) throws Exception {
|
public void afterAll(ExtensionContext context) throws Exception {
|
||||||
|
// @Wiremock stops the WireMockServer prior to this method being called
|
||||||
|
getWiremock(context).start();
|
||||||
|
MapPaintUtils.removeMapWithAIPaintStyles();
|
||||||
try {
|
try {
|
||||||
|
// This stops the WireMockServer again.
|
||||||
super.afterAll(context);
|
super.afterAll(context);
|
||||||
} finally {
|
} finally {
|
||||||
MapWithAIConflationCategory.resetConflationJsonLocation();
|
MapWithAIConfig.setUrlsProvider(new InvalidMapWithAIUrls());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class InvalidMapWithAIUrls implements IMapWithAIUrls {
|
||||||
|
@Override
|
||||||
|
public String getConflationServerJson() {
|
||||||
|
throw new UnsupportedOperationException("Please use the @Wiremock annotation");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeAll(ExtensionContext context) throws Exception {
|
public String getMapWithAISourcesJson() {
|
||||||
super.beforeAll(context);
|
return this.getConflationServerJson();
|
||||||
MapWithAIConflationCategory.setConflationJsonLocation(
|
|
||||||
replaceUrl(getWiremock(context), MapWithAIConflationCategory.getConflationJsonLocation()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMapWithAIPaintStyle() {
|
||||||
|
return this.getConflationServerJson();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue