r2.setDeleted(true);
r3.setDeleted(true);
r4.setDeleted(true);
APIDataSet apiDataSet = new APIDataSet();
// add r1 first to test functionality of APIDataSet#adjustRelationUploadOrder()
apiDataSet.getPrimitivesToDelete().add(r1);
apiDataSet.getPrimitivesToDelete().add(r2);
apiDataSet.getPrimitivesToDelete().add(r3);
apiDataSet.getPrimitivesToDelete().add(r4);
try {
apiDataSet.adjustRelationUploadOrder();
} catch(CyclicUploadDependencyException e) {
fail("unexpected exception:" + e);
}
List<OsmPrimitive> toDelete = apiDataSet.getPrimitivesToDelete();
assertEquals(4, toDelete.size());
assertEquals(true, toDelete.indexOf(r2) < toDelete.indexOf(r1));
assertEquals(true, toDelete.indexOf(r3) < toDelete.indexOf(r1));
}