diff --git a/test/unit/org/openstreetmap/josm/plugins/rapid/RapiDDataUtilsTest.java b/test/unit/org/openstreetmap/josm/plugins/rapid/RapiDDataUtilsTest.java index 91ac9a5..4906113 100644 --- a/test/unit/org/openstreetmap/josm/plugins/rapid/RapiDDataUtilsTest.java +++ b/test/unit/org/openstreetmap/josm/plugins/rapid/RapiDDataUtilsTest.java @@ -23,93 +23,93 @@ import org.openstreetmap.josm.plugins.rapid.backend.RapiDDataUtils; import org.openstreetmap.josm.testutils.JOSMTestRules; public class RapiDDataUtilsTest { - @Rule - public JOSMTestRules test = new JOSMTestRules().preferences(); + @Rule + public JOSMTestRules test = new JOSMTestRules().preferences(); - /** - * This gets data from RapiD. This test may fail if someone adds the data to OSM. - */ - @Test - public void testGetData() { - BBox testBBox = getTestBBox(); - DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox)); - Assert.assertEquals(1, ds.getWays().size()); - } + /** + * This gets data from RapiD. This test may fail if someone adds the data to OSM. + */ + @Test + public void testGetData() { + BBox testBBox = getTestBBox(); + DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox)); + Assert.assertEquals(1, ds.getWays().size()); + } - @Test - public void testAddSourceTags() { - BBox testBBox = getTestBBox(); - DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox)); - Assert.assertEquals(1, ds.getWays().size()); - Way way1 = (Way) ds.getWays().toArray()[0]; - String originalSource = way1.get("source"); - Assert.assertNotNull(originalSource); + @Test + public void testAddSourceTags() { + BBox testBBox = getTestBBox(); + DataSet ds = new DataSet(RapiDDataUtils.getData(testBBox)); + Assert.assertEquals(1, ds.getWays().size()); + Way way1 = (Way) ds.getWays().toArray()[0]; + String originalSource = way1.get("source"); + Assert.assertNotNull(originalSource); - way1.remove("source"); - Assert.assertNull(way1.get("source")); + way1.remove("source"); + Assert.assertNull(way1.get("source")); - RapiDDataUtils.addSourceTags(ds, "highway", originalSource); - Assert.assertEquals(originalSource, way1.get("source")); - } + RapiDDataUtils.addSourceTags(ds, "highway", originalSource); + Assert.assertEquals(originalSource, way1.get("source")); + } - private static BBox getTestBBox() { - BBox testBBox = new BBox(); - testBBox.add(new LatLon(39.0666521, -108.5707187)); - testBBox.add(new LatLon(39.0664016, -108.5702225)); - return testBBox; - } + private static BBox getTestBBox() { + BBox testBBox = new BBox(); + testBBox.add(new LatLon(39.0768984, -108.5462553)); + testBBox.add(new LatLon(39.0776276, -108.5452918)); + return testBBox; + } - @Test - public void testAddPrimitivesToCollection() { - Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.1))); - Collection collection = new TreeSet<>(); - Assert.assertEquals(0, collection.size()); - RapiDDataUtils.addPrimitivesToCollection(collection, Collections.singletonList(way1)); - Assert.assertEquals(3, collection.size()); - } + @Test + public void testAddPrimitivesToCollection() { + Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.1))); + Collection collection = new TreeSet<>(); + Assert.assertEquals(0, collection.size()); + RapiDDataUtils.addPrimitivesToCollection(collection, Collections.singletonList(way1)); + Assert.assertEquals(3, collection.size()); + } - @Test - public void testRemovePrimitivesFromDataSet() { - Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.1))); - DataSet ds1 = new DataSet(); - for (Node node : way1.getNodes()) { - ds1.addPrimitive(node); - } - ds1.addPrimitive(way1); + @Test + public void testRemovePrimitivesFromDataSet() { + Way way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0, 0.1))); + DataSet ds1 = new DataSet(); + for (Node node : way1.getNodes()) { + ds1.addPrimitive(node); + } + ds1.addPrimitive(way1); - Assert.assertEquals(3, ds1.allPrimitives().size()); - RapiDDataUtils.removePrimitivesFromDataSet(Collections.singleton(way1)); - Assert.assertEquals(0, ds1.allPrimitives().size()); - } + Assert.assertEquals(3, ds1.allPrimitives().size()); + RapiDDataUtils.removePrimitivesFromDataSet(Collections.singleton(way1)); + Assert.assertEquals(0, ds1.allPrimitives().size()); + } - @Test - public void testAddPaintStyle() { - List paintStyles = MapPaintPrefHelper.INSTANCE.get(); - // There are two default paint styles - Assert.assertEquals(2, paintStyles.size()); - RapiDDataUtils.addRapiDPaintStyles(); - paintStyles = MapPaintPrefHelper.INSTANCE.get(); - Assert.assertEquals(3, paintStyles.size()); - RapiDDataUtils.addRapiDPaintStyles(); - paintStyles = MapPaintPrefHelper.INSTANCE.get(); - Assert.assertEquals(3, paintStyles.size()); - RapiDDataUtils.addRapiDPaintStyles(); - } + @Test + public void testAddPaintStyle() { + List paintStyles = MapPaintPrefHelper.INSTANCE.get(); + // There are two default paint styles + Assert.assertEquals(2, paintStyles.size()); + RapiDDataUtils.addRapiDPaintStyles(); + paintStyles = MapPaintPrefHelper.INSTANCE.get(); + Assert.assertEquals(3, paintStyles.size()); + RapiDDataUtils.addRapiDPaintStyles(); + paintStyles = MapPaintPrefHelper.INSTANCE.get(); + Assert.assertEquals(3, paintStyles.size()); + RapiDDataUtils.addRapiDPaintStyles(); + } - @Test - public void testRapiDURLPreferences() { - String fakeUrl = "https://fake.url"; - Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL()); - RapiDDataUtils.setRapiDUrl(fakeUrl); - Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL()); - List urls = new ArrayList<>(RapiDDataUtils.getRapiDURLs()); - Assert.assertEquals(2, urls.size()); - RapiDDataUtils.setRapiDUrl(RapiDDataUtils.DEFAULT_RAPID_API); - Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL()); - RapiDDataUtils.setRapiDUrl(fakeUrl); - Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL()); - urls.remove(fakeUrl); - RapiDDataUtils.setRapiDURLs(urls); - Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL()); - } + @Test + public void testRapiDURLPreferences() { + String fakeUrl = "https://fake.url"; + Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL()); + RapiDDataUtils.setRapiDUrl(fakeUrl); + Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL()); + List urls = new ArrayList<>(RapiDDataUtils.getRapiDURLs()); + Assert.assertEquals(2, urls.size()); + RapiDDataUtils.setRapiDUrl(RapiDDataUtils.DEFAULT_RAPID_API); + Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL()); + RapiDDataUtils.setRapiDUrl(fakeUrl); + Assert.assertEquals(fakeUrl, RapiDDataUtils.getRapiDURL()); + urls.remove(fakeUrl); + RapiDDataUtils.setRapiDURLs(urls); + Assert.assertEquals(RapiDDataUtils.DEFAULT_RAPID_API, RapiDDataUtils.getRapiDURL()); + } }