kopia lustrzana https://github.com/JOSM/MapWithAI
Only reset MapWithAILayerInfo if the @Territories annotation is ued
Signed-off-by: Taylor Smock <tsmock@meta.com>pull/30/head v803
rodzic
35bad2f762
commit
3fdb8b0560
|
@ -12,6 +12,7 @@ import org.awaitility.Awaitility;
|
||||||
import org.awaitility.Durations;
|
import org.awaitility.Durations;
|
||||||
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.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;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo;
|
||||||
|
@ -108,13 +109,14 @@ public @interface Wiremock {
|
||||||
try {
|
try {
|
||||||
super.afterAll(context);
|
super.afterAll(context);
|
||||||
} finally {
|
} finally {
|
||||||
resetMapWithAILayerInfo();
|
resetMapWithAILayerInfo(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeAll(ExtensionContext context) throws Exception {
|
public void beforeAll(ExtensionContext context) throws Exception {
|
||||||
super.beforeAll(context);
|
super.beforeAll(context);
|
||||||
|
|
||||||
MapWithAILayerInfo.setImageryLayersSites(null);
|
MapWithAILayerInfo.setImageryLayersSites(null);
|
||||||
AtomicBoolean finished = new AtomicBoolean();
|
AtomicBoolean finished = new AtomicBoolean();
|
||||||
MapWithAILayerInfo.getInstance().clear();
|
MapWithAILayerInfo.getInstance().clear();
|
||||||
|
@ -122,14 +124,15 @@ public @interface Wiremock {
|
||||||
Awaitility.await().atMost(Durations.TEN_SECONDS).until(finished::get);
|
Awaitility.await().atMost(Durations.TEN_SECONDS).until(finished::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void resetMapWithAILayerInfo() {
|
private static void resetMapWithAILayerInfo(ExtensionContext context) {
|
||||||
// This should probably only be run if territories is initialized
|
|
||||||
// TODO update if @Territories becomes an annotation
|
|
||||||
synchronized (MapWithAILayerInfo.class) {
|
synchronized (MapWithAILayerInfo.class) {
|
||||||
MapWithAILayerInfo.getInstance().clear();
|
final var info = MapWithAILayerInfo.getInstance();
|
||||||
MapWithAILayerInfo.getInstance().getDefaultLayers().stream().filter(MapWithAIInfo::isDefaultEntry)
|
info.clear();
|
||||||
.forEach(MapWithAILayerInfo.getInstance()::add);
|
if (false && AnnotationSupport.isAnnotated(context.getTestClass(), Territories.class)) {
|
||||||
MapWithAILayerInfo.getInstance().save();
|
// This should probably only be run if territories is initialized
|
||||||
|
info.getDefaultLayers().stream().filter(MapWithAIInfo::isDefaultEntry).forEach(info::add);
|
||||||
|
}
|
||||||
|
info.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue