2019-12-18 20:47:39 +00:00
|
|
|
// License: GPL. For details, see LICENSE file.
|
|
|
|
package org.openstreetmap.josm.plugins.mapwithai.backend;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertAll;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.Future;
|
|
|
|
|
2020-06-15 17:27:01 +00:00
|
|
|
import org.junit.jupiter.api.Test;
|
2019-12-18 20:47:39 +00:00
|
|
|
import org.openstreetmap.josm.actions.downloadtasks.DownloadParams;
|
|
|
|
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
2020-03-31 17:03:42 +00:00
|
|
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
|
2021-07-21 14:14:36 +00:00
|
|
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
|
2021-09-07 22:26:46 +00:00
|
|
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions;
|
2021-09-30 18:56:20 +00:00
|
|
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
|
2021-07-20 16:48:25 +00:00
|
|
|
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
2023-10-24 19:24:07 +00:00
|
|
|
import org.openstreetmap.josm.testutils.annotations.OsmApi;
|
2023-07-20 17:34:18 +00:00
|
|
|
import org.openstreetmap.josm.testutils.annotations.Projection;
|
2023-08-08 19:25:49 +00:00
|
|
|
import org.openstreetmap.josm.testutils.annotations.Territories;
|
2020-06-01 22:35:49 +00:00
|
|
|
|
2021-07-20 16:48:25 +00:00
|
|
|
@BasicPreferences
|
2021-09-30 18:56:20 +00:00
|
|
|
@MapWithAISources
|
|
|
|
@NoExceptions
|
2023-10-24 19:24:07 +00:00
|
|
|
@OsmApi(OsmApi.APIType.FAKE)
|
2023-07-20 17:34:18 +00:00
|
|
|
@Projection
|
2023-10-24 19:24:07 +00:00
|
|
|
@Territories
|
|
|
|
@Wiremock
|
2020-06-15 17:27:01 +00:00
|
|
|
class DownloadMapWithAITaskTest {
|
2019-12-18 20:47:39 +00:00
|
|
|
|
|
|
|
@Test
|
2020-06-15 17:27:01 +00:00
|
|
|
void testDownloadOsmServerReaderDownloadParamsBoundsProgressMonitor()
|
2019-12-18 20:47:39 +00:00
|
|
|
throws InterruptedException, ExecutionException {
|
|
|
|
DownloadMapWithAITask task = new DownloadMapWithAITask();
|
|
|
|
Future<?> future = task.download(
|
|
|
|
new BoundingBoxMapWithAIDownloader(MapWithAIDataUtilsTest.getTestBounds(),
|
2020-06-24 19:50:39 +00:00
|
|
|
MapWithAILayerInfo.getInstance().getLayers().get(0), false),
|
2019-12-18 20:47:39 +00:00
|
|
|
new DownloadParams(), MapWithAIDataUtilsTest.getTestBounds(), NullProgressMonitor.INSTANCE);
|
|
|
|
future.get();
|
|
|
|
assertNotNull(task.getDownloadedData(), "Data should be downloaded");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2021-09-30 18:56:20 +00:00
|
|
|
void testGetConfirmationMessage() {
|
2019-12-18 20:47:39 +00:00
|
|
|
DownloadMapWithAITask task = new DownloadMapWithAITask();
|
|
|
|
assertAll(
|
|
|
|
() -> assertTrue(task.getConfirmationMessage(new URL("https://fake.api")).contains("fake.api"),
|
|
|
|
"We should get a confirmation message"),
|
|
|
|
() -> assertNull(task.getConfirmationMessage(null), "The message should be null if the URL is null"));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|