1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.validation.tests;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 |
|
---|
6 | import org.junit.BeforeClass;
|
---|
7 | import org.junit.Test;
|
---|
8 | import org.openstreetmap.josm.Main;
|
---|
9 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
10 | import org.openstreetmap.josm.data.osm.DataSet;
|
---|
11 | import org.openstreetmap.josm.data.osm.Node;
|
---|
12 | import org.openstreetmap.josm.data.projection.Projections;
|
---|
13 | import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * JUnit Test of "Duplicate node" validation test.
|
---|
17 | */
|
---|
18 | public class DuplicateNodeTest {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Setup test by initializing JOSM preferences and projection.
|
---|
22 | */
|
---|
23 | @BeforeClass
|
---|
24 | public static void setUp() {
|
---|
25 | Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
|
---|
26 | Main.initApplicationPreferences();
|
---|
27 | }
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Test of "Duplicate node" validation test.
|
---|
31 | */
|
---|
32 | @Test
|
---|
33 | public void test() {
|
---|
34 | DataSet ds = new DataSet();
|
---|
35 |
|
---|
36 | Node a = new Node(new LatLon(10.0, 5.0));
|
---|
37 | Node b = new Node(new LatLon(10.0, 5.0));
|
---|
38 | ds.addPrimitive(a);
|
---|
39 | ds.addPrimitive(b);
|
---|
40 |
|
---|
41 | DuplicateNode test = new DuplicateNode();
|
---|
42 | test.startTest(NullProgressMonitor.INSTANCE);
|
---|
43 | test.visit(ds.allPrimitives());
|
---|
44 | test.endTest();
|
---|
45 |
|
---|
46 | assertEquals(1, test.getErrors().size());
|
---|
47 | }
|
---|
48 | }
|
---|