1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertTrue;
|
---|
6 |
|
---|
7 | import java.io.FileNotFoundException;
|
---|
8 | import java.io.IOException;
|
---|
9 | import java.io.InputStream;
|
---|
10 |
|
---|
11 | import org.junit.Rule;
|
---|
12 | import org.junit.Test;
|
---|
13 | import org.openstreetmap.josm.Main;
|
---|
14 | import org.openstreetmap.josm.TestUtils;
|
---|
15 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
16 | import org.openstreetmap.josm.data.osm.Way;
|
---|
17 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
18 | import org.openstreetmap.josm.io.IllegalDataException;
|
---|
19 | import org.openstreetmap.josm.io.OsmReader;
|
---|
20 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
21 |
|
---|
22 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Unit tests for class {@link PurgeAction}.
|
---|
26 | */
|
---|
27 | public class PurgeActionTest {
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Setup test.
|
---|
31 | */
|
---|
32 | @Rule
|
---|
33 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
34 | public JOSMTestRules test = new JOSMTestRules().platform().commands();
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Non-regression test for ticket #12038.
|
---|
38 | * @throws IOException if any I/O error occurs
|
---|
39 | * @throws FileNotFoundException if the data file cannot be found
|
---|
40 | * @throws IllegalDataException if OSM parsing fails
|
---|
41 | */
|
---|
42 | @Test
|
---|
43 | public void testCopyStringWayRelation() throws FileNotFoundException, IOException, IllegalDataException {
|
---|
44 | try (InputStream is = TestUtils.getRegressionDataStream(12038, "data.osm")) {
|
---|
45 | DataSet ds = OsmReader.parseDataSet(is, null);
|
---|
46 | OsmDataLayer layer = new OsmDataLayer(ds, null, null);
|
---|
47 | Main.getLayerManager().addLayer(layer);
|
---|
48 | try {
|
---|
49 | for (Way w : ds.getWays()) {
|
---|
50 | if (w.getId() == 222191929L) {
|
---|
51 | ds.addSelected(w);
|
---|
52 | }
|
---|
53 | }
|
---|
54 | new PurgeAction().actionPerformed(null);
|
---|
55 | for (Way w : ds.getWays()) {
|
---|
56 | if (w.getId() == 222191929L) {
|
---|
57 | assertTrue(w.isIncomplete());
|
---|
58 | assertEquals(0, w.getNodesCount());
|
---|
59 | }
|
---|
60 | }
|
---|
61 | } finally {
|
---|
62 | // Ensure we clean the place before leaving, even if test fails.
|
---|
63 | Main.getLayerManager().removeLayer(layer);
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|
67 | }
|
---|