Changeset 15432 in josm for trunk/test/unit


Ignore:
Timestamp:
2019-10-06T15:22:40+02:00 (5 years ago)
Author:
Don-vip
Message:

see #2760 - fix unit tests

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java

    r15431 r15432  
    6666    /**
    6767     * Tests simplification
    68      * @throws IOException
    69      * @throws IllegalDataException
     68     * @throws Exception in case of error
    7069     */
    7170    @Test
    72     public void testSimplify() throws IllegalDataException, IOException {
     71    public void testSimplify() throws Exception {
    7372        DataSet DsSimplify = getDs("tracks");
    7473        DataSet DsExpected = getDs("tracks-simplify15");
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java

    r15431 r15432  
    8383    }
    8484
    85     private class genericNode {
    86         public genericNode(Node n) {
     85    private static class GenericNode {
     86        final LatLon coor;
     87        final Map<String, String> tags;
     88
     89        GenericNode(Node n) {
    8790            coor = n.getCoor().getRoundedToOsmPrecision();
    8891            tags = n.getKeys();
    8992        }
    90         public LatLon coor;
    91         public Map<String, String> tags;
     93
    9294        @Override
    9395        public boolean equals(Object obj) {
    94             if (!(obj instanceof genericNode)) {
     96            if (!(obj instanceof GenericNode)) {
    9597                return false;
    9698            }
    97             genericNode other = (genericNode) obj;
     99            GenericNode other = (GenericNode) obj;
    98100            return coor.equals(other.coor) && tags.equals(other.tags);
    99101        }
     102
    100103        @Override
    101104        public int hashCode() {
     
    106109    private void testFromTrack(String expected) throws IOException, SAXException, IllegalDataException {
    107110        final GpxData data = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + "tracks/tracks.gpx");
    108         final DataSet osmExpected = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "tracks/" + expected + ".osm")), null);
     111        final DataSet osmExpected = OsmReader.parseDataSet(Files.newInputStream(
     112                Paths.get(TestUtils.getTestDataRoot(), "tracks/" + expected + ".osm")), null);
    109113        final GpxLayer layer = new GpxLayer(data);
    110114        final DataSet osm = new ConvertFromGpxLayerAction(layer).convert();
    111115        //compare sorted coordinates/tags and total amount of primitives, because IDs and order will vary after reload
    112116
    113         List<genericNode> nodes = osm.getNodes().stream()
    114                 .map(genericNode::new)
     117        List<GenericNode> nodes = osm.getNodes().stream()
     118                .map(GenericNode::new)
    115119                .sorted(Comparator.comparing(g -> g.coor.hashCode()))
    116120                .collect(Collectors.toList());
    117121
    118         List<genericNode> nodesExpected = osmExpected.getNodes().stream()
    119                 .map(genericNode::new)
     122        List<GenericNode> nodesExpected = osmExpected.getNodes().stream()
     123                .map(GenericNode::new)
    120124                .sorted(Comparator.comparing(g -> g.coor.hashCode()))
    121125                .collect(Collectors.toList());
Note: See TracChangeset for help on using the changeset viewer.