Ignore:
Timestamp:
2016-07-08T22:37:38+02:00 (9 years ago)
Author:
darya
Message:

Solitary stop position test

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

Legend:

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

    r32603 r32616  
    4444 public static final String PATH_TO_ONEWAY_WRONG_DIRECTION = "test/data/oneway-wrong-direction.osm";
    4545 public static final String PATH_TO_ONEWAY_WRONG_DIRECTION2 = "test/data/oneway-wrong-direction2.osm";
     46 
     47 public static final String PATH_TO_SOLITARY_STOP_POSITION = "test/data/solitary-stop-position.osm";
    4648
    4749  /**
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/DirecionTestTest.java

    r32603 r32616  
    1717
    1818public class DirecionTestTest extends AbstractTest {
    19    
    20     @Test
    21     public void testOnewayTrue() {
    22        
    23         File file = new File(AbstractTest.PATH_TO_ONEWAY_WRONG_DIRECTION);
    24         DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
    25        
    26         PTAssistantValidatorTest test = new PTAssistantValidatorTest();
    27        
    28         Relation route = null;
    29         for (Relation r: ds.getRelations()) {
    30             if (r.hasKey("route")) {
    31                 route = r;
    32             }
    33         }
    34        
    35              
    36         List<TestError> errors = new ArrayList<>();
    37        
    38         for (Relation r: ds.getRelations()) {
    39                 WayChecker wayChecker = new WayChecker(r, test);
    40                 wayChecker.performDirectionTest();
    41                 errors.addAll(wayChecker.getErrors());
    42         }
    43        
    44         assertEquals(errors.size(), 2);
    45         int onewayErrorCaught = 0;
    46         for (TestError e: errors ) {
    47             if (e.getCode() == PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
    48                 onewayErrorCaught++;
    49             }
    50         }
    51        
    52         assertEquals(onewayErrorCaught, 2);
    53        
    54         // fix the direction errors:
    55        
    56         boolean detectedErrorsAreCorrect = true;
    57         for (TestError e: errors) {
    58             if (e.getCode() == PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
    59                 @SuppressWarnings("unchecked")
    60                 List<OsmPrimitive> highlighted = (List<OsmPrimitive>) e.getHighlighted();
    61                 if (highlighted.get(0).getId() != 225732678 && highlighted.get(0).getId() != 24215210)  {
    62                     detectedErrorsAreCorrect = false;
    63                 }
    64             }
    65         }
    66        
    67         assertTrue(detectedErrorsAreCorrect);
    68     }
     19
     20        @Test
     21        public void testOnewayTrue() {
     22
     23                File file = new File(AbstractTest.PATH_TO_ONEWAY_WRONG_DIRECTION);
     24                DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
     25
     26                PTAssistantValidatorTest test = new PTAssistantValidatorTest();
     27
     28                List<TestError> errors = new ArrayList<>();
     29
     30                for (Relation r : ds.getRelations()) {
     31                        WayChecker wayChecker = new WayChecker(r, test);
     32                        wayChecker.performDirectionTest();
     33                        errors.addAll(wayChecker.getErrors());
     34                }
     35
     36                assertEquals(errors.size(), 2);
     37                int onewayErrorCaught = 0;
     38                for (TestError e : errors) {
     39                        if (e.getCode() == PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
     40                                onewayErrorCaught++;
     41                        }
     42                }
     43
     44                assertEquals(onewayErrorCaught, 2);
     45
     46                // fix the direction errors:
     47
     48                boolean detectedErrorsAreCorrect = true;
     49                for (TestError e : errors) {
     50                        if (e.getCode() == PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
     51                                @SuppressWarnings("unchecked")
     52                                List<OsmPrimitive> highlighted = (List<OsmPrimitive>) e.getHighlighted();
     53                                if (highlighted.get(0).getId() != 225732678 && highlighted.get(0).getId() != 24215210) {
     54                                        detectedErrorsAreCorrect = false;
     55                                }
     56                        }
     57                }
     58
     59                assertTrue(detectedErrorsAreCorrect);
     60        }
    6961}
Note: See TracChangeset for help on using the changeset viewer.