Changeset 1753 in josm for trunk/test/unit


Ignore:
Timestamp:
2009-07-08T22:58:37+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #2245: Merge layers doesn't update the "action" tags

File:
1 edited

Legend:

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

    r1751 r1753  
    55import static org.junit.Assert.assertTrue;
    66import static org.junit.Assert.fail;
     7
    78
    89import java.io.File;
     
    2122import org.openstreetmap.josm.data.osm.DataSet;
    2223import org.openstreetmap.josm.data.osm.Node;
     24import org.openstreetmap.josm.data.osm.Relation;
     25import org.openstreetmap.josm.data.osm.RelationMember;
    2326import org.openstreetmap.josm.data.osm.User;
    2427import org.openstreetmap.josm.data.osm.Way;
     
    855858        assertEquals(theirWay.getTimestamp(), myWay.getTimestamp());
    856859    }
     860
     861
     862    /**
     863     * My dataset includes a deleted node.
     864     * Their dataset includes a way with three nodes, the first one being my node.
     865     *
     866     * => the merged way should include two nodes only. the deleted node should still be
     867     * in the data set
     868     *
     869     */
     870    @Test
     871    public void wayComplex_mergingADeletedNode() {
     872
     873        DataSet my = new DataSet();
     874        my.version = "0.6";
     875
     876        Node n1 = new Node(new LatLon(0,0));
     877        n1.id = 1;
     878        n1.version = 1;
     879        n1.delete(true);
     880        my.addPrimitive(n1);
     881
     882        DataSet their = new DataSet();
     883        their.version = "0.6";
     884
     885        Node n3 = new Node(new LatLon(0,0));
     886        n3.id = 1;
     887        n3.version = 1;
     888        their.addPrimitive(n3);
     889
     890        Node n4 = new Node(new LatLon(1,1));
     891        n4.id = 2;
     892        n4.version = 1;
     893        their.addPrimitive(n4);
     894
     895        Node n5 = new Node(new LatLon(2,2));
     896        n5.id = 3;
     897        n5.version = 1;
     898        their.addPrimitive(n5);
     899
     900
     901        Way theirWay = new Way();
     902        theirWay.id = 4;
     903        theirWay.version = 1;
     904        theirWay.nodes.add(n3);
     905        theirWay.nodes.add(n4);
     906        theirWay.nodes.add(n5);
     907        theirWay.user = User.get("their");
     908        theirWay.user.uid = "1111";
     909        theirWay.setTimestamp(new Date());
     910        their.addPrimitive(theirWay);
     911
     912        MergeVisitor visitor = new MergeVisitor(my,their);
     913        visitor.merge();
     914
     915        assertEquals(0,visitor.getConflicts().size());
     916
     917        Way myWay = (Way)my.getPrimitiveById(4);
     918        assertEquals(2, myWay.nodes.size());
     919
     920        Node n = (Node)my.getPrimitiveById(1);
     921        assertTrue(n != null);
     922    }
     923
     924    /**
     925     * My dataset includes a deleted node.
     926     * Their dataset includes a relation with thre nodes, the first one being my node.
     927     *
     928     * => the merged relation should include two nodes only. the deleted node should still be
     929     * in the data set
     930     *
     931     */
     932    @Test
     933    public void relationComplex_mergingADeletedNode() {
     934
     935        DataSet my = new DataSet();
     936        my.version = "0.6";
     937
     938        Node n1 = new Node(new LatLon(0,0));
     939        n1.id = 1;
     940        n1.version = 1;
     941        n1.delete(true);
     942        my.addPrimitive(n1);
     943
     944        DataSet their = new DataSet();
     945        their.version = "0.6";
     946
     947        Node n3 = new Node(new LatLon(0,0));
     948        n3.id = 1;
     949        n3.version = 1;
     950        their.addPrimitive(n3);
     951
     952        Node n4 = new Node(new LatLon(1,1));
     953        n4.id = 2;
     954        n4.version = 1;
     955        their.addPrimitive(n4);
     956
     957        Node n5 = new Node(new LatLon(2,2));
     958        n5.id = 3;
     959        n5.version = 1;
     960        their.addPrimitive(n5);
     961
     962
     963        Relation theirRelation = new Relation();
     964        theirRelation.id = 4;
     965        theirRelation.version = 1;
     966        theirRelation.members.add(new RelationMember("", n3));
     967        theirRelation.members.add(new RelationMember("", n4));
     968        theirRelation.members.add(new RelationMember("", n5));
     969        their.addPrimitive(theirRelation);
     970
     971        MergeVisitor visitor = new MergeVisitor(my,their);
     972        visitor.merge();
     973
     974        assertEquals(0,visitor.getConflicts().size());
     975
     976        Relation r = (Relation)my.getPrimitiveById(4);
     977        assertEquals(2, r.members.size());
     978
     979        Node n = (Node)my.getPrimitiveById(1);
     980        assertTrue(n != null);
     981    }
     982
     983
     984
     985
    857986}
Note: See TracChangeset for help on using the changeset viewer.