kopia lustrzana https://github.com/JOSM/MapWithAI
Fix broken test (again -- the test areas keep on breaking)
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
6401d0725b
commit
156004a9bb
|
@ -23,93 +23,93 @@ import org.openstreetmap.josm.plugins.rapid.backend.RapiDDataUtils;
|
||||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||||
|
|
||||||
public class RapiDDataUtilsTest {
|
public class RapiDDataUtilsTest {
|
||||||
@Rule
|
@Rule
|
||||||
public JOSMTestRules test = new JOSMTestRules().preferences();
|
public JOSMTestRules test = new JOSMTestRules().preferences();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This gets data from RapiD. This test may fail if someone adds the data to OSM.
|
* This gets data from RapiD. This test may fail if someone adds the data to OSM.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetData() {
|
public void testGetData() {
|
||||||
BBox testBBox = getTestBBox();
|
BBox testBBox = getTestBBox();
|
||||||
DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox));
|
DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox));
|
||||||
Assert.assertEquals(1, ds.getWays().size());
|
Assert.assertEquals(1, ds.getWays().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddSourceTags() {
|
public void testAddSourceTags() {
|
||||||
BBox testBBox = getTestBBox();
|
BBox testBBox = getTestBBox();
|
||||||
DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox));
|
DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox));
|
||||||
Assert.assertEquals(1, ds.getWays().size());
|
Assert.assertEquals(1, ds.getWays().size());
|
||||||
Way way1 = (Way) ds.getWays().toArray()[0];
|
Way way1 = (Way) ds.getWays().toArray()[0];
|
||||||
String originalSource = way1.get("source");
|
String originalSource = way1.get("source");
|
||||||
Assert.assertNotNull(originalSource);
|
Assert.assertNotNull(originalSource);
|
||||||
|
|
||||||
way1.remove("source");
|
way1.remove("source");
|
||||||
Assert.assertNull(way1.get("source"));
|
Assert.assertNull(way1.get("source"));
|
||||||
|
|
||||||
RapiDDataUtils.addSourceTags(ds, "highway", originalSource);
|
RapiDDataUtils.addSourceTags(ds, "highway", originalSource);
|
||||||
Assert.assertEquals(originalSource, way1.get("source"));
|
Assert.assertEquals(originalSource, way1.get("source"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BBox getTestBBox() {
|
private static BBox getTestBBox() {
|
||||||
BBox testBBox = new BBox();
|
BBox testBBox = new BBox();
|
||||||
testBBox.add(new LatLon(39.0666521, -108.5707187));
|
testBBox.add(new LatLon(39.0768984, -108.5462553));
|
||||||
testBBox.add(new LatLon(39.0664016, -108.5702225));
|
testBBox.add(new LatLon(39.0776276, -108.5452918));
|
||||||
return testBBox;
|
return testBBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddPrimitivesToCollection() {
|
public void testAddPrimitivesToCollection() {
|
||||||
Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.1)));
|
Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.1)));
|
||||||
Collection<OsmPrimitive> collection = new TreeSet<>();
|
Collection<OsmPrimitive> collection = new TreeSet<>();
|
||||||
Assert.assertEquals(0, collection.size());
|
Assert.assertEquals(0, collection.size());
|
||||||
RapiDDataUtils.addPrimitivesToCollection(collection, Collections.singletonList(way1));
|
RapiDDataUtils.addPrimitivesToCollection(collection, Collections.singletonList(way1));
|
||||||
Assert.assertEquals(3, collection.size());
|
Assert.assertEquals(3, collection.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemovePrimitivesFromDataSet() {
|
public void testRemovePrimitivesFromDataSet() {
|
||||||
Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.1)));
|
Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.1)));
|
||||||
DataSet ds1 = new DataSet();
|
DataSet ds1 = new DataSet();
|
||||||
for (Node node : way1.getNodes()) {
|
for (Node node : way1.getNodes()) {
|
||||||
ds1.addPrimitive(node);
|
ds1.addPrimitive(node);
|
||||||
}
|
}
|
||||||
ds1.addPrimitive(way1);
|
ds1.addPrimitive(way1);
|
||||||
|
|
||||||
Assert.assertEquals(3, ds1.allPrimitives().size());
|
Assert.assertEquals(3, ds1.allPrimitives().size());
|
||||||
RapiDDataUtils.removePrimitivesFromDataSet(Collections.singleton(way1));
|
RapiDDataUtils.removePrimitivesFromDataSet(Collections.singleton(way1));
|
||||||
Assert.assertEquals(0, ds1.allPrimitives().size());
|
Assert.assertEquals(0, ds1.allPrimitives().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddPaintStyle() {
|
public void testAddPaintStyle() {
|
||||||
List<SourceEntry> paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
List<SourceEntry> paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||||
// There are two default paint styles
|
// There are two default paint styles
|
||||||
Assert.assertEquals(2, paintStyles.size());
|
Assert.assertEquals(2, paintStyles.size());
|
||||||
RapiDDataUtils.addRapiDPaintStyles();
|
RapiDDataUtils.addRapiDPaintStyles();
|
||||||
paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||||
Assert.assertEquals(3, paintStyles.size());
|
Assert.assertEquals(3, paintStyles.size());
|
||||||
RapiDDataUtils.addRapiDPaintStyles();
|
RapiDDataUtils.addRapiDPaintStyles();
|
||||||
paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||||
Assert.assertEquals(3, paintStyles.size());
|
Assert.assertEquals(3, paintStyles.size());
|
||||||
RapiDDataUtils.addRapiDPaintStyles();
|
RapiDDataUtils.addRapiDPaintStyles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRapiDURLPreferences() {
|
public void testRapiDURLPreferences() {
|
||||||
String fakeUrl = "https://fake.url";
|
String fakeUrl = "https://fake.url";
|
||||||
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
||||||
RapiDDataUtils.setRapiDUrl(fakeUrl);
|
RapiDDataUtils.setRapiDUrl(fakeUrl);
|
||||||
Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL());
|
Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL());
|
||||||
List<String> urls = new ArrayList<>(RapiDDataUtils.getRapiDURLs());
|
List<String> urls = new ArrayList<>(RapiDDataUtils.getRapiDURLs());
|
||||||
Assert.assertEquals(2, urls.size());
|
Assert.assertEquals(2, urls.size());
|
||||||
RapiDDataUtils.setRapiDUrl(RapiDDataUtils.DEFAULT_RAPID_API);
|
RapiDDataUtils.setRapiDUrl(RapiDDataUtils.DEFAULT_RAPID_API);
|
||||||
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
||||||
RapiDDataUtils.setRapiDUrl(fakeUrl);
|
RapiDDataUtils.setRapiDUrl(fakeUrl);
|
||||||
Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL());
|
Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL());
|
||||||
urls.remove(fakeUrl);
|
urls.remove(fakeUrl);
|
||||||
RapiDDataUtils.setRapiDURLs(urls);
|
RapiDDataUtils.setRapiDURLs(urls);
|
||||||
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue