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 |
|
---|
6 | import org.junit.BeforeClass;
|
---|
7 | import org.junit.Test;
|
---|
8 | import org.openstreetmap.josm.JOSMFixture;
|
---|
9 | import org.openstreetmap.josm.TestUtils;
|
---|
10 | import org.openstreetmap.josm.data.gpx.GpxData;
|
---|
11 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
12 | import org.openstreetmap.josm.data.osm.TagMap;
|
---|
13 | import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
|
---|
14 | import org.openstreetmap.josm.io.GpxReaderTest;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Unit tests of {@link ConvertToDataLayerAction} class.
|
---|
18 | */
|
---|
19 | public class ConvertToDataLayerActionTest {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Setup test.
|
---|
23 | */
|
---|
24 | @BeforeClass
|
---|
25 | public static void setUpBeforeClass() {
|
---|
26 | JOSMFixture.createUnitTestFixture().init(false);
|
---|
27 | }
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Tests a conversion from a GPX marker layer to a OSM dataset
|
---|
31 | * @throws Exception if the parsing fails
|
---|
32 | */
|
---|
33 | @Test
|
---|
34 | public void testFromMarkerLayer() throws Exception {
|
---|
35 | final GpxData data = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + "minimal.gpx");
|
---|
36 | final MarkerLayer markers = new MarkerLayer(data, "Markers", data.storageFile, null);
|
---|
37 | final DataSet osm = new ConvertToDataLayerAction.FromMarkerLayer(markers).convert();
|
---|
38 | assertEquals(1, osm.getNodes().size());
|
---|
39 | assertEquals(new TagMap("name", "Schranke", "description", "Pfad", "note", "Pfad", "gpxicon", "Toll Booth"),
|
---|
40 | osm.getNodes().iterator().next().getKeys());
|
---|
41 | }
|
---|
42 | }
|
---|