source: josm/trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java@ 10378

Last change on this file since 10378 was 9669, checked in by bastiK, 8 years ago

add missing svn:eol-style=native (see #12410)

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.junit.Assert.assertEquals;
5
6import java.io.IOException;
7import java.io.InputStream;
8import java.util.HashSet;
9import java.util.List;
10import java.util.Set;
11
12import org.junit.BeforeClass;
13import org.junit.Test;
14import org.openstreetmap.josm.JOSMFixture;
15import org.openstreetmap.josm.TestUtils;
16import org.openstreetmap.josm.actions.CombineWayAction.NodeGraph;
17import org.openstreetmap.josm.actions.CombineWayAction.NodePair;
18import org.openstreetmap.josm.data.osm.DataSet;
19import org.openstreetmap.josm.data.osm.Node;
20import org.openstreetmap.josm.io.IllegalDataException;
21import org.openstreetmap.josm.io.OsmReader;
22
23import nl.jqno.equalsverifier.EqualsVerifier;
24
25/**
26 * Unit tests for class {@link CombineWayAction}.
27 */
28public class CombineWayActionTest {
29
30 /**
31 * Setup test.
32 */
33 @BeforeClass
34 public static void setUp() {
35 JOSMFixture.createUnitTestFixture().init();
36 }
37
38 /**
39 * Non-regression test for bug #11957.
40 * @throws IOException if any I/O error occurs
41 * @throws IllegalDataException if OSM parsing fails
42 */
43 @Test
44 public void testTicket11957() throws IOException, IllegalDataException {
45 try (InputStream is = TestUtils.getRegressionDataStream(11957, "data.osm")) {
46 DataSet ds = OsmReader.parseDataSet(is, null);
47 NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ds.getWays());
48 List<Node> path = graph.buildSpanningPath();
49 assertEquals(10, path.size());
50 Set<Long> firstAndLastObtained = new HashSet<>();
51 firstAndLastObtained.add(path.get(0).getId());
52 firstAndLastObtained.add(path.get(path.size()-1).getId());
53 Set<Long> firstAndLastExpected = new HashSet<>();
54 firstAndLastExpected.add(1618969016L);
55 firstAndLastExpected.add(35213705L);
56 assertEquals(firstAndLastExpected, firstAndLastObtained);
57 }
58 }
59
60 /**
61 * Unit test of methods {@link NodePair#equals} and {@link NodePair#hashCode}.
62 */
63 @Test
64 public void equalsContract() {
65 EqualsVerifier.forClass(NodePair.class).usingGetClass()
66 .withPrefabValues(Node.class, new Node(1), new Node(2))
67 .verify();
68 }
69}
Note: See TracBrowser for help on using the repository browser.