1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.validation.tests;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import org.junit.jupiter.api.Test;
|
---|
7 | import org.openstreetmap.josm.TestUtils;
|
---|
8 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
9 | import org.openstreetmap.josm.io.OsmReader;
|
---|
10 | import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * JUnit test for {@link CycleDetector} validation test.
|
---|
14 | */
|
---|
15 | @BasicPreferences
|
---|
16 | class CycleDetectorTest {
|
---|
17 |
|
---|
18 | @Test
|
---|
19 | void testCycleDetection() throws Exception {
|
---|
20 | CycleDetector cycleDetector = new CycleDetector();
|
---|
21 | DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(21881, "CycleDetector_test_wikipedia.osm"), null);
|
---|
22 | cycleDetector.startTest(null);
|
---|
23 | cycleDetector.visit(ds.allPrimitives());
|
---|
24 | cycleDetector.endTest();
|
---|
25 |
|
---|
26 | // we have 4 cycles in the test file
|
---|
27 | assertEquals(4, cycleDetector.getErrors().size());
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Test
|
---|
31 | void testNotConsecutive() throws Exception {
|
---|
32 | CycleDetector cycleDetector = new CycleDetector();
|
---|
33 | DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(21881, "not_consecutive.osm"), null);
|
---|
34 | cycleDetector.startTest(null);
|
---|
35 | cycleDetector.visit(ds.allPrimitives());
|
---|
36 | cycleDetector.endTest();
|
---|
37 |
|
---|
38 | // we have 1 cycles in the test file
|
---|
39 | assertEquals(1, cycleDetector.getErrors().size());
|
---|
40 | }
|
---|
41 | }
|
---|