Changeset 3034 in josm for trunk/test/unit


Ignore:
Timestamp:
2010-02-23T08:58:12+01:00 (10 years ago)
Author:
jttt
Message:

Fix #4467 Don't silently drop locally deleted member primitives from downloaded ways and relation (fix the issue when deleted primitive is referenced)

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r3025 r3034  
    815815     * Their dataset includes a way with three nodes, the first one being my node.
    816816     *
    817      * => the merged way should include two nodes only. the deleted node should still be
    818      * in the data set.
     817     * => the merged way should include all three nodes. Deleted node should have deleted=false and
     818     * special conflict with isDeleted should exist
    819819     *
    820820     */
     
    848848        theirWay.addNode(tn2);
    849849        theirWay.addNode(tn3);
    850         User user = User.getById(1111);
    851         if (user == null) {
    852             User.createOsmUser(1111, "their");
    853         }
    854         theirWay.setUser(user);
     850        theirWay.setUser(User.createOsmUser(1111, "their"));
    855851        theirWay.setTimestamp(new Date());
    856852        their.addPrimitive(theirWay);
     
    860856
    861857        assertEquals(1, visitor.getConflicts().size());
     858        assertTrue(visitor.getConflicts().get(0).isMyDeleted());
    862859
    863860        Way myWay = (Way)my.getPrimitiveById(4, OsmPrimitiveType.WAY);
     
    865862
    866863        Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE);
    867         assertTrue(!myWay.getNodes().contains(n));
    868         assertTrue(n != null);
    869 
    870         //a node was removed from the way,it should thus be modified
    871         assertTrue(myWay.isModified());
     864        assertTrue(myWay.getNodes().contains(n));
     865
     866        assertFalse(myWay.isModified());
    872867    }
    873868
     
    876871     * Their dataset includes a relation with three nodes, the first one being my node.
    877872     *
    878      * => the merged relation should include two nodes only. the deleted node should still be
    879      * in the data set
     873     * => the merged relation should include all three nodes. There should be conflict for deleted
     874     * node with isMyDeleted set
    880875     *
    881876     */
     
    884879
    885880
    886         Node n1 = new Node(new LatLon(0,0));
    887         n1.setOsmId(1,1);
    888         n1.setDeleted(true);
    889         my.addPrimitive(n1);
    890 
    891 
    892         Node n3 = new Node(new LatLon(0,0));
    893         n3.setOsmId(1,1);
    894         their.addPrimitive(n3);
    895 
    896         Node n4 = new Node(new LatLon(1,1));
    897         n4.setOsmId(2,1);
    898         their.addPrimitive(n4);
    899 
    900         Node n5 = new Node(new LatLon(2,2));
    901         n5.setOsmId(3,1);
    902         their.addPrimitive(n5);
     881        Node mn1 = new Node(new LatLon(0,0));
     882        mn1.setOsmId(1,1);
     883        mn1.setDeleted(true);
     884        my.addPrimitive(mn1);
     885
     886
     887        Node tn1 = new Node(new LatLon(0,0));
     888        tn1.setOsmId(1,1);
     889        their.addPrimitive(tn1);
     890
     891        Node tn2 = new Node(new LatLon(1,1));
     892        tn2.setOsmId(2,1);
     893        their.addPrimitive(tn2);
     894
     895        Node tn3 = new Node(new LatLon(2,2));
     896        tn3.setOsmId(3,1);
     897        their.addPrimitive(tn3);
    903898
    904899
     
    906901        theirRelation.setOsmId(4,1);
    907902
    908         theirRelation.addMember(new RelationMember("", n3));
    909         theirRelation.addMember(new RelationMember("", n4));
    910         theirRelation.addMember(new RelationMember("", n5));
     903        theirRelation.addMember(new RelationMember("", tn1));
     904        theirRelation.addMember(new RelationMember("", tn2));
     905        theirRelation.addMember(new RelationMember("", tn3));
    911906        their.addPrimitive(theirRelation);
    912907
    913908        DataSetMerger visitor = new DataSetMerger(my,their);
    914909        visitor.merge();
    915 
    916         assertEquals(0,visitor.getConflicts().size());
    917 
    918         Relation r = (Relation)my.getPrimitiveById(4,OsmPrimitiveType.RELATION);
    919         assertEquals(2, r.getMembersCount());
    920910
    921911        Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE);
    922912        assertTrue(n != null);
    923913
    924         assertTrue(r.isModified());
     914        assertEquals(1, visitor.getConflicts().size());
     915        assertTrue(visitor.getConflicts().hasConflictForMy(n));
     916        assertTrue(visitor.getConflicts().get(0).isMyDeleted());
     917
     918        Relation r = (Relation)my.getPrimitiveById(4,OsmPrimitiveType.RELATION);
     919        assertEquals(3, r.getMembersCount());
     920
     921        assertFalse(r.isModified());
    925922    }
    926923
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java

    r3025 r3034  
    1212import org.junit.Test;
    1313import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.data.conflict.Conflict;
    1415import org.openstreetmap.josm.data.coor.LatLon;
    1516import org.openstreetmap.josm.data.osm.DataSet;
    1617import org.openstreetmap.josm.data.osm.Node;
     18import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1719import org.openstreetmap.josm.data.osm.Relation;
    1820import org.openstreetmap.josm.data.osm.Way;
     
    4749    }
    4850
     51    private void populate(OsmPrimitive my, OsmPrimitive their) {
     52        model.populate(new Conflict<OsmPrimitive>(my, their));
     53    }
     54
    4955    @Test
    5056    public void populate() {
     
    5561        d1.addPrimitive(n1);
    5662        d2.addPrimitive(n2);
    57         model.populate(n1, n2);
     63        populate(n1, n2);
    5864
    5965        Way w1 = new Way(1);
     
    6167        d1.addPrimitive(w1);
    6268        d2.addPrimitive(w2);
    63         model.populate(w2, w2);
     69        populate(w2, w2);
    6470
    6571        Relation r1 = new Relation(1);
     
    6773        d1.addPrimitive(r1);
    6874        d2.addPrimitive(r2);
    69         model.populate(r1, r2);
     75        populate(r1, r2);
    7076    }
    7177
     
    7985        d1.addPrimitive(n1);
    8086        d2.addPrimitive(n2);
    81         model.populate(n1, n2);
     87        populate(n1, n2);
    8288        assertFalse(model.hasCoordConflict());
    8389
    8490        n1.setCoor(new LatLon(1,1));
    85         model.populate(n1, n2);
     91        populate(n1, n2);
    8692        assertTrue(model.hasCoordConflict());
    8793
     
    8995        n1.cloneFrom(new Node(1));
    9096        n2.setCoor(new LatLon(2,2));
    91         model.populate(n1, n2);
     97        populate(n1, n2);
    9298        assertTrue(model.hasCoordConflict());
    9399
    94100        n1.setCoor(new LatLon(1,1));
    95101        n2.setCoor(new LatLon(2,2));
    96         model.populate(n1, n2);
     102        populate(n1, n2);
    97103        assertTrue(model.hasCoordConflict());
    98104
Note: See TracChangeset for help on using the changeset viewer.