Add MapPaintUtilsTest

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2020-08-05 07:20:50 -06:00
rodzic 51aa40925d
commit 886f32153b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
3 zmienionych plików z 63 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,15 @@
{
"request": {
"method": "GET",
"url": "/josmfile?page=Styles/MapWithAI&zip=1"
},
"response": {
"status": 200,
"bodyFileName": "josmfile?page=Styles/MapWithAI&zip=1",
"headers": {
"Content-Type": "application/zip",
"Content-Disposition": "attachment; filename=Styles_MapWithAI.zip",
"Content-Length": "8103"
}
}
}

Wyświetl plik

@ -0,0 +1,48 @@
// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.plugins.mapwithai.tools;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.List;
import org.awaitility.Awaitility;
import org.awaitility.Durations;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
import org.openstreetmap.josm.gui.mappaint.StyleSource;
import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
import org.openstreetmap.josm.io.CachedFile;
import org.openstreetmap.josm.plugins.mapwithai.testutils.MapWithAITestRules;
import org.openstreetmap.josm.testutils.JOSMTestRules;
public class MapPaintUtilsTest {
@RegisterExtension
JOSMTestRules rule = new MapWithAITestRules().wiremock();
@Test
public void testAddPaintStyle() {
MapPaintUtils.removeMapWithAIPaintStyles();
Awaitility.await().atMost(Durations.TEN_SECONDS).until(() -> !MapPaintUtils.checkIfMapWithAIPaintStyleExists());
List<StyleSource> paintStyles = MapPaintStyles.getStyles().getStyleSources();
for (int i = 0; i < 10; i++) {
MapPaintUtils.addMapWithAIPaintStyles();
paintStyles = MapPaintStyles.getStyles().getStyleSources();
assertEquals(1, paintStyles.stream().filter(s -> s.title.contains("MapWithAI")).count(),
"The paintstyle should have been added, but only one of it");
}
}
@Test
public void testStableSource() throws IOException {
MapCSSStyleSource mapcssSource = new MapCSSStyleSource(MapPaintUtils.getMapWithAIPaintStyle());
mapcssSource.loadStyleSource();
try (CachedFile file = new CachedFile(mapcssSource.url)) {
file.clear();
MapPaintUtils.addSourcesToPaintStyle(new DataSet());
}
}
}