Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-02-24 15:56:39 -07:00
rodzic a365b4468f
commit 9bbf637d31
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
5 zmienionych plików z 41 dodań i 8 usunięć

Wyświetl plik

@ -191,7 +191,8 @@ public class DataAvailability {
* @return the unique instance
*/
public static DataAvailability getInstance() {
if (InstanceHelper.instance == null || COUNTRIES.isEmpty()) {
if (InstanceHelper.instance == null || COUNTRIES.isEmpty()
|| MapWithAIPreferenceHelper.getMapWithAIUrl().isEmpty()) {
InstanceHelper.instance = new DataAvailability();
}
return InstanceHelper.instance;

Wyświetl plik

@ -300,12 +300,8 @@ public class GetDataRunnable extends RecursiveTask<DataSet> {
}
private static boolean distanceCheck(Node nearNode, Node node, Double distance) {
try {
return nearNode.getCoor().greatCircleDistance(node.getCoor()) < distance;
} catch (Exception e) {
Logging.error(e);
return false;
}
return nearNode == null || node == null ? false
: nearNode.getCoor().greatCircleDistance(node.getCoor()) < distance;
}
private static boolean keyCheck(Node nearNode, Node node) {

Wyświetl plik

@ -180,7 +180,7 @@ public final class MapWithAIPreferenceHelper {
* @return true if the configuration changed
*/
public static boolean setMapWithAIURLs(List<Map<String, String>> urls) {
final List<Map<String, String>> setUrls = urls;
final List<Map<String, String>> setUrls = urls.isEmpty() ? new ArrayList<>() : urls;
if (urls.isEmpty()) {
final TreeMap<String, String> defaultAPIMap = new TreeMap<>();
defaultAPIMap.put(URL_STRING, DEFAULT_MAPWITHAI_API);

Wyświetl plik

@ -3,9 +3,13 @@ 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.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
import org.awaitility.Durations;
import org.junit.After;
import org.junit.Before;
@ -75,4 +79,35 @@ public class MapWithAIAvailabilityTest {
assertFalse(DataAvailability.getDataTypes(new LatLon(19.433333, -99.133333)).getOrDefault("building", false),
"Mexico does not yet have building data");
}
@Test
public void testNoURLs() {
MapWithAIPreferenceHelper.setMapWithAIURLs(Collections.emptyList());
DataAvailability.getInstance();
testgetDataLatLon();
MapWithAIPreferenceHelper.setMapWithAIURLs(Collections.emptyList());
DataAvailability.getInstance();
testHasDataLatLon();
MapWithAIPreferenceHelper.setMapWithAIURLs(Collections.emptyList());
DataAvailability.getInstance();
testHasDataBBox();
}
@Test
public void testGetPrivacyUrls() {
assertFalse(DataAvailability.getPrivacyPolicy().isEmpty());
}
@Test
public void testGetTOSUrls() {
assertFalse(DataAvailability.getTermsOfUse().isEmpty());
}
@Test
public void testDefaultUrlImplementations() {
DataAvailability instance = DataAvailability.getInstance();
assertNull(instance.getUrl());
assertEquals("", instance.getPrivacyPolicyUrl());
assertEquals("", instance.getTermsOfUseUrl());
}
}

Wyświetl plik

@ -11,6 +11,7 @@ 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) {