* the simulationstatistic plugin
*/
@Test
public void testInternalIDs(){
initTestCase();
ModelManager mm = ModelManager.getInstance();
// map all edges of the current map to their ids
Map<String, EdgeModel> edges = new HashMap<String, EdgeModel>();
for (ModelElement element : allModelElements) {
//for all ways
if (element instanceof WayModel) {
WayModel way = (WayModel) element;
//store all edges
for (EdgeModel edge: way.getBackwardEdges()){
edges.put(edge.getInternalID(), edge);
}
for (EdgeModel edge: way.getForwardEdges()){
edges.put(edge.getInternalID(), edge);
}
}
}
//check if internal ids are the same
for (ModelElement element : mm.getAllModelElements()){
//for all ways
if (element instanceof WayModel) {
WayModel way = (WayModel) element;
//store all edges
for (EdgeModel edge: way.getBackwardEdges()){
Assert.assertEquals(
edge.getId(),
edges.get(edge.getInternalID()).getId());
}
for (EdgeModel edge: way.getForwardEdges()){
Assert.assertEquals(
edge.getId(),
edges.get(edge.getInternalID()).getId());
}
}
}
PersistenceManager.getInstance().saveToFile(DIR_SAVE + "out.ewd");
mm.clearModel();
Assert.assertEquals(0,mm.getAllModelElements().size());
mm.clearModel();
PersistenceManager.getInstance().loadFromFile(DIR_SAVE + "out.ewd");
//check again if internal ids are the same
for (ModelElement element : mm.getAllModelElements()){
//for all ways
if (element instanceof WayModel) {
WayModel way = (WayModel) element;
//store all edges
for (EdgeModel edge: way.getBackwardEdges()){