Changeset 6776 in josm for trunk/test


Ignore:
Timestamp:
2014-01-29T22:41:40+01:00 (11 years ago)
Author:
simon04
Message:

fix #9624 - Create a sensible upload order of relations to be deleted

This fixes "Precondition failed: The relation X is used in relation Y" when X and Y are to be deleted

File:
1 edited

Legend:

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

    r6471 r6776  
    145145    }
    146146
     147    @Test // for ticket #9624
     148    public void deleteOneParentTwoNewChildren() {
     149        DataSet ds = new DataSet();
     150        Relation r1 = new Relation(1);
     151        ds.addPrimitive(r1);
     152        r1.put("name", "r1");
     153
     154        Relation r2 = new Relation(2);
     155        ds.addPrimitive(r2);
     156        r2.put("name", "r2");
     157
     158        Relation r3 = new Relation(3);
     159        ds.addPrimitive(r3);
     160        r3.put("name", "r3");
     161
     162        Relation r4 = new Relation(4);
     163        ds.addPrimitive(r4);
     164        r4.put("name", "unrelated");
     165
     166
     167        r1.addMember(new RelationMember("", r2));
     168        r1.addMember(new RelationMember("", r3));
     169
     170        r1.setDeleted(true);
     171        r2.setDeleted(true);
     172        r3.setDeleted(true);
     173        r4.setDeleted(true);
     174
     175
     176        APIDataSet apiDataSet = new APIDataSet();
     177        apiDataSet.init(ds);
     178        try {
     179            apiDataSet.adjustRelationUploadOrder();
     180        } catch(CyclicUploadDependencyException e) {
     181            fail("unexpected exception:" + e);
     182        }
     183        List<OsmPrimitive> toDelete = apiDataSet.getPrimitivesToDelete();
     184
     185        assertEquals(4, toDelete.size());
     186        assertEquals(true, toDelete.indexOf(r2) < toDelete.indexOf(r1));
     187        assertEquals(true, toDelete.indexOf(r3) < toDelete.indexOf(r1));
     188        assertEquals(true, toDelete.indexOf(r3) < toDelete.indexOf(r1));
     189    }
     190
    147191    @Test
    148192    public void oneCycle() {
Note: See TracChangeset for help on using the changeset viewer.