Changeset 12312 in josm for trunk/test/unit


Ignore:
Timestamp:
2017-06-04T18:39:14+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #14891 - improve roundabout/links validator test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/HighwaysTest.java

    r11403 r12312  
    55import static org.junit.Assert.assertFalse;
    66import static org.junit.Assert.assertTrue;
     7import static org.junit.Assert.fail;
     8
     9import java.io.InputStream;
     10import java.util.Collection;
    711
    812import org.junit.Before;
    913import org.junit.Test;
    1014import org.openstreetmap.josm.JOSMFixture;
     15import org.openstreetmap.josm.TestUtils;
    1116import org.openstreetmap.josm.data.coor.LatLon;
    1217import org.openstreetmap.josm.data.osm.DataSet;
     
    1419import org.openstreetmap.josm.data.osm.Way;
    1520import org.openstreetmap.josm.data.validation.TestError;
     21import org.openstreetmap.josm.io.OsmReader;
    1622
    1723/**
     
    96102        assertEquals("GB:nsl_single", link.get("source:maxspeed"));
    97103    }
     104
     105    /**
     106     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14891">Bug #14891</a>.
     107     * @throws Exception if an error occurs
     108     */
     109    @Test
     110    public void testTicket14891() throws Exception {
     111        try (InputStream is = TestUtils.getRegressionDataStream(14891, "14891.osm.bz2")) {
     112            Collection<Way> ways = OsmReader.parseDataSet(is, null).getWays();
     113            Way roundabout = ways.stream().filter(w -> 10068083 == w.getId()).findFirst().get();
     114            Highways test = new Highways();
     115            test.visit(roundabout);
     116            if (!test.getErrors().isEmpty()) {
     117                fail(test.getErrors().get(0).getMessage());
     118            }
     119            Way w1 = ways.stream().filter(w -> 28508494 == w.getId()).findFirst().get();
     120            Way w2 = ways.stream().filter(w -> 28508493 == w.getId()).findFirst().get();
     121            test.visit(w1);
     122            test.visit(w2);
     123            assertEquals(2, test.getErrors().size());
     124        }
     125    }
    98126}
Note: See TracChangeset for help on using the changeset viewer.