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


Ignore:
Timestamp:
2020-03-27T08:21:19+01:00 (5 years ago)
Author:
GerdP
Message:

fix #18990: Unable to Join Node To Way when way is the same one that the node belongs to

File:
1 edited

Legend:

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

    r15610 r16202  
    1717import org.openstreetmap.josm.data.osm.DataSet;
    1818import org.openstreetmap.josm.data.osm.Node;
     19import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     20import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
    1921import org.openstreetmap.josm.data.osm.Way;
    2022import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     
    213215    }
    214216
     217    /**
     218     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/18990">Bug #18990</a>.
     219     * @throws Exception if an error occurs
     220     */
     221    @Test
     222    public void testTicket18990() throws Exception {
     223        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(18990, "18990-sample.osm"), null);
     224        Layer layer = new OsmDataLayer(ds, OsmDataLayer.createNewName(), null);
     225        MainApplication.getLayerManager().addLayer(layer);
     226        try {
     227            Node toMove = (Node) ds.getPrimitiveById(new SimplePrimitiveId(7018586511L, OsmPrimitiveType.NODE));
     228            assertTrue(toMove != null);
     229            Node expected = new Node(new LatLon(43.48582074476985, -96.76897750613033));
     230
     231            ds.setSelected(toMove);
     232            setupMapView(ds);
     233            JoinNodeWayAction action = JoinNodeWayAction.createMoveNodeOntoWayAction();
     234            action.setEnabled(true);
     235            action.actionPerformed(null);
     236            assertTrue("Node was moved to an unexpected position", toMove.getEastNorth().equalsEpsilon(expected.getEastNorth(), 1e-7));
     237            assertTrue("Node was not added to expected way", toMove.getParentWays().size() == 1);
     238            assertTrue("Node was not added to expected way segment",
     239                    toMove.getParentWays().iterator().next().getNodes().indexOf(toMove) == 2);
     240        } finally {
     241            MainApplication.getLayerManager().removeLayer(layer);
     242        }
     243    }
     244
    215245}
Note: See TracChangeset for help on using the changeset viewer.