kopia lustrzana https://github.com/JOSM/MapWithAI
Fix a URL so that it catches other URL patterns
Also, make some modifications to rules so that a mocker can be used for some classes, to reduce time running tests Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
3565fcb232
commit
60e3d8f74a
|
@ -2,7 +2,7 @@
|
|||
"id" : "23497750-675c-440a-986a-34dd14b047f8",
|
||||
"name" : "josm_mapwithai_json_sourcesjson",
|
||||
"request" : {
|
||||
"url" : "/gokaart/JOSM_MapWithAI/-/raw/pages/public/json/sources.json",
|
||||
"urlPattern" : "(\/gokaart)?\/JOSM_MapWithAI\/(-\/raw\/pages\/public\/)?json\/sources.json",
|
||||
"method" : "GET"
|
||||
},
|
||||
"response" : {
|
||||
|
@ -21,4 +21,4 @@
|
|||
"uuid" : "23497750-675c-440a-986a-34dd14b047f8",
|
||||
"persistent" : true,
|
||||
"insertionIndex" : 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,14 +51,32 @@ public class MapWithAITestRules extends JOSMTestRules {
|
|||
private UncaughtExceptionHandler currentExceptionHandler;
|
||||
private String currentReleaseUrl;
|
||||
private Collection<String> sourceSites;
|
||||
private Runnable mapwithaiLayerInfoMocker;
|
||||
|
||||
public MapWithAITestRules() {
|
||||
super();
|
||||
super.assertionsInEDT();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@ -87,6 +105,9 @@ 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();
|
||||
}
|
||||
if (wiremock) {
|
||||
wireMock = new WireMockServer(options().usingFilesUnderDirectory("test/resources/wiremock")
|
||||
.extensions(new WireMockUrlTransformer()).dynamicPort());
|
||||
|
@ -129,23 +150,6 @@ public class MapWithAITestRules extends JOSMTestRules {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace URL servers with wiremock
|
||||
*
|
||||
* @param wireMock 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 wireMock, String url) {
|
||||
try {
|
||||
URL temp = new URL(url);
|
||||
return wireMock.baseUrl() + temp.getFile();
|
||||
} catch (MalformedURLException error) {
|
||||
Logging.error(error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void after() throws ReflectiveOperationException {
|
||||
super.after();
|
||||
|
@ -175,6 +179,23 @@ public class MapWithAITestRules extends JOSMTestRules {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace URL servers with wiremock
|
||||
*
|
||||
* @param wireMock 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 wireMock, String url) {
|
||||
try {
|
||||
URL temp = new URL(url);
|
||||
return wireMock.baseUrl() + temp.getFile();
|
||||
} catch (MalformedURLException error) {
|
||||
Logging.error(error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wiremock instance
|
||||
*
|
||||
|
|
Ładowanie…
Reference in New Issue