source: josm/trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java@ 10956

Last change on this file since 10956 was 10717, checked in by simon04, 8 years ago

see #11390, see #12890 - Lambda can be replaced with method reference

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.junit.Assert.assertArrayEquals;
5
6import java.util.ArrayList;
7import java.util.Arrays;
8import java.util.Collections;
9import java.util.List;
10
11import org.junit.Test;
12import org.openstreetmap.josm.data.osm.NodeData;
13
14/**
15 * Unit tests of {@link OsmWriter} class.
16 */
17public class OsmWriterTest {
18
19 /**
20 * Unit test of {@link OsmWriter#byIdComparator}.
21 */
22 @Test
23 public void testByIdComparator() {
24
25 final List<NodeData> ids = new ArrayList<>();
26 for (Long id : Arrays.asList(12L, Long.MIN_VALUE, 65L, -12L, 2L, 0L, -3L, -20L, Long.MAX_VALUE)) {
27 final NodeData n = new NodeData();
28 n.setId(id);
29 ids.add(n);
30 }
31
32 Collections.sort(ids, OsmWriter.byIdComparator);
33
34 final long[] longIds = ids.stream().mapToLong(NodeData::getUniqueId).toArray();
35 assertArrayEquals(new long[] {
36 -3, -12, -20, -9223372036854775808L, 0, 2, 12, 65, 9223372036854775807L
37 }, longIds);
38 }
39}
Note: See TracBrowser for help on using the repository browser.