Changeset 17376 in josm for trunk/test/unit/org
- Timestamp:
- 2020-11-30T10:57:50+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DuplicateNodeTest.java
r17275 r17376 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 9 import org.junit.jupiter.api.Test; 6 10 import org.junit.jupiter.api.extension.RegisterExtension; 7 import org. junit.jupiter.api.Test;11 import org.openstreetmap.josm.command.Command; 8 12 import org.openstreetmap.josm.data.coor.LatLon; 9 13 import org.openstreetmap.josm.data.osm.DataSet; … … 44 48 assertEquals(code, error.getCode()); 45 49 assertEquals(fixable, error.isFixable()); 50 if (fixable) { 51 Command c = error.getFix(); 52 assertNotNull(c); 53 c.executeCommand(); 54 assertFalse(error.isFixable()); 55 c.undoCommand(); 56 assertTrue(error.isFixable()); 57 error.getPrimitives().iterator().next().setDeleted(true); 58 if (error.getPrimitives().size() == 2) { 59 assertFalse(error.isFixable()); 60 } else { 61 assertTrue(error.isFixable()); 62 } 63 error.getPrimitives().iterator().next().setDeleted(false); 64 } 46 65 } 47 66 … … 67 86 68 87 /** 88 * Test of "Duplicate node" validation test - no duplicate 89 */ 90 @Test 91 void testNoDuplicateNode() { 92 DataSet ds = new DataSet(); 93 94 Node a = new Node(new LatLon(10.0, 5.0)); 95 Node b = new Node(new LatLon(10.0, 6.0)); 96 ds.addPrimitive(a); 97 ds.addPrimitive(b); 98 99 a.put("foo", "bar"); 100 b.put("bar", "foo"); 101 102 TEST.startTest(NullProgressMonitor.INSTANCE); 103 TEST.visit(ds.allPrimitives()); 104 TEST.endTest(); 105 106 assertEquals(0, TEST.getErrors().size()); 107 } 108 109 /** 110 * Test of "Duplicate node" validation test - same position, with ele value 111 */ 112 @Test 113 void testDuplicateNodeWithEle() { 114 DataSet ds = new DataSet(); 115 116 Node a = new Node(new LatLon(10.0, 5.0)); 117 Node b = new Node(new LatLon(10.0, 5.0)); 118 ds.addPrimitive(a); 119 ds.addPrimitive(b); 120 121 a.put("foo", "bar"); 122 b.put("bar", "foo"); 123 a.put("ele", "100"); 124 b.put("ele", "100"); 125 126 TEST.startTest(NullProgressMonitor.INSTANCE); 127 TEST.visit(ds.allPrimitives()); 128 TEST.endTest(); 129 130 assertEquals(1, TEST.getErrors().size()); 131 132 b.put("ele", "110"); 133 134 TEST.startTest(NullProgressMonitor.INSTANCE); 135 TEST.visit(ds.allPrimitives()); 136 TEST.endTest(); 137 138 assertEquals(0, TEST.getErrors().size()); 139 } 140 141 /** 142 * Test of "Duplicate node" validation test - three nodes 143 */ 144 @Test 145 void testDuplicateNodeTriple() { 146 DataSet ds = new DataSet(); 147 148 Node a = new Node(new LatLon(10.0, 5.0)); 149 Node b = new Node(new LatLon(10.0, 5.0)); 150 Node c = new Node(new LatLon(10.0, 5.0)); 151 ds.addPrimitive(a); 152 ds.addPrimitive(b); 153 ds.addPrimitive(c); 154 155 performTest(DuplicateNode.DUPLICATE_NODE_OTHER, ds, true); 156 a.put("foo", "bar"); 157 b.put("foo", "bar"); 158 performTest(DuplicateNode.DUPLICATE_NODE_OTHER, ds, true); 159 } 160 161 /** 69 162 * Test of "Duplicate node" validation test - different tag sets. 70 163 */
Note:
See TracChangeset
for help on using the changeset viewer.