Changeset 18690 in josm for trunk/test/unit/org/openstreetmap/josm/gui
- Timestamp:
- 2023-03-13T21:59:27+01:00 (3 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui
- Files:
-
- 31 edited
-
MainApplicationTest.java (modified) (5 diffs)
-
MapViewStateTest.java (modified) (1 diff)
-
NavigatableComponentTest.java (modified) (1 diff)
-
TableCellRendererTest.java (modified) (3 diffs)
-
datatransfer/ClipboardUtilsTest.java (modified) (2 diffs)
-
datatransfer/LayerTransferableTest.java (modified) (5 diffs)
-
datatransfer/PrimitiveTransferableTest.java (modified) (2 diffs)
-
datatransfer/data/PrimitiveTagTransferDataTest.java (modified) (4 diffs)
-
dialogs/MinimapDialogTest.java (modified) (22 diffs)
-
dialogs/layer/CycleLayerActionTest.java (modified) (1 diff)
-
dialogs/layer/DuplicateActionTest.java (modified) (2 diffs)
-
dialogs/relation/sort/RelationSorterTest.java (modified) (12 diffs)
-
dialogs/relation/sort/WayConnectionTypeCalculatorTest.java (modified) (22 diffs)
-
dialogs/validator/ValidatorTreePanelTest.java (modified) (3 diffs)
-
history/HistoryLoadTaskTest.java (modified) (1 diff)
-
io/AsynchronousUploadPrimitivesTaskTest.java (modified) (3 diffs)
-
layer/GpxLayerTest.java (modified) (5 diffs)
-
layer/gpx/ConvertToDataLayerActionTest.java (modified) (3 diffs)
-
layer/gpx/DownloadWmsAlongTrackActionTest.java (modified) (1 diff)
-
mappaint/AllMappaintTests.java (modified) (2 diffs)
-
mappaint/MapCSSWithExtendedTextDirectivesTest.java (modified) (3 diffs)
-
mappaint/mapcss/AllMapCSSTests.java (modified) (1 diff)
-
mappaint/mapcss/ConditionTest.java (modified) (2 diffs)
-
mappaint/mapcss/MapCSSParserTest.java (modified) (16 diffs)
-
preferences/AbstractExtendedSourceEntryTestCase.java (modified) (2 diffs)
-
preferences/ToolbarPreferencesTest.java (modified) (4 diffs)
-
preferences/imagery/ImageryPreferenceTestIT.java (modified) (3 diffs)
-
preferences/plugin/PluginPreferenceHighLevelTest.java (modified) (1 diff)
-
tagging/presets/TaggingPresetReaderTest.java (modified) (4 diffs)
-
tagging/presets/TaggingPresetsTest.java (modified) (2 diffs)
-
widgets/HistoryComboBoxTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java
r18602 r18690 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 7 8 import static org.junit.jupiter.api.Assertions.assertNotNull; 8 9 import static org.junit.jupiter.api.Assertions.assertNull; … … 125 126 try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { 126 127 System.setOut(new PrintStream(baos)); 127 Thread t = new Thread() { 128 @Override 129 public void run() { 130 MainApplication.main(new String[] {arg}); 131 } 132 }; 128 Thread t = new Thread(() -> MainApplication.main(new String[] {arg})); 133 129 t.start(); 134 130 t.join(); … … 229 225 .until(() -> !BugReportQueue.getInstance().exceptionHandlingInProgress()); 230 226 assertNotNull(exceptionAtomicReference.get()); 231 assert True(exceptionAtomicReference.get()instanceof UnsupportedOperationException);227 assertInstanceOf(UnsupportedOperationException.class, exceptionAtomicReference.get()); 232 228 // The LAF only resets on restart, so don't bother checking that it switched back in UIManager 233 229 assertEquals(LafPreference.LAF.getDefaultValue(), LafPreference.LAF.get()); … … 253 249 void testPostConstructorProcessCmdLineEmpty() { 254 250 // Check the method accepts no arguments 255 MainApplication.postConstructorProcessCmdLine(new ProgramArguments( new String[0]));251 MainApplication.postConstructorProcessCmdLine(new ProgramArguments()); 256 252 } 257 253 258 254 private static void doTestPostConstructorProcessCmdLine(String download, String downloadGps, boolean gpx) { 259 255 assertNull(MainApplication.getLayerManager().getEditDataSet()); 260 for (Future<?> f : MainApplication.postConstructorProcessCmdLine(new ProgramArguments(new String[]{ 261 "--download=" + download, 256 for (Future<?> f : MainApplication.postConstructorProcessCmdLine(new ProgramArguments("--download=" + download, 262 257 "--downloadgps=" + downloadGps, 263 "--selection=type: node" }))) {258 "--selection=type: node"))) { 264 259 try { 265 260 f.get(); … … 314 309 /** 315 310 * Unit test of {@link MainApplication#postConstructorProcessCmdLine} - nominal case with file names. 316 * @throws MalformedURLException if an error occurs 317 */ 318 @Test 319 void testPostConstructorProcessCmdLineFilename() throws MalformedURLException { 311 */ 312 @Test 313 void testPostConstructorProcessCmdLineFilename() { 320 314 doTestPostConstructorProcessCmdLine( 321 315 Paths.get(TestUtils.getTestDataRoot() + "multipolygon.osm").toFile().getAbsolutePath(), -
trunk/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java
r17275 r18690 65 65 @Test 66 66 void testGetCenter() { 67 doTestGetCenter( s -> s.getCenter(), t -> t / 2d);67 doTestGetCenter(MapViewState::getCenter, t -> t / 2d); 68 68 } 69 69 -
trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java
r18574 r18690 101 101 assertThat(component.getPoint2D((EastNorth) null), CustomMatchers.is(new Point2D.Double())); 102 102 Point2D shouldBeCenter = component.getPoint2D(component.getCenter()); 103 assertThat(shouldBeCenter, CustomMatchers.is(new Point2D.Double(WIDTH / 2, HEIGHT / 2))); 103 assertThat(shouldBeCenter, CustomMatchers.is(new Point2D.Double(WIDTH / 2.0, HEIGHT / 2.0))); 104 104 105 105 EastNorth testPoint = component.getCenter().add(300 * component.getScale(), 200 * component.getScale()); 106 106 Point2D testPointConverted = component.getPoint2D(testPoint); 107 assertThat(testPointConverted, CustomMatchers.is(new Point2D.Double(WIDTH / 2 + 300, HEIGHT / 2 - 200))); 107 assertThat(testPointConverted, CustomMatchers.is(new Point2D.Double(WIDTH / 2.0 + 300, HEIGHT / 2.0 - 200))); 108 108 } 109 109 -
trunk/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java
r17275 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertNotNull; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 5 6 6 7 import java.lang.reflect.Constructor; … … 14 15 import javax.swing.table.TableCellRenderer; 15 16 16 import org.junit.Assert;17 17 import org.junit.jupiter.api.extension.RegisterExtension; 18 18 import org.junit.jupiter.api.Test; … … 64 64 void testTableCellRenderer() throws ReflectiveOperationException { 65 65 Set<Class<? extends TableCellRenderer>> renderers = TestUtils.getJosmSubtypes(TableCellRenderer.class); 66 Assert.assertTrue(renderers.size() >= 10); // if it finds less than 10 classes, something is broken66 assertTrue(renderers.size() >= 10); // if it finds less than 10 classes, something is broken 67 67 JTable tbl = new JTable(2, 2); 68 68 for (Class<? extends TableCellRenderer> klass : renderers) { -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/ClipboardUtilsTest.java
r18037 r18690 58 58 59 59 @Override 60 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException , IOException{60 public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException { 61 61 throw new UnsupportedFlavorException(flavor); 62 62 } … … 84 84 85 85 ClipboardUtils.copy(new SupportNothingTransferable()); 86 assert Equals(null,ClipboardUtils.getClipboardStringContent());86 assertNull(ClipboardUtils.getClipboardStringContent()); 87 87 } 88 88 -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/LayerTransferableTest.java
r17275 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertSame; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; … … 47 48 @Test 48 49 void testLayerData() { 49 Data data = new Data(manager, Arrays. <Layer>asList(layer1, layer2));50 Data data = new Data(manager, Arrays.asList(layer1, layer2)); 50 51 51 52 // need to be identity … … 61 62 @Test 62 63 void testSupportedDataFlavor() { 63 LayerTransferable transferable = new LayerTransferable(manager, Arrays. <Layer>asList(layer1, layer2));64 LayerTransferable transferable = new LayerTransferable(manager, Arrays.asList(layer1, layer2)); 64 65 65 66 assertFalse(transferable.isDataFlavorSupported(DataFlavor.imageFlavor)); … … 77 78 @Test 78 79 void testTransferData() throws Exception { 79 LayerTransferable transferable = new LayerTransferable(manager, Arrays. <Layer>asList(layer1, layer2));80 LayerTransferable transferable = new LayerTransferable(manager, Arrays.asList(layer1, layer2)); 80 81 81 82 Object object = transferable.getTransferData(LayerTransferable.LAYER_DATA); 82 assertTrue(object instanceof Data); 83 Data data = (Data) object; 83 Data data = assertInstanceOf(Data.class, object); 84 84 assertSame(manager, data.getManager()); 85 85 assertSame(layer1, data.getLayers().get(0)); … … 92 92 @Test 93 93 void testTransferDataUnsupported() { 94 LayerTransferable transferable = new LayerTransferable(manager, Arrays. <Layer>asList(layer1, layer2));94 LayerTransferable transferable = new LayerTransferable(manager, Arrays.asList(layer1, layer2)); 95 95 96 96 assertThrows(UnsupportedFlavorException.class, () -> transferable.getTransferData(DataFlavor.imageFlavor)); -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferableTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertThrows; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; … … 67 68 Collection<PrimitiveData> td = ((PrimitiveTransferData) pt.getTransferData(PrimitiveTransferData.DATA_FLAVOR)).getAll(); 68 69 assertEquals(1, td.size()); 69 assert True(td.iterator().next()instanceof NodeData);70 assertInstanceOf(NodeData.class, td.iterator().next()); 70 71 71 72 -
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/data/PrimitiveTagTransferDataTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNull; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 … … 9 10 import java.util.Map; 10 11 12 import org.junit.jupiter.api.Test; 11 13 import org.openstreetmap.josm.data.osm.Node; 12 14 import org.openstreetmap.josm.data.osm.NodeData; … … 17 19 import org.openstreetmap.josm.data.osm.WayData; 18 20 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 19 20 import org.junit.jupiter.api.Test;21 21 22 22 /** … … 109 109 assertEquals(2, (int) stats.get(OsmPrimitiveType.NODE)); 110 110 assertEquals(1, (int) stats.get(OsmPrimitiveType.WAY)); 111 assert Equals(null,stats.get(OsmPrimitiveType.RELATION));111 assertNull(stats.get(OsmPrimitiveType.RELATION)); 112 112 } 113 113 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
r17279 r18690 3 3 4 4 import static java.util.concurrent.TimeUnit.MILLISECONDS; 5 import static org.junit.Assert.assertArrayEquals; 6 import static org.junit.Assert.assertEquals; 7 import static org.junit.Assert.assertFalse; 8 import static org.junit.Assert.assertTrue; 9 import static org.junit.Assert.fail; 5 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 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.assertInstanceOf; 9 import static org.junit.jupiter.api.Assertions.assertTrue; 10 import static org.junit.jupiter.api.Assertions.fail; 10 11 import static org.openstreetmap.josm.tools.I18n.tr; 11 12 … … 27 28 import javax.swing.JPopupMenu; 28 29 30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 29 31 import org.awaitility.Awaitility; 30 32 import org.junit.Rule; … … 50 52 import org.openstreetmap.josm.testutils.JOSMTestRules; 51 53 52 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;53 54 54 /** 55 55 * Unit tests of {@link MinimapDialog} class. … … 95 95 boolean found = false; 96 96 for (Component c: menu.getComponents()) { 97 if (JPopupMenu.Separator .class.isInstance(c)) {97 if (c instanceof JPopupMenu.Separator) { 98 98 break; 99 99 } else { … … 102 102 assertEquals(equalText, isSelected); 103 103 if (equalText) { 104 assertFalse("Second selected source found" , found);104 assertFalse(found, "Second selected source found"); 105 105 found = true; 106 106 } 107 107 } 108 108 } 109 assertTrue("Selected source not found in menu" , found);109 assertTrue(found, "Selected source not found in menu"); 110 110 } 111 111 … … 115 115 JPopupMenu menu = this.sourceButton.getPopupMenu(); 116 116 for (Component c: menu.getComponents()) { 117 if (JPopupMenu.Separator .class.isInstance(c)) {117 if (c instanceof JPopupMenu.Separator) { 118 118 // sources should all come before any separators 119 119 break; … … 124 124 // else continue... 125 125 } 126 fail(); 126 fail("Expected JMenuItem with text " + label + " not found"); 127 127 }); 128 128 } catch (Throwable e) { … … 196 196 /** 197 197 * Tests to switch imagery source. 198 * @throws Exception if any error occurs199 198 */ 200 199 @Test 201 public void testSourceSwitching() throws Exception{200 public void testSourceSwitching() { 202 201 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 203 202 // (not that there's a data layer for it to use) … … 243 242 /** 244 243 * Tests that the apparently-selected TileSource survives the tile sources being refreshed. 245 * @throws Exception if any error occurs246 244 */ 247 245 @Test 248 public void testRefreshSourcesRetainsSelection() throws Exception{246 public void testRefreshSourcesRetainsSelection() { 249 247 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 250 248 // (not that there's a data layer for it to use) … … 281 279 * Tests that the currently selected source being removed from ImageryLayerInfo will remain present and 282 280 * selected in the source menu even after the tile sources have been refreshed. 283 * @throws Exception if any error occurs284 281 */ 285 282 @Test 286 public void testRemovedSourceStillSelected() throws Exception{283 public void testRemovedSourceStillSelected() { 287 284 // relevant prefs starting out empty, should choose the first source and have shown download area enabled 288 285 // (not that there's a data layer for it to use) … … 314 311 /** 315 312 * Tests the tile source list includes sources only present in the LayerManager 316 * @throws Exception if any error occurs317 313 */ 318 314 @Test 319 public void testTileSourcesFromCurrentLayers() throws Exception{315 public void testTileSourcesFromCurrentLayers() { 320 316 // relevant prefs starting out empty, should choose the first (ImageryLayerInfo) source and have shown download area enabled 321 317 // (not that there's a data layer for it to use) … … 448 444 /** 449 445 * Tests minimap obeys a saved "mapstyle" preference on startup. 450 * @throws Exception if any error occurs451 446 */ 452 447 @Test 453 public void testSourcePrefObeyed() throws Exception{448 public void testSourcePrefObeyed() { 454 449 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 455 450 … … 475 470 /** 476 471 * Tests minimap handles an unrecognized "mapstyle" preference on startup 477 * @throws Exception if any error occurs478 472 */ 479 473 @Test 480 public void testSourcePrefInvalid() throws Exception{474 public void testSourcePrefInvalid() { 481 475 Config.getPref().put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles"); 482 476 … … 497 491 /** 498 492 * test viewport marker rectangle matches the mapView's aspect ratio 499 * @throws Exception if any error occurs500 493 */ 501 494 @Test 502 public void testViewportAspectRatio() throws Exception{495 public void testViewportAspectRatio() { 503 496 // Add a test layer to the layer manager to get the MapFrame & MapView 504 497 MainApplication.getLayerManager().addLayer(new TestLayer()); … … 546 539 // should equal the number on the right 547 540 assertTrue( 548 "Viewport marker not horizontally centered",549 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4550 ); 541 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4, 542 "Viewport marker not horizontally centered" 543 ); 551 544 552 545 Matcher colMatcher = ImagePatternMatching.columnMatch( … … 561 554 // should equal the number on the bottom 562 555 assertTrue( 563 "Viewport marker not vertically centered",564 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4565 ); 556 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4, 557 "Viewport marker not vertically centered" 558 ); 566 559 567 560 // (within a tolerance for numerical error) the viewport marker should be square 568 561 assertTrue( 569 "Viewport marker not square",570 Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4571 ); 562 Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4, 563 "Viewport marker not square" 564 ); 572 565 573 566 // now change the mapView size … … 591 584 ); 592 585 assertTrue( 593 "Viewport marker not horizontally centered",594 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4595 ); 586 Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4, 587 "Viewport marker not horizontally centered" 588 ); 596 589 597 590 colMatcher = ImagePatternMatching.columnMatch( … … 603 596 ); 604 597 assertTrue( 605 "Viewport marker not vertically centered",606 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4607 ); 598 Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4, 599 "Viewport marker not vertically centered" 600 ); 608 601 609 602 try { … … 614 607 615 608 assertTrue( 616 "Viewport marker not 2:1 aspect ratio",617 Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5618 ); 609 Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5, 610 "Viewport marker not 2:1 aspect ratio" 611 ); 619 612 } 620 613 … … 623 616 boolean afterSeparator = false; 624 617 for (Component c: menu.getComponents()) { 625 if (JPopupMenu.Separator .class.isInstance(c)) {626 assertFalse("More than one separator before target item" , afterSeparator);618 if (c instanceof JPopupMenu.Separator) { 619 assertFalse(afterSeparator, "More than one separator before target item"); 627 620 afterSeparator = true; 628 621 } else if (((JMenuItem) c).getText().equals(tr("Show downloaded area"))) { 629 assertTrue("Separator not found before target item", afterSeparator); 630 assertTrue("Target item doesn't appear to be a JCheckBoxMenuItem", JCheckBoxMenuItem.class.isInstance(c)); 631 return (JCheckBoxMenuItem) c; 622 assertTrue(afterSeparator, "Separator not found before target item"); 623 return assertInstanceOf(JCheckBoxMenuItem.class, c, "Target item doesn't appear to be a JCheckBoxMenuItem"); 632 624 } 633 625 } … … 638 630 /** 639 631 * test downloaded area is shown shaded 640 * @throws Exception if any error occurs641 632 */ 642 633 @Test 643 public void testShowDownloadedArea() throws Exception{634 public void testShowDownloadedArea() { 644 635 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 645 636 Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", false); … … 797 788 /** 798 789 * test display of downloaded area follows active layer switching 799 * @throws Exception if any error occurs800 790 */ 801 791 @Test 802 public void testShowDownloadedAreaLayerSwitching() throws Exception{792 public void testShowDownloadedAreaLayerSwitching() { 803 793 Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles"); 804 794 Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", true); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java
r17279 r18690 2 2 package org.openstreetmap.josm.gui.dialogs.layer; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/DuplicateActionTest.java
r18037 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assert False;5 import static org.junit.jupiter.api.Assertions.assertNotEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 7 import static org.junit.jupiter.api.Assertions.assertNull; … … 37 37 editLayer = MainApplication.getLayerManager().getEditLayer(); 38 38 assertNotNull(editLayer); 39 assert False(layer.equals(editLayer));39 assertNotEquals(layer, editLayer); 40 40 assertEquals(layer.data.getNodes().size(), editLayer.data.getNodes().size()); 41 41 assertEquals(layer.data.getWays().size(), editLayer.data.getWays().size()); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.dialogs.relation.sort; 3 4 import static org.junit.jupiter.api.Assertions.assertArrayEquals; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 3 6 4 7 import java.io.IOException; … … 8 11 import java.util.List; 9 12 10 import org.junit.Assert;11 13 import org.junit.jupiter.api.BeforeEach; 12 14 import org.junit.jupiter.api.Test; … … 68 70 final String[] expected = {"t1w4", "t1w3", "t1w2", "t1w1", "t1w7", "t1w6", "t1w5", "t1n1", "t1n2"}; 69 71 // expect nodes to be sorted correctly 70 Assert.assertEquals(expected[7], actual[7]);71 Assert.assertEquals(expected[8], actual[8]);72 assertEquals(expected[7], actual[7]); 73 assertEquals(expected[8], actual[8]); 72 74 } 73 75 … … 75 77 void testAssociatedStreet() { 76 78 String[] actual = getNames(sorter.sortMembers(getRelation("associatedStreet").getMembers())); 77 Assert.assertArrayEquals(new String[] {"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4"}, actual);79 assertArrayEquals(new String[] {"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4"}, actual); 78 80 } 79 81 … … 81 83 void testStreet() { 82 84 String[] actual = getNames(sorter.sortMembers(getRelation("street").getMembers())); 83 Assert.assertArrayEquals(new String[]{"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4", "playground", "tree"}, actual);85 assertArrayEquals(new String[]{"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4", "playground", "tree"}, actual); 84 86 } 85 87 … … 94 96 // Check the first way before sorting, otherwise the sorter 95 97 // might pick a different loop starting point than expected below 96 Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));98 assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name")); 97 99 98 100 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 99 Assert.assertArrayEquals(new String[]{101 assertArrayEquals(new String[]{ 100 102 "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", "t5w4b", 101 103 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b", … … 110 112 // Check the first way before sorting, otherwise the sorter 111 113 // might sort in reverse compared to what is expected below 112 Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));114 assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name")); 113 115 114 116 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 115 Assert.assertArrayEquals(new String[]{117 assertArrayEquals(new String[]{ 116 118 "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", "t5w4b", 117 119 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b", … … 125 127 Relation relation = getRelation("three-loops-ends-node"); 126 128 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 127 Assert.assertArrayEquals(new String[]{129 assertArrayEquals(new String[]{ 128 130 "t5w4a", "t5w3a", "t5w2a", "t5w2b", "t5w3b", "t5w4b", 129 131 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b", … … 136 138 Relation relation = getRelation("one-loop-ends-split"); 137 139 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 138 Assert.assertArrayEquals(new String[]{140 assertArrayEquals(new String[]{ 139 141 "t5w3a", "t5w4a", "t5w3b", "t5w4b", 140 142 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b", … … 150 152 // for now. 151 153 String[] actual = getNames(relation.getMembers()); 152 Assert.assertArrayEquals(new String[]{154 assertArrayEquals(new String[]{ 153 155 "t5w7a", "t5w8a", "t5w7b", "t5w8b", 154 156 "t5w9a", "t5w10a", "t5w9b", "t5w10b", … … 161 163 // TODO: This is not yet sorted perfectly (might not be possible) 162 164 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 163 Assert.assertArrayEquals(new String[]{165 assertArrayEquals(new String[]{ 164 166 "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", 165 167 "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w9a", "t5w10a", "t5w11a", "t5w6b", "t5w7b", … … 173 175 // TODO: This is not always sorted properly, only when the right 174 176 // way is already at the top, so check that 175 Assert.assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name"));177 assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name")); 176 178 177 179 String[] actual = getNames(sorter.sortMembers(relation.getMembers())); 178 Assert.assertArrayEquals(new String[]{180 assertArrayEquals(new String[]{ 179 181 "t6w1a", "t6w2a", "t6w3a", 180 182 "t6w1b", "t6w2b", "t6w3b", -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.dialogs.relation.sort; 3 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.assertTrue; 3 7 4 8 import java.io.IOException; … … 12 16 import java.util.List; 13 17 14 import org.junit.Assert;15 18 import org.junit.jupiter.api.BeforeEach; 16 19 import org.junit.jupiter.api.Test; … … 102 105 void testEmpty() { 103 106 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(new ArrayList<>())); 104 Assert.assertEquals("[]", actual);107 assertEquals("[]", actual); 105 108 } 106 109 … … 113 116 Relation relation = getRelation("generic"); 114 117 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(relation.getMembers())); 115 Assert.assertEquals("[NONE, NONE, FORWARD, FORWARD, NONE, NONE, NONE, I, I]", actual);118 assertEquals("[NONE, NONE, FORWARD, FORWARD, NONE, NONE, NONE, I, I]", actual); 116 119 actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 117 Assert.assertEquals("[FORWARD, FORWARD, FORWARD, FORWARD, BACKWARD, BACKWARD, NONE, I, I]", actual);120 assertEquals("[FORWARD, FORWARD, FORWARD, FORWARD, BACKWARD, BACKWARD, NONE, I, I]", actual); 118 121 } 119 122 … … 122 125 Relation relation = getRelation("associatedStreet"); 123 126 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(relation.getMembers())); 124 Assert.assertEquals("[NONE, I, I, I, NONE, I]", actual);127 assertEquals("[NONE, I, I, I, NONE, I]", actual); 125 128 actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 126 Assert.assertEquals("[FORWARD, FORWARD, I, I, I, I]", actual);129 assertEquals("[FORWARD, FORWARD, I, I, I, I]", actual); 127 130 } 128 131 … … 131 134 Relation relation = getRelation("loop"); 132 135 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(relation.getMembers())); 133 Assert.assertEquals("[FPH FORWARD, FP FORWARD, NONE, FPH FORWARD, NONE, FPH FORWARD, NONE]", actual);136 assertEquals("[FPH FORWARD, FP FORWARD, NONE, FPH FORWARD, NONE, FPH FORWARD, NONE]", actual); 134 137 //TODO Sorting doesn't work well in this case 135 138 actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 136 Assert.assertEquals("[BACKWARD, BACKWARD, BACKWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD]", actual);139 assertEquals("[BACKWARD, BACKWARD, BACKWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BPT BACKWARD]", actual); 137 140 } 138 141 … … 147 150 // Check the first way before sorting, otherwise the sorter 148 151 // might pick a different loop starting point than expected below 149 Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));152 assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name")); 150 153 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 151 154 String expected = "[" + … … 155 158 "L FORWARD, L FORWARD" + 156 159 "]"; 157 Assert.assertEquals(expected, actual);160 assertEquals(expected, actual); 158 161 } 159 162 … … 163 166 // Check the first way before sorting, otherwise the sorter 164 167 // might sort in reverse compared to what is expected below 165 Assert.assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name"));168 assertEquals("t5w1", relation.getMembers().get(0).getMember().get("name")); 166 169 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 167 170 String expected = "[" + … … 171 174 "FORWARD" + 172 175 "]"; 173 Assert.assertEquals(expected, actual);176 assertEquals(expected, actual); 174 177 } 175 178 … … 183 186 "FPH FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, BPT BACKWARD" + 184 187 "]"; 185 Assert.assertEquals(expected, actual);188 assertEquals(expected, actual); 186 189 } 187 190 … … 195 198 "FPH FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD" + 196 199 "]"; 197 Assert.assertEquals(expected, actual);200 assertEquals(expected, actual); 198 201 } 199 202 … … 208 211 "FPH FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD" + 209 212 "]"; 210 Assert.assertEquals(expected, actual);213 assertEquals(expected, actual); 211 214 } 212 215 … … 221 224 "BACKWARD, FPH FORWARD, FP FORWARD, FP FORWARD" + 222 225 "]"; 223 Assert.assertEquals(expected, actual);226 assertEquals(expected, actual); 224 227 } 225 228 … … 229 232 // TODO: This is not always sorted properly, only when the right 230 233 // way is already at the top, so check that 231 Assert.assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name"));234 assertEquals("t6w1a", relation.getMembers().get(0).getMember().get("name")); 232 235 String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers()))); 233 236 String expected = "[" + 234 237 "FP FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BP BACKWARD" + 235 238 "]"; 236 Assert.assertEquals(expected, actual);239 assertEquals(expected, actual); 237 240 } 238 241 … … 256 259 List<WayConnectionType> returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 257 260 for (int i = 0; i < 4; i++) { 258 Assert.assertTrue(returned.get(i).onewayFollowsPrevious);259 Assert.assertTrue(returned.get(i).onewayFollowsNext);260 } 261 262 Assert.assertTrue(returned.get(4).onewayFollowsPrevious);263 Assert.assertFalse(returned.get(4).onewayFollowsNext);264 265 Assert.assertFalse(returned.get(5).onewayFollowsPrevious);266 Assert.assertFalse(returned.get(5).onewayFollowsNext);267 268 Assert.assertFalse(returned.get(6).onewayFollowsPrevious);269 Assert.assertTrue(returned.get(6).onewayFollowsNext);261 assertTrue(returned.get(i).onewayFollowsPrevious); 262 assertTrue(returned.get(i).onewayFollowsNext); 263 } 264 265 assertTrue(returned.get(4).onewayFollowsPrevious); 266 assertFalse(returned.get(4).onewayFollowsNext); 267 268 assertFalse(returned.get(5).onewayFollowsPrevious); 269 assertFalse(returned.get(5).onewayFollowsNext); 270 271 assertFalse(returned.get(6).onewayFollowsPrevious); 272 assertTrue(returned.get(6).onewayFollowsNext); 270 273 271 274 // Reverse the last oneway … … 276 279 returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 277 280 for (int i = 0; i < 4; i++) { 278 Assert.assertTrue(returned.get(i).onewayFollowsPrevious);279 Assert.assertTrue(returned.get(i).onewayFollowsNext);281 assertTrue(returned.get(i).onewayFollowsPrevious); 282 assertTrue(returned.get(i).onewayFollowsNext); 280 283 } 281 284 282 Assert.assertTrue(returned.get(4).onewayFollowsPrevious);283 Assert.assertFalse(returned.get(4).onewayFollowsNext);284 285 Assert.assertFalse(returned.get(5).onewayFollowsPrevious);286 Assert.assertTrue(returned.get(5).onewayFollowsNext);287 288 Assert.assertTrue(returned.get(6).onewayFollowsPrevious);289 Assert.assertTrue(returned.get(6).onewayFollowsNext);285 assertTrue(returned.get(4).onewayFollowsPrevious); 286 assertFalse(returned.get(4).onewayFollowsNext); 287 288 assertFalse(returned.get(5).onewayFollowsPrevious); 289 assertTrue(returned.get(5).onewayFollowsNext); 290 291 assertTrue(returned.get(6).onewayFollowsPrevious); 292 assertTrue(returned.get(6).onewayFollowsNext); 290 293 reverseWay(way); 291 294 } … … 298 301 returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 299 302 for (int i = 0; i < 7; i++) { 300 Assert.assertTrue(returned.get(i).onewayFollowsPrevious);301 Assert.assertTrue(returned.get(i).onewayFollowsNext);303 assertTrue(returned.get(i).onewayFollowsPrevious); 304 assertTrue(returned.get(i).onewayFollowsNext); 302 305 } 303 306 } … … 309 312 returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 310 313 for (int i = 0; i < 7; i++) { 311 Assert.assertTrue(returned.get(i).onewayFollowsPrevious);312 Assert.assertTrue(returned.get(i).onewayFollowsNext);314 assertTrue(returned.get(i).onewayFollowsPrevious); 315 assertTrue(returned.get(i).onewayFollowsNext); 313 316 } 314 317 } … … 326 329 List<WayConnectionType> returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 327 330 for (WayConnectionType type : returned) { 328 Assert.assertTrue(type.onewayFollowsNext);329 Assert.assertTrue(type.onewayFollowsPrevious);331 assertTrue(type.onewayFollowsNext); 332 assertTrue(type.onewayFollowsPrevious); 330 333 } 331 334 … … 334 337 returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers()); 335 338 for (WayConnectionType type : returned) { 336 Assert.assertTrue(type.onewayFollowsNext);337 Assert.assertTrue(type.onewayFollowsPrevious);339 assertTrue(type.onewayFollowsNext); 340 assertTrue(type.onewayFollowsPrevious); 338 341 } 339 342 … … 346 349 for (int i = 0; i < returned.size() - 1; i++) { 347 350 WayConnectionType type = returned.get(i); 348 Assert.assertTrue(type.onewayFollowsNext);349 Assert.assertTrue(type.onewayFollowsPrevious);350 } 351 Assert.assertTrue(returned.get(6).onewayFollowsNext);352 Assert.assertFalse(returned.get(6).onewayFollowsPrevious);351 assertTrue(type.onewayFollowsNext); 352 assertTrue(type.onewayFollowsPrevious); 353 } 354 assertTrue(returned.get(6).onewayFollowsNext); 355 assertFalse(returned.get(6).onewayFollowsPrevious); 353 356 } 354 357 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanelTest.java
r18037 r18690 2 2 package org.openstreetmap.josm.gui.dialogs.validator; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 import static org.junit.jupiter.api.Assertions.assertNotNull; … … 31 32 @Test 32 33 void testValidatorTreePanel() { 33 assert NotNull(new ValidatorTreePanel());34 assertDoesNotThrow(() -> new ValidatorTreePanel()); 34 35 35 36 ValidatorTreePanel vtp = new ValidatorTreePanel(new ArrayList<>(Arrays.asList( … … 59 60 vtp.setVisible(false); 60 61 Node n = new Node(10); 61 vtp.setErrors( Arrays.asList(TestError.builder(null, Severity.ERROR, 0)62 vtp.setErrors(Collections.singletonList(TestError.builder(null, Severity.ERROR, 0) 62 63 .message("") 63 64 .primitives(n) 64 65 .build())); 65 66 assertEquals(1, vtp.getErrors().size()); 66 vtp.selectRelatedErrors(Collections. <OsmPrimitive>singleton(n));67 vtp.selectRelatedErrors(Collections.singleton(n)); 67 68 vtp.expandAll(); 68 69 assertNotNull(vtp.getRoot()); 69 70 vtp.resetErrors(); 70 Set<? extends OsmPrimitive> filter = new HashSet<>( Arrays.asList(n));71 Set<? extends OsmPrimitive> filter = new HashSet<>(Collections.singletonList(n)); 71 72 vtp.setFilter(filter); 72 73 assertEquals(filter, vtp.getFilter()); 73 vtp.setFilter(new HashSet< OsmPrimitive>());74 vtp.setFilter(new HashSet<>()); 74 75 assertNull(vtp.getFilter()); 75 76 vtp.setFilter(null); -
trunk/test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java
r17275 r18690 53 53 54 54 /** 55 * Unit test of {@link HistoryLoadTask#loadHistory} 55 * Unit test of {@link HistoryLoadTask#loadHistory(OsmServerHistoryReader, ProgressMonitor)} 56 56 * @throws OsmTransferException if an error occurs 57 57 */ -
trunk/test/unit/org/openstreetmap/josm/gui/io/AsynchronousUploadPrimitivesTaskTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.io; 3 4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 3 6 4 7 import java.util.Collections; … … 7 10 import javax.swing.JOptionPane; 8 11 9 import org.junit.Assert;10 12 import org.junit.jupiter.api.AfterEach; 11 13 import org.junit.jupiter.api.BeforeEach; … … 94 96 Optional<AsynchronousUploadPrimitivesTask> task = AsynchronousUploadPrimitivesTask. 95 97 createAsynchronousUploadTask(strategy, layer, toUpload, changeset); 96 Assert.assertNotNull(uploadPrimitivesTask);97 Assert.assertFalse(task.isPresent());98 assertNotNull(uploadPrimitivesTask); 99 assertFalse(task.isPresent()); 98 100 } 99 101 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java
r18008 r18690 5 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 7 8 import static org.junit.jupiter.api.Assertions.assertNull; 8 9 import static org.junit.jupiter.api.Assertions.assertThrows; … … 88 89 /** 89 90 * Unit test of {@link GpxLayer#GpxLayer}. 90 * @throws Exception if any error occurs 91 */ 92 @Test 93 void testGpxLayer() throws Exception { 91 */ 92 @Test 93 void testGpxLayer() { 94 94 GpxLayer layer = new GpxLayer(new GpxData(), "foo", false); 95 95 GpxTrack trk = new GpxTrack(new ArrayList<IGpxTrackSegment>(), new HashMap<>()); … … 211 211 void testGetTimespanForTrack() throws Exception { 212 212 assertEquals("", GpxLayer.getTimespanForTrack( 213 new GpxTrack(new ArrayList<Collection<WayPoint>>(), new HashMap< String, Object>())));213 new GpxTrack(new ArrayList<Collection<WayPoint>>(), new HashMap<>()))); 214 214 215 215 assertEquals("2016-01-03 11:59:58 \u2013 12:00:00 (2.0 s)", GpxLayer.getTimespanForTrack(getMinimalGpxData().tracks.iterator().next())); … … 238 238 @Test 239 239 void testMergeFromIAE() { 240 assertThrows(IllegalArgumentException.class, () -> new GpxLayer(new GpxData()).mergeFrom(new OsmDataLayer(new DataSet(), "", null))); 240 final GpxLayer gpxLayer = new GpxLayer(new GpxData()); 241 final OsmDataLayer osmDataLayer = new OsmDataLayer(new DataSet(), "testMergeFromIAE", null); 242 assertThrows(IllegalArgumentException.class, () -> gpxLayer.mergeFrom(osmDataLayer)); 241 243 } 242 244 … … 297 299 assertNull(layer.getAssociatedFile()); 298 300 Object infoComponent = layer.getInfoComponent(); 299 assertTrue(infoComponent instanceof JScrollPane); 300 Component view = ((JScrollPane) infoComponent).getViewport().getView(); 301 assertTrue(view instanceof HtmlPanel); 302 String text = ((HtmlPanel) view).getEditorPane().getText().trim(); 301 Component view = assertInstanceOf(JScrollPane.class, infoComponent).getViewport().getView(); 302 String text = assertInstanceOf(HtmlPanel.class, view).getEditorPane().getText().trim(); 303 303 assertTrue(text.startsWith("<html>"), text); 304 304 assertTrue(text.endsWith("</html>"), text); 305 305 assertEquals("<html><br></html>", layer.getToolTipText()); 306 assertDoesNotThrow( () -> layer.jumpToNextMarker());307 assertDoesNotThrow( () -> layer.jumpToPreviousMarker());306 assertDoesNotThrow(layer::jumpToNextMarker); 307 assertDoesNotThrow(layer::jumpToPreviousMarker); 308 308 assertDoesNotThrow(() -> layer.visitBoundingBox(new BoundingXYVisitor())); 309 309 assertDoesNotThrow(() -> layer.filterTracksByDate(null, null, false)); -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java
r17275 r18690 9 9 import java.nio.file.Paths; 10 10 import java.util.Arrays; 11 import java.util.Collections; 11 12 import java.util.Comparator; 12 13 import java.util.List; … … 73 74 74 75 Config.getPref().put("gpx.convert-tags", "list"); 75 Config.getPref().putList("gpx.convert-tags.list.yes", Arrays.asList("ele"));76 Config.getPref().putList("gpx.convert-tags.list.no", Arrays.asList("time"));76 Config.getPref().putList("gpx.convert-tags.list.yes", Collections.singletonList("ele")); 77 Config.getPref().putList("gpx.convert-tags.list.no", Collections.singletonList("time")); 77 78 testFromTrack("tracks.gpx", "tracks-ele.osm"); 78 79 79 Config.getPref().putList("gpx.convert-tags.list.yes", Arrays.asList("time"));80 Config.getPref().putList("gpx.convert-tags.list.no", Arrays.asList("ele"));80 Config.getPref().putList("gpx.convert-tags.list.yes", Collections.singletonList("time")); 81 Config.getPref().putList("gpx.convert-tags.list.no", Collections.singletonList("ele")); 81 82 testFromTrack("tracks.gpx", "tracks-time.osm"); 82 83 … … 141 142 142 143 List<String> ways = osm.getWays().stream() 143 .map(w -> Integer.toString(w.getNodes().size()) + ":" + w.getKeys().entrySet().stream()144 .sorted( Comparator.comparing(Map.Entry::getKey)).collect(Collectors.toList()).toString())144 .map(w -> w.getNodes().size() + ":" + w.getKeys().entrySet().stream() 145 .sorted(Map.Entry.comparingByKey()).collect(Collectors.toList())) 145 146 .sorted() 146 147 .collect(Collectors.toList()); 147 148 148 149 List<String> waysExpected = osmExpected.getWays().stream() 149 .map(w -> Integer.toString(w.getNodes().size()) + ":" + w.getKeys().entrySet().stream()150 .sorted( Comparator.comparing(Map.Entry::getKey)).collect(Collectors.toList()).toString())150 .map(w -> w.getNodes().size() + ":" + w.getKeys().entrySet().stream() 151 .sorted(Map.Entry.comparingByKey()).collect(Collectors.toList())) 151 152 .sorted() 152 153 .collect(Collectors.toList()); -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java
r16159 r18690 3 3 4 4 import static java.util.concurrent.TimeUnit.MILLISECONDS; 5 import static org.junit. Assert.assertEquals;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertNull;8 import static org.junit. Assert.assertTrue;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.assertNull; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 10 10 import java.util.Collections; -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/AllMappaintTests.java
r17275 r18690 2 2 package org.openstreetmap.josm.gui.mappaint; 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.gui.mappaint.mapcss.AllMapCSSTests; 7 7 … … 9 9 * All mappaint tests. 10 10 */ 11 @ RunWith(Suite.class)12 @S uite.SuiteClasses({11 @Suite 12 @SelectClasses({ 13 13 LabelCompositionStrategyTest.class, 14 14 MapCSSWithExtendedTextDirectivesTest.class, -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.java
r17275 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 7 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertTrue;8 8 9 9 import java.awt.Color; … … 46 46 TextLabel te = TextLabel.create(env, Color.WHITE, false /* no default annotate */); 47 47 assertNotNull(te.labelCompositionStrategy); 48 assert True(te.labelCompositionStrategy instanceofDeriveLabelFromNameTagsCompositionStrategy);48 assertInstanceOf(DeriveLabelFromNameTagsCompositionStrategy.class, te.labelCompositionStrategy); 49 49 } 50 50 … … 63 63 TextLabel te = TextLabel.create(env, Color.WHITE, false /* no default annotate */); 64 64 assertNotNull(te.labelCompositionStrategy); 65 assert True(te.labelCompositionStrategyinstanceof TagLookupCompositionStrategy);65 assertInstanceOf(TagLookupCompositionStrategy.class, te.labelCompositionStrategy); 66 66 assertEquals("my_name", ((TagLookupCompositionStrategy) te.labelCompositionStrategy).getDefaultLabelTag()); 67 67 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.java
r14068 r18690 2 2 package org.openstreetmap.josm.gui.mappaint.mapcss; 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 7 7 /** 8 8 * All MapCSS tests. 9 9 */ 10 @ RunWith(Suite.class)11 @S uite.SuiteClasses({10 @Suite 11 @SelectClasses({ 12 12 KeyValueConditionTest.class, 13 13 ParsingLinkSelectorTest.class, -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionTest.java
r18037 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 … … 54 55 assertFalse(op.applies(genEnv(node4))); 55 56 56 assertTrue(op instanceofSimpleKeyValueCondition);57 TagCondition tc = assertInstanceOf(SimpleKeyValueCondition.class, op); 57 58 assertEquals("[k1=v1]", op.toString()); 58 assertEquals("k1", ((TagCondition) op).asTag(null).getKey());59 assertEquals("v1", ((TagCondition) op).asTag(null).getValue());59 assertEquals("k1", tc.asTag(null).getKey()); 60 assertEquals("v1", tc.asTag(null).getValue()); 60 61 } 61 62 -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
r17920 r18690 4 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 6 7 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 8 import static org.junit.jupiter.api.Assertions.assertNull; … … 16 17 import java.util.regex.Pattern; 17 18 18 import org.junit.Assert;19 19 import org.junit.jupiter.api.Test; 20 20 import org.junit.jupiter.api.extension.RegisterExtension; … … 80 80 void testClassCondition() throws Exception { 81 81 List<Condition> conditions = getParser("way[name=X].highway:closed").selector().getConditions(); 82 assert True(conditions.get(0) instanceofSimpleKeyValueCondition);82 assertInstanceOf(SimpleKeyValueCondition.class, conditions.get(0)); 83 83 assertTrue(conditions.get(0).applies(getEnvironment("name", "X"))); 84 assert True(conditions.get(1)instanceof ClassCondition);85 assert True(conditions.get(2) instanceofPseudoClassCondition);84 assertInstanceOf(ClassCondition.class, conditions.get(1)); 85 assertInstanceOf(PseudoClassCondition.class, conditions.get(2)); 86 86 assertFalse(conditions.get(2).applies(getEnvironment("name", "X"))); 87 87 } … … 106 106 107 107 @Test 108 void testClassMatching() throws Exception{108 void testClassMatching() { 109 109 MapCSSStyleSource css = new MapCSSStyleSource( 110 110 "way[highway=footway] { set .path; color: #FF6644; width: 2; }\n" + … … 147 147 void testEqualCondition() throws Exception { 148 148 Condition condition = getParser("[surface=paved]").condition(PRIMITIVE); 149 assertTrue(condition instanceofSimpleKeyValueCondition);150 assertEquals("surface", ((SimpleKeyValueCondition) condition).k);151 assertEquals("paved", ((SimpleKeyValueCondition) condition).v);149 SimpleKeyValueCondition simpleKeyValueCondition = assertInstanceOf(SimpleKeyValueCondition.class, condition); 150 assertEquals("surface", simpleKeyValueCondition.k); 151 assertEquals("paved", simpleKeyValueCondition.v); 152 152 assertTrue(condition.applies(getEnvironment("surface", "paved"))); 153 153 assertFalse(condition.applies(getEnvironment("surface", "unpaved"))); … … 315 315 private void tagRegex(Way way, String parserString, Boolean[] expected) throws Exception { 316 316 Selector selector = getParser(parserString).selector(); 317 Assert.assertEquals(expected[0], selector.matches(new Environment(way)));317 assertEquals(expected[0], selector.matches(new Environment(way))); 318 318 way.put("old_ref", null); 319 Assert.assertEquals(expected[1], selector.matches(new Environment(way)));319 assertEquals(expected[1], selector.matches(new Environment(way))); 320 320 way.put("no_match_tag", "false"); 321 Assert.assertEquals(expected[2], selector.matches(new Environment(way)));321 assertEquals(expected[2], selector.matches(new Environment(way))); 322 322 way.put("old_ref", "A22"); 323 Assert.assertEquals(expected[3], selector.matches(new Environment(way)));323 assertEquals(expected[3], selector.matches(new Environment(way))); 324 324 way.put("old_ref", null); 325 325 way.put("OLD_REF", "A23"); 326 Assert.assertEquals(expected[4], selector.matches(new Environment(way)));326 assertEquals(expected[4], selector.matches(new Environment(way))); 327 327 } 328 328 … … 368 368 369 369 @Test 370 void testTicket8568() throws Exception{370 void testTicket8568() { 371 371 MapCSSStyleSource sheet = new MapCSSStyleSource( 372 372 "way { width: 5; }\n" + … … 385 385 386 386 @Test 387 void testTicket8071() throws Exception{387 void testTicket8071() { 388 388 MapCSSStyleSource sheet = new MapCSSStyleSource( 389 389 "*[rcn_ref], *[name] {text: concat(tag(rcn_ref), \" \", tag(name)); }"); … … 421 421 422 422 @Test 423 void testColorParsing() throws Exception{423 void testColorParsing() { 424 424 assertEquals(new Color(0x12, 0x34, 0x56, 0x78), ColorHelper.html2color("#12345678")); 425 425 } … … 459 459 460 460 @Test 461 void testParentTags() throws Exception{461 void testParentTags() { 462 462 DataSet ds = new DataSet(); 463 463 Node n = new Node(new LatLon(1, 2)); … … 486 486 487 487 @Test 488 void testSort() throws Exception{489 assertEquals(Arrays.asList( new String[] {"alpha", "beta"}), Functions.sort(null, "beta", "alpha"));488 void testSort() { 489 assertEquals(Arrays.asList("alpha", "beta"), Functions.sort(null, "beta", "alpha")); 490 490 Way way1 = TestUtils.newWay("highway=residential name=Alpha alt_name=Beta ref=\"A9;A8\"", new Node(new LatLon(0.001, 0.001)), 491 491 new Node(new LatLon(0.002, 0.002))); … … 508 508 509 509 @Test 510 void testUniqueValues() throws Exception{511 assertEquals(Arrays.asList( new String[] {"alpha", "beta"}),510 void testUniqueValues() { 511 assertEquals(Arrays.asList("alpha", "beta"), 512 512 Functions.uniq(null, "alpha", "alpha", "alpha", "beta")); 513 assertEquals(Arrays.asList( new String[] {"one", "two", "three"}),514 Functions.uniq_list(Arrays.asList( new String[] {"one", "one", "two", "two", "two", "three"})));515 } 516 517 @Test 518 void testCountRoles() throws Exception{513 assertEquals(Arrays.asList("one", "two", "three"), 514 Functions.uniq_list(Arrays.asList("one", "one", "two", "two", "two", "three"))); 515 } 516 517 @Test 518 void testCountRoles() { 519 519 DataSet ds = new DataSet(); 520 520 Way way1 = TestUtils.newWay("highway=residential name=1", … … 596 596 597 597 @Test 598 void testInvalidBaseSelector() throws Exception{598 void testInvalidBaseSelector() { 599 599 MapCSSStyleSource css = new MapCSSStyleSource("invalid_base[key=value] {}"); 600 600 css.loadStyleSource(); … … 624 624 assertEquals(24.0, mc.getCascade(null).get("div")); 625 625 assertEquals(-13.0, mc.getCascade(null).get("neg")); 626 assertEquals( true, mc.getCascade(null).get("not"));626 assertEquals(Boolean.TRUE, mc.getCascade(null).get("not")); 627 627 assertNull(mc.getCascade(null).get("null0")); 628 628 assertNull(mc.getCascade(null).get("null1")); … … 631 631 632 632 @Test 633 void testMinMaxFunctions() throws Exception{633 void testMinMaxFunctions() { 634 634 MapCSSStyleSource sheet = new MapCSSStyleSource("* {" + 635 635 "min_value: min(tag(x), tag(y), tag(z)); " + … … 700 700 @Test 701 701 void testZoomIAE() { 702 assertThrows(IllegalArgumentException.class, () -> getParser("|z16-15").zoom()); 702 final MapCSSParser parser = getParser("|z16-15"); 703 assertThrows(IllegalArgumentException.class, parser::zoom); 703 704 } 704 705 -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/AbstractExtendedSourceEntryTestCase.java
r17531 r18690 23 23 protected static final List<String> errorsToIgnore = new ArrayList<>(); 24 24 25 protected static List<Object[]> getTestParameters(Collection<ExtendedSourceEntry> entries) throws Exception{25 protected static List<Object[]> getTestParameters(Collection<ExtendedSourceEntry> entries) { 26 26 return entries.stream().map(x -> new Object[] {x.getDisplayName(), cleanUrl(x.url), x}).collect(Collectors.toList()); 27 27 } … … 45 45 protected final void handleException(ExtendedSourceEntry source, Throwable e, Set<String> errors, List<String> ignoredErrors) { 46 46 e.printStackTrace(); 47 String s = source.url + " => " + e .toString();47 String s = source.url + " => " + e; 48 48 if (isIgnoredSubstring(source, s)) { 49 49 ignoredErrors.add(s); -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/ToolbarPreferencesTest.java
r17275 r18690 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.preferences; 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 3 5 4 6 import java.awt.event.ActionEvent; … … 11 13 import javax.swing.Action; 12 14 13 import org.junit.Assert;14 15 import org.junit.jupiter.api.Test; 15 16 import org.openstreetmap.josm.actions.ActionParameter; … … 54 55 expected.put((String) params[i], params[i+1]); 55 56 } 56 Assert.assertEquals(expected, a.getParameters());57 assertEquals(expected, a.getParameters()); 57 58 } 58 59 … … 73 74 checkAction(parser.loadAction("action(uknownParam=aa)")); 74 75 75 Assert.assertEquals("action(param1=value1,param2=value2)",76 parser.saveAction(parser.loadAction("action(param1=value1,param2=value2)")));77 Assert.assertEquals("action(param1=value1,param2=)",78 parser.saveAction(parser.loadAction("action(param1=value1)")));79 Assert.assertEquals("action(param1=value1,param2=2\\(\\=\\,\\\\)",80 parser.saveAction(parser.loadAction("action(param1=value1,param2=2\\(\\=\\,\\\\)")));76 assertEquals("action(param1=value1,param2=value2)", parser.saveAction(parser.loadAction("action(param1=value1,param2=value2)"))); 77 assertEquals("action(param1=value1,param2=)", parser.saveAction(parser.loadAction("action(param1=value1)"))); 78 assertEquals( 79 "action(param1=value1,param2=2\\(\\=\\,\\\\)", 80 parser.saveAction(parser.loadAction("action(param1=value1,param2=2\\(\\=\\,\\\\)")) 81 ); 81 82 } 82 83 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
r18211 r18690 146 146 147 147 private static boolean isIgnoredSubstring(String substring) { 148 return errorsToIgnore.parallelStream().anyMatch( x ->substring.contains(x));148 return errorsToIgnore.parallelStream().anyMatch(substring::contains); 149 149 } 150 150 … … 342 342 } 343 343 } catch (IOException | RuntimeException | WMSGetCapabilitiesException e) { 344 addError(info, info.getUrl() + ERROR_SEP + e .toString());344 addError(info, info.getUrl() + ERROR_SEP + e); 345 345 } 346 346 … … 394 394 return new WMTSTileSource(info, proj); 395 395 } catch (IOException | WMTSGetCapabilitiesException e) { 396 addError(info, info.getUrl() + ERROR_SEP + e .toString());396 addError(info, info.getUrl() + ERROR_SEP + e); 397 397 return null; 398 398 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
r17195 r18690 4 4 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; 5 5 import static java.util.concurrent.TimeUnit.MILLISECONDS; 6 import static org.junit. Assert.assertEquals;7 import static org.junit. Assert.assertFalse;8 import static org.junit. Assert.assertTrue;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; 9 9 10 10 import java.awt.Component; -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java
r17369 r18690 5 5 import static org.hamcrest.MatcherAssert.assertThat; 6 6 import static org.junit.jupiter.api.Assertions.assertEquals; 7 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 7 8 import static org.junit.jupiter.api.Assertions.assertTrue; 8 9 import static org.junit.jupiter.api.Assertions.fail; … … 13 14 import java.util.stream.Collectors; 14 15 15 import org.junit.Assert;16 16 import org.junit.jupiter.api.Test; 17 17 import org.junit.jupiter.api.extension.RegisterExtension; … … 45 45 String presetfile = TestUtils.getRegressionDataFile(8954, "preset.xml"); 46 46 final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, false); 47 Assert.assertEquals("Number of preset items", 1, presets.size());47 assertEquals(1, presets.size(), "Number of preset items"); 48 48 final TaggingPreset preset = presets.iterator().next(); 49 Assert.assertEquals("Number of entries",1, preset.data.size());49 assertEquals(1, preset.data.size(), "Number of entries"); 50 50 final TaggingPresetItem item = preset.data.get(0); 51 Assert.assertTrue("Entry is not checkbox", item instanceof Check);51 assertInstanceOf(Check.class, item, "Entry is not checkbox"); 52 52 } 53 53 … … 93 93 String presetfile = "resource://data/defaultpresets.xml"; 94 94 final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, true); 95 Assert.assertTrue("Default presets are empty", presets.size() > 0);95 assertTrue(presets.size() > 0, "Default presets are empty"); 96 96 } 97 97 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetsTest.java
r18683 r18690 3 3 4 4 import static org.junit.jupiter.api.Assertions.assertAll; 5 import static org.junit.jupiter.api.Assertions.assertInstanceOf; 5 6 import static org.junit.jupiter.api.Assertions.assertSame; 6 import static org.junit.jupiter.api.Assertions.assertTrue;7 7 8 8 import java.util.Collection; … … 62 62 assertAll(() -> assertSame(menu.presetSearchAction, presetsMenu.getItem(0).getAction()), 63 63 () -> assertSame(menu.presetSearchPrimitiveAction, presetsMenu.getItem(1).getAction()), 64 () -> assert True(presetsMenu.getItem(2).getAction()instanceof PreferencesAction),65 () -> assert True(presetsMenu.getMenuComponent(3)instanceof JSeparator));64 () -> assertInstanceOf(PreferencesAction.class, presetsMenu.getItem(2).getAction()), 65 () -> assertInstanceOf(JSeparator.class, presetsMenu.getMenuComponent(3))); 66 66 } 67 67 -
trunk/test/unit/org/openstreetmap/josm/gui/widgets/HistoryComboBoxTest.java
r18131 r18690 21 21 class HistoryComboBoxTest { 22 22 static Stream<Arguments> testNonRegression21203() { 23 return Stream.of(Arguments.of("Hello world"), Arguments.of(new AutoCompletionItem("Hello world2")), Arguments.of( new Double(42)));23 return Stream.of(Arguments.of("Hello world"), Arguments.of(new AutoCompletionItem("Hello world2")), Arguments.of(42.0)); 24 24 } 25 25 … … 59 59 historyComboBox.addCurrentItemToHistory(); 60 60 61 // add a new item61 // Add a new item 62 62 historyComboBox.getEditor().setItem(new AutoCompletionItem("testNonRegression21215_2")); 63 63 historyComboBox.addCurrentItemToHistory();
Note:
See TracChangeset
for help on using the changeset viewer.
