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

Last change on this file since 13938 was 13079, checked in by Don-vip, 6 years ago

see #15560 - EqualsVerifier does not work with newer Java versions -> disable tests automatically in this case
Workaround to https://github.com/jqno/equalsverifier/issues/177 / https://github.com/raphw/byte-buddy/issues/370
Inspired by https://issues.apache.org/jira/browse/SOLR-11606

  • Property svn:eol-style set to native
File size: 2.6 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.Rule;
13import org.junit.Test;
14import org.openstreetmap.josm.TestUtils;
15import org.openstreetmap.josm.data.osm.DataSet;
16import org.openstreetmap.josm.data.osm.Node;
17import org.openstreetmap.josm.data.osm.NodeGraph;
18import org.openstreetmap.josm.data.osm.NodePair;
19import org.openstreetmap.josm.io.IllegalDataException;
20import org.openstreetmap.josm.io.OsmReader;
21import org.openstreetmap.josm.testutils.JOSMTestRules;
22
23import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
24import nl.jqno.equalsverifier.EqualsVerifier;
25import nl.jqno.equalsverifier.Warning;
26
27/**
28 * Unit tests for class {@link CombineWayAction}.
29 */
30public class CombineWayActionTest {
31
32 /**
33 * Setup test.
34 */
35 @Rule
36 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
37 public JOSMTestRules test = new JOSMTestRules();
38
39 /**
40 * Non-regression test for bug #11957.
41 * @throws IOException if any I/O error occurs
42 * @throws IllegalDataException if OSM parsing fails
43 */
44 @Test
45 public void testTicket11957() throws IOException, IllegalDataException {
46 try (InputStream is = TestUtils.getRegressionDataStream(11957, "data.osm")) {
47 DataSet ds = OsmReader.parseDataSet(is, null);
48 NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ds.getWays());
49 List<Node> path = graph.buildSpanningPath();
50 assertEquals(10, path.size());
51 Set<Long> firstAndLastObtained = new HashSet<>();
52 firstAndLastObtained.add(path.get(0).getId());
53 firstAndLastObtained.add(path.get(path.size()-1).getId());
54 Set<Long> firstAndLastExpected = new HashSet<>();
55 firstAndLastExpected.add(1618969016L);
56 firstAndLastExpected.add(35213705L);
57 assertEquals(firstAndLastExpected, firstAndLastObtained);
58 }
59 }
60
61 /**
62 * Unit test of methods {@link NodePair#equals} and {@link NodePair#hashCode}.
63 */
64 @Test
65 public void testEqualsContract() {
66 TestUtils.assumeWorkingEqualsVerifier();
67 EqualsVerifier.forClass(NodePair.class).usingGetClass()
68 .suppress(Warning.ANNOTATION) // FIXME: remove it after https://github.com/jqno/equalsverifier/issues/152 is fixed
69 .withPrefabValues(Node.class, new Node(1), new Node(2))
70 .verify();
71 }
72}
Note: See TracBrowser for help on using the repository browser.