Changeset 17186 in josm
- Timestamp:
- 2020-10-13T16:42:15+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/WayTest.java
r11383 r17186 7 7 8 8 import java.util.Arrays; 9 import java.util.HashSet; 9 10 10 11 import org.junit.BeforeClass; … … 57 58 58 59 /** 60 * Test remove node 61 */ 62 @Test 63 public void testRemoveNode() { 64 DataSet ds = new DataSet(); 65 Node n1 = new Node(1); 66 Node n2 = new Node(2); 67 Node n3 = new Node(3); 68 Node n4 = new Node(4); 69 n1.setCoor(new LatLon(10, 10)); 70 n2.setCoor(new LatLon(11, 11)); 71 n3.setCoor(new LatLon(12, 12)); 72 n4.setCoor(new LatLon(13, 13)); 73 ds.addPrimitive(n1); 74 ds.addPrimitive(n2); 75 ds.addPrimitive(n3); 76 ds.addPrimitive(n4); 77 Way way = new Way(1); 78 ds.addPrimitive(way); 79 // duplicated way node 80 way.setNodes(Arrays.asList(n1, n2, n2, n3, n4, n1)); 81 way.setIncomplete(false); 82 way.removeNode(n4); 83 assertEquals(Arrays.asList(n1, n2, n3, n1), way.getNodes()); 84 way.removeNode(n3); 85 assertEquals(Arrays.asList(n1, n2), way.getNodes()); 86 way.setNodes(Arrays.asList(n1, n2, n3, n4, n1)); 87 way.removeNode(n1); 88 assertEquals(Arrays.asList(n2, n3, n4, n2), way.getNodes()); 89 90 } 91 92 /** 93 * Test remove node 94 */ 95 @Test 96 public void testRemoveNodes() { 97 DataSet ds = new DataSet(); 98 Node n1 = new Node(1); 99 Node n2 = new Node(2); 100 Node n3 = new Node(3); 101 Node n4 = new Node(4); 102 n1.setCoor(new LatLon(10, 10)); 103 n2.setCoor(new LatLon(11, 11)); 104 n3.setCoor(new LatLon(12, 12)); 105 n4.setCoor(new LatLon(13, 13)); 106 ds.addPrimitive(n1); 107 ds.addPrimitive(n2); 108 ds.addPrimitive(n3); 109 ds.addPrimitive(n4); 110 Way way = new Way(1); 111 ds.addPrimitive(way); 112 // duplicated way node 113 way.setNodes(Arrays.asList(n1, n2, n2, n3, n4, n1)); 114 way.setIncomplete(false); 115 way.removeNodes(new HashSet<>(Arrays.asList(n3, n4))); 116 assertEquals(Arrays.asList(n1, n2, n1), way.getNodes()); 117 way.setNodes(Arrays.asList(n1, n2, n3, n4, n1)); 118 way.removeNodes(new HashSet<>(Arrays.asList(n1))); 119 assertEquals(Arrays.asList(n2, n3, n4, n2), way.getNodes()); 120 } 121 122 /** 59 123 * Test that {@link Way#cloneFrom} throws IAE for invalid arguments 60 124 */
Note:
See TracChangeset
for help on using the changeset viewer.