Changeset 33055 in osm for applications/editors/josm/plugins/pt_assistant/test
- Timestamp:
- 2016-11-12T20:44:31+01:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java
r32874 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant; 2 3 … … 13 14 public abstract class AbstractTest { 14 15 15 public static final String PATH_TO_DL131_BEFORE = "test/data/DL131_before.osm"; // 16 public static final String PATH_TO_DL131_BEFORE = "test/data/DL131_before.osm"; // 16 17 public static final String PATH_TO_DL131_AFTER = "test/data/DL131_after.osm"; 17 18 18 19 public static final String PATH_TO_DL4_BEFORE = "test/data/DL4_before.osm"; 19 20 public static final String PATH_TO_DL4_AFTER = "test/data/DL4_after.osm"; 20 21 21 22 public static final String PATH_TO_DL49_BEFORE = "test/data/DL49_before.osm"; // has wrong way sorting 22 23 public static final String PATH_TO_DL49_AFTER = "test/data/DL49_after.osm"; 23 24 24 25 public static final String PATH_TO_DL60_BEFORE = "test/data/DL60_before.osm"; 25 26 public static final String PATH_TO_DL60_AFTER = "test/data/DL60_after.osm"; 26 27 27 28 public static final String PATH_TO_DL94_BEFORE = "test/data/DL94_before.osm"; 28 29 public static final String PATH_TO_DL94_AFTER = "test/data/DL94_after.osm"; 29 30 30 31 public static final String PATH_TO_DL286_BEFORE = "test/data/DL286_before.osm"; 31 32 public static final String PATH_TO_DL286_AFTER = "test/data/DL286_after.osm"; 32 33 33 34 public static final String PATH_TO_TEC366_BEFORE = "test/data/TL366_before.osm"; 34 35 public static final String PATH_TO_TEC366_AFTER = "test/data/TL366_after.osm"; 35 36 36 37 public static final String PATH_TO_PLATFORM_AS_WAY = "test/data/route-with-platform-as-way.osm"; 37 38 38 39 public static final String PATH_TO_ROUNDABOUT_ONEWAY = "test/data/duesseldorf_roundabout.osm"; 39 40 40 41 public static final String PATH_TO_ROAD_TYPE_ERROR = "test/data/road-type.osm"; 41 42 42 43 public static final String PATH_TO_ONEWAY_BAD_MEMBER_SORTING = "test/data/oneway-bad-member-sorting.osm"; 43 44 44 45 public static final String PATH_TO_ONEWAY_WRONG_DIRECTION = "test/data/oneway-wrong-direction.osm"; 45 46 public static final String PATH_TO_ONEWAY_WRONG_DIRECTION2 = "test/data/oneway-wrong-direction2.osm"; 46 47 47 48 public static final String PATH_TO_SOLITARY_STOP_POSITION = "test/data/solitary-stop-position.osm"; 48 49 … … 54 55 public static final String PATH_TO_STOP_AREA_MANY_PLATFORMS = "test/data/stop-area-many-platforms.osm"; 55 56 56 57 57 58 public static final String PATH_TO_SEGMENT_TEST = "test/data/segment-test.osm"; 58 59 -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/ImportUtils.java
r32506 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant; 2 3 /**4 * This class provides functionality used by multiple test classes of pt_assistant plugin.5 */6 3 7 4 import java.io.File; … … 18 15 import org.openstreetmap.josm.io.OsmImporter.OsmImporterData; 19 16 20 public class ImportUtils { 21 17 /** 18 * This class provides functionality used by multiple test classes of pt_assistant plugin. 19 */ 20 public final class ImportUtils { 21 22 22 private ImportUtils() { 23 23 // private constructor for utils classes … … 42 42 e.printStackTrace(); 43 43 } 44 44 45 45 return null; 46 47 46 } 48 49 50 51 47 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/TestUtil.java
r32883 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant; 2 3 … … 34 35 * That is needed e.g. to use {@link MapillaryLayer#getInstance()} 35 36 */ 36 public static finalsynchronized void initPlugin() {37 public static synchronized void initPlugin() { 37 38 if (!isInitialized) { 38 39 System.setProperty("josm.home", "test/data/preferences"); -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/data/RouteRepresentationTest.java
r32567 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.data; 2 3 … … 15 16 * Tests if the representation of a route relation is created correctly in the 16 17 * pt_assistant plugin 17 * 18 * 18 19 * @author darya 19 20 * 20 21 */ 21 22 public class RouteRepresentationTest extends AbstractTest { 22 23 23 24 @Test 24 25 public void correctRouteTest() { 25 26 26 27 /*- 27 28 * Create a [correct] route which has: … … 36 37 * way4 (Way) 37 38 * stop5 (platform_exit_only, Relation) 38 * 39 * 39 40 */ 40 41 41 42 ArrayList<RelationMember> members = new ArrayList<>(); 42 43 43 44 // Create stops: 44 Node n1 = new Node(); 45 Node n1 = new Node(); 45 46 n1.put("name", "Stop1"); 46 47 n1.put("public_transport", "stop_position"); … … 72 73 RelationMember rm6 = new RelationMember("platform_exit_only", n5); 73 74 members.add(rm6); 74 75 75 76 // Create ways: 76 77 Way w2 = new Way(); … … 92 93 RelationMember rm10 = new RelationMember("", w7); 93 94 members.add(rm10); 94 95 95 96 Relation route = new Relation(); 96 97 route.setMembers(members); 97 98 98 99 PTRouteDataManager manager = new PTRouteDataManager(route); 99 100 100 101 assertEquals(manager.getPTStopCount(), 5); 101 102 assertEquals(manager.getPTWayCount(), 4); 102 103 103 104 } 104 105 105 106 @Test 106 107 public void nestedRelationTest() { 107 108 108 109 // Same as above, but the nested Relation has a Node (only ways are allowed) 109 110 110 111 ArrayList<RelationMember> members = new ArrayList<>(); 111 112 112 113 // Create stops: 113 Node n1 = new Node(); 114 Node n1 = new Node(); 114 115 n1.put("name", "Stop1"); 115 116 n1.put("public_transport", "stop_position"); … … 141 142 RelationMember rm6 = new RelationMember("platform_exit_only", n5); 142 143 members.add(rm6); 143 144 144 145 // Create ways: 145 146 Way w2 = new Way(); … … 161 162 RelationMember rm10 = new RelationMember("", w7); 162 163 members.add(rm10); 163 164 164 165 165 166 Relation route = new Relation(); 166 167 route.setMembers(members); 167 168 168 169 PTRouteDataManager manager = new PTRouteDataManager(route); 169 170 170 171 assertEquals(manager.getFailedMembers().size(), 1); 171 172 assertEquals(manager.getPTStopCount(), 5); 172 173 assertEquals(manager.getPTWayCount(), 3); 173 174 174 } 175 176 175 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/data/StopToWayAssignerTest.java
r32707 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.data; 2 3 … … 14 15 15 16 public class StopToWayAssignerTest extends AbstractTest { 16 17 @Test18 public void test() {19 20 File file = new File(AbstractTest.PATH_TO_ONEWAY_BAD_MEMBER_SORTING);21 DataSet ds = ImportUtils.importOsmFile(file, "testLayer");22 23 Relation route = null;24 for (Relation r: ds.getRelations()) {25 if (r.getId() == 4552871) {26 route = r;27 break;28 }29 }30 31 PTRouteDataManager manager = new PTRouteDataManager(route);32 StopToWayAssigner assigner = new StopToWayAssigner(manager.getPTWays());33 34 // test with a [correct] stop_position:35 PTStop ptstop1 = manager.getPTStop(447358573l);36 // PTWay ptway1 = assigner.get(ptstop1);37 // Way way1 = ptway1.getWays().get(0);38 Way way1 = assigner.get(ptstop1);39 assertEquals(way1.getId(), 26956744l);40 41 // test with a [wrong] stop_position:42 PTStop ptstop2 = manager.getPTStop(427562058l);43 Way way2 = assigner.get(ptstop2);44 assertEquals(way2.getId(), 46349880l);45 46 // test with a stop_area:47 PTStop ptstop3 = manager.getPTStop(2987217064l);48 Way way3 = assigner.get(ptstop3);49 assertEquals(way3.getId(), 7045925l);50 51 // test with a platform without a stop_area:52 PTStop ptstop4 = manager.getPTStop(3327206909l);53 Way way4 = assigner.get(ptstop4);54 assertEquals(way4.getId(), 120277227l);55 56 57 }58 59 60 17 18 @Test 19 public void test() { 20 21 File file = new File(AbstractTest.PATH_TO_ONEWAY_BAD_MEMBER_SORTING); 22 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 23 24 Relation route = null; 25 for (Relation r: ds.getRelations()) { 26 if (r.getId() == 4552871) { 27 route = r; 28 break; 29 } 30 } 31 32 PTRouteDataManager manager = new PTRouteDataManager(route); 33 StopToWayAssigner assigner = new StopToWayAssigner(manager.getPTWays()); 34 35 // test with a [correct] stop_position: 36 PTStop ptstop1 = manager.getPTStop(447358573L); 37 // PTWay ptway1 = assigner.get(ptstop1); 38 // Way way1 = ptway1.getWays().get(0); 39 Way way1 = assigner.get(ptstop1); 40 assertEquals(way1.getId(), 26956744L); 41 42 // test with a [wrong] stop_position: 43 PTStop ptstop2 = manager.getPTStop(427562058L); 44 Way way2 = assigner.get(ptstop2); 45 assertEquals(way2.getId(), 46349880L); 46 47 // test with a stop_area: 48 PTStop ptstop3 = manager.getPTStop(2987217064L); 49 Way way3 = assigner.get(ptstop3); 50 assertEquals(way3.getId(), 7045925L); 51 52 // test with a platform without a stop_area: 53 PTStop ptstop4 = manager.getPTStop(3327206909L); 54 Way way4 = assigner.get(ptstop4); 55 assertEquals(way4.getId(), 120277227L); 56 } 61 57 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/AdjacentWaysTest.java
r32603 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.validation; 2 3 … … 18 19 public class AdjacentWaysTest extends AbstractTest { 19 20 20 21 21 @Test 22 public void test1() { 22 23 23 24 24 File file = new File(AbstractTest.PATH_TO_ONEWAY_WRONG_DIRECTION); 25 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 25 26 26 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 27 long id = 24215210; 28 Way way = (Way) ds.getPrimitiveById(id, OsmPrimitiveType.WAY); 29 30 assertEquals(RouteUtils.isOnewayForPublicTransport(way), -1); 31 32 Relation route = null; 33 for (Relation r : ds.getRelations()) { 34 if (r.hasKey("route")) { 35 route = r; 36 } 37 } 38 39 WayChecker wayChecker = new WayChecker(route, test); 40 Set<Way> set = wayChecker.checkAdjacentWays(way, new HashSet<Way>()); 41 42 assertEquals(set.size(), 1); 27 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 28 long id = 24215210; 29 Way way = (Way) ds.getPrimitiveById(id, OsmPrimitiveType.WAY); 43 30 44 } 45 46 @Test 47 public void test2() { 31 assertEquals(RouteUtils.isOnewayForPublicTransport(way), -1); 48 32 49 File file = new File(AbstractTest.PATH_TO_ONEWAY_WRONG_DIRECTION2); 50 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 33 Relation route = null; 34 for (Relation r : ds.getRelations()) { 35 if (r.hasKey("route")) { 36 route = r; 37 } 38 } 51 39 52 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 53 long id = 24215210; 54 Way way = (Way) ds.getPrimitiveById(id, OsmPrimitiveType.WAY); 55 56 assertEquals(RouteUtils.isOnewayForPublicTransport(way), -1); 57 58 Relation route = null; 59 for (Relation r : ds.getRelations()) { 60 if (r.hasKey("route")) { 61 route = r; 62 } 63 } 40 WayChecker wayChecker = new WayChecker(route, test); 41 Set<Way> set = wayChecker.checkAdjacentWays(way, new HashSet<Way>()); 64 42 65 WayChecker wayChecker = new WayChecker(route, test); 66 Set<Way> set = wayChecker.checkAdjacentWays(way, new HashSet<Way>()); 67 68 assertEquals(set.size(), 2); 43 assertEquals(set.size(), 1); 69 44 70 } 45 } 46 47 @Test 48 public void test2() { 49 50 File file = new File(AbstractTest.PATH_TO_ONEWAY_WRONG_DIRECTION2); 51 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 52 53 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 54 long id = 24215210; 55 Way way = (Way) ds.getPrimitiveById(id, OsmPrimitiveType.WAY); 56 57 assertEquals(RouteUtils.isOnewayForPublicTransport(way), -1); 58 59 Relation route = null; 60 for (Relation r : ds.getRelations()) { 61 if (r.hasKey("route")) { 62 route = r; 63 } 64 } 65 66 WayChecker wayChecker = new WayChecker(route, test); 67 Set<Way> set = wayChecker.checkAdjacentWays(way, new HashSet<Way>()); 68 69 assertEquals(set.size(), 2); 70 71 } 71 72 72 73 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/DirecionTestTest.java
r32647 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.validation; 2 3 … … 19 20 public class DirecionTestTest extends AbstractTest { 20 21 21 22 22 @Test 23 public void testOnewayTrue() { 23 24 24 25 25 File file = new File(AbstractTest.PATH_TO_ONEWAY_WRONG_DIRECTION); 26 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 26 27 27 28 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 28 29 29 30 List<TestError> errors = new ArrayList<>(); 30 31 31 32 33 34 35 32 for (Relation r : ds.getRelations()) { 33 WayChecker wayChecker = new WayChecker(r, test); 34 wayChecker.performDirectionTest(); 35 errors.addAll(wayChecker.getErrors()); 36 } 36 37 37 38 39 40 41 42 43 38 assertEquals(errors.size(), 2); 39 int onewayErrorCaught = 0; 40 for (TestError e : errors) { 41 if (e.getCode() == PTAssistantValidatorTest.ERROR_CODE_DIRECTION) { 42 onewayErrorCaught++; 43 } 44 } 44 45 45 46 assertEquals(onewayErrorCaught, 2); 46 47 47 48 49 50 51 52 53 54 55 56 57 58 48 boolean detectedErrorsAreCorrect = true; 49 for (TestError e : errors) { 50 if (e.getCode() == PTAssistantValidatorTest.ERROR_CODE_DIRECTION) { 51 @SuppressWarnings("unchecked") 52 Collection<OsmPrimitive> highlighted = (Collection<OsmPrimitive>) e.getHighlighted(); 53 for (OsmPrimitive highlightedPrimitive: highlighted) { 54 if (highlightedPrimitive.getId() != 225732678 && highlightedPrimitive.getId() != 24215210) { 55 detectedErrorsAreCorrect = false; 56 } 57 } 58 } 59 } 59 60 60 61 61 assertTrue(detectedErrorsAreCorrect); 62 } 62 63 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/PlatformAsWayTest.java
r32582 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.validation; 2 3 … … 14 15 import org.openstreetmap.josm.plugins.pt_assistant.ImportUtils; 15 16 16 public class PlatformAsWayTest extends AbstractTest{ 17 17 public class PlatformAsWayTest extends AbstractTest { 18 18 19 @Test 19 20 public void sortingTest() { 20 21 File file = new File(AbstractTest.PATH_TO_PLATFORM_AS_WAY); 21 22 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 22 23 23 24 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 24 25 25 26 List<TestError> errors = new ArrayList<>(); 26 27 27 28 for (Relation r: ds.getRelations()) { 28 29 30 31 32 33 34 29 WayChecker wayChecker = new WayChecker(r, test); 30 wayChecker.performDirectionTest(); 31 wayChecker.performRoadTypeTest(); 32 errors.addAll(wayChecker.getErrors()); 33 RouteChecker routeChecker = new RouteChecker(r, test); 34 routeChecker.performSortingTest(); 35 errors.addAll(routeChecker.getErrors()); 35 36 } 36 37 37 38 assertEquals(errors.size(), 0); 38 39 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/RoadTypeTestTest.java
r32582 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.validation; 2 3 … … 18 19 19 20 public class RoadTypeTestTest extends AbstractTest { 20 21 21 22 @Test 22 23 public void test() { 23 24 24 25 File file = new File(AbstractTest.PATH_TO_ROAD_TYPE_ERROR); 25 26 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 26 27 27 28 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 28 29 List<TestError> errors = new ArrayList<>(); 29 30 30 31 for (Relation r: ds.getRelations()) { 31 32 33 32 WayChecker wayChecker = new WayChecker(r, test); 33 wayChecker.performRoadTypeTest(); 34 errors.addAll(wayChecker.getErrors()); 34 35 } 35 36 36 37 assertEquals(errors.size(), 2); 37 38 38 39 for (TestError e: errors) { 39 40 assertEquals(e.getCode(), PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE); -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentCheckerTest.java
r32874 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.validation; 2 3 … … 13 14 14 15 public class SegmentCheckerTest extends AbstractTest { 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 16 17 @Test 18 public void test() { 19 20 21 File file = new File(AbstractTest.PATH_TO_SEGMENT_TEST); 22 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 23 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 24 25 Relation route = null; 26 27 for (Relation r: ds.getRelations()) { 28 if (RouteUtils.isTwoDirectionRoute(r)) { 29 route = r; 30 break; 31 } 32 } 33 34 SegmentChecker segmentChecker = new SegmentChecker(route, test); 35 segmentChecker.performStopByStopTest(); 36 assertEquals(SegmentChecker.getCorrectSegmentCount(), 27); 37 assertEquals(segmentChecker.getErrors().size(), 0); 38 39 40 41 42 } 42 43 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SolitaryStopPositionTest.java
r32616 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.validation; 3 4 import static org.junit.Assert.assertEquals; 2 5 3 6 import java.io.File; 4 7 5 8 import org.junit.Test; 6 import static org.junit.Assert.assertEquals;7 9 import org.openstreetmap.josm.data.osm.DataSet; 8 10 import org.openstreetmap.josm.data.osm.Node; … … 12 14 public class SolitaryStopPositionTest extends AbstractTest { 13 15 14 15 16 @Test 17 public void test1() { 16 18 17 18 19 19 File file = new File(AbstractTest.PATH_TO_SOLITARY_STOP_POSITION); 20 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 21 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 20 22 21 22 23 24 25 26 27 28 29 30 23 Node platform = null; 24 Node stopPosition = null; 25 for (Node n : ds.getNodes()) { 26 if (n.hasTag("public_transport", "stop_position")) { 27 stopPosition = n; 28 } 29 if (n.hasTag("public_transport", "platform")) { 30 platform = n; 31 } 32 } 31 33 32 33 34 35 36 34 NodeChecker checkerPlatform = new NodeChecker(platform, test); 35 checkerPlatform.performPlatformPartOfWayTest(); 36 assertEquals(checkerPlatform.getErrors().size(), 1); 37 assertEquals(checkerPlatform.getErrors().get(0).getCode(), 38 PTAssistantValidatorTest.ERROR_CODE_PLATFORM_PART_OF_HIGHWAY); 37 39 38 39 40 41 42 40 NodeChecker checkerStopPosition = new NodeChecker(stopPosition, test); 41 checkerStopPosition.performSolitaryStopPositionTest(); 42 assertEquals(checkerStopPosition.getErrors().size(), 1); 43 assertEquals(checkerStopPosition.getErrors().get(0).getCode(), 44 PTAssistantValidatorTest.ERROR_CODE_SOLITARY_STOP_POSITION); 43 45 44 46 } 45 47 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SortingTestTest.java
r32582 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.validation; 2 3 … … 20 21 File file = new File(AbstractTest.PATH_TO_DL131_BEFORE); 21 22 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 22 23 23 24 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 24 25 25 26 List<TestError> errors = new ArrayList<>(); 26 27 27 28 for (Relation r: ds.getRelations()) { 28 29 30 31 29 RouteChecker routeChecker = new RouteChecker(r, test); 30 routeChecker.performSortingTest(); 31 errors.addAll(routeChecker.getErrors()); 32 32 33 } 33 34 … … 41 42 File file = new File(AbstractTest.PATH_TO_DL131_AFTER); 42 43 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 43 44 44 45 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 45 46 46 47 List<TestError> errors = new ArrayList<>(); 47 48 48 49 for (Relation r: ds.getRelations()) { 49 50 51 52 50 RouteChecker routeChecker = new RouteChecker(r, test); 51 routeChecker.performSortingTest(); 52 errors.addAll(routeChecker.getErrors()); 53 53 54 } 54 55 … … 80 81 File file = new File(AbstractTest.PATH_TO_DL286_AFTER); 81 82 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 82 83 83 84 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 84 85 85 86 List<TestError> errors = new ArrayList<>(); 86 87 87 88 for (Relation r: ds.getRelations()) { 88 89 90 89 RouteChecker routeChecker = new RouteChecker(r, test); 90 routeChecker.performSortingTest(); 91 errors.addAll(routeChecker.getErrors()); 91 92 } 92 93 -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/StopCheckerTest.java
r32822 r33055 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.pt_assistant.validation; 2 3 3 4 import java.io.File; 4 5 6 import org.junit.Assert; 5 7 import org.junit.Test; 6 import org.junit.Assert;7 8 import org.openstreetmap.josm.data.osm.DataSet; 8 9 import org.openstreetmap.josm.data.osm.Node; … … 13 14 public class StopCheckerTest extends AbstractTest { 14 15 15 16 16 @Test 17 public void nodePartOfStopAreaTest() { 17 18 18 // check if stop positions or platforms are in any stop_area relation: 19 20 File file = new File(AbstractTest.PATH_TO_STOP_AREA_MEMBERS); 21 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 22 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 23 Node node = null; 24 25 for (Node n : ds.getNodes()) { 26 if (n.hasTag("public_transport", "stop_position") | n.hasTag("public_transport", "platform")) { 27 node = n; 28 } 29 } 19 // check if stop positions or platforms are in any stop_area relation: 30 20 31 NodeChecker nodeChecker = new NodeChecker(node, test); 32 nodeChecker.performNodePartOfStopAreaTest(); 33 Assert.assertEquals(nodeChecker.getErrors().size(), 1); 34 Assert.assertEquals(nodeChecker.getErrors().get(0).getCode(), 35 PTAssistantValidatorTest.ERROR_CODE_NOT_PART_OF_STOP_AREA); 36 } 37 21 File file = new File(AbstractTest.PATH_TO_STOP_AREA_MEMBERS); 22 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 23 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 24 Node node = null; 38 25 26 for (Node n : ds.getNodes()) { 27 if (n.hasTag("public_transport", "stop_position") | n.hasTag("public_transport", "platform")) { 28 node = n; 29 } 30 } 39 31 40 @Test 41 public void stopAreaRelationsTest() { 42 43 // Check if stop positions belong the same routes as related platform(s) 44 45 File file = new File(AbstractTest.PATH_TO_STOP_AREA_RELATIONS); 46 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 47 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 48 Relation stopArea = null; 49 50 for (Relation r : ds.getRelations()) { 51 if (r.hasTag("public_transport", "stop_area")) { 52 stopArea = r; 53 } 54 } 55 56 StopChecker stopChecker = new StopChecker(stopArea, test); 57 stopChecker.performStopAreaRelationsTest(); 58 Assert.assertEquals(stopChecker.getErrors().size(), 1); 59 Assert.assertEquals(stopChecker.getErrors().get(0).getCode(), 60 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_COMPARE_RELATIONS); 61 } 62 32 NodeChecker nodeChecker = new NodeChecker(node, test); 33 nodeChecker.performNodePartOfStopAreaTest(); 34 Assert.assertEquals(nodeChecker.getErrors().size(), 1); 35 Assert.assertEquals(nodeChecker.getErrors().get(0).getCode(), 36 PTAssistantValidatorTest.ERROR_CODE_NOT_PART_OF_STOP_AREA); 37 } 63 38 64 @Test 65 public void stopAreaStopPositionTest() { 66 67 // Check if stop area relation has at least one stop position. 68 69 File file = new File(AbstractTest.PATH_TO_STOP_AREA_NO_STOPS); 70 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 71 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 72 Relation stopArea = null; 39 @Test 40 public void stopAreaRelationsTest() { 73 41 74 for (Relation r : ds.getRelations()) { 75 if (r.hasTag("public_transport", "stop_area")) { 76 stopArea = r; 77 } 78 } 79 80 StopChecker stopChecker = new StopChecker(stopArea, test); 81 stopChecker.performStopAreaStopPositionTest(); 82 Assert.assertEquals(stopChecker.getErrors().size(), 1); 83 Assert.assertEquals(stopChecker.getErrors().get(0).getCode(), 84 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_NO_STOPS); 42 // Check if stop positions belong the same routes as related platform(s) 85 43 86 } 87 44 File file = new File(AbstractTest.PATH_TO_STOP_AREA_RELATIONS); 45 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 46 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 47 Relation stopArea = null; 88 48 89 @Test 90 public void stopAreaPlatformTest() { 91 92 // Check if stop area relation has at least one platform. 93 94 File file = new File(AbstractTest.PATH_TO_STOP_AREA_NO_PLATFORMS); 95 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 96 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 97 Relation stopArea = null; 49 for (Relation r : ds.getRelations()) { 50 if (r.hasTag("public_transport", "stop_area")) { 51 stopArea = r; 52 } 53 } 98 54 99 for (Relation r : ds.getRelations()) { 100 if (r.hasTag("public_transport", "stop_area")) { 101 stopArea = r; 102 } 103 } 104 105 StopChecker stopChecker = new StopChecker(stopArea, test); 106 stopChecker.performStopAreaPlatformTest(); 107 Assert.assertEquals(stopChecker.getErrors().size(), 1); 108 Assert.assertEquals(stopChecker.getErrors().get(0).getCode(), 109 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_NO_PLATFORM); 55 StopChecker stopChecker = new StopChecker(stopArea, test); 56 stopChecker.performStopAreaRelationsTest(); 57 Assert.assertEquals(stopChecker.getErrors().size(), 1); 58 Assert.assertEquals(stopChecker.getErrors().get(0).getCode(), 59 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_COMPARE_RELATIONS); 60 } 110 61 111 } 62 @Test 63 public void stopAreaStopPositionTest() { 112 64 65 // Check if stop area relation has at least one stop position. 66 67 File file = new File(AbstractTest.PATH_TO_STOP_AREA_NO_STOPS); 68 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 69 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 70 Relation stopArea = null; 71 72 for (Relation r : ds.getRelations()) { 73 if (r.hasTag("public_transport", "stop_area")) { 74 stopArea = r; 75 } 76 } 77 78 StopChecker stopChecker = new StopChecker(stopArea, test); 79 stopChecker.performStopAreaStopPositionTest(); 80 Assert.assertEquals(stopChecker.getErrors().size(), 1); 81 Assert.assertEquals(stopChecker.getErrors().get(0).getCode(), 82 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_NO_STOPS); 83 } 84 85 @Test 86 public void stopAreaPlatformTest() { 87 88 // Check if stop area relation has at least one platform. 89 90 File file = new File(AbstractTest.PATH_TO_STOP_AREA_NO_PLATFORMS); 91 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 92 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 93 Relation stopArea = null; 94 95 for (Relation r : ds.getRelations()) { 96 if (r.hasTag("public_transport", "stop_area")) { 97 stopArea = r; 98 } 99 } 100 101 StopChecker stopChecker = new StopChecker(stopArea, test); 102 stopChecker.performStopAreaPlatformTest(); 103 Assert.assertEquals(stopChecker.getErrors().size(), 1); 104 Assert.assertEquals(stopChecker.getErrors().get(0).getCode(), 105 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_NO_PLATFORM); 106 107 } 113 108 }
Note:
See TracChangeset
for help on using the changeset viewer.