Changeset 32567 in osm for applications/editors/josm/plugins/pt_assistant/test/unit
- Timestamp:
- 2016-07-05T00:28:27+02:00 (8 years ago)
- 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 2 2 3 3 import static org.junit.Assert.assertEquals; 4 import static org.junit.Assert.assertTrue;5 4 6 5 import java.util.ArrayList; … … 31 30 * stop2(platform, Way) 32 31 * way2 (Way) 33 * stop3 ( stop_area)32 * stop3 (platform) 34 33 * way3 (Relation that consists of Ways only) 35 34 * stop4 (stop_position) … … 45 44 Node n1 = new Node(); 46 45 n1.put("name", "Stop1"); 46 n1.put("public_transport", "stop_position"); 47 47 RelationMember rm1 = new RelationMember("stop", n1); 48 48 members.add(rm1); … … 52 52 RelationMember rm2 = new RelationMember("platform", w1); 53 53 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); 57 58 members.add(rm3); 58 Node n2 = new Node();59 n2.put("name", "Stop4");60 RelationMember rm4 = new RelationMember("stop", n2);61 members.add(rm4);62 59 Node n3 = new Node(); 63 60 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); 65 68 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); 70 73 members.add(rm6); 71 74 … … 90 93 members.add(rm10); 91 94 92 93 94 95 Relation route = new Relation(); 95 96 route.setMembers(members); … … 112 113 Node n1 = new Node(); 113 114 n1.put("name", "Stop1"); 115 n1.put("public_transport", "stop_position"); 114 116 RelationMember rm1 = new RelationMember("stop", n1); 115 117 members.add(rm1); … … 119 121 RelationMember rm2 = new RelationMember("platform", w1); 120 122 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); 124 127 members.add(rm3); 125 Node n2 = new Node();126 n2.put("name", "Stop4");127 RelationMember rm4 = new RelationMember("stop", n2);128 members.add(rm4);129 128 Node n3 = new Node(); 130 129 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); 132 137 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); 137 142 members.add(rm6); 138 143 … … 146 151 Relation r3 = new Relation(); // nested relation 147 152 Way w4 = new Way(); 148 Node wrongNode = new Node(); // CHANGED COMPARED TO PREVIOUS TEST153 Node wrongNode = new Node(); 149 154 Way w6 = new Way(); 150 155 r3.addMember(new RelationMember("", w4)); 151 r3.addMember(new RelationMember(" platform", wrongNode));156 r3.addMember(new RelationMember("", wrongNode)); 152 157 r3.addMember(new RelationMember("", w6)); 153 158 RelationMember rm9 = new RelationMember("", r3); … … 161 166 route.setMembers(members); 162 167 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); 171 169 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); 174 173 175 174 } 176 175 177 178 @Test179 public void multipleStopElementTest() {180 181 // Same as correctRouteTest(), but182 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 relation221 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 246 176 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/DirecionTestTest.java
r32506 r32567 5 5 6 6 import java.io.File; 7 import java.util.ArrayList; 7 8 import java.util.List; 8 9 … … 19 20 @Test 20 21 public void test() { 21 // this file has:22 // Way23 24 22 25 23 File file = new File(AbstractTest.PATH_TO_ROUNDABOUT_ONEWAY); 26 24 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 25 26 PTAssitantValidatorTest test = new PTAssitantValidatorTest(); 27 27 28 28 Relation route = null; … … 35 35 assertEquals(route.getMembersCount(), 213); 36 36 37 DirectionTest directionTest = new DirectionTest(); 37 List<TestError> errors = new ArrayList<>(); 38 38 39 for (Relation r: ds.getRelations()) { 39 directionTest.visit(r); 40 WayChecker wayChecker = new WayChecker(r, test); 41 wayChecker.performDirectionTest(); 42 errors.addAll(wayChecker.getErrors()); 40 43 } 41 44 42 List<TestError> errors = directionTest.getErrors();43 45 assertEquals(errors.size(), 1); 44 46 int onewayErrorCaught = 0; 45 47 for (TestError e: errors ) { 46 if (e.getCode() == DirectionTest.ERROR_CODE_DIRECTION) {48 if (e.getCode() == PTAssitantValidatorTest.ERROR_CODE_DIRECTION) { 47 49 onewayErrorCaught++; 48 50 } … … 55 57 boolean detectedErrorsAreCorrect = true; 56 58 for (TestError e: errors) { 57 if (e.getCode() == DirectionTest.ERROR_CODE_DIRECTION) {59 if (e.getCode() == PTAssitantValidatorTest.ERROR_CODE_DIRECTION) { 58 60 @SuppressWarnings("unchecked") 59 61 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 4 4 5 5 import java.io.File; 6 import java.util.ArrayList; 6 7 import java.util.List; 7 8 … … 20 21 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 21 22 22 GapTest gapTest = new GapTest(); 23 PTAssitantValidatorTest test = new PTAssitantValidatorTest(); 24 25 List<TestError> errors = new ArrayList<>(); 26 23 27 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()); 25 35 } 26 27 List<TestError> errors = gapTest.getErrors();28 36 29 37 assertEquals(errors.size(), 0); -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/RoadTypeTestTest.java
r32506 r32567 5 5 6 6 import java.io.File; 7 import java.util.ArrayList; 7 8 import java.util.List; 8 9 … … 24 25 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 25 26 26 RoadTypeTest roadTypeTest = new RoadTypeTest(); 27 PTAssitantValidatorTest test = new PTAssitantValidatorTest(); 28 List<TestError> errors = new ArrayList<>(); 29 27 30 for (Relation r: ds.getRelations()) { 28 roadTypeTest.visit(r); 31 WayChecker wayChecker = new WayChecker(r, test); 32 wayChecker.performRoadTypeTest(); 33 errors.addAll(wayChecker.getErrors()); 29 34 } 30 35 31 List<TestError> errors = roadTypeTest.getErrors();32 36 assertEquals(errors.size(), 2); 33 37 34 38 for (TestError e: errors) { 35 assertEquals(e.getCode(), RoadTypeTest.ERROR_CODE_ROAD_TYPE);39 assertEquals(e.getCode(), PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE); 36 40 @SuppressWarnings("unchecked") 37 41 List<OsmPrimitive> highlighted = (List<OsmPrimitive>) e.getHighlighted();
Note:
See TracChangeset
for help on using the changeset viewer.