kopia lustrzana https://github.com/JOSM/MapWithAI
rodzic
cecb9f40be
commit
5d9df1fba4
|
@ -16,12 +16,12 @@ jobs:
|
||||||
call-workflow:
|
call-workflow:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
josm-revision: ["", "r18877"]
|
josm-revision: ["", "r19067"]
|
||||||
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v2
|
uses: JOSM/JOSMPluginAction/.github/workflows/ant.yml@v3
|
||||||
with:
|
with:
|
||||||
java-version: 17
|
java-version: 17
|
||||||
josm-revision: ${{ matrix.josm-revision }}
|
josm-revision: ${{ matrix.josm-revision }}
|
||||||
plugin-jar-name: 'mapwithai'
|
plugin-jar-name: 'mapwithai'
|
||||||
perform-revision-tagging: ${{ matrix.josm-revision == 'r18877' && github.repository == 'JOSM/MapWithAI' && github.ref_type == 'branch' && github.ref_name == 'master' && github.event_name != 'schedule' && github.event_name != 'pull_request' }}
|
perform-revision-tagging: ${{ matrix.josm-revision == 'r19067' && github.repository == 'JOSM/MapWithAI' && github.ref_type == 'branch' && github.ref_name == 'master' && github.event_name != 'schedule' && github.event_name != 'pull_request' }}
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
|
|
|
@ -10,4 +10,4 @@ permissions:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
call-workflow:
|
call-workflow:
|
||||||
uses: JOSM/JOSMPluginAction/.github/workflows/reports.yaml@v2
|
uses: JOSM/JOSMPluginAction/.github/workflows/reports.yaml@v3
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# The minimum JOSM version this plugin is compatible with (can be any numeric version
|
# The minimum JOSM version this plugin is compatible with (can be any numeric version
|
||||||
plugin.main.version = 18877
|
plugin.main.version = 19067
|
||||||
# The JOSM version this plugin is currently compiled against
|
# The JOSM version this plugin is currently compiled against
|
||||||
# Please make sure this version is available at https://josm.openstreetmap.de/download
|
# Please make sure this version is available at https://josm.openstreetmap.de/download
|
||||||
# The special values "latest" and "tested" are also possible here, but not recommended.
|
# The special values "latest" and "tested" are also possible here, but not recommended.
|
||||||
plugin.compile.version = 18877
|
plugin.compile.version = 19067
|
||||||
plugin.canloadatruntime = true
|
plugin.canloadatruntime = true
|
||||||
plugin.author = Taylor Smock
|
plugin.author = Taylor Smock
|
||||||
plugin.class = org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin
|
plugin.class = org.openstreetmap.josm.plugins.mapwithai.MapWithAIPlugin
|
||||||
|
|
|
@ -0,0 +1,193 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openstreetmap.josm.plugins</groupId>
|
||||||
|
<artifactId>MapWithAI</artifactId>
|
||||||
|
<version>SNAPSHOT</version>
|
||||||
|
<properties>
|
||||||
|
<jmockit.version>1.49.a</jmockit.version>
|
||||||
|
<pmd.version>7.5.0</pmd.version>
|
||||||
|
<jacoco.version>0.8.12</jacoco.version>
|
||||||
|
<checkstyle.version>10.18.1</checkstyle.version>
|
||||||
|
<spotbugs.version>4.8.6</spotbugs.version>
|
||||||
|
</properties>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>JOSM-releases</id>
|
||||||
|
<url>https://josm.openstreetmap.de/nexus/content/repositories/releases/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>JOSM-snapshots</id>
|
||||||
|
<url>https://josm.openstreetmap.de/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit</groupId>
|
||||||
|
<artifactId>junit-bom</artifactId>
|
||||||
|
<version>5.11.1</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openstreetmap.josm</groupId>
|
||||||
|
<artifactId>josm</artifactId>
|
||||||
|
<version>SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openstreetmap.josm.plugins</groupId>
|
||||||
|
<artifactId>pmtiles</artifactId>
|
||||||
|
<version>SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openstreetmap.josm.plugins</groupId>
|
||||||
|
<artifactId>utilsplugin2</artifactId>
|
||||||
|
<version>SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openstreetmap.josm</groupId>
|
||||||
|
<artifactId>josm-unittest</artifactId>
|
||||||
|
<version>SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wiremock</groupId>
|
||||||
|
<artifactId>wiremock</artifactId>
|
||||||
|
<version>3.9.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency> <!-- needed until JOSM core removes Junit4 support -->
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.13.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.awaitility</groupId>
|
||||||
|
<artifactId>awaitility</artifactId>
|
||||||
|
<version>4.2.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.jqno.equalsverifier</groupId>
|
||||||
|
<artifactId>equalsverifier</artifactId>
|
||||||
|
<version>3.17</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jmockit</groupId>
|
||||||
|
<artifactId>jmockit</artifactId>
|
||||||
|
<version>1.49.a</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.json</groupId>
|
||||||
|
<artifactId>jakarta.json-api</artifactId>
|
||||||
|
<version>2.1.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<testSourceDirectory>src/test/unit</testSourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>17</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.diffplug.spotless</groupId>
|
||||||
|
<artifactId>spotless-maven-plugin</artifactId>
|
||||||
|
<version>2.43.0</version>
|
||||||
|
<configuration>
|
||||||
|
<java>
|
||||||
|
<eclipse>
|
||||||
|
<version>4.21</version>
|
||||||
|
<file>${project.basedir}/../00_core_tools/eclipse/formatter.xml</file>
|
||||||
|
</eclipse>
|
||||||
|
<removeUnusedImports/>
|
||||||
|
<licenseHeader>
|
||||||
|
<content>// License: GPL. For details, see LICENSE file.</content>
|
||||||
|
</licenseHeader>
|
||||||
|
<includes>
|
||||||
|
<include>src/main/java/**/*.java</include>
|
||||||
|
<include>src/test/unit/**/*.java</include>
|
||||||
|
<include>src/test/integration/**/*.java</include>
|
||||||
|
</includes>
|
||||||
|
</java>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>enforce-maven</id>
|
||||||
|
<goals>
|
||||||
|
<goal>enforce</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<requireMavenVersion>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</requireMavenVersion>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<!-- Configure the test plugin, specifically enable autodetection of global extensions -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.2.5</version>
|
||||||
|
<configuration>
|
||||||
|
<skipAfterFailureCount>1</skipAfterFailureCount>
|
||||||
|
<argLine>-javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar</argLine>
|
||||||
|
<properties>
|
||||||
|
<configurationParameters>
|
||||||
|
file.encoding = UTF-8
|
||||||
|
java.locale.providers = SPI,CLDR
|
||||||
|
junit.jupiter.extensions.autodetection.enabled = true
|
||||||
|
junit.jupiter.execution.parallel.enabled = true
|
||||||
|
</configurationParameters>
|
||||||
|
</properties>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<josm.home>src/test/build/config/josm.home</josm.home>
|
||||||
|
<josm.test.data>src/test/resources</josm.test.data>
|
||||||
|
<java.awt.headless>true</java.awt.headless>
|
||||||
|
<glass.platform>Monocle</glass.platform>
|
||||||
|
<monocle.platform>Headless</monocle.platform>
|
||||||
|
<prism.order>sw</prism.order>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -359,8 +359,6 @@ public class MapWithAILayerInfo {
|
||||||
Logging.error(e);
|
Logging.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
esriInfo.add(layer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layers.addAll(esriInfo);
|
layers.addAll(esriInfo);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
resources
|
|
@ -7,7 +7,20 @@
|
||||||
},
|
},
|
||||||
"response" : {
|
"response" : {
|
||||||
"status" : 200,
|
"status" : 200,
|
||||||
"body" : "{\n \"Taylor's Address Conflation Server\" : {\n \"categories\" : [\n \"addresses\"\n ],\n \"description\" : \"Originally developed for use with local datasets, it now accepts external datasets for conflation purposes. In the event of a failure, the plugin will use the original dataset.\",\n \"license\" : \"AGPL\",\n \"source\" : \"https://gitlab.com/smocktaylor/serve_osm_files/\",\n \"url\" : \"https://importdata.riverviewtechnologies.com/conflate\"\n }\n}\n",
|
"jsonBody": {
|
||||||
|
"Taylor's Address Conflation Server": {
|
||||||
|
"categories": [
|
||||||
|
"addresses"
|
||||||
|
],
|
||||||
|
"description": "Originally developed for use with local datasets, it now accepts external datasets for conflation purposes. In the event of a failure, the plugin will use the original dataset.",
|
||||||
|
"license": "AGPL",
|
||||||
|
"source": "{{ request.baseUrl }}/smocktaylor/serve_osm_files/",
|
||||||
|
"url": "{{ request.baseUrl }}/conflate"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transformers": [
|
||||||
|
"response-template"
|
||||||
|
],
|
||||||
"headers" : {
|
"headers" : {
|
||||||
"Accept-Ranges" : "bytes",
|
"Accept-Ranges" : "bytes",
|
||||||
"Cache-Control" : "max-age=600",
|
"Cache-Control" : "max-age=600",
|
|
@ -0,0 +1,641 @@
|
||||||
|
{
|
||||||
|
"id" : "23497750-675c-440a-986a-34dd14b047f8",
|
||||||
|
"name" : "josm_mapwithai_json_sourcesjson",
|
||||||
|
"request" : {
|
||||||
|
"urlPattern" : "\/MapWithAI\/?json\/sources.json",
|
||||||
|
"method" : "GET"
|
||||||
|
},
|
||||||
|
"response" : {
|
||||||
|
"status" : 200,
|
||||||
|
"jsonBody": {
|
||||||
|
"Statewide Aggregate Addresses in Colorado 2019 (Public)": {
|
||||||
|
"countries": {
|
||||||
|
"US-CO": [
|
||||||
|
"addr:housenumber"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"license": "Public Domain",
|
||||||
|
"osm_compatible": "yes",
|
||||||
|
"parameters": [],
|
||||||
|
"permission_url": "{{ request.baseUrl }}/wiki/Import/Colorado_Addresses",
|
||||||
|
"url": "{{ request.baseUrl }}/coloradoAddresses/map?bbox={bbox}"
|
||||||
|
},
|
||||||
|
"MapWithAI": {
|
||||||
|
"countries": {
|
||||||
|
"AE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AF": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AI": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AL": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AO": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AT": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AU": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"AZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BB": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BD": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BF": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BI": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BJ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BL": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BO": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BS": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BT": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BW": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BY": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"BZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CA": [
|
||||||
|
"building",
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CD": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CF": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CH": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CI": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CL": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CO": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CU": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CY": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"CZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"DE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"DJ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"DK": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"DM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"DO": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"DZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"EC": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"EE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"EG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"EH": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ER": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ES": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ET": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"FK": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"FI": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"FJ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"FR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GB": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GD": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GF": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GH": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GP": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GQ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GT": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GW": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"GY": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"HN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"HR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"HT": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"HU": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ID": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"IE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"IL": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"IN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"IQ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"IS": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"IT": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"JM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"JO": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"JP": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"KE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"KG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"KH": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"KN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"KY": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"KR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"KW": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"KZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LB": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LC": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LK": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LS": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LT": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LU": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LV": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"LY": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MD": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ME": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MF": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MK": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ML": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MQ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MS": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MW": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MX": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MY": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"MZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NI": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NL": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NL-BQ2": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NL-BQ3": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NO": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NP": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"NZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"OM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PF": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PH": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PK": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PL": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PS": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PT": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"PY": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"QA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"RO": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"RS": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"RS-KM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"RU": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"RW": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SB": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SD": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SI": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SK": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SL": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SO": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SS": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ST": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SV": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SX": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"SZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TC": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TD": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TH": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TJ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TL": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TR": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TT": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TW": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"TZ": [
|
||||||
|
"building",
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"UA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"UG": [
|
||||||
|
"building",
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"US": [
|
||||||
|
"building",
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"US-AK": [
|
||||||
|
"building"
|
||||||
|
],
|
||||||
|
"US-HI": [
|
||||||
|
"building"
|
||||||
|
],
|
||||||
|
"UY": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"UZ": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"VC": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"VE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"VG": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"VN": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"VU": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"YE": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ZA": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ZM": [
|
||||||
|
"highway"
|
||||||
|
],
|
||||||
|
"ZW": [
|
||||||
|
"highway"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"default": true,
|
||||||
|
"license": "ODBL",
|
||||||
|
"osm_compatible": "yes",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "buildings",
|
||||||
|
"enabled": true,
|
||||||
|
"parameter": "result_type=road_building_vector_xml"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"permission_url": "{{ request.baseUrl }}/facebookmicrosites/Open-Mapping-At-Facebook/wiki/FAQ",
|
||||||
|
"terms_of_use_url": "{{ request.baseUrl }}/doc/license/MapWithAILicense.pdf",
|
||||||
|
"privacy_policy_url": "{{ request.baseUrl }}/doc/license/MapWithAIPrivacyPolicy.pdf#page=3",
|
||||||
|
"url": "{{ request.baseUrl }}/maps/ml_roads?conflate_with_osm=true&theme=ml_road_vector&collaborator=josm&token=ASb3N5o9HbX8QWn8G_NtHIRQaYv3nuG2r7_f3vnGld3KhZNCxg57IsaQyssIaEw5rfRNsPpMwg4TsnrSJtIJms5m&hash=ASawRla3rBcwEjY4HIY&bbox={bbox}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"transformers": [
|
||||||
|
"response-template"
|
||||||
|
],
|
||||||
|
"headers" : {
|
||||||
|
"Accept-Ranges" : "bytes",
|
||||||
|
"Cache-Control" : "max-age=600",
|
||||||
|
"Content-Type" : "application/json",
|
||||||
|
"Expires" : "Tue, 21 Apr 2020 19:51:40 UTC",
|
||||||
|
"Last-Modified" : "Tue, 21 Apr 2020 17:34:08 GMT",
|
||||||
|
"Vary" : "Origin",
|
||||||
|
"Date" : "Tue, 21 Apr 2020 19:41:40 GMT"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uuid" : "23497750-675c-440a-986a-34dd14b047f8",
|
||||||
|
"persistent" : true,
|
||||||
|
"insertionIndex" : 1
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
|
@ -24,6 +24,7 @@ import javax.imageio.ImageIO;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
@ -74,14 +75,11 @@ class AddMapWithAILayerActionTest {
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
static ThreadSyncMWAI threadSync = new ThreadSyncMWAI();
|
static ThreadSyncMWAI threadSync = new ThreadSyncMWAI();
|
||||||
|
|
||||||
@BasicWiremock
|
|
||||||
WireMockServer wireMockServer;
|
|
||||||
|
|
||||||
private static MapWithAIInfo info;
|
private static MapWithAIInfo info;
|
||||||
private static MapWithAIInfo backupInfo;
|
private static MapWithAIInfo backupInfo;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setup() {
|
void setup(WireMockRuntimeInfo wireMockRuntimeInfo) {
|
||||||
final Map<String, StringValuePattern> parameterMap = new HashMap<>();
|
final Map<String, StringValuePattern> parameterMap = new HashMap<>();
|
||||||
final AnythingPattern anythingPattern = new AnythingPattern();
|
final AnythingPattern anythingPattern = new AnythingPattern();
|
||||||
parameterMap.put("geometryType", anythingPattern);
|
parameterMap.put("geometryType", anythingPattern);
|
||||||
|
@ -91,7 +89,7 @@ class AddMapWithAILayerActionTest {
|
||||||
parameterMap.put("outfields", new EqualToPattern("*"));
|
parameterMap.put("outfields", new EqualToPattern("*"));
|
||||||
parameterMap.put("result_type", new EqualToPattern("road_building_vector_xml"));
|
parameterMap.put("result_type", new EqualToPattern("road_building_vector_xml"));
|
||||||
parameterMap.put("resultOffset", anythingPattern);
|
parameterMap.put("resultOffset", anythingPattern);
|
||||||
wireMockServer.stubFor(
|
wireMockRuntimeInfo.getWireMock().register(
|
||||||
WireMock.get(new UrlPathPattern(new EqualToPattern("/query"), false)).withQueryParams(parameterMap)
|
WireMock.get(new UrlPathPattern(new EqualToPattern("/query"), false)).withQueryParams(parameterMap)
|
||||||
.willReturn(WireMock.aResponse()
|
.willReturn(WireMock.aResponse()
|
||||||
.withBody(Json.createObjectBuilder().add("type", "FeatureCollection")
|
.withBody(Json.createObjectBuilder().add("type", "FeatureCollection")
|
||||||
|
@ -142,7 +140,7 @@ class AddMapWithAILayerActionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testRemoteIcon() throws IOException {
|
void testRemoteIcon(WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {
|
||||||
final ImageIcon blankImage = ImageProvider.createBlankIcon(ImageProvider.ImageSizes.LARGEICON);
|
final ImageIcon blankImage = ImageProvider.createBlankIcon(ImageProvider.ImageSizes.LARGEICON);
|
||||||
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
// BufferedImage is what the current implementation uses. Otherwise, we will
|
// BufferedImage is what the current implementation uses. Otherwise, we will
|
||||||
|
@ -150,10 +148,9 @@ class AddMapWithAILayerActionTest {
|
||||||
final BufferedImage bi = assertInstanceOf(BufferedImage.class, blankImage.getImage());
|
final BufferedImage bi = assertInstanceOf(BufferedImage.class, blankImage.getImage());
|
||||||
ImageIO.write(bi, "png", byteArrayOutputStream);
|
ImageIO.write(bi, "png", byteArrayOutputStream);
|
||||||
byte[] originalImage = byteArrayOutputStream.toByteArray();
|
byte[] originalImage = byteArrayOutputStream.toByteArray();
|
||||||
wireMockServer.addStubMapping(
|
wireMockRuntimeInfo.getWireMock().register(WireMock.get("/icon").willReturn(WireMock.aResponse().withBody(originalImage)));
|
||||||
wireMockServer.stubFor(WireMock.get("/icon").willReturn(WireMock.aResponse().withBody(originalImage))));
|
|
||||||
final MapWithAIInfo remoteInfo = new MapWithAIInfo(info);
|
final MapWithAIInfo remoteInfo = new MapWithAIInfo(info);
|
||||||
remoteInfo.setIcon(wireMockServer.baseUrl() + "/icon");
|
remoteInfo.setIcon(wireMockRuntimeInfo.getHttpBaseUrl() + "/icon");
|
||||||
final AddMapWithAILayerAction action = new AddMapWithAILayerAction(remoteInfo);
|
final AddMapWithAILayerAction action = new AddMapWithAILayerAction(remoteInfo);
|
||||||
threadSync.threadSync();
|
threadSync.threadSync();
|
||||||
final Object image = action.getValue(Action.LARGE_ICON_KEY);
|
final Object image = action.getValue(Action.LARGE_ICON_KEY);
|
||||||
|
@ -166,7 +163,7 @@ class AddMapWithAILayerActionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testNonRegression22683() {
|
void testNonRegression22683(WireMockRuntimeInfo wireMockRuntimeInfo) {
|
||||||
final OsmDataLayer layer = new OsmDataLayer(new DataSet(), "testNonRegression22683", null);
|
final OsmDataLayer layer = new OsmDataLayer(new DataSet(), "testNonRegression22683", null);
|
||||||
layer.getDataSet().addDataSource(new DataSource(new Bounds(0, 0, 0.001, 0.001), "Area 1"));
|
layer.getDataSet().addDataSource(new DataSource(new Bounds(0, 0, 0.001, 0.001), "Area 1"));
|
||||||
layer.getDataSet().addDataSource(new DataSource(new Bounds(-0.001, -0.001, 0, 0), "Area 2"));
|
layer.getDataSet().addDataSource(new DataSource(new Bounds(-0.001, -0.001, 0, 0), "Area 2"));
|
||||||
|
@ -190,7 +187,7 @@ class AddMapWithAILayerActionTest {
|
||||||
};
|
};
|
||||||
Logging.getLogger().addHandler(testHandler);
|
Logging.getLogger().addHandler(testHandler);
|
||||||
try {
|
try {
|
||||||
info.setUrl(wireMockServer.baseUrl());
|
info.setUrl(wireMockRuntimeInfo.getHttpBaseUrl());
|
||||||
info.setSourceType(MapWithAIType.ESRI_FEATURE_SERVER);
|
info.setSourceType(MapWithAIType.ESRI_FEATURE_SERVER);
|
||||||
final AddMapWithAILayerAction action = new AddMapWithAILayerAction(info);
|
final AddMapWithAILayerAction action = new AddMapWithAILayerAction(info);
|
||||||
Logging.clearLastErrorAndWarnings();
|
Logging.clearLastErrorAndWarnings();
|
||||||
|
|
|
@ -5,8 +5,11 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
|
||||||
|
import com.github.tomakehurst.wiremock.stubbing.ServeEvent;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.openstreetmap.josm.data.Bounds;
|
import org.openstreetmap.josm.data.Bounds;
|
||||||
import org.openstreetmap.josm.data.osm.DataSet;
|
import org.openstreetmap.josm.data.osm.DataSet;
|
||||||
|
@ -17,12 +20,9 @@ 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.MapWithAIConfig;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
|
import org.openstreetmap.josm.plugins.mapwithai.testutils.annotations.Wiremock;
|
||||||
import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
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.HTTP;
|
||||||
import org.openstreetmap.josm.testutils.annotations.OsmApi;
|
import org.openstreetmap.josm.testutils.annotations.OsmApi;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
import com.github.tomakehurst.wiremock.admin.model.GetServeEventsResult;
|
|
||||||
import com.github.tomakehurst.wiremock.admin.model.ServeEventQuery;
|
import com.github.tomakehurst.wiremock.admin.model.ServeEventQuery;
|
||||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||||
import com.github.tomakehurst.wiremock.http.Request;
|
import com.github.tomakehurst.wiremock.http.Request;
|
||||||
|
@ -46,35 +46,32 @@ import com.github.tomakehurst.wiremock.verification.LoggedRequest;
|
||||||
class BoundingBoxMapWithAIDownloaderTest {
|
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>";
|
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>";
|
||||||
|
|
||||||
@BasicWiremock
|
|
||||||
public WireMockServer wireMockServer;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testThirdPartyConflation() {
|
void testThirdPartyConflation(WireMockRuntimeInfo wireMockRuntimeInfo) {
|
||||||
MapWithAIInfo.THIRD_PARTY_CONFLATE.put(true);
|
MapWithAIInfo.THIRD_PARTY_CONFLATE.put(true);
|
||||||
final MapWithAIInfo info = new MapWithAIInfo("testThirdPartyConflation",
|
final MapWithAIInfo info = new MapWithAIInfo("testThirdPartyConflation",
|
||||||
this.wireMockServer.baseUrl() + "/testThirdPartyConflation");
|
wireMockRuntimeInfo.getHttpBaseUrl() + "/testThirdPartyConflation");
|
||||||
// ADDRESS has a default /conflate endpoint from a mocked copy of conflation
|
// ADDRESS has a default /conflate endpoint from a mocked copy of conflation
|
||||||
// servers.
|
// servers.
|
||||||
info.setCategory(MapWithAICategory.ADDRESS);
|
info.setCategory(MapWithAICategory.ADDRESS);
|
||||||
final Bounds downloadBounds = new Bounds(-10, -10, 10, 10);
|
final Bounds downloadBounds = new Bounds(-10, -10, 10, 10);
|
||||||
final BoundingBoxMapWithAIDownloader boundingBoxMapWithAIDownloader = new BoundingBoxMapWithAIDownloader(
|
final BoundingBoxMapWithAIDownloader boundingBoxMapWithAIDownloader = new BoundingBoxMapWithAIDownloader(
|
||||||
downloadBounds, info, false);
|
downloadBounds, info, false);
|
||||||
this.wireMockServer.stubFor(
|
wireMockRuntimeInfo.getWireMock().register(
|
||||||
WireMock.get("/testThirdPartyConflation").willReturn(WireMock.aResponse().withBody(TEST_DATA)));
|
WireMock.get("/testThirdPartyConflation").willReturn(WireMock.aResponse().withBody(TEST_DATA)));
|
||||||
|
|
||||||
final StubMapping conflationStub = this.wireMockServer
|
final StubMapping conflationStub = wireMockRuntimeInfo.getWireMock()
|
||||||
.stubFor(WireMock.post("/conflate").willReturn(WireMock.aResponse()
|
.register(WireMock.post("/conflate").willReturn(WireMock.aResponse()
|
||||||
.withBody("<osm version=\"0.6\"><node id=\"1\" lat=\"0\" lon=\"0\" version=\"1\"/></osm>")));
|
.withBody("<osm version=\"0.6\"><node id=\"1\" lat=\"0\" lon=\"0\" version=\"1\"/></osm>")));
|
||||||
final DataSet ds = assertDoesNotThrow(
|
final DataSet ds = assertDoesNotThrow(
|
||||||
() -> boundingBoxMapWithAIDownloader.parseOsm(NullProgressMonitor.INSTANCE));
|
() -> boundingBoxMapWithAIDownloader.parseOsm(NullProgressMonitor.INSTANCE));
|
||||||
assertEquals(1, ds.allPrimitives().size());
|
assertEquals(1, ds.allPrimitives().size());
|
||||||
assertEquals(1L, ds.allPrimitives().iterator().next().getPrimitiveId().getUniqueId());
|
assertEquals(1L, ds.allPrimitives().iterator().next().getPrimitiveId().getUniqueId());
|
||||||
|
|
||||||
final GetServeEventsResult serveEvents = this.wireMockServer
|
final List<ServeEvent> serveEvents = wireMockRuntimeInfo.getWireMock()
|
||||||
.getServeEvents(ServeEventQuery.forStubMapping(conflationStub));
|
.getServeEvents(ServeEventQuery.forStubMapping(conflationStub));
|
||||||
assertEquals(1, serveEvents.getRequests().size());
|
assertEquals(1, serveEvents.size());
|
||||||
final LoggedRequest request = serveEvents.getRequests().get(0).getRequest();
|
final LoggedRequest request = serveEvents.get(0).getRequest();
|
||||||
assertEquals(1, request.getParts().size(),
|
assertEquals(1, request.getParts().size(),
|
||||||
request.getParts().stream().map(Request.Part::getName).collect(Collectors.joining(",")));
|
request.getParts().stream().map(Request.Part::getName).collect(Collectors.joining(",")));
|
||||||
assertNotNull(request.getPart("external"));
|
assertNotNull(request.getPart("external"));
|
||||||
|
@ -85,29 +82,29 @@ class BoundingBoxMapWithAIDownloaderTest {
|
||||||
* MapWithAI servers
|
* MapWithAI servers
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void testNonRegression22624() {
|
void testNonRegression22624(WireMockRuntimeInfo wireMockRuntimeInfo) {
|
||||||
MapWithAIInfo.THIRD_PARTY_CONFLATE.put(true);
|
MapWithAIInfo.THIRD_PARTY_CONFLATE.put(true);
|
||||||
MapWithAIInfo info = new MapWithAIInfo("testNonRegression22624",
|
MapWithAIInfo info = new MapWithAIInfo("testNonRegression22624",
|
||||||
this.wireMockServer.baseUrl() + "/no-conflation?bbox={bbox}",
|
wireMockRuntimeInfo.getHttpBaseUrl() + "/no-conflation?bbox={bbox}",
|
||||||
MapWithAIType.ESRI_FEATURE_SERVER.getTypeString(), null, "testNonRegression22624");
|
MapWithAIType.ESRI_FEATURE_SERVER.getTypeString(), null, "testNonRegression22624");
|
||||||
info.setConflationUrl(this.wireMockServer.baseUrl() + "/conflation?bbox={bbox}");
|
info.setConflationUrl(wireMockRuntimeInfo.getHttpBaseUrl() + "/conflation?bbox={bbox}");
|
||||||
info.setConflation(true);
|
info.setConflation(true);
|
||||||
final Bounds downloadBounds = new Bounds(-10, -10, 10, 10);
|
final Bounds downloadBounds = new Bounds(-10, -10, 10, 10);
|
||||||
final BoundingBoxMapWithAIDownloader boundingBoxMapWithAIDownloader = new BoundingBoxMapWithAIDownloader(
|
final BoundingBoxMapWithAIDownloader boundingBoxMapWithAIDownloader = new BoundingBoxMapWithAIDownloader(
|
||||||
downloadBounds, info, false);
|
downloadBounds, info, false);
|
||||||
|
|
||||||
StubMapping noConflation = this.wireMockServer
|
StubMapping noConflation = wireMockRuntimeInfo.getWireMock()
|
||||||
.stubFor(WireMock.get("/no-conflation").willReturn(WireMock.badRequest()));
|
.register(WireMock.get("/no-conflation").willReturn(WireMock.badRequest()));
|
||||||
StubMapping resultOffset = this.wireMockServer.stubFor(
|
StubMapping resultOffset = wireMockRuntimeInfo.getWireMock().register(
|
||||||
WireMock.get(WireMock.urlPathEqualTo("/conflation")).withQueryParam("bbox", new AnythingPattern())
|
WireMock.get(WireMock.urlPathEqualTo("/conflation")).withQueryParam("bbox", new AnythingPattern())
|
||||||
.withQueryParam("resultOffset", new EqualToPattern("0")).willReturn(WireMock.badRequest()));
|
.withQueryParam("resultOffset", new EqualToPattern("0")).willReturn(WireMock.badRequest()));
|
||||||
StubMapping noResultOffset = this.wireMockServer.stubFor(WireMock.get(WireMock.urlPathEqualTo("/conflation"))
|
StubMapping noResultOffset = wireMockRuntimeInfo.getWireMock().register(WireMock.get(WireMock.urlPathEqualTo("/conflation"))
|
||||||
.withQueryParam("bbox", new AnythingPattern()).withQueryParam("resultOffset", AbsentPattern.ABSENT)
|
.withQueryParam("bbox", new AnythingPattern()).withQueryParam("resultOffset", AbsentPattern.ABSENT)
|
||||||
.willReturn(WireMock.aResponse().withBody(TEST_DATA)));
|
.willReturn(WireMock.aResponse().withBody(TEST_DATA)));
|
||||||
|
|
||||||
assertDoesNotThrow(() -> boundingBoxMapWithAIDownloader.parseOsm(NullProgressMonitor.INSTANCE));
|
assertDoesNotThrow(() -> boundingBoxMapWithAIDownloader.parseOsm(NullProgressMonitor.INSTANCE));
|
||||||
this.wireMockServer.verify(0, RequestPatternBuilder.forCustomMatcher(noConflation.getRequest()));
|
wireMockRuntimeInfo.getWireMock().verifyThat(0, RequestPatternBuilder.forCustomMatcher(noConflation.getRequest()));
|
||||||
this.wireMockServer.verify(0, RequestPatternBuilder.forCustomMatcher(resultOffset.getRequest()));
|
wireMockRuntimeInfo.getWireMock().verifyThat(0, RequestPatternBuilder.forCustomMatcher(resultOffset.getRequest()));
|
||||||
this.wireMockServer.verify(1, RequestPatternBuilder.forCustomMatcher(noResultOffset.getRequest()));
|
wireMockRuntimeInfo.getWireMock().verifyThat(1, RequestPatternBuilder.forCustomMatcher(noResultOffset.getRequest()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
|
||||||
|
import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.function.ThrowingSupplier;
|
import org.junit.jupiter.api.function.ThrowingSupplier;
|
||||||
|
@ -46,9 +48,6 @@ import mockit.MockUp;
|
||||||
@Wiremock
|
@Wiremock
|
||||||
@MapWithAISources
|
@MapWithAISources
|
||||||
class DataConflationSenderTest {
|
class DataConflationSenderTest {
|
||||||
@BasicWiremock
|
|
||||||
WireMockServer wireMockServer;
|
|
||||||
|
|
||||||
static class MapWithAIConflationCategoryMock extends MockUp<MapWithAIConflationCategory> {
|
static class MapWithAIConflationCategoryMock extends MockUp<MapWithAIConflationCategory> {
|
||||||
static String url;
|
static String url;
|
||||||
|
|
||||||
|
@ -81,10 +80,10 @@ class DataConflationSenderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testWorkingUrl() {
|
void testWorkingUrl(WireMockRuntimeInfo wireMockRuntimeInfo) {
|
||||||
MapWithAIConflationCategoryMock.url = wireMockServer.baseUrl() + "/conflate";
|
MapWithAIConflationCategoryMock.url = wireMockRuntimeInfo.getHttpBaseUrl() + "/conflate";
|
||||||
final StubMapping stubMapping = wireMockServer
|
final StubMapping stubMapping = wireMockRuntimeInfo.getWireMock()
|
||||||
.stubFor(WireMock.post("/conflate").willReturn(WireMock.aResponse().withBody(
|
.register(WireMock.post("/conflate").willReturn(WireMock.aResponse().withBody(
|
||||||
"<?xml version='1.0' encoding='UTF-8'?><osm version='0.6' generator='DataConflationSenderTest#testWorkingUrl'><node id='1' version='1' visible='true' lat='89.0' lon='0.1' /></osm>")));
|
"<?xml version='1.0' encoding='UTF-8'?><osm version='0.6' generator='DataConflationSenderTest#testWorkingUrl'><node id='1' version='1' visible='true' lat='89.0' lon='0.1' /></osm>")));
|
||||||
new MapWithAIConflationCategoryMock();
|
new MapWithAIConflationCategoryMock();
|
||||||
|
|
||||||
|
@ -99,14 +98,13 @@ class DataConflationSenderTest {
|
||||||
assertEquals(1, conflated.getNodes().size());
|
assertEquals(1, conflated.getNodes().size());
|
||||||
final Node conflatedNode = conflated.getNodes().iterator().next();
|
final Node conflatedNode = conflated.getNodes().iterator().next();
|
||||||
assertEquals(new LatLon(89, 0.1), conflatedNode.getCoor());
|
assertEquals(new LatLon(89, 0.1), conflatedNode.getCoor());
|
||||||
assertEquals(1, wireMockServer.getAllServeEvents().stream()
|
wireMockRuntimeInfo.getWireMock().verifyThat(1, RequestPatternBuilder.like(stubMapping.getRequest()));
|
||||||
.filter(serveEvent -> stubMapping.equals(serveEvent.getStubMapping())).count());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testWorkingUrlTimeout() {
|
void testWorkingUrlTimeout(WireMockRuntimeInfo wireMockRuntimeInfo) {
|
||||||
MapWithAIConflationCategoryMock.url = wireMockServer.baseUrl() + "/conflate";
|
MapWithAIConflationCategoryMock.url = wireMockRuntimeInfo.getHttpBaseUrl() + "/conflate";
|
||||||
final StubMapping stubMapping = wireMockServer.stubFor(WireMock.post("/conflate")
|
final StubMapping stubMapping = wireMockRuntimeInfo.getWireMock().register(WireMock.post("/conflate")
|
||||||
.willReturn(WireMock.aResponse().withBody(
|
.willReturn(WireMock.aResponse().withBody(
|
||||||
"<?xml version='1.0' encoding='UTF-8'?><osm version='0.6' generator='DataConflationSenderTest#testWorkingUrl'><node id='1' version='1' visible='true' lat='89.0' lon='0.1' /></osm>")
|
"<?xml version='1.0' encoding='UTF-8'?><osm version='0.6' generator='DataConflationSenderTest#testWorkingUrl'><node id='1' version='1' visible='true' lat='89.0' lon='0.1' /></osm>")
|
||||||
.withFixedDelay(500)));
|
.withFixedDelay(500)));
|
||||||
|
@ -123,8 +121,7 @@ class DataConflationSenderTest {
|
||||||
assertEquals(1, conflated.getNodes().size());
|
assertEquals(1, conflated.getNodes().size());
|
||||||
final Node conflatedNode = conflated.getNodes().iterator().next();
|
final Node conflatedNode = conflated.getNodes().iterator().next();
|
||||||
assertEquals(new LatLon(89, 0.1), conflatedNode.getCoor());
|
assertEquals(new LatLon(89, 0.1), conflatedNode.getCoor());
|
||||||
assertEquals(1, wireMockServer.getAllServeEvents().stream()
|
wireMockRuntimeInfo.getWireMock().verifyThat(1, RequestPatternBuilder.like(stubMapping.getRequest()));
|
||||||
.filter(serveEvent -> stubMapping.equals(serveEvent.getStubMapping())).count());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Stream<Arguments> testNonWorkingUrl() {
|
static Stream<Arguments> testNonWorkingUrl() {
|
||||||
|
@ -135,9 +132,9 @@ class DataConflationSenderTest {
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource
|
@MethodSource
|
||||||
void testNonWorkingUrl(final ResponseDefinitionBuilder response) {
|
void testNonWorkingUrl(final ResponseDefinitionBuilder response, final WireMockRuntimeInfo wireMockRuntimeInfo) {
|
||||||
MapWithAIConflationCategoryMock.url = wireMockServer.baseUrl() + "/conflate";
|
MapWithAIConflationCategoryMock.url = wireMockRuntimeInfo.getHttpBaseUrl() + "/conflate";
|
||||||
final StubMapping stubMapping = wireMockServer.stubFor(WireMock.post("/conflate").willReturn(response));
|
final StubMapping stubMapping = wireMockRuntimeInfo.getWireMock().register(WireMock.post("/conflate").willReturn(response));
|
||||||
new MapWithAIConflationCategoryMock();
|
new MapWithAIConflationCategoryMock();
|
||||||
|
|
||||||
final DataSet external = new DataSet(new Node(LatLon.NORTH_POLE));
|
final DataSet external = new DataSet(new Node(LatLon.NORTH_POLE));
|
||||||
|
@ -147,7 +144,6 @@ class DataConflationSenderTest {
|
||||||
dataConflationSender.run();
|
dataConflationSender.run();
|
||||||
final DataSet conflated = assertDoesNotThrow((ThrowingSupplier<DataSet>) dataConflationSender::get);
|
final DataSet conflated = assertDoesNotThrow((ThrowingSupplier<DataSet>) dataConflationSender::get);
|
||||||
assertNull(conflated);
|
assertNull(conflated);
|
||||||
assertEquals(1, wireMockServer.getAllServeEvents().stream()
|
wireMockRuntimeInfo.getWireMock().verifyThat(1, RequestPatternBuilder.like(stubMapping.getRequest()));
|
||||||
.filter(serveEvent -> stubMapping.equals(serveEvent.getStubMapping())).count());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
@ -31,9 +32,6 @@ import com.github.tomakehurst.wiremock.WireMockServer;
|
||||||
@Wiremock
|
@Wiremock
|
||||||
class ESRISourceReaderTest {
|
class ESRISourceReaderTest {
|
||||||
|
|
||||||
@BasicWiremock
|
|
||||||
public WireMockServer wireMockServer;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
ESRISourceReader.SOURCE_CACHE.clear();
|
ESRISourceReader.SOURCE_CACHE.clear();
|
||||||
|
@ -51,11 +49,11 @@ class ESRISourceReaderTest {
|
||||||
* file/wiremocked file
|
* file/wiremocked file
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void testAddEsriLayer() throws IOException {
|
void testAddEsriLayer(WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {
|
||||||
// TODO wiremock
|
// TODO wiremock
|
||||||
MapWithAIInfo info = new MapWithAIInfo("TEST", "test_url", "bdf6c800b3ae453b9db239e03d7c1727");
|
MapWithAIInfo info = new MapWithAIInfo("TEST", "test_url", "bdf6c800b3ae453b9db239e03d7c1727");
|
||||||
info.setSourceType(MapWithAIType.ESRI);
|
info.setSourceType(MapWithAIType.ESRI);
|
||||||
String tUrl = wireMockServer.url("/sharing/rest");
|
String tUrl = wireMockRuntimeInfo.getHttpBaseUrl() + "/sharing/rest";
|
||||||
for (String url : Arrays.asList(tUrl, tUrl + "/")) {
|
for (String url : Arrays.asList(tUrl, tUrl + "/")) {
|
||||||
info.setUrl(url);
|
info.setUrl(url);
|
||||||
final ESRISourceReader reader = new ESRISourceReader(info);
|
final ESRISourceReader reader = new ESRISourceReader(info);
|
||||||
|
@ -65,7 +63,7 @@ class ESRISourceReaderTest {
|
||||||
} catch (ExecutionException | InterruptedException e) {
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
throw new JosmRuntimeException(e);
|
throw new JosmRuntimeException(e);
|
||||||
}
|
}
|
||||||
}).collect(Collectors.toList());
|
}).toList();
|
||||||
Future<?> workerQueue = MainApplication.worker.submit(() -> {
|
Future<?> workerQueue = MainApplication.worker.submit(() -> {
|
||||||
/* Sync threads */});
|
/* Sync threads */});
|
||||||
Awaitility.await().atMost(Durations.FIVE_SECONDS).until(workerQueue::isDone);
|
Awaitility.await().atMost(Durations.FIVE_SECONDS).until(workerQueue::isDone);
|
||||||
|
|
|
@ -8,14 +8,13 @@ import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
|
||||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.IMapWithAIUrls;
|
import org.openstreetmap.josm.plugins.mapwithai.spi.preferences.IMapWithAIUrls;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the MapWithAI config for the test
|
* Set the MapWithAI config for the test
|
||||||
*
|
*
|
||||||
|
@ -29,7 +28,7 @@ import com.github.tomakehurst.wiremock.WireMockServer;
|
||||||
public @interface MapWithAIConfig {
|
public @interface MapWithAIConfig {
|
||||||
class MapWithAIConfigExtension extends Wiremock.WiremockExtension implements BeforeEachCallback, AfterEachCallback {
|
class MapWithAIConfigExtension extends Wiremock.WiremockExtension implements BeforeEachCallback, AfterEachCallback {
|
||||||
@Override
|
@Override
|
||||||
public void beforeEach(ExtensionContext context) throws Exception {
|
public void beforeEach(ExtensionContext context) {
|
||||||
org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig
|
org.openstreetmap.josm.plugins.mapwithai.spi.preferences.MapWithAIConfig
|
||||||
.setUrlsProvider(new WireMockMapWithAIUrls(getWiremock(context)));
|
.setUrlsProvider(new WireMockMapWithAIUrls(getWiremock(context)));
|
||||||
}
|
}
|
||||||
|
@ -42,25 +41,25 @@ public @interface MapWithAIConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class WireMockMapWithAIUrls implements IMapWithAIUrls {
|
private static final class WireMockMapWithAIUrls implements IMapWithAIUrls {
|
||||||
private final WireMockServer wireMockServer;
|
private final WireMockRuntimeInfo wireMockServer;
|
||||||
|
|
||||||
public WireMockMapWithAIUrls(final WireMockServer wireMockServer) {
|
public WireMockMapWithAIUrls(final WireMockRuntimeInfo wireMockServer) {
|
||||||
this.wireMockServer = wireMockServer;
|
this.wireMockServer = wireMockServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getConflationServerJson() {
|
public String getConflationServerJson() {
|
||||||
return this.wireMockServer.baseUrl() + "/MapWithAI/json/conflation_servers.json";
|
return this.wireMockServer.getHttpBaseUrl() + "/MapWithAI/json/conflation_servers.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMapWithAISourcesJson() {
|
public String getMapWithAISourcesJson() {
|
||||||
return this.wireMockServer.baseUrl() + "/MapWithAI/json/sources.json";
|
return this.wireMockServer.getHttpBaseUrl() + "/MapWithAI/json/sources.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMapWithAIPaintStyle() {
|
public String getMapWithAIPaintStyle() {
|
||||||
return this.wireMockServer.baseUrl() + "/josmfile?page=Styles/MapWithAI&zip=1";
|
return this.wireMockServer.getHttpBaseUrl() + "/josmfile?page=Styles/MapWithAI&zip=1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,29 @@
|
||||||
// License: GPL. For details, see LICENSE file.
|
// License: GPL. For details, see LICENSE file.
|
||||||
package org.openstreetmap.josm.plugins.mapwithai.testutils.annotations;
|
package org.openstreetmap.josm.plugins.mapwithai.testutils.annotations;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
|
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||||
|
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||||
|
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||||
|
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
|
import org.junit.jupiter.api.extension.ParameterContext;
|
||||||
|
import org.junit.jupiter.api.extension.ParameterResolutionException;
|
||||||
import org.junit.platform.commons.support.AnnotationSupport;
|
import org.junit.platform.commons.support.AnnotationSupport;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.backend.DataAvailability;
|
import org.openstreetmap.josm.plugins.mapwithai.backend.DataAvailability;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIConflationCategory;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIConflationCategory;
|
||||||
|
@ -29,11 +41,8 @@ import org.openstreetmap.josm.testutils.annotations.Territories;
|
||||||
|
|
||||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||||
import com.github.tomakehurst.wiremock.common.FileSource;
|
import org.openstreetmap.josm.tools.Logging;
|
||||||
import com.github.tomakehurst.wiremock.extension.Parameters;
|
import org.openstreetmap.josm.tools.ReflectionUtils;
|
||||||
import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
|
|
||||||
import com.github.tomakehurst.wiremock.http.Request;
|
|
||||||
import com.github.tomakehurst.wiremock.http.Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test annotation to ensure that wiremock is used
|
* Test annotation to ensure that wiremock is used
|
||||||
|
@ -44,8 +53,8 @@ import com.github.tomakehurst.wiremock.http.Response;
|
||||||
@Target({ ElementType.PARAMETER, ElementType.TYPE, ElementType.METHOD })
|
@Target({ ElementType.PARAMETER, ElementType.TYPE, ElementType.METHOD })
|
||||||
@BasicPreferences
|
@BasicPreferences
|
||||||
@HTTP
|
@HTTP
|
||||||
|
@BasicWiremock(value = "src/test/resources/wiremock")
|
||||||
@ExtendWith(Wiremock.TestMapWithAIUrls.class)
|
@ExtendWith(Wiremock.TestMapWithAIUrls.class)
|
||||||
@BasicWiremock(value = "src/test/resources/wiremock", responseTransformers = Wiremock.WireMockUrlTransformer.class)
|
|
||||||
public @interface Wiremock {
|
public @interface Wiremock {
|
||||||
/**
|
/**
|
||||||
* Set to {@code false} to turn off wiremock (use only in integration tests)
|
* Set to {@code false} to turn off wiremock (use only in integration tests)
|
||||||
|
@ -54,72 +63,35 @@ public @interface Wiremock {
|
||||||
*/
|
*/
|
||||||
boolean value() default true;
|
boolean value() default true;
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace URL's with the wiremock URL
|
|
||||||
*
|
|
||||||
* @author Taylor Smock
|
|
||||||
*/
|
|
||||||
class WireMockUrlTransformer extends ResponseTransformer {
|
|
||||||
private final ExtensionContext context;
|
|
||||||
|
|
||||||
public WireMockUrlTransformer(ExtensionContext context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Convert urls in responses to wiremock url";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Response transform(Request request, Response response, FileSource files, Parameters parameters) {
|
|
||||||
if (!request.getUrl().endsWith("/capabilities")
|
|
||||||
&& response.getHeaders().getContentTypeHeader().mimeTypePart() != null
|
|
||||||
&& !response.getHeaders().getContentTypeHeader().mimeTypePart().contains("application/zip")) {
|
|
||||||
String origBody = response.getBodyAsString();
|
|
||||||
String newBody = origBody.replaceAll("https?://.*?/",
|
|
||||||
WiremockExtension.getWiremock(context).baseUrl() + "/");
|
|
||||||
return Response.Builder.like(response).but().body(newBody).build();
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the base wiremock extension class
|
* This is the base wiremock extension class
|
||||||
*/
|
*/
|
||||||
class WiremockExtension extends BasicWiremock.WireMockExtension {
|
class WiremockExtension {
|
||||||
/**
|
/**
|
||||||
* Get the default wiremock server
|
* Get the default wiremock server
|
||||||
*
|
*
|
||||||
* @param context The context to search
|
* @param context The context to search
|
||||||
* @return The wiremock server
|
* @return The wiremock server
|
||||||
*/
|
*/
|
||||||
public static WireMockServer getWiremock(ExtensionContext context) {
|
public static WireMockRuntimeInfo getWiremock(ExtensionContext context) {
|
||||||
ExtensionContext.Namespace namespace = ExtensionContext.Namespace.create(BasicWiremock.class);
|
return context.getStore(ExtensionContext.Namespace.create(BasicWiremock.WireMockExtension.class))
|
||||||
return context.getStore(namespace).get(WireMockServer.class, WireMockServer.class);
|
.get(BasicWiremock.WireMockExtension.class, BasicWiremock.WireMockExtension.class)
|
||||||
|
.getRuntimeInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension for {@link MapWithAILayerInfo}
|
* Extension for {@link MapWithAILayerInfo}
|
||||||
*/
|
*/
|
||||||
class MapWithAILayerInfoExtension extends WiremockExtension {
|
class MapWithAILayerInfoExtension extends WiremockExtension implements BeforeAllCallback, AfterAllCallback {
|
||||||
private static int hashCode;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterAll(ExtensionContext context) throws Exception {
|
public void afterAll(ExtensionContext context) {
|
||||||
try {
|
resetMapWithAILayerInfo(context);
|
||||||
super.afterAll(context);
|
|
||||||
} finally {
|
|
||||||
resetMapWithAILayerInfo(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeAll(ExtensionContext context) throws Exception {
|
public void beforeAll(ExtensionContext context) {
|
||||||
super.beforeAll(context);
|
|
||||||
|
|
||||||
MapWithAILayerInfo.setImageryLayersSites(null);
|
MapWithAILayerInfo.setImageryLayersSites(null);
|
||||||
AtomicBoolean finished = new AtomicBoolean();
|
AtomicBoolean finished = new AtomicBoolean();
|
||||||
MapWithAILayerInfo.getInstance().clear();
|
MapWithAILayerInfo.getInstance().clear();
|
||||||
|
@ -141,29 +113,45 @@ public @interface Wiremock {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestMapWithAIUrls extends WiremockExtension implements IMapWithAIUrls {
|
class TestMapWithAIUrls extends WiremockExtension implements IMapWithAIUrls, BeforeAllCallback, BeforeEachCallback, AfterAllCallback, AfterEachCallback {
|
||||||
ExtensionContext context;
|
ExtensionContext context;
|
||||||
private static boolean conflationServerInitialized;
|
private static boolean conflationServerInitialized;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace URL servers with wiremock
|
||||||
|
*
|
||||||
|
* @param baseUrl The wiremock to point to
|
||||||
|
* @param url The URL to fix
|
||||||
|
* @return A url that points at the wiremock server
|
||||||
|
*/
|
||||||
|
public static String replaceUrl(String baseUrl, String url) {
|
||||||
|
try {
|
||||||
|
URL temp = new URL(url);
|
||||||
|
return baseUrl + temp.getFile();
|
||||||
|
} catch (MalformedURLException error) {
|
||||||
|
Logging.error(error);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getConflationServerJson() {
|
public String getConflationServerJson() {
|
||||||
conflationServerInitialized = true;
|
conflationServerInitialized = true;
|
||||||
return replaceUrl(getWiremock(this.context), MapWithAIUrls.getInstance().getConflationServerJson());
|
return replaceUrl(getWiremock(this.context).getHttpBaseUrl(), MapWithAIUrls.getInstance().getConflationServerJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMapWithAISourcesJson() {
|
public String getMapWithAISourcesJson() {
|
||||||
return replaceUrl(getWiremock(this.context), MapWithAIUrls.getInstance().getMapWithAISourcesJson());
|
return replaceUrl(getWiremock(this.context).getHttpBaseUrl(), MapWithAIUrls.getInstance().getMapWithAISourcesJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMapWithAIPaintStyle() {
|
public String getMapWithAIPaintStyle() {
|
||||||
return replaceUrl(getWiremock(this.context), MapWithAIUrls.getInstance().getMapWithAIPaintStyle());
|
return replaceUrl(getWiremock(this.context).getHttpBaseUrl(), MapWithAIUrls.getInstance().getMapWithAIPaintStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeAll(ExtensionContext context) throws Exception {
|
public void beforeAll(ExtensionContext context) {
|
||||||
super.beforeAll(context);
|
|
||||||
final Optional<Wiremock> annotation = AnnotationUtils.findFirstParentAnnotation(context, Wiremock.class);
|
final Optional<Wiremock> annotation = AnnotationUtils.findFirstParentAnnotation(context, Wiremock.class);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
if (Boolean.FALSE.equals(annotation.map(Wiremock::value).orElse(Boolean.TRUE))) {
|
if (Boolean.FALSE.equals(annotation.map(Wiremock::value).orElse(Boolean.TRUE))) {
|
||||||
|
@ -174,44 +162,48 @@ public @interface Wiremock {
|
||||||
if (conflationServerInitialized) {
|
if (conflationServerInitialized) {
|
||||||
MapWithAIConflationCategory.initialize();
|
MapWithAIConflationCategory.initialize();
|
||||||
}
|
}
|
||||||
AnnotationUtils.resetStaticClass(DataAvailability.class);
|
assertDoesNotThrow(() -> AnnotationUtils.resetStaticClass(DataAvailability.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeEach(ExtensionContext context) throws Exception {
|
public void beforeEach(ExtensionContext context) {
|
||||||
final Optional<Wiremock> annotation = AnnotationUtils.findFirstParentAnnotation(context, Wiremock.class);
|
final Optional<Wiremock> annotation = AnnotationUtils.findFirstParentAnnotation(context, Wiremock.class);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
if (annotation.isPresent()) {
|
if (annotation.isPresent()) {
|
||||||
this.beforeAll(context);
|
this.beforeAll(context);
|
||||||
}
|
}
|
||||||
final WireMockServer wireMockServer = getWiremock(context);
|
final WireMock wireMockServer = getWiremock(context).getWireMock();
|
||||||
|
|
||||||
super.beforeEach(context);
|
if (wireMockServer.allStubMappings().getMappings().stream().filter(mapping -> mapping.getRequest().getUrl() != null)
|
||||||
|
|
||||||
if (wireMockServer.getStubMappings().stream().filter(mapping -> mapping.getRequest().getUrl() != null)
|
|
||||||
.noneMatch(mapping -> mapping.getRequest().getUrl()
|
.noneMatch(mapping -> mapping.getRequest().getUrl()
|
||||||
.equals("/MapWithAI/json/conflation_servers.json"))) {
|
.equals("/MapWithAI/json/conflation_servers.json"))) {
|
||||||
wireMockServer.stubFor(WireMock.get("/MapWithAI/json/conflation_servers.json")
|
wireMockServer.register(WireMock.get("/MapWithAI/json/conflation_servers.json")
|
||||||
.willReturn(WireMock.aResponse().withBody("{}")).atPriority(-5));
|
.willReturn(WireMock.aResponse().withBody("{}")).atPriority(-5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterAll(ExtensionContext context) throws Exception {
|
public void afterEach(ExtensionContext extensionContext) {
|
||||||
|
this.context = extensionContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterAll(ExtensionContext context) {
|
||||||
|
this.context = context;
|
||||||
// @Wiremock stops the WireMockServer prior to this method being called
|
// @Wiremock stops the WireMockServer prior to this method being called
|
||||||
getWiremock(context).start();
|
final WireMockServer wireMockServer = assertDoesNotThrow(() -> {
|
||||||
MapPaintUtils.removeMapWithAIPaintStyles();
|
final Field serverField = WireMockRuntimeInfo.class.getDeclaredField("wireMockServer");
|
||||||
|
ReflectionUtils.setObjectsAccessible(serverField);
|
||||||
|
return (WireMockServer) serverField.get(getWiremock(context));
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
// This stops the WireMockServer again.
|
wireMockServer.start();
|
||||||
super.afterAll(context);
|
MapPaintUtils.removeMapWithAIPaintStyles();
|
||||||
|
wireMockServer.stop();
|
||||||
} finally {
|
} finally {
|
||||||
MapWithAIConfig.setUrlsProvider(new InvalidMapWithAIUrls());
|
MapWithAIConfig.setUrlsProvider(new InvalidMapWithAIUrls());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WireMockServer getWireMockServer() {
|
|
||||||
return getWiremock(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class InvalidMapWithAIUrls implements IMapWithAIUrls {
|
class InvalidMapWithAIUrls implements IMapWithAIUrls {
|
||||||
|
|
Ładowanie…
Reference in New Issue