Changeset 17222 in josm


Ignore:
Timestamp:
2020-10-17T11:38:34+02:00 (4 days ago)
Author:
GerdP
Message:

Add unit test for validator test DuplicateWay to improve test coverage

(prepares change to usage of ChangeMembersCommnad)

Location:
trunk/test
Files:
1 added
1 edited

Legend:

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

    r14817 r17222  
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertNotNull;
     6import static org.junit.Assert.assertTrue;
     7
     8import java.nio.file.Files;
     9import java.nio.file.Paths;
    510
    611import org.junit.Rule;
    712import org.junit.Test;
    813import org.openstreetmap.josm.TestUtils;
     14import org.openstreetmap.josm.command.Command;
    915import org.openstreetmap.josm.data.coor.LatLon;
    1016import org.openstreetmap.josm.data.osm.DataSet;
     
    1218import org.openstreetmap.josm.data.validation.TestError;
    1319import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     20import org.openstreetmap.josm.io.OsmReader;
    1421import org.openstreetmap.josm.testutils.JOSMTestRules;
    1522
     
    8895        doTest(DuplicateWay.SAME_WAY, "highway=motorway", "highway=trunk", false);
    8996    }
     97
     98    /**
     99     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/14891">Bug #14891</a>.
     100     * @throws Exception if an error occurs
     101     */
     102    @Test
     103    public void testFixError() throws Exception {
     104        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "duplicate-ways.osm")), null);
     105        TEST.startTest(NullProgressMonitor.INSTANCE);
     106        TEST.visit(ds.allPrimitives());
     107        TEST.endTest();
     108
     109        assertEquals(2, TEST.getErrors().size());
     110        for (TestError error: TEST.getErrors()) {
     111            error = TEST.getErrors().iterator().next();
     112            assertTrue(error.isFixable());
     113            Command fix = error.getFix();
     114            assertNotNull(fix);
     115        }
     116        for (TestError error: TEST.getErrors()) {
     117            error.getFix().executeCommand();
     118        }
     119        TEST.startTest(NullProgressMonitor.INSTANCE);
     120        TEST.visit(ds.allPrimitives());
     121        TEST.endTest();
     122        assertTrue(TEST.getErrors().isEmpty());
     123
     124    }
     125
    90126}
Note: See TracChangeset for help on using the changeset viewer.