Changeset 11609 in josm for trunk/test


Ignore:
Timestamp:
2017-02-25T12:52:18+01:00 (3 years ago)
Author:
Don-vip
Message:

fix #14410 - AddPrimitivesCommand undo remove existing data (patch by Tyndare)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/command/AddPrimitivesCommandTest.java

    r10804 r11609  
    176176
    177177    /**
     178     * Tests if the undo command does not remove
     179     * data ignored by by the add command because they where already existing.
     180     */
     181    @Test
     182    public void testUndoIgnoresExisting() {
     183        OsmDataLayer layer1 = new OsmDataLayer(new DataSet(), "l1", null);
     184        Main.getLayerManager().addLayer(layer1);
     185
     186        List<PrimitiveData> testData = createTestData();
     187
     188        assertTrue(new AddPrimitivesCommand(testData).executeCommand());
     189        assertEquals(2, layer1.data.getNodes().size());
     190        assertEquals(1, layer1.data.getWays().size());
     191
     192        testData.set(2, createTestNode(7));
     193
     194        AddPrimitivesCommand command = new AddPrimitivesCommand(testData);
     195
     196        assertTrue(command.executeCommand());
     197
     198        assertEquals(3, layer1.data.getNodes().size());
     199        assertEquals(1, layer1.data.getWays().size());
     200
     201        for (int i = 0; i < 2; i++) {
     202            // Needs to work multiple times.
     203            command.undoCommand();
     204
     205            assertEquals(2, layer1.data.getNodes().size());
     206            assertEquals(1, layer1.data.getWays().size());
     207
     208            // redo
     209            assertTrue(command.executeCommand());
     210
     211            assertEquals(3, layer1.data.getNodes().size());
     212            assertEquals(1, layer1.data.getWays().size());
     213        }
     214    }
     215
     216    /**
    178217     * Test {@link AddCommand#getParticipatingPrimitives()}
    179218     */
Note: See TracChangeset for help on using the changeset viewer.