Ignore:
Timestamp:
2016-07-05T00:28:27+02:00 (8 years ago)
Author:
darya
Message:

removed old classes, updated unit tests, added AddStopPositionAction

Location:
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/data/RouteRepresentationTest.java

    r32506 r32567  
    22
    33import static org.junit.Assert.assertEquals;
    4 import static org.junit.Assert.assertTrue;
    54
    65import java.util.ArrayList;
     
    3130         * stop2(platform, Way)
    3231         * way2 (Way)
    33          * stop3 (stop_area)
     32         * stop3 (platform)
    3433         * way3 (Relation that consists of Ways only)
    3534         * stop4 (stop_position)
     
    4544        Node n1 = new Node();
    4645        n1.put("name", "Stop1");
     46        n1.put("public_transport", "stop_position");
    4747        RelationMember rm1 = new RelationMember("stop", n1);
    4848        members.add(rm1);
     
    5252        RelationMember rm2 = new RelationMember("platform", w1);
    5353        members.add(rm2);
    54         Relation r1 = new Relation();
    55         r1.put("name", "Stop3");
    56         RelationMember rm3 = new RelationMember("stop_area", r1);
     54        Node n2 = new Node();
     55        n2.put("name", "Stop3");
     56        n2.put("public_transport", "platform");
     57        RelationMember rm3 = new RelationMember("platform", n2);
    5758        members.add(rm3);
    58         Node n2 = new Node();
    59         n2.put("name", "Stop4");
    60         RelationMember rm4 = new RelationMember("stop", n2);
    61         members.add(rm4);
    6259        Node n3 = new Node();
    6360        n3.put("name", "Stop4");
    64         RelationMember rm5 = new RelationMember("platform", n3);
     61        n3.put("public_transport", "stop_position");
     62        RelationMember rm4 = new RelationMember("stop", n3);
     63        members.add(rm4);
     64        Node n4 = new Node();
     65        n4.put("name", "Stop4");
     66        n4.put("public_transport", "platform");
     67        RelationMember rm5 = new RelationMember("platform", n4);
    6568        members.add(rm5);
    66         Relation r2 = new Relation();
    67         r2.put("name", "Stop5");
    68         r2.put("highway", "platform_exit_only");
    69         RelationMember rm6 = new RelationMember("platform_exit_only", r2);
     69        Node n5 = new Node();
     70        n5.put("name", "Stop5");
     71        n5.put("highway", "platform");
     72        RelationMember rm6 = new RelationMember("platform_exit_only", n5);
    7073        members.add(rm6);
    7174               
     
    9093        members.add(rm10);
    9194       
    92 
    93        
    9495        Relation route = new Relation();
    9596        route.setMembers(members);
     
    112113        Node n1 = new Node();
    113114        n1.put("name", "Stop1");
     115        n1.put("public_transport", "stop_position");
    114116        RelationMember rm1 = new RelationMember("stop", n1);
    115117        members.add(rm1);
     
    119121        RelationMember rm2 = new RelationMember("platform", w1);
    120122        members.add(rm2);
    121         Relation r1 = new Relation();
    122         r1.put("name", "Stop3");
    123         RelationMember rm3 = new RelationMember("stop_area", r1);
     123        Node n2 = new Node();
     124        n2.put("name", "Stop3");
     125        n2.put("public_transport", "platform");
     126        RelationMember rm3 = new RelationMember("platform", n2);
    124127        members.add(rm3);
    125         Node n2 = new Node();
    126         n2.put("name", "Stop4");
    127         RelationMember rm4 = new RelationMember("stop", n2);
    128         members.add(rm4);
    129128        Node n3 = new Node();
    130129        n3.put("name", "Stop4");
    131         RelationMember rm5 = new RelationMember("platform", n3);
     130        n3.put("public_transport", "stop_position");
     131        RelationMember rm4 = new RelationMember("stop", n3);
     132        members.add(rm4);
     133        Node n4 = new Node();
     134        n4.put("name", "Stop4");
     135        n4.put("public_transport", "platform");
     136        RelationMember rm5 = new RelationMember("platform", n4);
    132137        members.add(rm5);
    133         Relation r2 = new Relation();
    134         r2.put("name", "Stop5");
    135         r2.put("highway", "platform_exit_only");
    136         RelationMember rm6 = new RelationMember("platform_exit_only", r2);
     138        Node n5 = new Node();
     139        n5.put("name", "Stop5");
     140        n5.put("highway", "platform");
     141        RelationMember rm6 = new RelationMember("platform_exit_only", n5);
    137142        members.add(rm6);
    138143               
     
    146151        Relation r3 = new Relation(); // nested relation
    147152        Way w4 = new Way();
    148         Node wrongNode = new Node(); // CHANGED COMPARED TO PREVIOUS TEST
     153        Node wrongNode = new Node();
    149154        Way w6 = new Way();
    150155        r3.addMember(new RelationMember("", w4));
    151         r3.addMember(new RelationMember("platform", wrongNode));
     156        r3.addMember(new RelationMember("", wrongNode));
    152157        r3.addMember(new RelationMember("", w6));
    153158        RelationMember rm9 = new RelationMember("", r3);
     
    161166        route.setMembers(members);
    162167       
    163         boolean thrown = false;
    164         String message = "";
    165         try {
    166             /*PTRouteDataManager manager =*/ new PTRouteDataManager(route);
    167         } catch(IllegalArgumentException e) {
    168             thrown = true;
    169             message = e.getMessage();
    170         }
     168        PTRouteDataManager manager = new PTRouteDataManager(route);
    171169       
    172         assertTrue(thrown);
    173         assertEquals(message, "A route relation member of OsmPrimitiveType.RELATION can only have ways as members");
     170        assertEquals(manager.getFailedMembers().size(), 1);
     171        assertEquals(manager.getPTStopCount(), 5);
     172        assertEquals(manager.getPTWayCount(), 3);
    174173       
    175174    }
    176175   
    177    
    178     @Test
    179     public void multipleStopElementTest() {
    180        
    181         // Same as correctRouteTest(), but
    182        
    183         ArrayList<RelationMember> members = new ArrayList<>();
    184        
    185         // Create stops:
    186         Node n1 = new Node();
    187         n1.put("name", "Stop1");
    188         RelationMember rm1 = new RelationMember("stop", n1);
    189         members.add(rm1);
    190         Way w1 = new Way();
    191         w1.put("name", "Stop2");
    192         w1.put("highway", "platform");
    193         RelationMember rm2 = new RelationMember("platform", w1);
    194         members.add(rm2);
    195         Relation r1 = new Relation();
    196         r1.put("name", "Stop3");
    197         RelationMember rm3 = new RelationMember("stop_area", r1);
    198         members.add(rm3);
    199         Node n2 = new Node();
    200         n2.put("name", "Stop4");
    201         RelationMember rm4 = new RelationMember("stop", n2);
    202         members.add(rm4);
    203         Node n3 = new Node();
    204         n3.put("name", "Stop4");
    205         RelationMember rm5 = new RelationMember("platform", n3);
    206         members.add(rm5);
    207         Relation r2 = new Relation();
    208         r2.put("name", "Stop5");
    209         r2.put("highway", "platform_exit_only");
    210         RelationMember rm6 = new RelationMember("platform_exit_only", r2);
    211         members.add(rm6);
    212                
    213         // Create ways:
    214         Way w2 = new Way();
    215         RelationMember rm7 = new RelationMember("", w2);
    216         members.add(rm7);
    217         Way w3 = new Way();
    218         RelationMember rm8 = new RelationMember("", w3);
    219         members.add(rm8);
    220         Relation r3 = new Relation(); // nested relation
    221         Way w4 = new Way();
    222         Way w5 = new Way();
    223         Way w6 = new Way();
    224         r3.addMember(new RelationMember("", w4));
    225         r3.addMember(new RelationMember("", w5));
    226         r3.addMember(new RelationMember("", w6));
    227         RelationMember rm9 = new RelationMember("", r3);
    228         members.add(rm9);
    229         Way w7 = new Way();
    230         RelationMember rm10 = new RelationMember("", w7);
    231         members.add(rm10);
    232        
    233 
    234        
    235         Relation route = new Relation();
    236         route.setMembers(members);
    237        
    238         PTRouteDataManager manager = new PTRouteDataManager(route);
    239    
    240         assertEquals(manager.getPTStopCount(), 5);
    241         assertEquals(manager.getPTWayCount(), 4);
    242        
    243     }
    244    
    245 
    246176}
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/DirecionTestTest.java

    r32506 r32567  
    55
    66import java.io.File;
     7import java.util.ArrayList;
    78import java.util.List;
    89
     
    1920    @Test
    2021    public void test() {
    21         // this file has:
    22         // Way
    23        
    2422       
    2523        File file = new File(AbstractTest.PATH_TO_ROUNDABOUT_ONEWAY);
    2624        DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
     25       
     26        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
    2727       
    2828        Relation route = null;
     
    3535        assertEquals(route.getMembersCount(), 213);
    3636               
    37         DirectionTest directionTest = new DirectionTest();
     37        List<TestError> errors = new ArrayList<>();
     38       
    3839        for (Relation r: ds.getRelations()) {
    39             directionTest.visit(r);
     40                WayChecker wayChecker = new WayChecker(r, test);
     41                wayChecker.performDirectionTest();
     42                errors.addAll(wayChecker.getErrors());
    4043        }
    4144       
    42         List<TestError> errors = directionTest.getErrors();
    4345        assertEquals(errors.size(), 1);
    4446        int onewayErrorCaught = 0;
    4547        for (TestError e: errors ) {
    46             if (e.getCode() == DirectionTest.ERROR_CODE_DIRECTION) {
     48            if (e.getCode() == PTAssitantValidatorTest.ERROR_CODE_DIRECTION) {
    4749                onewayErrorCaught++;
    4850            }
     
    5557        boolean detectedErrorsAreCorrect = true;
    5658        for (TestError e: errors) {
    57             if (e.getCode() == DirectionTest.ERROR_CODE_DIRECTION) {
     59            if (e.getCode() == PTAssitantValidatorTest.ERROR_CODE_DIRECTION) {
    5860                @SuppressWarnings("unchecked")
    5961                List<OsmPrimitive> highlighted = (List<OsmPrimitive>) e.getHighlighted();
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/PlatformAsWayTest.java

    r32506 r32567  
    44
    55import java.io.File;
     6import java.util.ArrayList;
    67import java.util.List;
    78
     
    2021        DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
    2122       
    22         GapTest gapTest = new GapTest();
     23        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
     24       
     25        List<TestError> errors = new ArrayList<>();
     26       
    2327        for (Relation r: ds.getRelations()) {
    24             gapTest.visit(r);
     28                WayChecker wayChecker = new WayChecker(r, test);
     29                wayChecker.performDirectionTest();
     30                wayChecker.performRoadTypeTest();
     31                errors.addAll(wayChecker.getErrors());
     32                RouteChecker routeChecker = new RouteChecker(r, test);
     33                routeChecker.performSortingTest();
     34                errors.addAll(routeChecker.getErrors());
    2535        }
    26        
    27         List<TestError> errors = gapTest.getErrors();
    2836       
    2937        assertEquals(errors.size(), 0);
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/RoadTypeTestTest.java

    r32506 r32567  
    55
    66import java.io.File;
     7import java.util.ArrayList;
    78import java.util.List;
    89
     
    2425        DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
    2526       
    26         RoadTypeTest roadTypeTest = new RoadTypeTest();
     27        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
     28        List<TestError> errors = new ArrayList<>();
     29       
    2730        for (Relation r: ds.getRelations()) {
    28             roadTypeTest.visit(r);
     31                WayChecker wayChecker = new WayChecker(r, test);
     32                wayChecker.performRoadTypeTest();
     33                errors.addAll(wayChecker.getErrors());
    2934        }
    3035       
    31         List<TestError> errors = roadTypeTest.getErrors();
    3236        assertEquals(errors.size(), 2);
    3337       
    3438        for (TestError e: errors) {
    35             assertEquals(e.getCode(), RoadTypeTest.ERROR_CODE_ROAD_TYPE);
     39            assertEquals(e.getCode(), PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE);
    3640            @SuppressWarnings("unchecked")
    3741            List<OsmPrimitive> highlighted = (List<OsmPrimitive>) e.getHighlighted();
Note: See TracChangeset for help on using the changeset viewer.