MapWithAILayerInfo: Make new @MapWithAISources annotation

Signed-off-by: Taylor Smock <tsmock@fb.com>
pull/1/head
Taylor Smock 2021-07-21 08:14:36 -06:00
rodzic cd95357e43
commit 73e64116f9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
31 zmienionych plików z 167 dodań i 91 usunięć

Wyświetl plik

@ -24,6 +24,7 @@ import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
import org.openstreetmap.josm.plugins.PluginInformation;
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.MapWithAIPreferences;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
import org.openstreetmap.josm.plugins.mapwithai.tools.MapPaintUtils;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.testutils.JOSMTestRules;
@ -33,13 +34,16 @@ import org.openstreetmap.josm.testutils.mockers.WindowMocker;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Test class for {@link MapWithAIPlugin}
*
* @author Taylor Smock
*/
@MapWithAISources
@BasicPreferences
class MapWithAIPluginTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules test = new MapWithAITestRules().sources().wiremock().main().projection();
JOSMTestRules test = new MapWithAITestRules().wiremock().main().projection();
PluginInformation info;
MapWithAIPlugin plugin;

Wyświetl plik

@ -21,11 +21,20 @@ import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
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.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
/**
* Test class for {@link AddMapWithAILayerAction}
*
* @author Taylor Smock
*/
@MapWithAISources
@BasicPreferences
class AddMapWithAILayerActionTest {
@RegisterExtension
JOSMTestRules rule = new MapWithAITestRules().wiremock().sources().projection();
JOSMTestRules rule = new MapWithAITestRules().wiremock().projection();
@Test
void testAddMapWithAILayerActionTest() {

Wyświetl plik

@ -19,16 +19,23 @@ import org.openstreetmap.josm.data.osm.DataSet;
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.testutils.JOSMTestRules;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
/**
* Test class for {@link DownloadListener}
*
* @author Taylor Smock
*/
@MapWithAISources
@BasicPreferences
class DownloadListenerTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules rule = new MapWithAITestRules().sources().wiremock().projection();
JOSMTestRules rule = new MapWithAITestRules().wiremock().projection();
@Test
void testDataSourceChange() {

Wyświetl plik

@ -17,16 +17,18 @@ 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.testutils.JOSMTestRules;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
@MapWithAISources
@BasicPreferences
class DownloadMapWithAITaskTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules rule = new MapWithAITestRules().sources().wiremock().fakeAPI().projection().territories();
JOSMTestRules rule = new MapWithAITestRules().wiremock().fakeAPI().projection().territories();
@Test
void testDownloadOsmServerReaderDownloadParamsBoundsProgressMonitor()

Wyświetl plik

@ -28,6 +28,7 @@ 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.testutils.JOSMTestRules;
import org.openstreetmap.josm.tools.Geometry;
@ -35,10 +36,16 @@ import com.github.tomakehurst.wiremock.WireMockServer;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Test class for {@link GetDataRunnable}
*
* @author Taylor Smock
*/
@MapWithAISources
class GetDataRunnableTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules rule = new MapWithAITestRules().sources().wiremock().projection().fakeAPI().territories();
JOSMTestRules rule = new MapWithAITestRules().wiremock().projection().fakeAPI().territories();
static String getDefaultMapWithAIAPIForTest(WireMockServer wireMock, String url) {
return getDefaultMapWithAIAPIForTest(wireMock, url, "https://www.mapwith.ai");

Wyświetl plik

@ -23,16 +23,19 @@ import org.openstreetmap.josm.gui.Notification;
import org.openstreetmap.josm.gui.layer.Layer;
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.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.tools.Territories;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@MapWithAISources
@BasicPreferences
class MapWithAIActionTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules test = new MapWithAITestRules().sources().wiremock().main().projection().territories()
.timeout(100000);
JOSMTestRules test = new MapWithAITestRules().wiremock().main().projection().territories().timeout(100000);
private MapWithAIAction action;

Wyświetl plik

@ -17,17 +17,24 @@ import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.coor.LatLon;
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.testutils.JOSMTestRules;
import org.openstreetmap.josm.tools.Territories;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Test class for testing availability
*
* @author Taylor Smock
*/
@MapWithAISources
class MapWithAIAvailabilityTest {
private DataAvailability instance;
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules test = new MapWithAITestRules().sources().wiremock().projection().territories();
JOSMTestRules test = new MapWithAITestRules().wiremock().projection().territories();
@BeforeEach
void setUp() {

Wyświetl plik

@ -30,12 +30,19 @@ 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.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.tools.Logging;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Test class for {@link MapWithAIDataUtils}
*
* @author Taylor Smock
*/
@MapWithAISources
@BasicPreferences
public class MapWithAIDataUtilsTest {
/** This is the default MapWithAI URL */
@ -43,7 +50,7 @@ public class MapWithAIDataUtilsTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules test = new MapWithAITestRules().sources().wiremock().main().projection().fakeAPI().territories();
JOSMTestRules test = new MapWithAITestRules().wiremock().main().projection().fakeAPI().territories();
/**
* This gets data from MapWithAI. This test may fail if someone adds the data to

Wyświetl plik

@ -47,6 +47,7 @@ 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.tools.MapPaintUtils;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.testutils.JOSMTestRules;
@ -56,15 +57,16 @@ import org.openstreetmap.josm.tools.Territories;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* @author Taylor Smock
* Test class for {@link MapWithAILayer}
*
* @author Taylor Smock
*/
@MapWithAISources
@BasicPreferences
class MapWithAILayerTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
static JOSMTestRules test = new MapWithAITestRules().sources().wiremock().main().projection().fakeAPI()
.territories();
static JOSMTestRules test = new MapWithAITestRules().wiremock().main().projection().fakeAPI().territories();
MapWithAILayer layer;

Wyświetl plik

@ -28,11 +28,13 @@ import org.openstreetmap.josm.plugins.mapwithai.commands.MapWithAIAddCommand;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
/**
* @author Taylor Smock
*
*/
@BasicPreferences
class MapWithAIObjectTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")

Wyświetl plik

@ -20,22 +20,27 @@ import org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
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.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.tools.Utils;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* @author Taylor Smock
* Test class for {@link MapWithAIRemoteControl}
*
* @author Taylor Smock
*/
@BasicPreferences
@MapWithAISources
class MapWithAIRemoteControlTest {
/**
* Setup test.
*/
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules test = new MapWithAITestRules().sources().wiremock().main().projection().territories();
JOSMTestRules test = new MapWithAITestRules().wiremock().main().projection().territories();
private static MapWithAIRemoteControl newHandler(String url) throws RequestHandlerBadRequestException {
final MapWithAIRemoteControl req = new MapWithAIRemoteControl();

Wyświetl plik

@ -33,20 +33,23 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
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.testutils.JOSMTestRules;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
/**
* @author Taylor Smock
* Test class for {@link MapWithAIUploadHook}
*
* @author Taylor Smock
*/
@MapWithAISources
@BasicPreferences
class MapWithAIUploadHookTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
static JOSMTestRules test = new MapWithAITestRules().sources().wiremock().main().projection().territories();
static JOSMTestRules test = new MapWithAITestRules().wiremock().main().projection().territories();
private PluginInformation info;
private OsmDataLayer osmLayer;
private MapWithAILayer aiLayer;

Wyświetl plik

@ -92,4 +92,4 @@ class AddNodeToWayCommandTest {
assertEquals(new LatLon(-0.01, -0.01), way.getNode(2).getCoor());
assertEquals(new LatLon(-0.1, -0.1), way.lastNode().getCoor());
}
}
}

Wyświetl plik

@ -25,6 +25,7 @@ import org.openstreetmap.josm.data.osm.Way;
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.testutils.JOSMTestRules;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@ -34,11 +35,12 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
*
* @author Taylor Smock
*/
@MapWithAISources
@org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command
class CreateConnectionsCommandTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules test = new MapWithAITestRules().sources().wiremock().projection();
JOSMTestRules test = new MapWithAITestRules().wiremock().projection();
/**
* Test method for
@ -205,4 +207,4 @@ class CreateConnectionsCommandTest {
assertNotNull(text, "There should be a description for the command");
assertFalse(text.isEmpty(), "The description should not be an empty string");
}
}
}

Wyświetl plik

@ -42,20 +42,29 @@ import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MissingConnectionTagsMocker;
import org.openstreetmap.josm.plugins.mapwithai.testutils.PleaseWaitDialogMocker;
import org.openstreetmap.josm.plugins.mapwithai.testutils.SwingUtilitiesMocker;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.mockers.WindowMocker;
import org.openstreetmap.josm.tools.Logging;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import mockit.Mock;
/**
* Test class for {@link MapWithAIAddCommand}
*
* @author Taylor Smock
*/
@BasicPreferences
@MapWithAISources
@Command
class MapWithAIAddComandTest {
private final static String HIGHWAY_RESIDENTIAL = "highway=residential";
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules test = new MapWithAITestRules().sources().wiremock().projection().assertionsInEDT().main();
JOSMTestRules test = new MapWithAITestRules().wiremock().projection().assertionsInEDT().main();
@BeforeEach
void setUp() {
@ -125,8 +134,8 @@ class MapWithAIAddComandTest {
"w".concat(Long.toString(way1.getUniqueId())).concat(",n")
.concat(Long.toString(way1.firstNode().getUniqueId())).concat(",n")
.concat(Long.toString(way1.lastNode().getUniqueId())));
way1.getNodes().forEach(node -> ds1.addPrimitive(node));
way2.getNodes().forEach(node -> ds1.addPrimitive(node));
way1.getNodes().forEach(ds1::addPrimitive);
way2.getNodes().forEach(ds1::addPrimitive);
ds1.addPrimitive(way2);
ds1.addPrimitive(way1);
MapWithAIAddCommand.createConnections(ds1, Collections.singletonList(way2.firstNode().save())).executeCommand();
@ -155,8 +164,8 @@ class MapWithAIAddComandTest {
new Node(new LatLon(0.1, 0.1)));
final Way way2 = TestUtils.newWay(HIGHWAY_RESIDENTIAL, new Node(new LatLon(-0.1, -0.1)),
new Node(new LatLon(0.1, 0.1)));
way1.getNodes().forEach(node -> mapWithAIData.addPrimitive(node));
way2.getNodes().forEach(node -> osmData.addPrimitive(node));
way1.getNodes().forEach(mapWithAIData::addPrimitive);
way2.getNodes().forEach(osmData::addPrimitive);
osmData.addPrimitive(way2);
mapWithAIData.addPrimitive(way1);
mapWithAIData.setSelected(way1);
@ -194,7 +203,7 @@ class MapWithAIAddComandTest {
final DataSet from = new DataSet();
final Way way1 = TestUtils.newWay("highway=tertiary", new Node(new LatLon(0, 0)),
new Node(new LatLon(0.1, 0.1)));
way1.getNodes().stream().forEach(node -> from.addPrimitive(node));
way1.getNodes().stream().forEach(from::addPrimitive);
from.addPrimitive(way1);
from.addPrimitive(new Node(new LatLon(-0.1, 0.1)));
@ -320,4 +329,4 @@ class MapWithAIAddComandTest {
SaveActionBase.doSave(layer, new File("post_command2.osm"), false);
}
}
}

Wyświetl plik

@ -353,4 +353,4 @@ class MergeDuplicateWaysTest {
way2.setDeleted(true);
assertDoesNotThrow(() -> new MergeDuplicateWays(ds, ways).executeCommand());
}
}
}

Wyświetl plik

@ -170,4 +170,4 @@ class MovePrimitiveDataSetCommandTest {
assertNotNull(new MovePrimitiveDataSetCommand(new DataSet(), from, Collections.singleton(tNode))
.getDescriptionText());
}
}
}

Wyświetl plik

@ -93,4 +93,4 @@ class AlreadyConflatedCommandTest {
assertFalse(alreadyConflatedCommand.getDescriptionText().trim().isEmpty());
}
}
}

Wyświetl plik

@ -105,4 +105,4 @@ class MergeAddressBuildingsTest {
assertEquals(tr("Merge added buildings with existing address nodes"), command.getDescriptionText());
}
}
}

Wyświetl plik

@ -28,10 +28,12 @@ import org.openstreetmap.josm.plugins.mapwithai.commands.cleanup.MissingConnecti
import org.openstreetmap.josm.plugins.mapwithai.testutils.MissingConnectionTagsMocker;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.WoundedTest;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.testutils.mockers.WindowMocker;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@BasicPreferences
@org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Command
class MissingConnectionTagsTest {
@RegisterExtension
@ -100,4 +102,4 @@ class MissingConnectionTagsTest {
}
}
}
}

Wyświetl plik

@ -22,7 +22,9 @@ import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.layer.OsmDataLayer;
import org.openstreetmap.josm.plugins.mapwithai.actions.AddMapWithAILayerAction;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
import org.openstreetmap.josm.tools.Logging;
/**
@ -31,9 +33,11 @@ import org.openstreetmap.josm.tools.Logging;
* @author Taylor Smock
*
*/
@BasicPreferences
@MapWithAISources
class MapWithAIMenuTest {
@RegisterExtension
static JOSMTestRules rule = new MapWithAITestRules().wiremock().sources().territories().projection().main();
static JOSMTestRules rule = new MapWithAITestRules().wiremock().territories().projection().main();
private static MapWithAIMenu menu;
@BeforeAll

Wyświetl plik

@ -17,7 +17,9 @@ import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtilsTest;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
@BasicPreferences
class MapWithAIDownloadSourceTypeTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")

Wyświetl plik

@ -15,17 +15,23 @@ import org.openstreetmap.josm.gui.widgets.JosmTextArea;
import org.openstreetmap.josm.gui.widgets.JosmTextField;
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.testutils.JOSMTestRules;
import org.openstreetmap.josm.testutils.mockers.WindowMocker;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
/**
* Test class for {@link AddMapWithAIPanel}
*
* @author Taylor Smock
*/
@MapWithAISources
class AddMapWithAIPanelTest {
@RegisterExtension
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
JOSMTestRules rule = new MapWithAITestRules().wiremock().sources().territories().projection().assertionsInEDT();
JOSMTestRules rule = new MapWithAITestRules().wiremock().territories().projection().assertionsInEDT();
@SuppressWarnings("unused")
@Test
void test() throws ReflectiveOperationException {
new WindowMocker();
@ -61,5 +67,4 @@ class AddMapWithAIPanelTest {
rawUrl.setText("");
assertFalse(panel.isSourceValid());
}
}

Wyświetl plik

@ -16,11 +16,18 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
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.testutils.JOSMTestRules;
/**
* Test class for {@link MapWithAIDefaultLayerTableModel}
*
* @author Taylor Smock
*/
@MapWithAISources
class MapWithAIDefaultLayerTableModelTest {
@RegisterExtension
JOSMTestRules rule = new MapWithAITestRules().wiremock().sources().projection();
JOSMTestRules rule = new MapWithAITestRules().wiremock().projection();
@Test
void testGetRow() {

Wyświetl plik

@ -21,6 +21,7 @@ import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
import org.openstreetmap.josm.plugins.mapwithai.gui.preferences.mapwithai.MapWithAIProvidersPanel.AreaListener;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.MapWithAISources;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.tools.ListenerList;
@ -29,9 +30,10 @@ import org.openstreetmap.josm.tools.ListenerList;
*
* @author Taylor Smock
*/
@MapWithAISources
class MapWithAIProvidersPanelTest {
@RegisterExtension
JOSMTestRules rule = new MapWithAITestRules().sources().wiremock().projection();
JOSMTestRules rule = new MapWithAITestRules().wiremock().projection();
private MapWithAIProvidersPanel mapwithaiProvidersPanel;

Wyświetl plik

@ -12,13 +12,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.junit.jupiter.api.extension.InvocationInterceptor.Invocation;
import org.junit.runners.model.InitializationError;
import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
@ -43,13 +39,10 @@ import com.github.tomakehurst.wiremock.http.Request;
import com.github.tomakehurst.wiremock.http.Response;
import com.github.tomakehurst.wiremock.verification.LoggedRequest;
import mockit.Mock;
import mockit.MockUp;
import mockit.integration.TestRunnerDecorator;
public class MapWithAITestRules extends JOSMTestRules {
private boolean sources;
private boolean wiremock;
private static WireMockServer wireMock;
private static final List<Object> wireMockUsers = Collections.synchronizedList(new ArrayList<>());
@ -57,35 +50,12 @@ public class MapWithAITestRules extends JOSMTestRules {
private UncaughtExceptionHandler currentExceptionHandler;
private String currentReleaseUrl;
private Collection<String> sourceSites;
private Runnable mapwithaiLayerInfoMocker;
private boolean territories;
public MapWithAITestRules() {
super();
}
/**
* Use if a fully initialized {@link MapWithAILayerInfo} is required
*
* @return this, for easy chaining
*/
public MapWithAITestRules sources() {
return sources(null);
}
/**
* Use if you don't need all of {@link MapWithAILayerInfo}
*
* @param mapwithaiLayerInfoMocker A mocker so that MapWithAILayerInfo isn't
* fully instantiated
* @return this, for easy chaining
*/
public MapWithAITestRules sources(Runnable mapwithaiLayerInfoMocker) {
this.sources = true;
this.mapwithaiLayerInfoMocker = mapwithaiLayerInfoMocker;
return this;
}
@Override
public MapWithAITestRules territories() {
this.territories = true;
@ -118,9 +88,6 @@ public class MapWithAITestRules extends JOSMTestRules {
Logging.getLogger().setFilter(record -> record.getLevel().intValue() >= Level.WARNING.intValue()
|| record.getSourceClassName().startsWith("org.openstreetmap.josm.plugins.mapwithai"));
if (mapwithaiLayerInfoMocker != null) {
mapwithaiLayerInfoMocker.run();
}
synchronized (wireMockUsers) {
if (wiremock && wireMock == null) {
wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock")
@ -153,23 +120,7 @@ public class MapWithAITestRules extends JOSMTestRules {
wireMockUsers.add(this);
}
}
if (sources) {
AtomicBoolean finished = new AtomicBoolean();
MapWithAILayerInfo.getInstance().load(false, () -> finished.set(true));
Awaitility.await().atMost(Durations.TEN_SECONDS).until(finished::get);
} else {
// This only exists to ensure that if MapWithAILayerInfo is called, things
// happen...
new MockUp<MapWithAILayerInfo>() {
@Mock
public MapWithAILayerInfo getInstance(Invocation<MapWithAILayerInfo> inv) throws Throwable {
if (!sources) {
return null;
}
return inv.proceed();
}
};
}
if (workerExceptions) {
currentExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {

Wyświetl plik

@ -23,4 +23,4 @@ import org.junit.jupiter.api.Test;
*/
public @interface BleedTest {
}
}

Wyświetl plik

@ -19,4 +19,4 @@ import org.junit.jupiter.api.Tag;
*/
public @interface Command {
}
}

Wyświetl plik

@ -0,0 +1,34 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.mapwithai.testutils.annotations;
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAILayerInfo;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* An annotation to use {@link MapWithAILayerInfo}
*
* @author Taylor Smock
*/
@ExtendWith(MapWithAISources.MapWithAILayerInfoExtension.class)
public @interface MapWithAISources {
class MapWithAILayerInfoExtension implements AfterAllCallback, BeforeAllCallback {
@Override
public void afterAll(ExtensionContext context) {
MapWithAILayerInfo.getInstance().clear();
}
@Override
public void beforeAll(ExtensionContext context) {
AtomicBoolean finished = new AtomicBoolean();
MapWithAILayerInfo.getInstance().load(false, () -> finished.set(true));
Awaitility.await().atMost(Durations.TEN_SECONDS).until(finished::get);
}
}
}

Wyświetl plik

@ -21,4 +21,4 @@ import org.junit.jupiter.api.Test;
*/
public @interface SlowTest {
}
}

Wyświetl plik

@ -23,4 +23,4 @@ import org.junit.jupiter.api.Test;
public @interface WoundedTest {
}
}