Update test code

Signed-off-by: Taylor Smock <tsmock@meta.com>
pull/39/head
Taylor Smock 2023-08-28 10:23:52 -06:00
rodzic 409662a664
commit 4831fee88e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 233BB2E466604E27
7 zmienionych plików z 14 dodań i 45 usunięć

Wyświetl plik

@ -224,7 +224,7 @@ public class MissingConnectionTags extends AbstractConflationCommand {
final var commands = new ArrayList<Command>();
if (intersectionNodes.stream().anyMatch(way::containsNode)) {
final var searchWays = way.getDataSet().searchWays(way.getBBox()).stream()
.filter(w -> w != way && w.hasKey(HIGHWAY)).toList();
.filter(w -> !Objects.equals(w, way) && w.hasKey(HIGHWAY)).toList();
for (var potential : searchWays) {
for (var node : way.getNodes()) {
final var command = createAddNodeCommand(potential, node, precision);

Wyświetl plik

@ -193,8 +193,7 @@ class AddMapWithAILayerActionTest {
MainApplication.worker.submit(() -> {
/* Sync thread */ }).get();
final List<LogRecord> ides = logs.stream()
.filter(record -> record.getThrown() instanceof IllegalArgumentException)
.collect(Collectors.toList());
.filter(record -> record.getThrown() instanceof IllegalArgumentException).toList();
assertTrue(ides.isEmpty(), ides.stream().map(LogRecord::getMessage).collect(Collectors.joining("\n")));
} finally {
server.stop();

Wyświetl plik

@ -8,7 +8,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
@ -17,10 +16,10 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIType;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAIConfig;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
import org.openstreetmap.josm.testutils.annotations.HTTP;
import org.openstreetmap.josm.testutils.annotations.OsmApi;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.admin.model.GetServeEventsResult;
@ -43,10 +42,9 @@ import com.github.tomakehurst.wiremock.verification.LoggedRequest;
@HTTP
@Wiremock
@MapWithAIConfig
@OsmApi(OsmApi.APIType.FAKE)
class BoundingBoxMapWithAIDownloaderTest {
private static final String TEST_DATA = "<osm version=\"0.6\"><node id=\"1\" lat=\"0\" lon=\"0\" version=\"1\"/><node id=\"2\" lat=\"1\" lon=\"1\" version=\"1\"/></osm>";
@RegisterExtension
JOSMTestRules josmTestRules = new JOSMTestRules().fakeAPI();
@BasicWiremock
public WireMockServer wireMockServer;

Wyświetl plik

@ -11,32 +11,25 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.actions.downloadtasks.DownloadParams;
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
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.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.annotations.OsmApi;
import org.openstreetmap.josm.testutils.annotations.Projection;
import org.openstreetmap.josm.testutils.annotations.Territories;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@BasicPreferences
@MapWithAISources
@NoExceptions
@Wiremock
@Territories
@OsmApi(OsmApi.APIType.FAKE)
@Projection
@Territories
class DownloadMapWithAITaskTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules rule = new MapWithAITestRules().fakeAPI();
@Test
void testDownloadOsmServerReaderDownloadParamsBoundsProgressMonitor()
throws InterruptedException, ExecutionException {

Wyświetl plik

@ -17,7 +17,6 @@ import java.util.Map;
import java.util.Objects;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.coor.LatLon;
@ -28,16 +27,13 @@ import org.openstreetmap.josm.data.osm.Way;
import org.openstreetmap.josm.data.projection.ProjectionRegistry;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.NoExceptions;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.OsmApi;
import org.openstreetmap.josm.testutils.annotations.Projection;
import org.openstreetmap.josm.testutils.annotations.Territories;
import org.openstreetmap.josm.tools.Geometry;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Test class for {@link GetDataRunnable}
*
@ -45,13 +41,10 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
*/
@NoExceptions
@MapWithAISources
@OsmApi(OsmApi.APIType.FAKE)
@Projection
@Territories
class GetDataRunnableTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
static JOSMTestRules rule = new MapWithAITestRules().fakeAPI();
@Test
void testAddMissingElement() {
Way way1 = TestUtils.newWay("", new Node(new LatLon(-5.7117803, 34.5011898)),
@ -65,7 +58,7 @@ class GetDataRunnableTest {
assertEquals(4, way1.getNodesCount());
assertEquals(4, way2.getNodesCount());
assertSame(way2.getNode(1), way2.getNode(1));
assertSame(way1.getNode(1), way2.getNode(1));
way1.removeNode(way1.getNode(1));
List<Node> nodes = way2.getNodes();

Wyświetl plik

@ -17,7 +17,6 @@ import java.util.stream.Collectors;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.coor.ILatLon;
@ -32,19 +31,16 @@ import org.openstreetmap.josm.data.osm.Way;
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.layer.GpxLayer;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
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.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.annotations.Main;
import org.openstreetmap.josm.testutils.annotations.OsmApi;
import org.openstreetmap.josm.testutils.annotations.Projection;
import org.openstreetmap.josm.testutils.annotations.Territories;
import org.openstreetmap.josm.tools.Logging;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Test class for {@link MapWithAIDataUtils}
*
@ -54,6 +50,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@Main
@MapWithAISources
@NoExceptions
@OsmApi(OsmApi.APIType.FAKE)
@Projection
@Territories
@Wiremock
@ -61,10 +58,6 @@ public class MapWithAIDataUtilsTest {
/** This is the default MapWithAI URL */
private static final String DEFAULT_MAPWITHAI_API = "https://www.mapwith.ai/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&bbox={bbox}";
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
static JOSMTestRules test = new MapWithAITestRules().fakeAPI();
/**
* This gets data from MapWithAI. This test may fail if someone adds the data to
* OSM.

Wyświetl plik

@ -27,7 +27,6 @@ import org.awaitility.Durations;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.DataSource;
@ -46,19 +45,16 @@ import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer.Continuou
import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAIPluginMock;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
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.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.annotations.Main;
import org.openstreetmap.josm.testutils.annotations.OsmApi;
import org.openstreetmap.josm.testutils.annotations.Projection;
import org.openstreetmap.josm.testutils.annotations.Territories;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Test class for {@link MapWithAILayer}
*
@ -67,14 +63,11 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@BasicPreferences
@Main
@MapWithAISources
@OsmApi(OsmApi.APIType.FAKE)
@Projection
@Territories(Territories.Initialize.ALL)
@Wiremock
class MapWithAILayerTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
static JOSMTestRules test = new MapWithAITestRules().main().fakeAPI();
MapWithAILayer layer;
@BeforeAll