Changeset 17408 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2020-12-14T11:52:24+01:00 (3 years ago)
Author:
GerdP
Message:

fix #20238: update multipolygon on old-style multipolygon action cannot be fully undone

  • make sure that a command to update the relation is generated
  • add unit test
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

    r17406 r17408  
    191191        assertEquals(0, ds.getWays().stream().filter(w -> w.hasTag("building", "yes")).count());
    192192    }
     193
     194    /**
     195     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/20238">Bug #20238</a>.
     196     * @throws Exception if an error occurs
     197     */
     198    @Test
     199    void testTicket20238() throws Exception {
     200        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(20238, "data.osm"), null);
     201        assertEquals(1, ds.getRelations().size());
     202        Relation mp = ds.getRelations().iterator().next();
     203        assertFalse(ds.getRelations().iterator().next().hasTag("building", "yes"));
     204        assertEquals(1, ds.getWays().stream().filter(w -> w.hasTag("building", "yes")).count());
     205        Pair<SequenceCommand, Relation> cmd = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), mp);
     206        assertNotNull(cmd);
     207        cmd.a.executeCommand();
     208        assertEquals(1, ds.getRelations().size());
     209        assertTrue(ds.getRelations().iterator().next().hasTag("building", "yes"));
     210        assertEquals(0, ds.getWays().stream().filter(w -> w.hasTag("building", "yes")).count());
     211        cmd.a.undoCommand();
     212        assertEquals(1, ds.getRelations().size());
     213        assertFalse(ds.getRelations().iterator().next().hasTag("building", "yes"));
     214        assertEquals(1, ds.getWays().stream().filter(w -> w.hasTag("building", "yes")).count());
     215    }
    193216}
Note: See TracChangeset for help on using the changeset viewer.