Ignore:
Timestamp:
2023-03-13T21:59:27+01:00 (3 years ago)
Author:
taylor.smock
Message:

See #16567: Convert all assertion calls to JUnit 5 (patch by gaben, modified)

The modifications are as follows:

  • Merge DomainValidatorTest.testIDN and DomainValidatorTest.testIDNJava6OrLater
  • Update some tests to use @ParameterizedTest (DomainValidatorTest)
  • Replace various exception blocks with assertThrows. These typically looked like
        try {
            // Something that should throw an exception here
            fail("An exception should have been thrown");
        } catch (Exception e) {
            // Verify the exception matches expectations here
        }
    
  • Replace assertTrue(val instanceof Clazz) with assertInstanceOf
  • Replace JUnit 4 @Suite with JUnit 5 @Suite

Both the original patch and the modified patch fix various lint issues.

Location:
trunk/test/unit/org/openstreetmap/josm/gui
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

    r18602 r18690  
    55import static org.junit.jupiter.api.Assertions.assertEquals;
    66import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    78import static org.junit.jupiter.api.Assertions.assertNotNull;
    89import static org.junit.jupiter.api.Assertions.assertNull;
     
    125126        try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
    126127            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}));
    133129            t.start();
    134130            t.join();
     
    229225                    .until(() -> !BugReportQueue.getInstance().exceptionHandlingInProgress());
    230226            assertNotNull(exceptionAtomicReference.get());
    231             assertTrue(exceptionAtomicReference.get() instanceof UnsupportedOperationException);
     227            assertInstanceOf(UnsupportedOperationException.class, exceptionAtomicReference.get());
    232228            // The LAF only resets on restart, so don't bother checking that it switched back in UIManager
    233229            assertEquals(LafPreference.LAF.getDefaultValue(), LafPreference.LAF.get());
     
    253249    void testPostConstructorProcessCmdLineEmpty() {
    254250        // Check the method accepts no arguments
    255         MainApplication.postConstructorProcessCmdLine(new ProgramArguments(new String[0]));
     251        MainApplication.postConstructorProcessCmdLine(new ProgramArguments());
    256252    }
    257253
    258254    private static void doTestPostConstructorProcessCmdLine(String download, String downloadGps, boolean gpx) {
    259255        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,
    262257                "--downloadgps=" + downloadGps,
    263                 "--selection=type: node"}))) {
     258                "--selection=type: node"))) {
    264259            try {
    265260                f.get();
     
    314309    /**
    315310     * 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() {
    320314        doTestPostConstructorProcessCmdLine(
    321315                Paths.get(TestUtils.getTestDataRoot() + "multipolygon.osm").toFile().getAbsolutePath(),
  • trunk/test/unit/org/openstreetmap/josm/gui/MapViewStateTest.java

    r17275 r18690  
    6565    @Test
    6666    void testGetCenter() {
    67         doTestGetCenter(s -> s.getCenter(), t -> t / 2d);
     67        doTestGetCenter(MapViewState::getCenter, t -> t / 2d);
    6868    }
    6969
  • trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java

    r18574 r18690  
    101101        assertThat(component.getPoint2D((EastNorth) null), CustomMatchers.is(new Point2D.Double()));
    102102        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)));
    104104
    105105        EastNorth testPoint = component.getCenter().add(300 * component.getScale(), 200 * component.getScale());
    106106        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)));
    108108    }
    109109
  • trunk/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java

    r17275 r18690  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    56
    67import java.lang.reflect.Constructor;
     
    1415import javax.swing.table.TableCellRenderer;
    1516
    16 import org.junit.Assert;
    1717import org.junit.jupiter.api.extension.RegisterExtension;
    1818import org.junit.jupiter.api.Test;
     
    6464    void testTableCellRenderer() throws ReflectiveOperationException {
    6565        Set<Class<? extends TableCellRenderer>> renderers = TestUtils.getJosmSubtypes(TableCellRenderer.class);
    66         Assert.assertTrue(renderers.size() >= 10); // if it finds less than 10 classes, something is broken
     66        assertTrue(renderers.size() >= 10); // if it finds less than 10 classes, something is broken
    6767        JTable tbl = new JTable(2, 2);
    6868        for (Class<? extends TableCellRenderer> klass : renderers) {
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/ClipboardUtilsTest.java

    r18037 r18690  
    5858
    5959        @Override
    60         public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
     60        public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
    6161            throw new UnsupportedFlavorException(flavor);
    6262        }
     
    8484
    8585        ClipboardUtils.copy(new SupportNothingTransferable());
    86         assertEquals(null, ClipboardUtils.getClipboardStringContent());
     86        assertNull(ClipboardUtils.getClipboardStringContent());
    8787    }
    8888
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/LayerTransferableTest.java

    r17275 r18690  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    67import static org.junit.jupiter.api.Assertions.assertSame;
    78import static org.junit.jupiter.api.Assertions.assertTrue;
     
    4748    @Test
    4849    void testLayerData() {
    49         Data data = new Data(manager, Arrays.<Layer>asList(layer1, layer2));
     50        Data data = new Data(manager, Arrays.asList(layer1, layer2));
    5051
    5152        // need to be identity
     
    6162    @Test
    6263    void testSupportedDataFlavor() {
    63         LayerTransferable transferable = new LayerTransferable(manager, Arrays.<Layer>asList(layer1, layer2));
     64        LayerTransferable transferable = new LayerTransferable(manager, Arrays.asList(layer1, layer2));
    6465
    6566        assertFalse(transferable.isDataFlavorSupported(DataFlavor.imageFlavor));
     
    7778    @Test
    7879    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));
    8081
    8182        Object object = transferable.getTransferData(LayerTransferable.LAYER_DATA);
    82         assertTrue(object instanceof Data);
    83         Data data = (Data) object;
     83        Data data = assertInstanceOf(Data.class, object);
    8484        assertSame(manager, data.getManager());
    8585        assertSame(layer1, data.getLayers().get(0));
     
    9292    @Test
    9393    void testTransferDataUnsupported() {
    94         LayerTransferable transferable = new LayerTransferable(manager, Arrays.<Layer>asList(layer1, layer2));
     94        LayerTransferable transferable = new LayerTransferable(manager, Arrays.asList(layer1, layer2));
    9595
    9696        assertThrows(UnsupportedFlavorException.class, () -> transferable.getTransferData(DataFlavor.imageFlavor));
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferableTest.java

    r18037 r18690  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    67import static org.junit.jupiter.api.Assertions.assertThrows;
    78import static org.junit.jupiter.api.Assertions.assertTrue;
     
    6768        Collection<PrimitiveData> td = ((PrimitiveTransferData) pt.getTransferData(PrimitiveTransferData.DATA_FLAVOR)).getAll();
    6869        assertEquals(1, td.size());
    69         assertTrue(td.iterator().next() instanceof NodeData);
     70        assertInstanceOf(NodeData.class, td.iterator().next());
    7071
    7172
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/data/PrimitiveTagTransferDataTest.java

    r18037 r18690  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNull;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    78
     
    910import java.util.Map;
    1011
     12import org.junit.jupiter.api.Test;
    1113import org.openstreetmap.josm.data.osm.Node;
    1214import org.openstreetmap.josm.data.osm.NodeData;
     
    1719import org.openstreetmap.josm.data.osm.WayData;
    1820import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    19 
    20 import org.junit.jupiter.api.Test;
    2121
    2222/**
     
    109109        assertEquals(2, (int) stats.get(OsmPrimitiveType.NODE));
    110110        assertEquals(1, (int) stats.get(OsmPrimitiveType.WAY));
    111         assertEquals(null, stats.get(OsmPrimitiveType.RELATION));
     111        assertNull(stats.get(OsmPrimitiveType.RELATION));
    112112    }
    113113}
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    r17279 r18690  
    33
    44import 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;
     5import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     6import static org.junit.jupiter.api.Assertions.assertEquals;
     7import static org.junit.jupiter.api.Assertions.assertFalse;
     8import static org.junit.jupiter.api.Assertions.assertInstanceOf;
     9import static org.junit.jupiter.api.Assertions.assertTrue;
     10import static org.junit.jupiter.api.Assertions.fail;
    1011import static org.openstreetmap.josm.tools.I18n.tr;
    1112
     
    2728import javax.swing.JPopupMenu;
    2829
     30import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2931import org.awaitility.Awaitility;
    3032import org.junit.Rule;
     
    5052import org.openstreetmap.josm.testutils.JOSMTestRules;
    5153
    52 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    53 
    5454/**
    5555 * Unit tests of {@link MinimapDialog} class.
     
    9595        boolean found = false;
    9696        for (Component c: menu.getComponents()) {
    97             if (JPopupMenu.Separator.class.isInstance(c)) {
     97            if (c instanceof JPopupMenu.Separator) {
    9898                break;
    9999            } else {
     
    102102                assertEquals(equalText, isSelected);
    103103                if (equalText) {
    104                     assertFalse("Second selected source found", found);
     104                    assertFalse(found, "Second selected source found");
    105105                    found = true;
    106106                }
    107107            }
    108108        }
    109         assertTrue("Selected source not found in menu", found);
     109        assertTrue(found, "Selected source not found in menu");
    110110    }
    111111
     
    115115                JPopupMenu menu = this.sourceButton.getPopupMenu();
    116116                for (Component c: menu.getComponents()) {
    117                     if (JPopupMenu.Separator.class.isInstance(c)) {
     117                    if (c instanceof JPopupMenu.Separator) {
    118118                        // sources should all come before any separators
    119119                        break;
     
    124124                    // else continue...
    125125                }
    126                 fail();
     126                fail("Expected JMenuItem with text " + label + " not found");
    127127            });
    128128        } catch (Throwable e) {
     
    196196    /**
    197197     * Tests to switch imagery source.
    198      * @throws Exception if any error occurs
    199198     */
    200199    @Test
    201     public void testSourceSwitching() throws Exception {
     200    public void testSourceSwitching() {
    202201        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    203202        // (not that there's a data layer for it to use)
     
    243242    /**
    244243     * Tests that the apparently-selected TileSource survives the tile sources being refreshed.
    245      * @throws Exception if any error occurs
    246244     */
    247245    @Test
    248     public void testRefreshSourcesRetainsSelection() throws Exception {
     246    public void testRefreshSourcesRetainsSelection() {
    249247        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    250248        // (not that there's a data layer for it to use)
     
    281279     * Tests that the currently selected source being removed from ImageryLayerInfo will remain present and
    282280     * selected in the source menu even after the tile sources have been refreshed.
    283      * @throws Exception if any error occurs
    284281     */
    285282    @Test
    286     public void testRemovedSourceStillSelected() throws Exception {
     283    public void testRemovedSourceStillSelected() {
    287284        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    288285        // (not that there's a data layer for it to use)
     
    314311    /**
    315312     * Tests the tile source list includes sources only present in the LayerManager
    316      * @throws Exception if any error occurs
    317313     */
    318314    @Test
    319     public void testTileSourcesFromCurrentLayers() throws Exception {
     315    public void testTileSourcesFromCurrentLayers() {
    320316        // relevant prefs starting out empty, should choose the first (ImageryLayerInfo) source and have shown download area enabled
    321317        // (not that there's a data layer for it to use)
     
    448444    /**
    449445     * Tests minimap obeys a saved "mapstyle" preference on startup.
    450      * @throws Exception if any error occurs
    451446     */
    452447    @Test
    453     public void testSourcePrefObeyed() throws Exception {
     448    public void testSourcePrefObeyed() {
    454449        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    455450
     
    475470    /**
    476471     * Tests minimap handles an unrecognized "mapstyle" preference on startup
    477      * @throws Exception if any error occurs
    478472     */
    479473    @Test
    480     public void testSourcePrefInvalid() throws Exception {
     474    public void testSourcePrefInvalid() {
    481475        Config.getPref().put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles");
    482476
     
    497491    /**
    498492     * test viewport marker rectangle matches the mapView's aspect ratio
    499      * @throws Exception if any error occurs
    500493     */
    501494    @Test
    502     public void testViewportAspectRatio() throws Exception {
     495    public void testViewportAspectRatio() {
    503496        // Add a test layer to the layer manager to get the MapFrame & MapView
    504497        MainApplication.getLayerManager().addLayer(new TestLayer());
     
    546539        // should equal the number on the right
    547540        assertTrue(
    548             "Viewport marker not horizontally centered",
    549             Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4
    550         );
     541                Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4,
     542                "Viewport marker not horizontally centered"
     543                );
    551544
    552545        Matcher colMatcher = ImagePatternMatching.columnMatch(
     
    561554        // should equal the number on the bottom
    562555        assertTrue(
    563             "Viewport marker not vertically centered",
    564             Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4
    565         );
     556                Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4,
     557                "Viewport marker not vertically centered"
     558                );
    566559
    567560        // (within a tolerance for numerical error) the viewport marker should be square
    568561        assertTrue(
    569             "Viewport marker not square",
    570             Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4
    571         );
     562                Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4,
     563                "Viewport marker not square"
     564                );
    572565
    573566        // now change the mapView size
     
    591584        );
    592585        assertTrue(
    593             "Viewport marker not horizontally centered",
    594             Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4
    595         );
     586                Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4,
     587                "Viewport marker not horizontally centered"
     588                );
    596589
    597590        colMatcher = ImagePatternMatching.columnMatch(
     
    603596        );
    604597        assertTrue(
    605             "Viewport marker not vertically centered",
    606             Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4
    607         );
     598                Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4,
     599                "Viewport marker not vertically centered"
     600                );
    608601
    609602        try {
     
    614607
    615608        assertTrue(
    616             "Viewport marker not 2:1 aspect ratio",
    617             Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5
    618         );
     609                Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5,
     610                "Viewport marker not 2:1 aspect ratio"
     611                );
    619612    }
    620613
     
    623616        boolean afterSeparator = false;
    624617        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");
    627620                afterSeparator = true;
    628621            } 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");
    632624            }
    633625        }
     
    638630    /**
    639631     * test downloaded area is shown shaded
    640      * @throws Exception if any error occurs
    641632     */
    642633    @Test
    643     public void testShowDownloadedArea() throws Exception {
     634    public void testShowDownloadedArea() {
    644635        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    645636        Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", false);
     
    797788    /**
    798789     * test display of downloaded area follows active layer switching
    799      * @throws Exception if any error occurs
    800790     */
    801791    @Test
    802     public void testShowDownloadedAreaLayerSwitching() throws Exception {
     792    public void testShowDownloadedAreaLayerSwitching() {
    803793        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    804794        Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", true);
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java

    r17279 r18690  
    22package org.openstreetmap.josm.gui.dialogs.layer;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.openstreetmap.josm.tools.I18n.tr;
    66
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/DuplicateActionTest.java

    r18037 r18690  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    5 import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertNotEquals;
    66import static org.junit.jupiter.api.Assertions.assertNotNull;
    77import static org.junit.jupiter.api.Assertions.assertNull;
     
    3737                editLayer = MainApplication.getLayerManager().getEditLayer();
    3838                assertNotNull(editLayer);
    39                 assertFalse(layer.equals(editLayer));
     39                assertNotEquals(layer, editLayer);
    4040                assertEquals(layer.data.getNodes().size(), editLayer.data.getNodes().size());
    4141                assertEquals(layer.data.getWays().size(), editLayer.data.getWays().size());
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java

    r17275 r18690  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.dialogs.relation.sort;
     3
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
    36
    47import java.io.IOException;
     
    811import java.util.List;
    912
    10 import org.junit.Assert;
    1113import org.junit.jupiter.api.BeforeEach;
    1214import org.junit.jupiter.api.Test;
     
    6870        final String[] expected = {"t1w4", "t1w3", "t1w2", "t1w1", "t1w7", "t1w6", "t1w5", "t1n1", "t1n2"};
    6971        // 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]);
    7274    }
    7375
     
    7577    void testAssociatedStreet() {
    7678        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);
    7880    }
    7981
     
    8183    void testStreet() {
    8284        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);
    8486    }
    8587
     
    9496        // Check the first way before sorting, otherwise the sorter
    9597        // 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"));
    9799
    98100        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
    99         Assert.assertArrayEquals(new String[]{
     101        assertArrayEquals(new String[]{
    100102            "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", "t5w4b",
    101103            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b",
     
    110112        // Check the first way before sorting, otherwise the sorter
    111113        // 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"));
    113115
    114116        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
    115         Assert.assertArrayEquals(new String[]{
     117        assertArrayEquals(new String[]{
    116118            "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b", "t5w4b",
    117119            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b",
     
    125127        Relation relation = getRelation("three-loops-ends-node");
    126128        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
    127         Assert.assertArrayEquals(new String[]{
     129        assertArrayEquals(new String[]{
    128130            "t5w4a", "t5w3a", "t5w2a", "t5w2b", "t5w3b", "t5w4b",
    129131            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b",
     
    136138        Relation relation = getRelation("one-loop-ends-split");
    137139        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
    138         Assert.assertArrayEquals(new String[]{
     140        assertArrayEquals(new String[]{
    139141            "t5w3a", "t5w4a", "t5w3b", "t5w4b",
    140142            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w6b", "t5w7b", "t5w8b",
     
    150152        // for now.
    151153        String[] actual = getNames(relation.getMembers());
    152         Assert.assertArrayEquals(new String[]{
     154        assertArrayEquals(new String[]{
    153155            "t5w7a", "t5w8a", "t5w7b", "t5w8b",
    154156            "t5w9a", "t5w10a", "t5w9b", "t5w10b",
     
    161163        // TODO: This is not yet sorted perfectly (might not be possible)
    162164        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
    163         Assert.assertArrayEquals(new String[]{
     165        assertArrayEquals(new String[]{
    164166            "t5w1", "t5w2a", "t5w3a", "t5w4a", "t5w2b", "t5w3b",
    165167            "t5w5", "t5w6a", "t5w7a", "t5w8a", "t5w9a", "t5w10a", "t5w11a", "t5w6b", "t5w7b",
     
    173175        // TODO: This is not always sorted properly, only when the right
    174176        // 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"));
    176178
    177179        String[] actual = getNames(sorter.sortMembers(relation.getMembers()));
    178         Assert.assertArrayEquals(new String[]{
     180        assertArrayEquals(new String[]{
    179181            "t6w1a", "t6w2a", "t6w3a",
    180182            "t6w1b", "t6w2b", "t6w3b",
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java

    r17275 r18690  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.dialogs.relation.sort;
     3
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    37
    48import java.io.IOException;
     
    1216import java.util.List;
    1317
    14 import org.junit.Assert;
    1518import org.junit.jupiter.api.BeforeEach;
    1619import org.junit.jupiter.api.Test;
     
    102105    void testEmpty() {
    103106        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(new ArrayList<>()));
    104         Assert.assertEquals("[]", actual);
     107        assertEquals("[]", actual);
    105108    }
    106109
     
    113116        Relation relation = getRelation("generic");
    114117        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);
    116119        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);
    118121    }
    119122
     
    122125        Relation relation = getRelation("associatedStreet");
    123126        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);
    125128        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);
    127130    }
    128131
     
    131134        Relation relation = getRelation("loop");
    132135        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);
    134137        //TODO Sorting doesn't work well in this case
    135138        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);
    137140    }
    138141
     
    147150        // Check the first way before sorting, otherwise the sorter
    148151        // 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"));
    150153        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
    151154        String expected = "[" +
     
    155158            "L FORWARD, L FORWARD" +
    156159        "]";
    157         Assert.assertEquals(expected, actual);
     160        assertEquals(expected, actual);
    158161    }
    159162
     
    163166        // Check the first way before sorting, otherwise the sorter
    164167        // 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"));
    166169        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
    167170        String expected = "[" +
     
    171174            "FORWARD" +
    172175        "]";
    173         Assert.assertEquals(expected, actual);
     176        assertEquals(expected, actual);
    174177    }
    175178
     
    183186            "FPH FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, FP FORWARD, BPT BACKWARD" +
    184187        "]";
    185         Assert.assertEquals(expected, actual);
     188        assertEquals(expected, actual);
    186189    }
    187190
     
    195198            "FPH FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD" +
    196199        "]";
    197         Assert.assertEquals(expected, actual);
     200        assertEquals(expected, actual);
    198201    }
    199202
     
    208211            "FPH FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD" +
    209212        "]";
    210         Assert.assertEquals(expected, actual);
     213        assertEquals(expected, actual);
    211214    }
    212215
     
    221224            "BACKWARD, FPH FORWARD, FP FORWARD, FP FORWARD" +
    222225        "]";
    223         Assert.assertEquals(expected, actual);
     226        assertEquals(expected, actual);
    224227    }
    225228
     
    229232        // TODO: This is not always sorted properly, only when the right
    230233        // 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"));
    232235        String actual = getConnections(wayConnectionTypeCalculator.updateLinks(sorter.sortMembers(relation.getMembers())));
    233236        String expected = "[" +
    234237            "FP FORWARD, FP FORWARD, FP FORWARD, BP BACKWARD, BP BACKWARD, BP BACKWARD" +
    235238        "]";
    236         Assert.assertEquals(expected, actual);
     239        assertEquals(expected, actual);
    237240    }
    238241
     
    256259        List<WayConnectionType> returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers());
    257260        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);
    270273
    271274        // Reverse the last oneway
     
    276279            returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers());
    277280            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);
    280283            }
    281284
    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);
    290293            reverseWay(way);
    291294        }
     
    298301            returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers());
    299302            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);
    302305            }
    303306        }
     
    309312        returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers());
    310313        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);
    313316        }
    314317    }
     
    326329        List<WayConnectionType> returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers());
    327330        for (WayConnectionType type : returned) {
    328             Assert.assertTrue(type.onewayFollowsNext);
    329             Assert.assertTrue(type.onewayFollowsPrevious);
     331            assertTrue(type.onewayFollowsNext);
     332            assertTrue(type.onewayFollowsPrevious);
    330333        }
    331334
     
    334337        returned = wayConnectionTypeCalculator.updateLinks(relation.getMembers());
    335338        for (WayConnectionType type : returned) {
    336             Assert.assertTrue(type.onewayFollowsNext);
    337             Assert.assertTrue(type.onewayFollowsPrevious);
     339            assertTrue(type.onewayFollowsNext);
     340            assertTrue(type.onewayFollowsPrevious);
    338341        }
    339342
     
    346349        for (int i = 0; i < returned.size() - 1; i++) {
    347350            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);
    353356    }
    354357}
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/validator/ValidatorTreePanelTest.java

    r18037 r18690  
    22package org.openstreetmap.josm.gui.dialogs.validator;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
    45import static org.junit.jupiter.api.Assertions.assertEquals;
    56import static org.junit.jupiter.api.Assertions.assertNotNull;
     
    3132    @Test
    3233    void testValidatorTreePanel() {
    33         assertNotNull(new ValidatorTreePanel());
     34        assertDoesNotThrow(() -> new ValidatorTreePanel());
    3435
    3536        ValidatorTreePanel vtp = new ValidatorTreePanel(new ArrayList<>(Arrays.asList(
     
    5960        vtp.setVisible(false);
    6061        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)
    6263                .message("")
    6364                .primitives(n)
    6465                .build()));
    6566        assertEquals(1, vtp.getErrors().size());
    66         vtp.selectRelatedErrors(Collections.<OsmPrimitive>singleton(n));
     67        vtp.selectRelatedErrors(Collections.singleton(n));
    6768        vtp.expandAll();
    6869        assertNotNull(vtp.getRoot());
    6970        vtp.resetErrors();
    70         Set<? extends OsmPrimitive> filter = new HashSet<>(Arrays.asList(n));
     71        Set<? extends OsmPrimitive> filter = new HashSet<>(Collections.singletonList(n));
    7172        vtp.setFilter(filter);
    7273        assertEquals(filter, vtp.getFilter());
    73         vtp.setFilter(new HashSet<OsmPrimitive>());
     74        vtp.setFilter(new HashSet<>());
    7475        assertNull(vtp.getFilter());
    7576        vtp.setFilter(null);
  • trunk/test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java

    r17275 r18690  
    5353
    5454    /**
    55      * Unit test of {@link HistoryLoadTask#loadHistory}
     55     * Unit test of {@link HistoryLoadTask#loadHistory(OsmServerHistoryReader, ProgressMonitor)}
    5656     * @throws OsmTransferException if an error occurs
    5757     */
  • trunk/test/unit/org/openstreetmap/josm/gui/io/AsynchronousUploadPrimitivesTaskTest.java

    r17275 r18690  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.io;
     3
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
    36
    47import java.util.Collections;
     
    710import javax.swing.JOptionPane;
    811
    9 import org.junit.Assert;
    1012import org.junit.jupiter.api.AfterEach;
    1113import org.junit.jupiter.api.BeforeEach;
     
    9496        Optional<AsynchronousUploadPrimitivesTask> task = AsynchronousUploadPrimitivesTask.
    9597                createAsynchronousUploadTask(strategy, layer, toUpload, changeset);
    96         Assert.assertNotNull(uploadPrimitivesTask);
    97         Assert.assertFalse(task.isPresent());
     98        assertNotNull(uploadPrimitivesTask);
     99        assertFalse(task.isPresent());
    98100    }
    99101}
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java

    r18008 r18690  
    55import static org.junit.jupiter.api.Assertions.assertEquals;
    66import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    78import static org.junit.jupiter.api.Assertions.assertNull;
    89import static org.junit.jupiter.api.Assertions.assertThrows;
     
    8889    /**
    8990     * 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() {
    9494        GpxLayer layer = new GpxLayer(new GpxData(), "foo", false);
    9595        GpxTrack trk = new GpxTrack(new ArrayList<IGpxTrackSegment>(), new HashMap<>());
     
    211211    void testGetTimespanForTrack() throws Exception {
    212212        assertEquals("", GpxLayer.getTimespanForTrack(
    213                 new GpxTrack(new ArrayList<Collection<WayPoint>>(), new HashMap<String, Object>())));
     213                new GpxTrack(new ArrayList<Collection<WayPoint>>(), new HashMap<>())));
    214214
    215215        assertEquals("2016-01-03 11:59:58 \u2013 12:00:00 (2.0 s)", GpxLayer.getTimespanForTrack(getMinimalGpxData().tracks.iterator().next()));
     
    238238    @Test
    239239    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));
    241243    }
    242244
     
    297299        assertNull(layer.getAssociatedFile());
    298300        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();
    303303        assertTrue(text.startsWith("<html>"), text);
    304304        assertTrue(text.endsWith("</html>"), text);
    305305        assertEquals("<html><br></html>", layer.getToolTipText());
    306         assertDoesNotThrow(() -> layer.jumpToNextMarker());
    307         assertDoesNotThrow(() -> layer.jumpToPreviousMarker());
     306        assertDoesNotThrow(layer::jumpToNextMarker);
     307        assertDoesNotThrow(layer::jumpToPreviousMarker);
    308308        assertDoesNotThrow(() -> layer.visitBoundingBox(new BoundingXYVisitor()));
    309309        assertDoesNotThrow(() -> layer.filterTracksByDate(null, null, false));
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java

    r17275 r18690  
    99import java.nio.file.Paths;
    1010import java.util.Arrays;
     11import java.util.Collections;
    1112import java.util.Comparator;
    1213import java.util.List;
     
    7374
    7475        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"));
    7778        testFromTrack("tracks.gpx", "tracks-ele.osm");
    7879
    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"));
    8182        testFromTrack("tracks.gpx", "tracks-time.osm");
    8283
     
    141142
    142143        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()))
    145146                .sorted()
    146147                .collect(Collectors.toList());
    147148
    148149        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()))
    151152                .sorted()
    152153                .collect(Collectors.toList());
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java

    r16159 r18690  
    33
    44import 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;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertNull;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.util.Collections;
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/AllMappaintTests.java

    r17275 r18690  
    22package org.openstreetmap.josm.gui.mappaint;
    33
    4 import org.junit.runner.RunWith;
    5 import org.junit.runners.Suite;
     4import org.junit.platform.suite.api.SelectClasses;
     5import org.junit.platform.suite.api.Suite;
    66import org.openstreetmap.josm.gui.mappaint.mapcss.AllMapCSSTests;
    77
     
    99 * All mappaint tests.
    1010 */
    11 @RunWith(Suite.class)
    12 @Suite.SuiteClasses({
     11@Suite
     12@SelectClasses({
    1313    LabelCompositionStrategyTest.class,
    1414    MapCSSWithExtendedTextDirectivesTest.class,
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.java

    r17275 r18690  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    56import static org.junit.jupiter.api.Assertions.assertNotNull;
    67import static org.junit.jupiter.api.Assertions.assertNull;
    7 import static org.junit.jupiter.api.Assertions.assertTrue;
    88
    99import java.awt.Color;
     
    4646        TextLabel te = TextLabel.create(env, Color.WHITE, false /* no default annotate */);
    4747        assertNotNull(te.labelCompositionStrategy);
    48         assertTrue(te.labelCompositionStrategy instanceof DeriveLabelFromNameTagsCompositionStrategy);
     48        assertInstanceOf(DeriveLabelFromNameTagsCompositionStrategy.class, te.labelCompositionStrategy);
    4949    }
    5050
     
    6363        TextLabel te = TextLabel.create(env, Color.WHITE, false /* no default annotate */);
    6464        assertNotNull(te.labelCompositionStrategy);
    65         assertTrue(te.labelCompositionStrategy instanceof TagLookupCompositionStrategy);
     65        assertInstanceOf(TagLookupCompositionStrategy.class, te.labelCompositionStrategy);
    6666        assertEquals("my_name", ((TagLookupCompositionStrategy) te.labelCompositionStrategy).getDefaultLabelTag());
    6767    }
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.java

    r14068 r18690  
    22package org.openstreetmap.josm.gui.mappaint.mapcss;
    33
    4 import org.junit.runner.RunWith;
    5 import org.junit.runners.Suite;
     4import org.junit.platform.suite.api.SelectClasses;
     5import org.junit.platform.suite.api.Suite;
    66
    77/**
    88 * All MapCSS tests.
    99 */
    10 @RunWith(Suite.class)
    11 @Suite.SuiteClasses({
     10@Suite
     11@SelectClasses({
    1212    KeyValueConditionTest.class,
    1313    ParsingLinkSelectorTest.class,
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionTest.java

    r18037 r18690  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    78
     
    5455        assertFalse(op.applies(genEnv(node4)));
    5556
    56         assertTrue(op instanceof SimpleKeyValueCondition);
     57        TagCondition tc = assertInstanceOf(SimpleKeyValueCondition.class, op);
    5758        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());
    6061    }
    6162
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java

    r17920 r18690  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    67import static org.junit.jupiter.api.Assertions.assertNotNull;
    78import static org.junit.jupiter.api.Assertions.assertNull;
     
    1617import java.util.regex.Pattern;
    1718
    18 import org.junit.Assert;
    1919import org.junit.jupiter.api.Test;
    2020import org.junit.jupiter.api.extension.RegisterExtension;
     
    8080    void testClassCondition() throws Exception {
    8181        List<Condition> conditions = getParser("way[name=X].highway:closed").selector().getConditions();
    82         assertTrue(conditions.get(0) instanceof SimpleKeyValueCondition);
     82        assertInstanceOf(SimpleKeyValueCondition.class, conditions.get(0));
    8383        assertTrue(conditions.get(0).applies(getEnvironment("name", "X")));
    84         assertTrue(conditions.get(1) instanceof ClassCondition);
    85         assertTrue(conditions.get(2) instanceof PseudoClassCondition);
     84        assertInstanceOf(ClassCondition.class, conditions.get(1));
     85        assertInstanceOf(PseudoClassCondition.class, conditions.get(2));
    8686        assertFalse(conditions.get(2).applies(getEnvironment("name", "X")));
    8787    }
     
    106106
    107107    @Test
    108     void testClassMatching() throws Exception {
     108    void testClassMatching() {
    109109        MapCSSStyleSource css = new MapCSSStyleSource(
    110110                "way[highway=footway] { set .path; color: #FF6644; width: 2; }\n" +
     
    147147    void testEqualCondition() throws Exception {
    148148        Condition condition = getParser("[surface=paved]").condition(PRIMITIVE);
    149         assertTrue(condition instanceof SimpleKeyValueCondition);
    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);
    152152        assertTrue(condition.applies(getEnvironment("surface", "paved")));
    153153        assertFalse(condition.applies(getEnvironment("surface", "unpaved")));
     
    315315    private void tagRegex(Way way, String parserString, Boolean[] expected) throws Exception {
    316316        Selector selector = getParser(parserString).selector();
    317         Assert.assertEquals(expected[0], selector.matches(new Environment(way)));
     317        assertEquals(expected[0], selector.matches(new Environment(way)));
    318318        way.put("old_ref", null);
    319         Assert.assertEquals(expected[1], selector.matches(new Environment(way)));
     319        assertEquals(expected[1], selector.matches(new Environment(way)));
    320320        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)));
    322322        way.put("old_ref", "A22");
    323         Assert.assertEquals(expected[3], selector.matches(new Environment(way)));
     323        assertEquals(expected[3], selector.matches(new Environment(way)));
    324324        way.put("old_ref", null);
    325325        way.put("OLD_REF", "A23");
    326         Assert.assertEquals(expected[4], selector.matches(new Environment(way)));
     326        assertEquals(expected[4], selector.matches(new Environment(way)));
    327327    }
    328328
     
    368368
    369369    @Test
    370     void testTicket8568() throws Exception {
     370    void testTicket8568() {
    371371        MapCSSStyleSource sheet = new MapCSSStyleSource(
    372372                "way { width: 5; }\n" +
     
    385385
    386386    @Test
    387     void testTicket8071() throws Exception {
     387    void testTicket8071() {
    388388        MapCSSStyleSource sheet = new MapCSSStyleSource(
    389389                "*[rcn_ref], *[name] {text: concat(tag(rcn_ref), \" \", tag(name)); }");
     
    421421
    422422    @Test
    423     void testColorParsing() throws Exception {
     423    void testColorParsing() {
    424424        assertEquals(new Color(0x12, 0x34, 0x56, 0x78), ColorHelper.html2color("#12345678"));
    425425    }
     
    459459
    460460    @Test
    461     void testParentTags() throws Exception {
     461    void testParentTags() {
    462462        DataSet ds = new DataSet();
    463463        Node n = new Node(new LatLon(1, 2));
     
    486486
    487487    @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"));
    490490        Way way1 = TestUtils.newWay("highway=residential name=Alpha alt_name=Beta ref=\"A9;A8\"", new Node(new LatLon(0.001, 0.001)),
    491491                new Node(new LatLon(0.002, 0.002)));
     
    508508
    509509    @Test
    510     void testUniqueValues() throws Exception {
    511         assertEquals(Arrays.asList(new String[] {"alpha", "beta"}),
     510    void testUniqueValues() {
     511        assertEquals(Arrays.asList("alpha", "beta"),
    512512                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() {
    519519        DataSet ds = new DataSet();
    520520        Way way1 = TestUtils.newWay("highway=residential name=1",
     
    596596
    597597    @Test
    598     void testInvalidBaseSelector() throws Exception {
     598    void testInvalidBaseSelector() {
    599599        MapCSSStyleSource css = new MapCSSStyleSource("invalid_base[key=value] {}");
    600600        css.loadStyleSource();
     
    624624        assertEquals(24.0, mc.getCascade(null).get("div"));
    625625        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"));
    627627        assertNull(mc.getCascade(null).get("null0"));
    628628        assertNull(mc.getCascade(null).get("null1"));
     
    631631
    632632    @Test
    633     void testMinMaxFunctions() throws Exception {
     633    void testMinMaxFunctions() {
    634634        MapCSSStyleSource sheet = new MapCSSStyleSource("* {" +
    635635                "min_value: min(tag(x), tag(y), tag(z)); " +
     
    700700    @Test
    701701    void testZoomIAE() {
    702         assertThrows(IllegalArgumentException.class, () -> getParser("|z16-15").zoom());
     702        final MapCSSParser parser = getParser("|z16-15");
     703        assertThrows(IllegalArgumentException.class, parser::zoom);
    703704    }
    704705
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/AbstractExtendedSourceEntryTestCase.java

    r17531 r18690  
    2323    protected static final List<String> errorsToIgnore = new ArrayList<>();
    2424
    25     protected static List<Object[]> getTestParameters(Collection<ExtendedSourceEntry> entries) throws Exception {
     25    protected static List<Object[]> getTestParameters(Collection<ExtendedSourceEntry> entries) {
    2626        return entries.stream().map(x -> new Object[] {x.getDisplayName(), cleanUrl(x.url), x}).collect(Collectors.toList());
    2727    }
     
    4545    protected final void handleException(ExtendedSourceEntry source, Throwable e, Set<String> errors, List<String> ignoredErrors) {
    4646        e.printStackTrace();
    47         String s = source.url + " => " + e.toString();
     47        String s = source.url + " => " + e;
    4848        if (isIgnoredSubstring(source, s)) {
    4949            ignoredErrors.add(s);
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/ToolbarPreferencesTest.java

    r17275 r18690  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.preferences;
     3
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    35
    46import java.awt.event.ActionEvent;
     
    1113import javax.swing.Action;
    1214
    13 import org.junit.Assert;
    1415import org.junit.jupiter.api.Test;
    1516import org.openstreetmap.josm.actions.ActionParameter;
     
    5455            expected.put((String) params[i], params[i+1]);
    5556        }
    56         Assert.assertEquals(expected, a.getParameters());
     57        assertEquals(expected, a.getParameters());
    5758    }
    5859
     
    7374        checkAction(parser.loadAction("action(uknownParam=aa)"));
    7475
    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        );
    8182    }
    8283}
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java

    r18211 r18690  
    146146
    147147    private static boolean isIgnoredSubstring(String substring) {
    148         return errorsToIgnore.parallelStream().anyMatch(x -> substring.contains(x));
     148        return errorsToIgnore.parallelStream().anyMatch(substring::contains);
    149149    }
    150150
     
    342342            }
    343343        } catch (IOException | RuntimeException | WMSGetCapabilitiesException e) {
    344             addError(info, info.getUrl() + ERROR_SEP + e.toString());
     344            addError(info, info.getUrl() + ERROR_SEP + e);
    345345        }
    346346
     
    394394                return new WMTSTileSource(info, proj);
    395395            } catch (IOException | WMTSGetCapabilitiesException e) {
    396                 addError(info, info.getUrl() + ERROR_SEP + e.toString());
     396                addError(info, info.getUrl() + ERROR_SEP + e);
    397397                return null;
    398398            }
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java

    r17195 r18690  
    44import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
    55import 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;
     6import static org.junit.jupiter.api.Assertions.assertEquals;
     7import static org.junit.jupiter.api.Assertions.assertFalse;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.awt.Component;
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java

    r17369 r18690  
    55import static org.hamcrest.MatcherAssert.assertThat;
    66import static org.junit.jupiter.api.Assertions.assertEquals;
     7import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    78import static org.junit.jupiter.api.Assertions.assertTrue;
    89import static org.junit.jupiter.api.Assertions.fail;
     
    1314import java.util.stream.Collectors;
    1415
    15 import org.junit.Assert;
    1616import org.junit.jupiter.api.Test;
    1717import org.junit.jupiter.api.extension.RegisterExtension;
     
    4545        String presetfile = TestUtils.getRegressionDataFile(8954, "preset.xml");
    4646        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");
    4848        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");
    5050        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");
    5252    }
    5353
     
    9393        String presetfile = "resource://data/defaultpresets.xml";
    9494        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");
    9696    }
    9797}
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetsTest.java

    r18683 r18690  
    33
    44import static org.junit.jupiter.api.Assertions.assertAll;
     5import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    56import static org.junit.jupiter.api.Assertions.assertSame;
    6 import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    88import java.util.Collection;
     
    6262        assertAll(() -> assertSame(menu.presetSearchAction, presetsMenu.getItem(0).getAction()),
    6363                () -> assertSame(menu.presetSearchPrimitiveAction, presetsMenu.getItem(1).getAction()),
    64                 () -> assertTrue(presetsMenu.getItem(2).getAction() instanceof PreferencesAction),
    65                 () -> assertTrue(presetsMenu.getMenuComponent(3) instanceof JSeparator));
     64                () -> assertInstanceOf(PreferencesAction.class, presetsMenu.getItem(2).getAction()),
     65                () -> assertInstanceOf(JSeparator.class, presetsMenu.getMenuComponent(3)));
    6666    }
    6767
  • trunk/test/unit/org/openstreetmap/josm/gui/widgets/HistoryComboBoxTest.java

    r18131 r18690  
    2121class HistoryComboBoxTest {
    2222    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));
    2424    }
    2525
     
    5959        historyComboBox.addCurrentItemToHistory();
    6060
    61         // add a new item
     61        // Add a new item
    6262        historyComboBox.getEditor().setItem(new AutoCompletionItem("testNonRegression21215_2"));
    6363        historyComboBox.addCurrentItemToHistory();
Note: See TracChangeset for help on using the changeset viewer.