r4.setModified(true);
r1.addMember(new RelationMember("", r2));
r2.addMember(new RelationMember("", r3));
APIDataSet apiDataSet = new APIDataSet();
apiDataSet.init(ds);
try {
apiDataSet.adjustRelationUploadOrder();
} catch(CyclicUploadDependencyException e) {
fail("unexpected exception:" + e);
}
List<OsmPrimitive> toAdd = apiDataSet.getPrimitivesToAdd();
assertEquals(3, toAdd.size());
assertEquals(r3, toAdd.get(0));
assertEquals(r2, toAdd.get(1));
assertEquals(r1, toAdd.get(2));
List<OsmPrimitive> toUpdate = apiDataSet.getPrimitivesToUpdate();
assertEquals(1, toUpdate.size());
assertEquals(r4, toUpdate.get(0));
}