Ignore:
Timestamp:
2017-07-14T18:51:47+02:00 (7 years ago)
Author:
giackserva
Message:

[pt_assistant] #josm14977 - unit tests

Location:
applications/editors/josm/plugins/pt_assistant
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SortPTStopsAction.java

    r33442 r33446  
    2121import org.openstreetmap.josm.actions.relation.DownloadSelectedIncompleteMembersAction;
    2222import org.openstreetmap.josm.command.ChangeCommand;
    23 import org.openstreetmap.josm.command.Command;
    2423import org.openstreetmap.josm.data.coor.EastNorth;
    2524import org.openstreetmap.josm.data.osm.Node;
     
    4443public class SortPTStopsAction extends JosmAction {
    4544
    46     private static final long serialVersionUID = 1714879296430852530L;
    4745    private static final String ACTION_NAME = "Sort PT Stops";
    4846
     
    8785
    8886    private void continueAfterDownload(Relation rel) {
    89         Main.main.undoRedo.add(getSortPTStopCommand(rel));
    90     }
    91 
    92     public Command getSortPTStopCommand(Relation rel) {
    9387        Relation newRel = new Relation(rel);
    94         List<RelationMember> members = newRel.getMembers();
     88        sortPTStops(newRel);
     89        Main.main.undoRedo.add(new ChangeCommand(rel, newRel));
     90    }
     91
     92    public void sortPTStops(Relation rel) {
     93        List<RelationMember> members = rel.getMembers();
    9594        for (int i = 0; i < members.size(); i++) {
    96             newRel.removeMember(0);
     95            rel.removeMember(0);
    9796        }
    9897        members = new RelationSorter().sortMembers(members);
     
    154153                        if (stop != null) {
    155154                            if (stop.getStopPositionRM() != null)
    156                                 newRel.addMember(stop.getStopPositionRM());
     155                                rel.addMember(stop.getStopPositionRM());
    157156                            if (stop.getPlatformRM() != null)
    158                                 newRel.addMember(stop.getPlatformRM());
     157                                rel.addMember(stop.getPlatformRM());
    159158                        }
    160159                    });
     
    164163        }
    165164
    166         wayMembers.forEach(newRel::addMember);
    167 
    168         return new ChangeCommand(rel, newRel);
     165        wayMembers.forEach(rel::addMember);
    169166    }
    170167
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java

    r33404 r33446  
    4040 public static final String PATH_TO_ROUNDABOUT_ONEWAY = "test/data/duesseldorf_roundabout.osm";
    4141
     42 public static final String PATH_TO_SORT_PT_STOPS = "test/data/sort_test.osm";
     43
    4244 public static final String PATH_TO_ROAD_TYPE_ERROR = "test/data/road-type.osm";
    4345
Note: See TracChangeset for help on using the changeset viewer.