Changeset 17240 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2020-10-19T10:56:31+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/command/AddPrimitivesCommandTest.java
r13907 r17240 187 187 assertTrue(command.executeCommand()); 188 188 189 assertEquals(3, ds.getNodes().size());190 assertEquals(1, ds.getWays().size());191 192 189 for (int i = 0; i < 2; i++) { 193 190 // Needs to work multiple times. 191 assertEquals(3, ds.getNodes().size()); 192 assertEquals(1, ds.getWays().size()); 193 194 194 command.undoCommand(); 195 195 … … 199 199 // redo 200 200 assertTrue(command.executeCommand()); 201 202 assertEquals(3, ds.getNodes().size()); 203 assertEquals(1, ds.getWays().size()); 201 } 202 } 203 204 /** 205 * Tests if the undo command does not remove 206 * data ignored by by the add command because they where already existing. 207 * Simulates regression in #14620 208 */ 209 @Test 210 public void testUndoIgnoresExistingAsDeleted() { 211 DataSet ds = new DataSet(); 212 213 List<PrimitiveData> testData = createTestData(); 214 215 assertTrue(new AddPrimitivesCommand(testData, ds).executeCommand()); 216 assertEquals(2, ds.getNodes().size()); 217 assertEquals(1, ds.getWays().size()); 218 219 ds.getNodes().forEach(n -> n.setDeleted(true)); 220 221 AddPrimitivesCommand command = new AddPrimitivesCommand(testData, ds); 222 223 assertTrue(command.executeCommand()); 224 225 for (int i = 0; i < 2; i++) { 226 // Needs to work multiple times. 227 assertEquals(2, ds.getNodes().size()); 228 assertEquals(1, ds.getWays().size()); 229 230 command.undoCommand(); 231 232 assertEquals(2, ds.getNodes().size()); 233 assertEquals(1, ds.getWays().size()); 234 235 // redo 236 assertTrue(command.executeCommand()); 237 } 238 } 239 240 /** 241 * Tests if the undo command does not remove 242 * data ignored by by the add command because they where already existing. 243 */ 244 @Test 245 public void testUndoIgnoresExistingSameUniqueIdDifferentType() { 246 DataSet ds = new DataSet(); 247 248 List<PrimitiveData> testData = new ArrayList<>(createTestData()); 249 250 assertTrue(new AddPrimitivesCommand(testData, ds).executeCommand()); 251 assertEquals(2, ds.getNodes().size()); 252 assertEquals(1, ds.getWays().size()); 253 254 NodeData n7Data = createTestNode(7); 255 NodeData n8Data = createTestNode(8); 256 Way w2 = new Way(5); 257 Node n7 = new Node(7); 258 n7.load(n7Data); 259 Node n8 = new Node(8); 260 n8.load(n8Data); 261 w2.setNodes(Arrays.asList(n7, n8)); 262 testData.set(2, createTestNode(7)); 263 testData.add(n8.save()); 264 testData.add(w2.save()); 265 266 AddPrimitivesCommand command = new AddPrimitivesCommand(testData, ds); 267 268 assertTrue(command.executeCommand()); 269 270 for (int i = 0; i < 2; i++) { 271 assertEquals(4, ds.getNodes().size()); 272 assertEquals(2, ds.getWays().size()); 273 274 // Needs to work multiple times. 275 command.undoCommand(); 276 277 assertEquals(2, ds.getNodes().size()); 278 assertEquals(1, ds.getWays().size()); 279 280 // redo 281 assertTrue(command.executeCommand()); 282 204 283 } 205 284 } … … 266 345 NodeData node1 = createTestNode(5); 267 346 NodeData node2 = createTestNode(6); 268 WayData way = new WayData( );347 WayData way = new WayData(2); 269 348 way.put("test", "test"); 270 349 way.setNodeIds(Arrays.asList(node1.getId(), node2.getId()));
Note:
See TracChangeset
for help on using the changeset viewer.