Changeset 36064 in osm for applications/editors/josm/plugins/turnrestrictions
- Timestamp:
- 2023-03-21T14:49:10+01:00 (22 months ago)
- Location:
- applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/AllUnitTests.java
r32519 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions; 3 3 4 import org.junit. runner.RunWith;5 import org.junit. runners.Suite;4 import org.junit.platform.suite.api.SelectClasses; 5 import org.junit.platform.suite.api.Suite; 6 6 import org.openstreetmap.josm.plugins.turnrestrictions.editor.AllEditorTests; 7 7 8 @ RunWith(Suite.class)9 @S uite.SuiteClasses({8 @Suite 9 @SelectClasses({ 10 10 AllEditorTests.class, 11 11 TurnRestrictionBuilderTest.class -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilderTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertNull;8 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertNull; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 import static org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.intersectionAngle; 10 10 import static org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.selectToWayAfterSplit; … … 12 12 import java.util.ArrayList; 13 13 import java.util.Arrays; 14 import java.util.Collections; 14 15 import java.util.List; 15 16 import java.util.Optional; 16 17 17 import org.junit.Rule; 18 import org.junit.Test; 18 import org.junit.jupiter.api.Test; 19 19 import org.openstreetmap.josm.data.coor.LatLon; 20 20 import org.openstreetmap.josm.data.osm.Node; … … 25 25 import org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.RelativeWayJoinOrientation; 26 26 import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionType; 27 import org.openstreetmap.josm.testutils.JOSMTestRules; 28 29 public class TurnRestrictionBuilderTest { 30 31 @Rule 32 public JOSMTestRules rules = new JOSMTestRules().preferences(); 33 27 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 28 29 @BasicPreferences 30 class TurnRestrictionBuilderTest { 34 31 TurnRestrictionBuilder builder = new TurnRestrictionBuilder(); 35 32 36 33 boolean hasExactlyOneMemberWithRole(Relation r, final String role) { 37 return r.getMembers().stream(). filter(rm -> role.equals(rm.getRole())).findFirst().isPresent();34 return r.getMembers().stream().anyMatch(rm -> role.equals(rm.getRole())); 38 35 } 39 36 40 37 OsmPrimitive memberWithRole(Relation r, final String role) { 41 38 Optional<RelationMember> opt = r.getMembers().stream().filter(rm -> role.equals(rm.getRole())).findFirst(); 42 if (!opt.isPresent()) 43 return null; 44 return opt.get().getMember(); 39 return opt.map(RelationMember::getMember).orElse(null); 45 40 } 46 41 … … 57 52 */ 58 53 @Test 59 public void noUTurn_1() {54 void testNoUTurn1() { 60 55 Way w = new Way(1); 61 56 Node n1 = new Node(1); … … 84 79 */ 85 80 @Test 86 public void noUTurn_2() {81 void testNoUTurn2() { 87 82 Way w = new Way(1); 88 83 Node n1 = new Node(1); … … 106 101 107 102 @Test 108 public void nullSelection() {103 void testNullSelection() { 109 104 assertEmptyTurnRestriction(builder.build(null)); 110 105 } 111 106 112 107 @Test 113 public void emptySelection() {108 void testEmptySelection() { 114 109 assertEmptyTurnRestriction(builder.build(new ArrayList<>())); 115 110 } … … 120 115 */ 121 116 @Test 122 public void oneSelectedWay() {117 void testOneSelectedWay() { 123 118 Way w = new Way(1); 124 Relation tr = builder.build( Arrays.asList(w));119 Relation tr = builder.build(Collections.singletonList(w)); 125 120 assertNotNull(tr); 126 121 assertEquals("restriction", tr.get("type")); … … 134 129 */ 135 130 @Test 136 public void twoUnconnectedWays() {131 void testTwoUnconnectedWays() { 137 132 Way w1 = new Way(1); 138 133 w1.setNodes(Arrays.asList(new Node(11), new Node(12))); … … 159 154 */ 160 155 @Test 161 public void twoConnectedWays_1() {156 void testTwoConnectedWays1() { 162 157 Node n1 = new Node(1); 163 158 n1.setCoor(new LatLon(1, 1)); … … 217 212 */ 218 213 @Test 219 public void twoConnectedWays_2() {214 void testTwoConnectedWays2() { 220 215 Node n1 = new Node(1); 221 216 n1.setCoor(new LatLon(5, 5)); … … 260 255 261 256 /** 262 * Two connected ways. end node of the first way connects to end node of 263 * the second way. left turn. 264 * 265 * 266 * (7,5) - 267 * ^ - w2 268 * | w1 ------> (6,7) 269 * | 270 * (5,5) 271 */ 272 @Test 273 public void twoConnectedWays_3() { 274 Node n1 = new Node(1); 275 n1.setCoor(new LatLon(5, 5)); 276 Node n2 = new Node(2); 277 n2.setCoor(new LatLon(7, 5)); 278 Node n3 = new Node(3); 279 n3.setCoor(new LatLon(6, 7)); 280 281 Way w1 = new Way(1); 282 w1.setNodes(Arrays.asList(n1, n2)); 283 Way w2 = new Way(2); 284 w2.setNodes(Arrays.asList(n2, n3)); 285 286 Relation tr = builder.build(Arrays.asList(w1, w2, n2)); 287 288 assertNotNull(tr); 289 assertEquals("restriction", tr.get("type")); 290 assertEquals(3, tr.getMembersCount()); 291 assertEquals(w1, memberWithRole(tr, "from")); 292 assertEquals(w2, memberWithRole(tr, "to")); 293 assertEquals(n2, memberWithRole(tr, "via")); 294 295 assertEquals("no_right_turn", tr.get("restriction")); 296 } 297 298 /** 299 * Two connected ways. end node of the first way connects to end node of 300 * the second way. left turn. 301 * 302 * 303 * (10,10) 304 * \ 305 * \ 306 * \ 307 * v 308 * (8,15) 309 * / 310 * / 311 * / 312 * v 313 * (5,11) 314 */ 315 @Test 316 public void twoConnectedWays_4() { 317 Node n1 = new Node(1); 318 n1.setCoor(new LatLon(10, 10)); 319 Node n2 = new Node(2); 320 n2.setCoor(new LatLon(8, 15)); 321 Node n3 = new Node(3); 322 n3.setCoor(new LatLon(5, 11)); 323 324 Way w1 = new Way(1); 325 w1.setNodes(Arrays.asList(n1, n2)); 326 Way w2 = new Way(2); 327 w2.setNodes(Arrays.asList(n2, n3)); 328 329 Relation tr = builder.build(Arrays.asList(w1, w2, n2)); 330 331 assertNotNull(tr); 332 assertEquals("restriction", tr.get("type")); 333 assertEquals(3, tr.getMembersCount()); 334 assertEquals(w1, memberWithRole(tr, "from")); 335 assertEquals(w2, memberWithRole(tr, "to")); 336 assertEquals(n2, memberWithRole(tr, "via")); 337 338 assertEquals("no_right_turn", tr.get("restriction")); 339 340 /* 341 * opposite order, from w2 to w1. In this case we have left turn. 342 */ 343 tr = builder.build(Arrays.asList(w2, w1, n2)); 344 345 assertNotNull(tr); 346 assertEquals("restriction", tr.get("type")); 347 assertEquals(3, tr.getMembersCount()); 348 assertEquals(w2, memberWithRole(tr, "from")); 349 assertEquals(w1, memberWithRole(tr, "to")); 350 assertEquals(n2, memberWithRole(tr, "via")); 351 352 assertEquals("no_left_turn", tr.get("restriction")); 257 * Two connected ways. end node of the first way connects to end node of 258 * the second way. left turn. 259 * 260 * (7,5) - 261 * ^ - w2 262 * | w1 ------> (6,7) 263 * | 264 * (5,5) 265 */ 266 @Test 267 void testTwoConnectedWays3() { 268 Node n1 = new Node(1); 269 n1.setCoor(new LatLon(5, 5)); 270 Node n2 = new Node(2); 271 n2.setCoor(new LatLon(7, 5)); 272 Node n3 = new Node(3); 273 n3.setCoor(new LatLon(6, 7)); 274 275 Way w1 = new Way(1); 276 w1.setNodes(Arrays.asList(n1, n2)); 277 Way w2 = new Way(2); 278 w2.setNodes(Arrays.asList(n2, n3)); 279 280 Relation tr = builder.build(Arrays.asList(w1, w2, n2)); 281 282 assertNotNull(tr); 283 assertEquals("restriction", tr.get("type")); 284 assertEquals(3, tr.getMembersCount()); 285 assertEquals(w1, memberWithRole(tr, "from")); 286 assertEquals(w2, memberWithRole(tr, "to")); 287 assertEquals(n2, memberWithRole(tr, "via")); 288 289 assertEquals("no_right_turn", tr.get("restriction")); 290 } 291 292 /** 293 * Two connected ways. end node of the first way connects to end node of 294 * the second way. left turn. 295 * 296 * (10,10) 297 * \ 298 * \ 299 * \ 300 * v 301 * (8,15) 302 * / 303 * / 304 * / 305 * v 306 * (5,11) 307 */ 308 @Test 309 void testTwoConnectedWays4() { 310 Node n1 = new Node(1); 311 n1.setCoor(new LatLon(10, 10)); 312 Node n2 = new Node(2); 313 n2.setCoor(new LatLon(8, 15)); 314 Node n3 = new Node(3); 315 n3.setCoor(new LatLon(5, 11)); 316 317 Way w1 = new Way(1); 318 w1.setNodes(Arrays.asList(n1, n2)); 319 Way w2 = new Way(2); 320 w2.setNodes(Arrays.asList(n2, n3)); 321 322 Relation tr = builder.build(Arrays.asList(w1, w2, n2)); 323 324 assertNotNull(tr); 325 assertEquals("restriction", tr.get("type")); 326 assertEquals(3, tr.getMembersCount()); 327 assertEquals(w1, memberWithRole(tr, "from")); 328 assertEquals(w2, memberWithRole(tr, "to")); 329 assertEquals(n2, memberWithRole(tr, "via")); 330 331 assertEquals("no_right_turn", tr.get("restriction")); 332 333 /* 334 * opposite order, from w2 to w1. In this case we have left turn. 335 */ 336 tr = builder.build(Arrays.asList(w2, w1, n2)); 337 338 assertNotNull(tr); 339 assertEquals("restriction", tr.get("type")); 340 assertEquals(3, tr.getMembersCount()); 341 assertEquals(w2, memberWithRole(tr, "from")); 342 assertEquals(w1, memberWithRole(tr, "to")); 343 assertEquals(n2, memberWithRole(tr, "via")); 344 345 assertEquals("no_left_turn", tr.get("restriction")); 353 346 } 354 347 … … 374 367 */ 375 368 @Test 376 public void intersectionAngle_1() {369 void testIntersectionAngle1() { 377 370 Node n1 = nn(1, 5, 5); 378 371 Node n2 = nn(2, 5, 10); … … 429 422 */ 430 423 @Test 431 public void intersectionAngle_2() {424 void testIntersectionAngle2() { 432 425 Node n1 = nn(1, 5, 5); 433 426 Node n2 = nn(2, 5, 10); … … 473 466 * / 474 467 * (-5, -10) n2 475 * ^ 476 * | 477 * | from 478 * | 479 * (-10,-10) n1 480 */ 481 @Test 482 public void intersectionAngle_3() { 483 Node n1 = nn(1, -10, -10); 484 Node n2 = nn(2, -5, -10); 485 Node n3 = nn(3, -1, -6); 486 Way from = nw(1, n1, n2); 487 Way to = nw(2, n2, n3); 488 489 double a = TurnRestrictionBuilder.intersectionAngle(from, to); 490 assertEquals(45, Math.toDegrees(a), 1e-7); 491 492 /* 493 * if reversed from, the intersection angle is still 45 494 */ 495 from = nw(1, n2, n1); 496 to = nw(2, n2, n3); 497 a = TurnRestrictionBuilder.intersectionAngle(from, to); 498 assertEquals(45, Math.toDegrees(a), 1e-7); 499 500 /* 501 * if reversed to, the intersection angle is still 45 502 */ 503 from = nw(1, n1, n2); 504 to = nw(2, n3, n2); 505 a = TurnRestrictionBuilder.intersectionAngle(from, to); 506 assertEquals(45, Math.toDegrees(a), 1e-7); 507 508 /* 509 * if reversed both, the intersection angle is still 45 510 */ 511 from = nw(1, n2, n1); 512 to = nw(2, n3, n2); 513 a = TurnRestrictionBuilder.intersectionAngle(from, to); 514 assertEquals(45, Math.toDegrees(a), 1e-7); 515 } 516 517 /** 518 * 519 * 520 * (-1,-14) (n3) 521 * ^ 522 * \ 523 * \ to 524 * \ 525 * (-5, -10) n2 526 * ^ 527 * | 528 * | from 529 * | 530 * (-10,-10) n1 531 */ 532 @Test 533 public void intersectionAngle_4() { 534 Node n1 = nn(1, -10, -10); 535 Node n2 = nn(2, -5, -10); 536 Node n3 = nn(3, -1, -14); 537 Way from = nw(1, n1, n2); 538 Way to = nw(2, n2, n3); 539 540 double a = TurnRestrictionBuilder.intersectionAngle(from, to); 541 assertEquals(-45, Math.toDegrees(a), 1e-7); 542 543 /* 544 * if reversed from, the intersection angle is still -45 545 */ 546 from = nw(1, n2, n1); 547 to = nw(2, n2, n3); 548 a = TurnRestrictionBuilder.intersectionAngle(from, to); 549 assertEquals(-45, Math.toDegrees(a), 1e-7); 550 551 /* 552 * if reversed to, the intersection angle is still -45 468 * ^ 469 * | 470 * | from 471 * | 472 * (-10,-10) n1 553 473 */ 554 from = nw(1, n1, n2); 555 to = nw(2, n3, n2); 556 a = TurnRestrictionBuilder.intersectionAngle(from, to); 557 assertEquals(-45, Math.toDegrees(a), 1e-7); 558 559 /* 560 * if reversed both, the intersection angle is still 45 474 @Test 475 void testIntersectionAngle3() { 476 Node n1 = nn(1, -10, -10); 477 Node n2 = nn(2, -5, -10); 478 Node n3 = nn(3, -1, -6); 479 Way from = nw(1, n1, n2); 480 Way to = nw(2, n2, n3); 481 482 double a = TurnRestrictionBuilder.intersectionAngle(from, to); 483 assertEquals(45, Math.toDegrees(a), 1e-7); 484 485 /* 486 * if reversed from, the intersection angle is still 45 487 */ 488 from = nw(1, n2, n1); 489 to = nw(2, n2, n3); 490 a = TurnRestrictionBuilder.intersectionAngle(from, to); 491 assertEquals(45, Math.toDegrees(a), 1e-7); 492 493 /* 494 * if reversed to, the intersection angle is still 45 495 */ 496 from = nw(1, n1, n2); 497 to = nw(2, n3, n2); 498 a = TurnRestrictionBuilder.intersectionAngle(from, to); 499 assertEquals(45, Math.toDegrees(a), 1e-7); 500 501 /* 502 * if reversed both, the intersection angle is still 45 503 */ 504 from = nw(1, n2, n1); 505 to = nw(2, n3, n2); 506 a = TurnRestrictionBuilder.intersectionAngle(from, to); 507 assertEquals(45, Math.toDegrees(a), 1e-7); 508 } 509 510 /** 511 * 512 * 513 * (-1,-14) (n3) 514 * ^ 515 * \ 516 * \ to 517 * \ 518 * (-5, -10) n2 519 * ^ 520 * | 521 * | from 522 * | 523 * (-10,-10) n1 561 524 */ 562 from = nw(1, n2, n1); 563 to = nw(2, n3, n2); 564 a = TurnRestrictionBuilder.intersectionAngle(from, to); 565 assertEquals(-45, Math.toDegrees(a), 1e-7); 566 } 567 568 569 /* 525 @Test 526 void testIntersectionAngle4() { 527 Node n1 = nn(1, -10, -10); 528 Node n2 = nn(2, -5, -10); 529 Node n3 = nn(3, -1, -14); 530 Way from = nw(1, n1, n2); 531 Way to = nw(2, n2, n3); 532 533 double a = TurnRestrictionBuilder.intersectionAngle(from, to); 534 assertEquals(-45, Math.toDegrees(a), 1e-7); 535 536 /* 537 * if reversed from, the intersection angle is still -45 538 */ 539 from = nw(1, n2, n1); 540 to = nw(2, n2, n3); 541 a = TurnRestrictionBuilder.intersectionAngle(from, to); 542 assertEquals(-45, Math.toDegrees(a), 1e-7); 543 544 /* 545 * if reversed to, the intersection angle is still -45 546 */ 547 from = nw(1, n1, n2); 548 to = nw(2, n3, n2); 549 a = TurnRestrictionBuilder.intersectionAngle(from, to); 550 assertEquals(-45, Math.toDegrees(a), 1e-7); 551 552 /* 553 * if reversed both, the intersection angle is still 45 554 */ 555 from = nw(1, n2, n1); 556 to = nw(2, n3, n2); 557 a = TurnRestrictionBuilder.intersectionAngle(from, to); 558 assertEquals(-45, Math.toDegrees(a), 1e-7); 559 } 560 561 /** 570 562 * 571 563 * n21 w21 n22 w22 n23 … … 579 571 */ 580 572 @Test 581 public void splitToWay() {573 void testSplitToWay() { 582 574 Node n11 = new Node(11); 583 575 n11.setCoor(new LatLon(5, 15)); -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/AllEditorTests.java
r32519 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import org.junit.runner.RunWith; 5 import org.junit.runners.Suite; 4 import org.junit.platform.suite.api.SelectClasses; 6 5 7 6 import junit.framework.TestCase; 7 import org.junit.platform.suite.api.Suite; 8 8 9 @ RunWith(Suite.class)10 @S uite.SuiteClasses({9 @Suite 10 @SelectClasses({ 11 11 JosmSelectionListModelTest.class, 12 12 TurnRestrictionEditorModelUnitTest.class, -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/BasicEditorPanelTest.java
r32519 r36064 7 7 import javax.swing.JFrame; 8 8 9 import org.junit. Ignore;9 import org.junit.jupiter.api.Disabled; 10 10 import org.openstreetmap.josm.data.osm.DataSet; 11 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 15 15 * 16 16 */ 17 @ Ignore("no test")17 @Disabled("no test") 18 18 public class BasicEditorPanelTest extends JFrame { 19 19 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ExceptValueModelTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertTrue; 4 import static org.junit.jupiter.api.Assertions.assertAll; 5 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 6 import static org.junit.jupiter.api.Assertions.assertEquals; 7 import static org.junit.jupiter.api.Assertions.assertFalse; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 7 9 8 import org.junit.Test; 10 import org.junit.jupiter.api.Test; 11 import org.junit.jupiter.params.ParameterizedTest; 12 import org.junit.jupiter.params.provider.ValueSource; 9 13 10 publicclass ExceptValueModelTest {14 class ExceptValueModelTest { 11 15 12 @Test 13 public void testConstructors() { 14 new ExceptValueModel(); 15 new ExceptValueModel(null); 16 new ExceptValueModel(""); 17 new ExceptValueModel(" "); 18 new ExceptValueModel("hgv"); 19 new ExceptValueModel("hgv;psv"); 20 new ExceptValueModel("non_standard"); 16 @ParameterizedTest 17 @ValueSource(strings = {"", " ", "hgv", "hgv;psv", "non_standard"}) 18 void testStringConstructors(String value) { 19 assertDoesNotThrow(() -> new ExceptValueModel(value)); 21 20 } 22 21 23 22 @Test 24 public void testSetValue() { 23 void testAdditionalConstructors() { 24 assertAll(() -> assertDoesNotThrow(() -> new ExceptValueModel()), 25 () -> assertDoesNotThrow(() -> new ExceptValueModel(null))); 26 } 27 28 @Test 29 void testSetValue() { 25 30 ExceptValueModel evm; 26 31 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModelTest.java
r33847 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assertTrue; 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertThrows; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 7 9 8 10 import java.util.ArrayList; … … 14 16 import javax.swing.ListSelectionModel; 15 17 16 import org.junit.Rule; 17 import org.junit.Test; 18 import org.junit.jupiter.api.Test; 18 19 import org.openstreetmap.josm.data.coor.LatLon; 19 20 import org.openstreetmap.josm.data.osm.DataSet; … … 24 25 import org.openstreetmap.josm.gui.MainApplication; 25 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 26 import org.openstreetmap.josm.testutils. JOSMTestRules;27 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 27 28 28 29 /** 29 30 * Unit test for {@see JosmSelctionListModel} 30 31 */ 31 public class JosmSelectionListModelTest { 32 33 @Rule 34 public JOSMTestRules rules = new JOSMTestRules().preferences(); 32 @BasicPreferences 33 class JosmSelectionListModelTest { 35 34 36 35 @Test 37 public void testConstructor() { 38 assertNotNull(new JosmSelectionListModel(new OsmDataLayer(new DataSet(), "test", null))); 39 } 40 41 @Test(expected = IllegalArgumentException.class) 42 public void testConstructorNull() { 43 new JosmSelectionListModel(null); 36 void testConstructor() { 37 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "test", null); 38 assertDoesNotThrow(() -> new JosmSelectionListModel(layer)); 44 39 } 45 40 46 41 @Test 47 public void test_setJOSMSelection() { 42 void testConstructorNull() { 43 assertThrows(IllegalArgumentException.class, () -> new JosmSelectionListModel(null)); 44 } 45 46 @Test 47 void testSetJOSMSelection() { 48 48 DataSet ds = new DataSet(); 49 49 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); … … 66 66 67 67 @Test 68 public void test_setJOSMSelection_withSelected() {68 void testSetJOSMSelectionWithSelected() { 69 69 DataSet ds = new DataSet(); 70 70 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); … … 84 84 85 85 @Test 86 public void test_getSelected() {86 void testGetSelected() { 87 87 DataSet ds = new DataSet(); 88 88 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); … … 105 105 106 106 @Test 107 public void test_setSelected() {107 void testSetSelected() { 108 108 // set selected with null is OK - nothing selected thereafter 109 109 JosmSelectionListModel model = new JosmSelectionListModel(new OsmDataLayer(new DataSet(), "test", null)); … … 118 118 List<OsmPrimitive> objects = (Arrays.asList(new Node(new LatLon(1, 1)), new Way(), new Relation())); 119 119 model.setJOSMSelection(objects); 120 model.setSelected( Arrays.asList(objects.get(0)));120 model.setSelected(Collections.singletonList(objects.get(0))); 121 121 assertEquals(Collections.singleton(objects.get(0)), model.getSelected()); 122 122 123 123 // select an object not-existing in the list of displayed objects 124 124 model.setJOSMSelection(objects); 125 model.setSelected( Arrays.asList(new Way()));125 model.setSelected(Collections.singletonList(new Way())); 126 126 assertTrue(model.getSelected().isEmpty()); 127 127 } 128 128 129 129 @Test 130 public void test_editLayerChanged() {130 void testEditLayerChanged() { 131 131 DataSet ds = new DataSet(); 132 132 133 133 List<OsmPrimitive> objects = (Arrays.asList(new Node(new LatLon(1, 1)), new Way(), new Relation())); 134 objects. stream().forEach(ds::addPrimitive);134 objects.forEach(ds::addPrimitive); 135 135 136 136 OsmDataLayer layer1 = new OsmDataLayer(ds, "layer1", null); -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionComboBoxTest.java
r32519 r36064 8 8 import javax.swing.JFrame; 9 9 10 import org.junit. Ignore;10 import org.junit.jupiter.api.Disabled; 11 11 import org.openstreetmap.josm.data.osm.DataSet; 12 12 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 17 17 * 18 18 */ 19 @ Ignore("no test")19 @Disabled("no test") 20 20 public class TurnRestrictionComboBoxTest extends JFrame { 21 21 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModelUnitTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assertTrue; 7 import static org.junit.Assert.fail; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 import static org.junit.jupiter.api.Assertions.fail; 8 9 import static org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole.FROM; 9 10 import static org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole.TO; … … 13 14 import java.util.Collections; 14 15 15 import org.junit.Before; 16 import org.junit.Rule; 17 import org.junit.Test; 16 import org.junit.jupiter.api.BeforeEach; 17 import org.junit.jupiter.api.Test; 18 18 import org.openstreetmap.josm.data.coor.LatLon; 19 19 import org.openstreetmap.josm.data.osm.DataSet; … … 21 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 22 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 23 import org.openstreetmap.josm.data.osm.PrimitiveId; 23 24 import org.openstreetmap.josm.data.osm.Relation; 24 25 import org.openstreetmap.josm.data.osm.RelationMember; … … 26 27 import org.openstreetmap.josm.data.osm.Way; 27 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 28 import org.openstreetmap.josm.testutils. JOSMTestRules;29 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 29 30 30 31 /** 31 32 * This is a unit test for {@link TurnRestrictionEditorModel} 32 33 */ 33 public class TurnRestrictionEditorModelUnitTest { 34 35 @Rule 36 public JOSMTestRules rules = new JOSMTestRules().preferences(); 34 @BasicPreferences 35 class TurnRestrictionEditorModelUnitTest { 37 36 38 37 private final NavigationControler navigationControlerMock = new NavigationControler() { … … 114 113 } 115 114 116 @Before 115 @BeforeEach 117 116 public void setUp() { 118 117 ds = new DataSet(); … … 124 123 * Test the constructor 125 124 */ 126 @Test (expected = IllegalArgumentException.class)127 publicvoid testConstructor1() {128 new TurnRestrictionEditorModel(null, navigationControlerMock);125 @Test 126 void testConstructor1() { 127 assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionEditorModel(null, navigationControlerMock)); 129 128 } 130 129 … … 132 131 * Test the constructor 133 132 */ 134 @Test (expected = IllegalArgumentException.class)135 publicvoid testConstructor2() {136 new TurnRestrictionEditorModel(layer, null);137 } 138 139 @Test 140 publicvoid testPopulateEmptyTurnRestriction() {133 @Test 134 void testConstructor2() { 135 assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionEditorModel(layer, null)); 136 } 137 138 @Test 139 void testPopulateEmptyTurnRestriction() { 141 140 // an "empty" turn restriction with a public id 142 141 Relation r = new Relation(1); … … 156 155 */ 157 156 @Test 158 public void test_populate_SimpleStandardTurnRestriction() {157 void testPopulateSimpleStandardTurnRestriction() { 159 158 buildDataSet1(); 160 159 model.populate(rel(1)); … … 162 161 assertEquals(Collections.singleton(way(2)), model.getTurnRestrictionLeg(FROM)); 163 162 assertEquals(Collections.singleton(way(3)), model.getTurnRestrictionLeg(TO)); 164 assertEquals( Arrays.asList(node(22)), model.getVias());163 assertEquals(Collections.singletonList(node(22)), model.getVias()); 165 164 assertEquals("no_left_turn", model.getRestrictionTagValue()); 166 165 assertEquals("", model.getExcept().getValue()); … … 168 167 169 168 @Test 170 public void setFrom() {169 void testSetFrom() { 171 170 buildDataSet1(); 172 171 model.populate(rel(1)); … … 178 177 // set another way as from 179 178 model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, way(4).getPrimitiveId()); 180 assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg( TurnRestrictionLegRole.FROM));179 assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(FROM)); 181 180 182 181 // delete the/all members with role 'from' 183 182 model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, null); 184 assertTrue(model.getTurnRestrictionLeg(TurnRestrictionLegRole.FROM).isEmpty()); 185 186 try { 187 // can't add a node as 'from' 188 model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, node(21).getPrimitiveId()); 189 fail(); 190 } catch (IllegalArgumentException e) { 191 // OK 192 System.out.println(e.getMessage()); 193 } 194 195 try { 196 // can't set a way as 'from' if it isn't part of the dataset 197 model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, new Way().getPrimitiveId()); 198 fail(); 199 } catch (IllegalStateException e) { 200 // OK 201 System.out.println(e.getMessage()); 202 } 203 } 204 205 @Test 206 public void setTo() { 183 assertTrue(model.getTurnRestrictionLeg(FROM).isEmpty()); 184 185 // can't add a node as 'from' 186 PrimitiveId node = node(21).getPrimitiveId(); 187 assertThrows(IllegalArgumentException.class, 188 () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, node)); 189 190 // can't set a way as 'from' if it isn't part of the dataset 191 PrimitiveId way = new Way().getPrimitiveId(); 192 assertThrows(IllegalStateException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, way)); 193 } 194 195 @Test 196 void setTo() { 207 197 buildDataSet1(); 208 198 model.populate(rel(1)); … … 214 204 // set another way as from 215 205 model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, way(4).getPrimitiveId()); 216 assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(T urnRestrictionLegRole.TO));206 assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(TO)); 217 207 218 208 // delete the/all members with role 'from' 219 209 model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, null); 220 assertTrue(model.getTurnRestrictionLeg(TurnRestrictionLegRole.TO).isEmpty()); 221 222 try { 223 // can't add a node as 'from' 224 model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, node(21).getPrimitiveId()); 225 fail(); 226 } catch (IllegalArgumentException e) { 227 // OK 228 System.out.println(e.getMessage()); 229 } 230 231 try { 232 // can't set a way as 'from' if it isn't part of the dataset 233 model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, new Way().getPrimitiveId()); 234 fail(); 235 } catch (IllegalStateException e) { 236 // OK 237 System.out.println(e.getMessage()); 238 } 210 assertTrue(model.getTurnRestrictionLeg(TO).isEmpty()); 211 212 PrimitiveId node = node(21).getPrimitiveId(); 213 assertThrows(IllegalArgumentException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, node)); 214 215 PrimitiveId way = new Way().getPrimitiveId(); 216 assertThrows(IllegalStateException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, way)); 239 217 } 240 218 … … 269 247 270 248 // one node as via - OK 271 model.setVias( Arrays.asList(node(22)));272 assertEquals( Arrays.asList(node(22)), model.getVias());249 model.setVias(Collections.singletonList(node(22))); 250 assertEquals(Collections.singletonList(node(22)), model.getVias()); 273 251 274 252 // pass in null as vias -> remove all vias … … 291 269 // null values in the list of vias are skipped 292 270 model.setVias(Arrays.asList(null, node(22))); 293 assertEquals( Arrays.asList(node(22)), model.getVias());271 assertEquals(Collections.singletonList(node(22)), model.getVias()); 294 272 295 273 try { 296 274 // an object which doesn't belong to the same dataset can't be a via 297 model.setVias( Arrays.asList(new Node(LatLon.ZERO)));275 model.setVias(Collections.singletonList(new Node(LatLon.ZERO))); 298 276 fail(); 299 277 } catch (IllegalArgumentException e) { -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorTest.java
r32519 r36064 4 4 import javax.swing.JFrame; 5 5 6 import org.junit. Ignore;6 import org.junit.jupiter.api.Disabled; 7 7 import org.openstreetmap.josm.data.osm.DataSet; 8 8 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 11 11 * 12 12 */ 13 @ Ignore("no test")13 @Disabled("no test") 14 14 public class TurnRestrictionEditorTest extends JFrame { 15 15 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorTest.java
r34148 r36064 17 17 import javax.swing.JScrollPane; 18 18 19 import org.junit. Ignore;19 import org.junit.jupiter.api.Disabled; 20 20 import org.openstreetmap.josm.data.coor.LatLon; 21 21 import org.openstreetmap.josm.data.osm.DataSet; … … 34 34 * {@see TurnRestrictionLegEditor} 35 35 */ 36 @ Ignore("no test")36 @Disabled("no test") 37 37 public class TurnRestrictionLegEditorTest extends JFrame { 38 38 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorUnitTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit.Assert.assertEquals;5 4 6 import org.junit.Before; 7 import org.junit.Rule; 8 import org.junit.Test; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 8 import org.junit.jupiter.api.BeforeEach; 9 import org.junit.jupiter.api.Test; 9 10 import org.openstreetmap.josm.data.osm.DataSet; 10 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 11 import org.openstreetmap.josm.testutils. JOSMTestRules;12 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 12 13 13 14 /** 14 15 * Unit test for the {@link TurnRestrictionLegEditor} 15 16 */ 16 public class TurnRestrictionLegEditorUnitTest { 17 18 @Rule 19 public JOSMTestRules rules = new JOSMTestRules().preferences(); 20 17 @BasicPreferences 18 class TurnRestrictionLegEditorUnitTest { 21 19 private DataSet ds; 22 20 private OsmDataLayer layer; 23 21 private TurnRestrictionEditorModel model; 24 22 25 @Before 23 @BeforeEach 26 24 public void setUp() { 27 25 ds = new DataSet(); … … 43 41 44 42 @Test 45 publicvoid testConstructor1() {43 void testConstructor1() { 46 44 TurnRestrictionLegEditor editor = new TurnRestrictionLegEditor(model, TurnRestrictionLegRole.FROM); 47 45 assertEquals(model, editor.getModel()); … … 49 47 } 50 48 51 @Test (expected = IllegalArgumentException.class)52 publicvoid testConstructor2() {53 new TurnRestrictionLegEditor(null, TurnRestrictionLegRole.FROM);49 @Test 50 void testConstructor2() { 51 assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionLegEditor(null, TurnRestrictionLegRole.FROM)); 54 52 } 55 53 56 @Test (expected = IllegalArgumentException.class)57 publicvoid testConstructor3() {58 new TurnRestrictionLegEditor(model, null);54 @Test 55 void testConstructor3() { 56 assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionLegEditor(model, null)); 59 57 } 60 58 } -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionTypeRendererTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNotNull;6 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 7 8 8 import javax.swing.JLabel; 9 9 10 import org.junit.Rule; 11 import org.junit.Test; 12 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 13 12 14 public class TurnRestrictionTypeRendererTest { 15 16 @Rule 17 public JOSMTestRules rules = new JOSMTestRules().preferences(); 18 13 @BasicPreferences 14 class TurnRestrictionTypeRendererTest { 19 15 @Test 20 public void test_Constructor() {16 void testConstructor() { 21 17 TurnRestrictionTypeRenderer renderer = new TurnRestrictionTypeRenderer(); 22 18 … … 26 22 27 23 @Test 28 public void test_getListCellRendererComponent_1() {24 void testGetListCellRendererComponent1() { 29 25 TurnRestrictionTypeRenderer renderer = new TurnRestrictionTypeRenderer(); 30 26 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionTypeTest.java
r32925 r36064 2 2 package org.openstreetmap.josm.plugins.turnrestrictions.editor; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 6 7 import org.junit. Test;7 import org.junit.jupiter.api.Test; 8 8 9 public class TurnRestrictionTypeTest { 9 10 class TurnRestrictionTypeTest { 10 11 11 12 @Test 12 public void test_fromTagValue() {13 void testFromTagValue() { 13 14 14 15 TurnRestrictionType type = TurnRestrictionType.fromTagValue("no_left_turn"); -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditorTest.java
r32519 r36064 7 7 import javax.swing.JFrame; 8 8 9 import org.junit. Ignore;9 import org.junit.jupiter.api.Disabled; 10 10 import org.openstreetmap.josm.data.osm.DataSet; 11 11 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 16 16 * 17 17 */ 18 @ Ignore("no test")18 @Disabled("no test") 19 19 public class VehicleExceptionEditorTest extends JFrame { 20 20 TurnRestrictionEditorModel model; -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ViaListTest.java
r32519 r36064 11 11 import javax.swing.JList; 12 12 13 import org.junit. Ignore;13 import org.junit.jupiter.api.Disabled; 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 15 import org.openstreetmap.josm.data.osm.DataSet; … … 23 23 * 24 24 */ 25 @ Ignore("no test")25 @Disabled("no test") 26 26 public class ViaListTest extends JFrame { 27 27 -
applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesViewTest.java
r32519 r36064 11 11 import javax.swing.JScrollPane; 12 12 13 import org.junit. Ignore;13 import org.junit.jupiter.api.Disabled; 14 14 import org.openstreetmap.josm.data.osm.DataSet; 15 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 20 20 * Simple test application for layout and functionality of the issues view. 21 21 */ 22 @ Ignore("no test")22 @Disabled("no test") 23 23 public class IssuesViewTest extends JFrame { 24 24 private IssuesModel model;
Note:
See TracChangeset
for help on using the changeset viewer.