1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer.gpx;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertNotNull;
|
---|
6 |
|
---|
7 | import java.io.IOException;
|
---|
8 |
|
---|
9 | import org.junit.Rule;
|
---|
10 | import org.junit.Test;
|
---|
11 | import org.openstreetmap.josm.TestUtils;
|
---|
12 | import org.openstreetmap.josm.data.gpx.GpxData;
|
---|
13 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
14 | import org.openstreetmap.josm.data.osm.TagMap;
|
---|
15 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
|
---|
16 | import org.openstreetmap.josm.io.GpxReaderTest;
|
---|
17 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
18 | import org.xml.sax.SAXException;
|
---|
19 |
|
---|
20 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Unit tests of {@link ConvertToDataLayerAction} class.
|
---|
24 | */
|
---|
25 | public class ConvertToDataLayerActionTest {
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Setup test.
|
---|
29 | */
|
---|
30 | @Rule
|
---|
31 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
32 | public JOSMTestRules test = new JOSMTestRules();
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Tests a conversion from a GPX marker layer to a OSM dataset
|
---|
36 | * @throws Exception if the parsing fails
|
---|
37 | */
|
---|
38 | @Test
|
---|
39 | public void testFromMarkerLayer() throws Exception {
|
---|
40 | final GpxData data = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + "minimal.gpx");
|
---|
41 | final MarkerLayer markers = new MarkerLayer(data, "Markers", data.storageFile, null);
|
---|
42 | final DataSet osm = new ConvertToDataLayerAction.FromMarkerLayer(markers).convert();
|
---|
43 | assertEquals(1, osm.getNodes().size());
|
---|
44 | assertEquals(new TagMap("name", "Schranke", "description", "Pfad", "note", "Pfad", "gpxicon", "Toll Booth"),
|
---|
45 | osm.getNodes().iterator().next().getKeys());
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/14275">#14275</a>
|
---|
50 | * @throws IOException if an error occurs during reading
|
---|
51 | * @throws SAXException if any XML error occurs
|
---|
52 | */
|
---|
53 | @Test
|
---|
54 | public void testTicket14275() throws IOException, SAXException {
|
---|
55 | assertNotNull(GpxReaderTest.parseGpxData(TestUtils.getRegressionDataFile(14275, "1485101437.8189685.gpx")));
|
---|
56 | }
|
---|
57 | }
|
---|