Ignore:
Timestamp:
2023-03-21T14:49:10+01:00 (20 months ago)
Author:
taylor.smock
Message:

See #16567: Convert most plugin tests to JUnit 5

Location:
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideAbstractImageTest.java

    r34432 r36064  
    22package org.openstreetmap.josm.plugins.streetside;
    33
    4 import static org.junit.Assert.assertFalse;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    7 import org.junit.Test;
     7import org.junit.jupiter.api.Test;
    88import org.openstreetmap.josm.data.coor.LatLon;
    99
    10 public class StreetsideAbstractImageTest {
    11 
    12   /*@Rule
    13   public JOSMTestRules rules = new StreetsideTestRules().platform();*/
    14 
     10class StreetsideAbstractImageTest {
    1511  @Test
    16   public void testIsModified() {
     12  void testIsModified() {
    1713    StreetsideImage img = new StreetsideImage("key___________________", new LatLon(0, 0), 0);
    1814    assertFalse(img.isModified());
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideDataTest.java

    r34434 r36064  
    22package org.openstreetmap.josm.plugins.streetside;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
    58
    69import java.util.Arrays;
    710import java.util.concurrent.ConcurrentSkipListSet;
    811
    9 import org.junit.Before;
    10 import org.junit.Ignore;
    11 import org.junit.Test;
     12import org.junit.jupiter.api.BeforeEach;
     13import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.condition.DisabledIf;
    1215import org.openstreetmap.josm.data.coor.LatLon;
    1316
     
    1821 * @see StreetsideData
    1922 */
    20 public class StreetsideDataTest {
     23@DisabledIf(value = "org.openstreetmap.josm.plugins.streetside.utils.TestUtil#cannotLoadImages", disabledReason = "At JOSM maintainer request (flaky?)")
     24class StreetsideDataTest {
    2125
    2226  /*@Rule
     
    3337   * objects and a {@link StreetsideSequence} object.
    3438   */
    35   @Before
     39  @BeforeEach
    3640  public void setUp() {
    3741    img1 = new StreetsideImage("id1__________________", new LatLon(0.1, 0.1), 90);
     
    5155   * another one in the database, the one that is being added should be ignored.
    5256   */
    53   @Ignore
    5457  @Test
    55   public void addTest() {
     58  void testAdd() {
    5659    data = new StreetsideData();
    5760    assertEquals(0, data.getImages().size());
     
    6972   * Test that the size is properly calculated.
    7073   */
    71   @Ignore
    7274  @Test
    73   public void sizeTest() {
     75  void testSize() {
    7476    assertEquals(4, data.getImages().size());
    7577    data.add(new StreetsideImage("id5__________________", new LatLon(0.1, 0.1), 90));
     
    8183   * and {@link StreetsideData#getHighlightedImage()} methods.
    8284   */
    83   @Ignore
    8485  @Test
    85   public void highlighTest() {
     86  void testHighlight() {
    8687    data.setHighlightedImage(img1);
    8788    assertEquals(img1, data.getHighlightedImage());
    8889
    8990    data.setHighlightedImage(null);
    90     assertEquals(null, data.getHighlightedImage());
     91    assertNull(data.getHighlightedImage());
    9192  }
    9293
     
    9495   * Tests the selection of images.
    9596   */
    96   @Ignore
    9797  @Test
    98   public void selectTest() {
     98  void testSelect() {
    9999    data.setSelectedImage(img1);
    100100    assertEquals(img1, data.getSelectedImage());
     
    104104
    105105    data.setSelectedImage(null);
    106     assertEquals(null, data.getSelectedImage());
     106    assertNull(data.getSelectedImage());
    107107  }
    108108
     
    111111   * {@link StreetsideData#selectPrevious()} methods.
    112112   */
    113   @Ignore
    114113  @Test
    115   public void nextAndPreviousTest() {
     114  void testNextAndPrevious() {
    116115    data.setSelectedImage(img1);
    117116
     
    126125  }
    127126
    128   @Ignore
    129   @Test(expected=IllegalStateException.class)
    130   public void nextOfNullImgTest() {
     127  @Test
     128  void testNextOfNullImg() {
    131129    data.setSelectedImage(null);
    132     data.selectNext();
     130    assertThrows(IllegalStateException.class, data::selectNext);
    133131  }
    134132
    135   @Ignore
    136   @Test(expected=IllegalStateException.class)
    137   public void previousOfNullImgTest() {
     133  @Test
     134  void testPreviousOfNullImg() {
    138135    data.setSelectedImage(null);
    139     data.selectPrevious();
     136    assertThrows(IllegalStateException.class, data::selectPrevious);
    140137  }
    141138
     
    144141   * multiselected List should reset.
    145142   */
    146   @Ignore
    147143  @Test
    148   public void multiSelectTest() {
     144  void testMultiSelect() {
    149145    assertEquals(0, data.getMultiSelectedImages().size());
    150146    data.setSelectedImage(img1);
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideLayerTest.java

    r34434 r36064  
    22package org.openstreetmap.josm.plugins.streetside;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertNotNull;
    7 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    88
    9 import org.junit.Ignore;
    10 import org.junit.Rule;
    11 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
     10import org.junit.jupiter.api.condition.DisabledIf;
    1211import org.openstreetmap.josm.data.coor.LatLon;
    1312import org.openstreetmap.josm.data.imagery.ImageryInfo;
     
    1514import org.openstreetmap.josm.gui.layer.Layer;
    1615import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils;
    17 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    1816import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     18import org.openstreetmap.josm.testutils.annotations.Main;
     19import org.openstreetmap.josm.testutils.annotations.Projection;
    1920
    20 public class StreetsideLayerTest {
    21 
    22   @Rule
    23   public JOSMTestRules rules = new StreetsideTestRules().main().preferences().projection();
    24 
     21@BasicPreferences
     22@Main
     23@Projection
     24@DisabledIf(value = "org.openstreetmap.josm.plugins.streetside.utils.TestUtil#cannotLoadImages", disabledReason = "At JOSM maintainer request (flaky?)")
     25class StreetsideLayerTest {
    2526  private static Layer getDummyLayer() {
    2627    return ImageryLayer.create(new ImageryInfo("dummy", "https://example.org"));
    2728  }
    2829
    29   @Ignore
    3030  @Test
    31   public void testGetIcon() {
     31  void testGetIcon() {
    3232    assertNotNull(StreetsideLayer.getInstance().getIcon());
    3333  }
    3434
    35   @Ignore
    3635  @Test
    37   public void testIsMergable() {
     36  void testIsMergable() {
    3837    assertFalse(StreetsideLayer.getInstance().isMergable(getDummyLayer()));
    3938  }
    4039
    41   @Ignore
    42   @Test(expected = UnsupportedOperationException.class)
    43   public void testMergeFrom() {
    44     StreetsideLayer.getInstance().mergeFrom(getDummyLayer());
     40  @Test
     41  void testMergeFrom() {
     42    StreetsideLayer layer = StreetsideLayer.getInstance();
     43    Layer dummyLayer = getDummyLayer();
     44    assertThrows(UnsupportedOperationException.class, () -> layer.mergeFrom(dummyLayer));
    4545  }
    4646
    47   @Ignore
    4847  @Test
    49   public void testSetVisible() {
     48  void testSetVisible() {
    5049    StreetsideLayer.getInstance().getData().add(new StreetsideImage(CubemapUtils.TEST_IMAGE_ID, new LatLon(0.0, 0.0), 0.0));
    5150    StreetsideLayer.getInstance().getData().add(new StreetsideImage(CubemapUtils.TEST_IMAGE_ID, new LatLon(0.0, 0.0), 0.0));
     
    5655    StreetsideLayer.getInstance().setVisible(false);
    5756    for (StreetsideAbstractImage img : StreetsideLayer.getInstance().getData().getImages()) {
    58       assertEquals(false, img.isVisible());
     57      assertFalse(img.isVisible());
    5958    }
    6059
     
    6261    StreetsideLayer.getInstance().setVisible(true);
    6362    for (StreetsideAbstractImage img : StreetsideLayer.getInstance().getData().getImages()) {
    64       assertEquals(true, img.isVisible());
     63      assertTrue(img.isVisible());
    6564    }
    6665  }
    6766
    68   @Ignore
    6967  @Test
    70   public void testGetInfoComponent() {
     68  void testGetInfoComponent() {
    7169    Object comp = StreetsideLayer.getInstance().getInfoComponent();
    7270    assertTrue(comp instanceof String);
     
    7472  }
    7573
    76   @Ignore
    7774  @Test
    78   public void testClearInstance() {
     75  void testClearInstance() {
    7976    StreetsideLayer.getInstance();
    8077    assertTrue(StreetsideLayer.hasInstance());
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideSequenceTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
    6 import static org.junit.Assert.assertTrue;
    7 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    87
    98import java.util.Arrays;
    109
    11 import org.junit.Before;
    12 import org.junit.Test;
    13 
     10import org.junit.jupiter.api.BeforeEach;
     11import org.junit.jupiter.api.Test;
    1412import org.openstreetmap.josm.data.coor.LatLon;
    1513
     
    2018 * @see StreetsideSequence
    2119 */
    22 public class StreetsideSequenceTest {
     20class StreetsideSequenceTest {
    2321
    2422  private final StreetsideImage img1 = new StreetsideImage("key1", new LatLon(0.1, 0.1), 90);
     
    3331   * {@link StreetsideSequence} object.
    3432   */
    35   @Before
     33  @BeforeEach
    3634  public void setUp() {
    3735    seq.add(Arrays.asList(img1, img2, img3, img4));
     
    4341   */
    4442  @Test
    45   public void nextAndPreviousTest() {
     43  void testNextAndPrevious() {
    4644    assertEquals(img2, img1.next());
    4745    assertEquals(img1, img2.previous());
     
    6058    // Test IllegalArgumentException when asking for the next image of an image
    6159    // that is not in the sequence.
    62     try {
    63       seq.next(imgWithoutSeq);
    64       fail();
    65     } catch (IllegalArgumentException e) {
    66       assertTrue(true);
    67     }
     60    assertThrows(IllegalArgumentException.class, () -> seq.next(imgWithoutSeq));
     61
    6862    // Test IllegalArgumentException when asking for the previous image of an
    6963    // image that is not in the sequence.
    70     try {
    71       seq.previous(imgWithoutSeq);
    72       fail();
    73     } catch (IllegalArgumentException e) {
    74       assertTrue(true);
    75     }
     64    assertThrows(IllegalArgumentException.class, () -> seq.previous(imgWithoutSeq));
    7665  }
    7766}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cache/CachesTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.cache;
    33
    4 import org.junit.Test;
    54
     5import org.junit.jupiter.api.Test;
    66import org.openstreetmap.josm.plugins.streetside.utils.TestUtil;
    77
    8 public class CachesTest {
     8class CachesTest {
    99
    1010  @Test
    11   public void testUtilityClass() {
     11  void testUtilityClass() {
    1212    TestUtil.testUtilityClass(Caches.class);
    1313  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cache/StreetsideCacheTest.java

    r34386 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.streetside.cache;
    3 //License: GPL. For details, see LICENSE file.
    43
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertNotNull;
    7 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
    87
    9 import org.junit.Rule;
    10 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
     9import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache.Type;
     10import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1111
    12 import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache.Type;
    13 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
    15 
    16 public class StreetsideCacheTest {
    17 
    18   @Rule
    19   public JOSMTestRules rules = new StreetsideTestRules().preferences();
     12@BasicPreferences
     13class StreetsideCacheTest {
    2014
    2115  @Test
    22   public void test() {
     16  void testCache() {
    2317    StreetsideCache cache = new StreetsideCache("00000", Type.FULL_IMAGE);
    2418    assertNotNull(cache.getUrl());
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapUtilsTest.java

    r34432 r36064  
    11package org.openstreetmap.josm.plugins.streetside.cubemap;
    22
    3 import static org.junit.Assert.assertEquals;
    43
    5 import org.junit.Ignore;
    6 import org.junit.Test;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    75
    8 public class CubemapUtilsTest {
     6import org.junit.jupiter.api.Disabled;
     7import org.junit.jupiter.api.Test;
    98
    10   @SuppressWarnings("static-method")
     9class CubemapUtilsTest {
     10
    1111  @Test
    12   public final void testConvertDecimal2Quaternary() {
    13    final long decimal0 = 680730040l;
    14    final long decimal1 = 680931568l;
     12  void testConvertDecimal2Quaternary() {
     13   final long decimal0 = 680730040L;
     14   final long decimal1 = 680931568L;
    1515   String res = CubemapUtils.convertDecimal2Quaternary(decimal0);
    1616   assertEquals("220210301312320", res);
     
    1919  }
    2020
    21   @SuppressWarnings("static-method")
    2221  @Test
    23   public final void testConvertQuaternary2Decimal() {
     22  void testConvertQuaternary2Decimal() {
    2423    final String quadKey0 = "220210301312320";
    2524    final String quadKey1 = "220211203003300";
     
    3029  }
    3130
    32   @SuppressWarnings("static-method")
    33   @Ignore
     31  @Disabled
    3432  @Test
    35   public final void testGetFaceNumberForCount() {
     33  void testGetFaceNumberForCount() {
    3634    String faceNrFront = CubemapUtils.getFaceNumberForCount(0);
    3735    String faceNrRight = CubemapUtils.getFaceNumberForCount(1);
     
    4846  }
    4947
    50   @SuppressWarnings("static-method")
    51   @Ignore
     48  @Disabled
    5249  @Test
    53   public final void testGetCount4FaceNumber() {
     50  void testGetCount4FaceNumber() {
    5451    int count4Front = CubemapUtils.getCount4FaceNumber("01");
    5552    int count4Right = CubemapUtils.getCount4FaceNumber("02");
     
    6663  }
    6764
    68   @SuppressWarnings("static-method")
    6965  @Test
    70   public final void testConvertDoubleCountNrto16TileNr() {
     66  void testConvertDoubleCountNrto16TileNr() {
    7167    String x0y0 = CubemapUtils.convertDoubleCountNrto16TileNr("00");
    7268    String x0y1 = CubemapUtils.convertDoubleCountNrto16TileNr("01");
     
    9288    assertEquals(x1y0, "02");
    9389    assertEquals(x1y1, "03");
    94     assertEquals(x1y2,"12");
     90    assertEquals(x1y2, "12");
    9591    assertEquals(x1y3, "13");
    9692    assertEquals(x2y0, "20");
     
    9995    assertEquals(x2y3, "31");
    10096    assertEquals(x3y0, "22");
    101     assertEquals(x3y1,"23");
     97    assertEquals(x3y1, "23");
    10298    assertEquals(x3y2, "32");
    10399    assertEquals(x3y3, "33");
    104100  }
    105 
    106101}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/TileDownloadingTaskTest.java

    r34428 r36064  
    11package org.openstreetmap.josm.plugins.streetside.cubemap;
    22
    3 import static org.junit.Assert.assertEquals;
    4 import static org.junit.Assert.fail;
     3
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.util.ArrayList;
     
    1111import java.util.concurrent.Future;
    1212
    13 import org.junit.Ignore;
    14 import org.junit.Test;
     13import org.junit.jupiter.api.Disabled;
     14import org.junit.jupiter.api.Test;
    1515
    16 public class TileDownloadingTaskTest {
     16@Disabled
     17class TileDownloadingTaskTest {
    1718
    18   @SuppressWarnings("static-method")
    19   @Ignore
    2019  @Test
    21   public final void testCall() {
     20  final void testCall() throws InterruptedException {
    2221    ExecutorService pool = Executors.newFixedThreadPool(1);
    2322    List<Callable<List<String>>> tasks = new ArrayList<>(1);
    2423      tasks.add(new TileDownloadingTask("2202112030033001233"));
    25       try {
    26         List<Future<List<String>>> results = pool.invokeAll(tasks);
    27         assertEquals(results.get(0),"2202112030033001233");
    28       } catch (InterruptedException e) {
    29         e.printStackTrace();
    30         fail("Test threw an exception.");
    31       }
     24    List<Future<List<String>>> results = pool.invokeAll(tasks);
     25    assertEquals(results.get(0), "2202112030033001233");
    3226  }
    3327}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/ImageDisplayTest.java

    r34432 r36064  
    22package org.openstreetmap.josm.plugins.streetside.gui;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.awt.GraphicsEnvironment;
     
    1111import javax.swing.JFrame;
    1212
    13 import org.junit.Rule;
    14 import org.junit.Test;
    15 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.junit.jupiter.api.Test;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1715
    1816/**
    1917 * Tests {@link StreetsideImageDisplay}
    2018 */
    21 public class ImageDisplayTest {
    22 
    23   @Rule
    24   public JOSMTestRules rules = new StreetsideTestRules().preferences();
     19@BasicPreferences
     20class ImageDisplayTest {
    2521
    2622  private static final BufferedImage DUMMY_IMAGE = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
    2723
    2824  @Test
    29   public void testImagePersistence() {
     25  void testImagePersistence() {
    3026    StreetsideImageDisplay display = new StreetsideImageDisplay();
    3127    display.setImage(DUMMY_IMAGE, null);
     
    3935
    4036  @Test
    41   public void testMouseWheelMoved() {
     37  void testMouseWheelMoved() {
    4238    if (GraphicsEnvironment.isHeadless()) {
    4339      return;
     
    6561   */
    6662  @Test
    67   public void testMouseClicked() {
     63  void testMouseClicked() {
    6864    if (GraphicsEnvironment.isHeadless()) {
    6965      return;
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/StreetsidePreferenceSettingTest.java

    r34434 r36064  
    11package org.openstreetmap.josm.plugins.streetside.gui;
    22
    3 import static org.junit.Assert.assertEquals;
    4 import static org.junit.Assert.assertFalse;
     3import static org.junit.jupiter.api.Assertions.assertEquals;
    54import static org.openstreetmap.josm.plugins.streetside.utils.TestUtil.getPrivateFieldValue;
    65
     
    1110import javax.swing.SpinnerNumberModel;
    1211
    13 import org.junit.Ignore;
    14 import org.junit.Rule;
    15 import org.junit.Test;
     12import org.junit.jupiter.api.Assertions;
     13import org.junit.jupiter.api.Disabled;
     14import org.junit.jupiter.api.Test;
    1615import org.openstreetmap.josm.data.preferences.BooleanProperty;
    1716import org.openstreetmap.josm.data.preferences.StringProperty;
    1817import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    1918import org.openstreetmap.josm.plugins.streetside.io.download.StreetsideDownloader.DOWNLOAD_MODE;
    20 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.Main;
    2220
    23 public class StreetsidePreferenceSettingTest {
    24 
    25   @Rule
    26   public JOSMTestRules rules = new StreetsideTestRules().main();
    27 
     21@Main
     22@Disabled
     23class StreetsidePreferenceSettingTest {
    2824  // TODO: repair broken unit test from Mapillary
    29   @Ignore
    3025  @Test
    31   public void testAddGui() {
     26  void testAddGui() {
    3227    if (GraphicsEnvironment.isHeadless()) {
    3328      return;
     
    4237  }
    4338
    44   @Ignore
    4539  @Test
    46   public void testIsExpert() {
    47     assertFalse(new StreetsidePreferenceSetting().isExpert());
     40  void testIsExpert() {
     41    Assertions.assertFalse(new StreetsidePreferenceSetting().isExpert());
    4842  }
    4943
    5044  @SuppressWarnings("unchecked")
    51   @Ignore
    5245  @Test
    53   public void testOk() {
     46  void testOk() {
    5447    StreetsidePreferenceSetting settings = new StreetsidePreferenceSetting();
    5548
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/boilerplate/SelectableLabelTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.gui.boilerplate;
    33
    4 import static org.junit.Assert.assertFalse;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    7 import org.junit.Test;
     7import org.junit.jupiter.api.Test;
    88
    9 public class SelectableLabelTest {
     9
     10class SelectableLabelTest {
    1011  @Test
    11   public void test() {
     12  void testSelectableLabel() {
    1213    SelectableLabel l1 = new SelectableLabel();
    1314    assertFalse(l1.isEditable());
     
    1516    assertTrue(l2.getText().contains("some text"));
    1617    assertFalse(l2.isEditable());
    17 
    1818  }
    1919}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/history/StreetsideRecordTest.java

    r34433 r36064  
    22package org.openstreetmap.josm.plugins.streetside.history;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.fail;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67
    78import java.util.Arrays;
     
    910import java.util.concurrent.ConcurrentSkipListSet;
    1011
    11 import org.junit.Before;
    12 import org.junit.Ignore;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     12import org.junit.jupiter.api.BeforeEach;
     13import org.junit.jupiter.api.Disabled;
     14import org.junit.jupiter.api.Test;
    1515import org.openstreetmap.josm.data.coor.LatLon;
    1616import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
     
    2222import org.openstreetmap.josm.plugins.streetside.history.commands.CommandUnjoin;
    2323import org.openstreetmap.josm.plugins.streetside.history.commands.StreetsideCommand;
    24 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    25 import org.openstreetmap.josm.testutils.JOSMTestRules;
     24import org.openstreetmap.josm.testutils.annotations.Main;
     25import org.openstreetmap.josm.testutils.annotations.Projection;
    2626
    2727/**
     
    3030 * @author nokutu
    3131 */
    32 public class StreetsideRecordTest {
    33 
    34   @Rule
    35   public JOSMTestRules rules = new StreetsideTestRules().main().projection();
     32@Main
     33@Projection
     34@Disabled
     35class StreetsideRecordTest {
    3636
    3737  private StreetsideRecord record;
     
    4444   * objects.
    4545   */
    46   @Before
     46  @BeforeEach
    4747  public void setUp() {
    4848    record = new StreetsideRecord();
     
    5858   * Test commands in general.
    5959   */
    60   @Ignore
    61   @Test
    62   public void commandTest() {
     60  @Test
     61  void testCommand() {
    6362    StreetsideCommand cmd12 = new CommandMove(
    6463            new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)),
     
    115114   * Tests {@link CommandMove} class.
    116115   */
    117   @Ignore
    118   @Test
    119   public void commandMoveTest() {
     116  @Test
     117  void testCommandMove() {
    120118    CommandMove cmd1 = new CommandMove(
    121119            new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)),
     
    150148   * Tests {@link CommandTurn} class.
    151149   */
    152   @Ignore
    153   @Test
    154   public void commandTurnTest() {
     150  @Test
     151  void testCommandTurn() {
    155152    CommandTurn cmd1 = new CommandTurn(
    156153            new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)),
     
    182179   * Tests {@link CommandJoin} class.
    183180   */
    184   @Ignore
    185   @Test
    186   public void commandJoinClass() {
     181  @Test
     182  void testCommandJoinClass() {
    187183    CommandJoin cmd1 = new CommandJoin(img1, img2);
    188184    CommandJoin cmd2 = new CommandJoin(img2, img3);
     
    199195  }
    200196
    201   @Ignore
    202   @Test(expected=NullPointerException.class)
    203   public void commandJoinNull1() {
    204     new CommandJoin(img1, null);
    205   }
    206 
    207   @Ignore
    208   @Test(expected=NullPointerException.class)
    209   public void commandJoinNull2() {
    210     new CommandJoin(null, img1);
     197  @Test
     198  void testCommandJoinNull1() {
     199    assertThrows(NullPointerException.class, () -> new CommandJoin(img1, null));
     200  }
     201
     202  @Test
     203  void commandJoinNull2() {
     204    assertThrows(NullPointerException.class, () -> new CommandJoin(null, img1));
    211205  }
    212206
     
    214208   * Tests {@link CommandUnjoin} class.
    215209   */
    216   @Ignore
    217   @Test
    218   public void commandUnjoinClass() {
     210  @Test
     211  void testCommandUnjoinClass() {
    219212    CommandJoin join1 = new CommandJoin(img1, img2);
    220213    CommandJoin join2 = new CommandJoin(img2, img3);
     
    237230    assertEquals(1, img2.getSequence().getImages().size());
    238231
    239     try {
    240       record.addCommand(new CommandUnjoin(Arrays.asList(new StreetsideAbstractImage[]{img1, img2, img3})));
    241       fail();
    242     } catch (IllegalArgumentException e) {
    243       // Expected output.
    244     }
     232    CommandUnjoin command = new CommandUnjoin(Arrays.asList(new StreetsideAbstractImage[]{img1, img2, img3}));
     233    assertThrows(IllegalArgumentException.class, () -> record.addCommand(command));
    245234  }
    246235}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/io/download/SequenceDownloadRunnableTest.java

    r34577 r36064  
    22package org.openstreetmap.josm.plugins.streetside.io.download;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
    56
    67import java.lang.reflect.Field;
     
    910import java.util.function.Function;
    1011
    11 import org.junit.AfterClass;
    12 import org.junit.Ignore;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     12import org.junit.jupiter.api.Disabled;
     13import org.junit.jupiter.api.Test;
    1514import org.openstreetmap.josm.data.Bounds;
    16 import org.openstreetmap.josm.gui.MainApplication;
    1715import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
    1816import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties;
    19 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    20 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.LayerManager;
    2118
    22 public class SequenceDownloadRunnableTest {
    23 
    24   @Rule
    25   public JOSMTestRules rules = new StreetsideTestRules();
     19@Disabled
     20@LayerManager
     21class SequenceDownloadRunnableTest {
    2622
    2723  private static final Function<Bounds, URL> SEARCH_SEQUENCES_URL_GEN = b -> {
     
    3026  private Field urlGenField;
    3127
    32   @AfterClass
    33   public static void tearDown() {
    34     MainApplication.getLayerManager().resetState();
    35   }
    3628
    37   @Ignore
    3829  @Test
    39   public void testRun1() throws IllegalArgumentException, IllegalAccessException {
     30  void testRun1() throws IllegalArgumentException, IllegalAccessException {
    4031    testNumberOfDecodedImages(4, SEARCH_SEQUENCES_URL_GEN, new Bounds(7.246497, 16.432955, 7.249027, 16.432976));
    4132  }
    4233
    43   @Ignore
    4434  @Test
    45   public void testRun2() throws IllegalArgumentException, IllegalAccessException {
     35  void testRun2() throws IllegalArgumentException, IllegalAccessException {
    4636    testNumberOfDecodedImages(0, SEARCH_SEQUENCES_URL_GEN, new Bounds(0, 0, 0, 0));
    4737  }
    4838
    49   @Ignore
    5039  @Test
    51   public void testRun3() throws IllegalArgumentException, IllegalAccessException {
     40  void testRun3() throws IllegalArgumentException, IllegalAccessException {
    5241    testNumberOfDecodedImages(0, b -> {
    5342      try { return new URL("https://streetside/nonexistentURL"); } catch (MalformedURLException e) { return null; }
     
    5544  }
    5645
    57   @Ignore
    5846  @Test
    59   public void testRun4() throws IllegalArgumentException, IllegalAccessException {
     47  void testRun4() throws IllegalArgumentException, IllegalAccessException {
    6048    StreetsideProperties.CUT_OFF_SEQUENCES_AT_BOUNDS.put(true);
    6149    testNumberOfDecodedImages(4, SEARCH_SEQUENCES_URL_GEN, new Bounds(7.246497, 16.432955, 7.249027, 16.432976));
    6250  }
    6351
    64   @Ignore
    6552  @Test
    66   public void testRun5() throws IllegalArgumentException, IllegalAccessException {
     53  void testRun5() throws IllegalArgumentException, IllegalAccessException {
    6754    StreetsideProperties.CUT_OFF_SEQUENCES_AT_BOUNDS.put(true);
    6855    testNumberOfDecodedImages(0, SEARCH_SEQUENCES_URL_GEN, new Bounds(0, 0, 0, 0));
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/ImageUtilTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
    56
    67import java.awt.image.BufferedImage;
     
    89import javax.swing.ImageIcon;
    910
    10 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
    1112
    12 public class ImageUtilTest {
     13
     14class ImageUtilTest {
    1315
    1416  @Test
    15   public void testUtilityClass() {
     17  void testUtilityClass() {
    1618    TestUtil.testUtilityClass(ImageUtil.class);
    1719  }
    1820
    1921  @Test
    20   public void testScaleImageIcon() {
     22  void testScaleImageIcon() {
    2123    ImageIcon largeLandscape = new ImageIcon(new BufferedImage(72, 60, BufferedImage.TYPE_4BYTE_ABGR));
    2224    ImageIcon largePortrait = new ImageIcon(new BufferedImage(56, 88, BufferedImage.TYPE_4BYTE_ABGR));
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/PluginStateTest.java

    r34583 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    58
    69import javax.swing.JOptionPane;
    710
    8 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
    912import org.openstreetmap.josm.TestUtils;
    1013import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
     
    1619 * @see PluginState
    1720 */
    18 public class PluginStateTest {
     21class PluginStateTest {
    1922
    2023  /**
     
    2225   */
    2326  @Test
    24   public void downloadTest() {
    25     assertEquals(false, PluginState.isDownloading());
     27  void testDownload() {
     28    assertFalse(PluginState.isDownloading());
    2629    PluginState.startDownload();
    27     assertEquals(true, PluginState.isDownloading());
     30    assertTrue(PluginState.isDownloading());
    2831    PluginState.startDownload();
    29     assertEquals(true, PluginState.isDownloading());
     32    assertTrue(PluginState.isDownloading());
    3033    PluginState.finishDownload();
    31     assertEquals(true, PluginState.isDownloading());
     34    assertTrue(PluginState.isDownloading());
    3235    PluginState.finishDownload();
    33     assertEquals(false, PluginState.isDownloading());
     36    assertFalse(PluginState.isDownloading());
    3437  }
    3538
     
    3841   */
    3942  @Test
    40   public void uploadTest() {
     43  void testUpload() {
    4144    TestUtils.assumeWorkingJMockit();
    4245    JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker();
     
    4548            JOptionPane.OK_OPTION
    4649        );
    47     assertEquals(false, PluginState.isUploading());
     50    assertFalse(PluginState.isUploading());
    4851    PluginState.addImagesToUpload(2);
    4952    assertEquals(2, PluginState.getImagesToUpload());
    5053    assertEquals(0, PluginState.getImagesUploaded());
    51     assertEquals(true, PluginState.isUploading());
     54    assertTrue(PluginState.isUploading());
    5255    PluginState.imageUploaded();
    5356    assertEquals(1, PluginState.getImagesUploaded());
    54     assertEquals(true, PluginState.isUploading());
     57    assertTrue(PluginState.isUploading());
    5558    PluginState.imageUploaded();
    56     assertEquals(false, PluginState.isUploading());
     59    assertFalse(PluginState.isUploading());
    5760    assertEquals(2, PluginState.getImagesToUpload());
    5861    assertEquals(2, PluginState.getImagesUploaded());
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideColorSchemeTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     5
    46import javax.swing.JComponent;
    57
    6 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
    79
    8 public class StreetsideColorSchemeTest {
     10class StreetsideColorSchemeTest {
    911
    1012  @Test
    11   public void testUtilityClass() {
     13  void testUtilityClass() {
    1214    TestUtil.testUtilityClass(StreetsideColorScheme.class);
    1315  }
    1416
    1517  @Test
    16   public void testStyleAsDefaultPanel() {
    17     StreetsideColorScheme.styleAsDefaultPanel();
    18     StreetsideColorScheme.styleAsDefaultPanel((JComponent[]) null);
     18  void testStyleAsDefaultPanel() {
     19    assertDoesNotThrow(() -> StreetsideColorScheme.styleAsDefaultPanel());
     20    assertDoesNotThrow(() -> StreetsideColorScheme.styleAsDefaultPanel((JComponent[]) null));
    1921  }
    2022}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsidePropertiesTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import org.junit.Rule;
    5 import org.junit.Test;
    6 
    7 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    8 import org.openstreetmap.josm.testutils.JOSMTestRules;
     4import org.junit.jupiter.api.Test;
    95
    106public class StreetsidePropertiesTest {
    11 
    12   @Rule
    13   public JOSMTestRules rules = new StreetsideTestRules();
    14 
    157  @Test
    16   public void test() {
     8  public void testUtilityClass() {
    179    TestUtil.testUtilityClass(StreetsideProperties.class);
    1810  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideURLTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    77
    88import java.lang.reflect.InvocationTargetException;
     
    1111import java.net.URL;
    1212
    13 import org.junit.Ignore;
    14 import org.junit.Test;
     13import org.junit.jupiter.api.Assertions;
     14import org.junit.jupiter.api.Disabled;
     15import org.junit.jupiter.api.Test;
    1516
    16 public class StreetsideURLTest {
     17class StreetsideURLTest {
    1718  // TODO: replace with Streetside URL @rrh
    1819  private static final String CLIENT_ID_QUERY_PART = "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
     
    4445
    4546        @Test
    46     public void testParseNextFromHeaderValue() throws MalformedURLException {
     47    void testParseNextFromHeaderValue() throws MalformedURLException {
    4748      String headerVal =
    4849        "<https://a.streetside.com/v3/sequences?page=1&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"first\", " +
    4950        "<https://a.streetside.com/v3/sequences?page=2&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"prev\", " +
    5051        "<https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"next\"";
    51       assertEquals(
    52         new URL("https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2"),
    53         StreetsideURL.APIv3.parseNextFromLinkHeaderValue(headerVal)
    54       );
     52      assertEquals(new URL("https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2"), StreetsideURL.APIv3.parseNextFromLinkHeaderValue(headerVal));
    5553    }
    5654
    5755    @Test
    58     public void testParseNextFromHeaderValue2() throws MalformedURLException {
     56    void testParseNextFromHeaderValue2() throws MalformedURLException {
    5957      String headerVal =
    6058        "<https://urlFirst>; rel=\"first\", " +
     
    6664
    6765    @Test
    68     public void testParseNextFromHeaderValueNull() {
    69       assertEquals(null, StreetsideURL.APIv3.parseNextFromLinkHeaderValue(null));
     66    void testParseNextFromHeaderValueNull() {
     67      assertNull(StreetsideURL.APIv3.parseNextFromLinkHeaderValue(null));
    7068    }
    7169
    7270    @Test
    73     public void testParseNextFromHeaderValueMalformed() {
    74       assertEquals(null, StreetsideURL.APIv3.parseNextFromLinkHeaderValue("<###>; rel=\"next\", blub"));
     71    void testParseNextFromHeaderValueMalformed() {
     72      assertNull(StreetsideURL.APIv3.parseNextFromLinkHeaderValue("<###>; rel=\"next\", blub"));
    7573    }
    7674
     
    8583  }*/
    8684
    87   @Ignore
     85  @Disabled
    8886  @Test
    89   public void testBrowseImageURL() throws MalformedURLException {
    90     assertEquals(
    91         new URL("https://www.streetside.com/map/im/1234567890123456789012"),
    92         StreetsideURL.MainWebsite.browseImage("1234567890123456789012")
    93     );
     87  void testBrowseImageURL() throws MalformedURLException {
     88    assertEquals(new URL("https://www.streetside.com/map/im/1234567890123456789012"), StreetsideURL.MainWebsite.browseImage("1234567890123456789012"));
    9489  }
    9590
    96   @Test(expected = IllegalArgumentException.class)
    97   public void testIllegalBrowseImageURL() {
    98     StreetsideURL.MainWebsite.browseImage(null);
     91  @Test
     92  void testIllegalBrowseImageURL() {
     93    assertThrows(IllegalArgumentException.class, () -> StreetsideURL.MainWebsite.browseImage(null));
    9994  }
    10095
    101   @Ignore
     96  @Disabled
    10297  @Test
    103   public void testConnectURL() {
     98  void testConnectURL() {
    10499    /*assertUrlEquals(
    105100        StreetsideURL.MainWebsite.connect("http://redirect-host/ä"),
     
    128123  }
    129124
    130   @Ignore
     125  @Disabled
    131126  @Test
    132   public void testUploadSecretsURL() throws MalformedURLException {
     127  void testUploadSecretsURL() throws MalformedURLException {
    133128    /*assertEquals(
    134129        new URL("https://a.streetside.com/v2/me/uploads/secrets?"+CLIENT_ID_QUERY_PART),
     
    137132  }
    138133
    139   @Ignore
     134  @Disabled
    140135  @Test
    141   public void testUserURL() throws MalformedURLException {
     136  void testUserURL() throws MalformedURLException {
    142137    /*assertEquals(
    143138        new URL("https://a.streetside.com/v3/me?"+CLIENT_ID_QUERY_PART),
     
    147142
    148143  @Test
    149   public void testString2MalformedURL()
     144  void testString2MalformedURL()
    150145      throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    151146    Method method = StreetsideURL.class.getDeclaredMethod("string2URL", String[].class);
    152147    method.setAccessible(true);
    153     assertNull(method.invoke(null, new Object[]{new String[]{"malformed URL"}})); // this simply invokes string2URL("malformed URL")
    154     assertNull(method.invoke(null, new Object[]{null})); // invokes string2URL(null)
     148    Assertions.assertNull(method.invoke(null, new Object[]{new String[]{"malformed URL"}})); // this simply invokes string2URL("malformed URL")
     149    Assertions.assertNull(method.invoke(null, new Object[]{null})); // invokes string2URL(null)
    155150  }
    156151
    157152  @Test
    158   public void testUtilityClass() {
     153  void testUtilityClass() {
    159154    TestUtil.testUtilityClass(StreetsideURL.class);
    160155    TestUtil.testUtilityClass(StreetsideURL.APIv3.class);
     
    173168        parameterIsPresent |= actualParams[acIndex].equals(expectedParams[exIndex]);
    174169      }
    175       assertTrue(
    176           expectedParams[exIndex] + " was expected in the query string of " + actualUrl.toString() + " but wasn't there.",
    177           parameterIsPresent
    178       );
     170      Assertions.assertTrue(parameterIsPresent, expectedParams[exIndex] + " was expected in the query string of " + actualUrl.toString() + " but wasn't there.");
    179171    }
    180172  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideUtilsTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import org.apache.commons.imaging.common.RationalNumber;
    77import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
    8 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
    99
    1010/**
     
    1515 *
    1616 */
    17 public class StreetsideUtilsTest {
     17class StreetsideUtilsTest {
    1818
    1919  @Test
    20   public void testUtilityClass() {
     20  void testUtilityClass() {
    2121    TestUtil.testUtilityClass(StreetsideUtils.class);
    2222  }
     
    2727   */
    2828  @Test
    29   public void degMinSecToDoubleTest() {
     29  void testDegMinSecToDouble() {
    3030    RationalNumber[] num = new RationalNumber[3];
    3131    num[0] = new RationalNumber(1, 1);
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/TestUtil.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertTrue;
    6 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6import static org.junit.jupiter.api.Assertions.fail;
    77
    88import java.awt.GraphicsEnvironment;
     
    1515
    1616import org.junit.runners.model.InitializationError;
    17 
     17import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin;
     18import org.openstreetmap.josm.spi.preferences.Config;
     19import org.openstreetmap.josm.spi.preferences.MemoryPreferences;
    1820import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.tools.ImageProvider;
    1922import org.openstreetmap.josm.tools.Logging;
    2023import org.openstreetmap.josm.tools.Utils;
     
    2730  private TestUtil() {
    2831    // Prevent instantiation
     32  }
     33
     34  /**
     35   * Check if we can load images
     36   * @return {@code true} if the {@link StreetsidePlugin#LOGO} could be loaded
     37   */
     38  public static boolean cannotLoadImages() {
     39    // The class-level @DisabledIf seems to be run prior to any possible setup code
     40    if (Config.getPref() == null) {
     41      Config.setPreferencesInstance(new MemoryPreferences());
     42    }
     43    return new ImageProvider("streetside-logo").setOptional(true).getResource() == null;
    2944  }
    3045
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/api/JsonDecoderTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils.api;
    33
    4 import static org.junit.Assert.assertNull;
     4
     5import static org.junit.jupiter.api.Assertions.assertNull;
    56
    67import java.io.ByteArrayInputStream;
     
    1112import javax.json.JsonObject;
    1213
    13 import org.junit.Test;
    14 
     14import org.junit.jupiter.api.Test;
    1515import org.openstreetmap.josm.plugins.streetside.utils.TestUtil;
    1616
    17 public class JsonDecoderTest {
     17class JsonDecoderTest {
    1818
    1919  @Test
    20   public void testUtilityClass() {
     20  void testUtilityClass() {
    2121    TestUtil.testUtilityClass(JsonDecoder.class);
    2222  }
    2323
    2424  @Test
    25   public void testDecodeDoublePair() {
     25  void testDecodeDoublePair() {
    2626    assertNull(JsonDecoder.decodeDoublePair(null));
    2727  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/api/JsonSequencesDecoderTest.java

    r34432 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils.api;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
    76import static org.openstreetmap.josm.plugins.streetside.utils.api.JsonDecoderTest.assertDecodesToNull;
    87
     
    1918import javax.json.JsonValue;
    2019
    21 import org.junit.Ignore;
    22 import org.junit.Test;
     20import org.junit.jupiter.api.Assertions;
     21import org.junit.jupiter.api.Disabled;
     22import org.junit.jupiter.api.Test;
    2323import org.openstreetmap.josm.data.coor.LatLon;
    2424import org.openstreetmap.josm.plugins.streetside.StreetsideImage;
     
    2727import org.openstreetmap.josm.plugins.streetside.utils.TestUtil;
    2828
    29 public class JsonSequencesDecoderTest {
    30 
    31   @Ignore
    32   @Test
    33   public void testDecodeSequences() {
     29class JsonSequencesDecoderTest {
     30
     31  @Disabled
     32  @Test
     33  void testDecodeSequences() {
    3434    Collection<StreetsideSequence> exampleSequences = JsonDecoder.decodeFeatureCollection(
    3535      Json.createReader(this.getClass().getResourceAsStream("test/data/api/v3/responses/searchSequences.json")).readObject(),
     
    5151    assertEquals(329.94820000000004, seq.getImages().get(3).getHe(), 1e-10);
    5252
    53     assertEquals(new LatLon(7.246497, 16.432958),  seq.getImages().get(0).getLatLon());
    54     assertEquals(new LatLon(7.246567, 16.432955),  seq.getImages().get(1).getLatLon());
    55     assertEquals(new LatLon(7.248372, 16.432971),  seq.getImages().get(2).getLatLon());
    56     assertEquals(new LatLon(7.249027, 16.432976),  seq.getImages().get(3).getLatLon());
     53    assertEquals(new LatLon(7.246497, 16.432958), seq.getImages().get(0).getLatLon());
     54    assertEquals(new LatLon(7.246567, 16.432955), seq.getImages().get(1).getLatLon());
     55    assertEquals(new LatLon(7.248372, 16.432971), seq.getImages().get(2).getLatLon());
     56    assertEquals(new LatLon(7.249027, 16.432976), seq.getImages().get(3).getLatLon());
    5757
    5858    assertEquals(1_457_963_093_860L, seq.getCd()); // 2016-03-14T13:44:53.860 UTC
     
    6060
    6161  @Test
    62   public void testDecodeSequencesInvalid() {
     62  void testDecodeSequencesInvalid() {
    6363    // null input
    6464    assertEquals(0, JsonDecoder.decodeFeatureCollection(null, JsonSequencesDecoder::decodeSequence).size());
     
    7676
    7777  @Test
    78   public void testDecodeSequencesWithArbitraryObjectAsFeature() {
     78  void testDecodeSequencesWithArbitraryObjectAsFeature() {
    7979    assertNumberOfDecodedSequences(0, "{\"type\": \"FeatureCollection\", \"features\": [{}]}");
    8080  }
    8181
    8282  private static void assertNumberOfDecodedSequences(int expectedNumberOfSequences, String jsonString) {
    83     assertEquals(
    84       expectedNumberOfSequences,
    85       JsonDecoder.decodeFeatureCollection(
    86         Json.createReader(new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8))).readObject(),
    87         JsonSequencesDecoder::decodeSequence
    88       ).size()
    89     );
    90   }
    91 
    92   @Ignore
    93   @Test
    94   public void testDecodeSequence() {
     83    assertEquals(expectedNumberOfSequences, JsonDecoder.decodeFeatureCollection(
     84      Json.createReader(new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8))).readObject(),
     85      JsonSequencesDecoder::decodeSequence
     86    ).size());
     87  }
     88
     89  @Disabled
     90  @Test
     91  void testDecodeSequence() {
    9592    StreetsideSequence exampleSequence = JsonSequencesDecoder.decodeSequence(
    9693      Json.createReader(this.getClass().getResourceAsStream("/api/v3/responses/sequence.json")).readObject()
     
    10097    assertEquals(2, exampleSequence.getImages().size());
    10198
    102     assertEquals(
    103       new StreetsideImage("76P0YUrlDD_lF6J7Od3yoA", new LatLon(16.43279, 7.246085), 96.71454),
    104       exampleSequence.getImages().get(0)
    105     );
    106     assertEquals(
    107       new StreetsideImage("Ap_8E0BwoAqqewhJaEbFyQ", new LatLon(16.432799, 7.246082), 96.47705000000002),
    108       exampleSequence.getImages().get(1)
    109     );
    110   }
    111 
    112   @Test
    113   public void testDecodeSequenceInvalid() {
     99    assertEquals(new StreetsideImage("76P0YUrlDD_lF6J7Od3yoA", new LatLon(16.43279, 7.246085), 96.71454), exampleSequence.getImages().get(0));
     100    assertEquals(new StreetsideImage("Ap_8E0BwoAqqewhJaEbFyQ", new LatLon(16.432799, 7.246082), 96.47705000000002), exampleSequence.getImages().get(1));
     101  }
     102
     103  @Test
     104  void testDecodeSequenceInvalid() {
    114105    // null input
    115     assertNull(JsonSequencesDecoder.decodeSequence(null));
     106    Assertions.assertNull(JsonSequencesDecoder.decodeSequence(null));
    116107    // `properties` key is not set
    117108    assertDecodesToNull(JsonSequencesDecoder::decodeSequence, "{\"type\": \"Feature\"}");
     
    150141   */
    151142  @Test
    152   public void testDecodeJsonArray()
     143  void testDecodeJsonArray()
    153144      throws NoSuchMethodException, SecurityException, IllegalAccessException,
    154145      IllegalArgumentException, InvocationTargetException {
    155146    Method method = JsonSequencesDecoder.class.getDeclaredMethod("decodeJsonArray", JsonArray.class, Function.class, Class.class);
    156147    method.setAccessible(true);
    157     assertEquals(
    158       0,
    159       ((String[]) method.invoke(null, null, (Function<JsonValue, String>) val -> null, String.class)).length
    160     );
    161   }
    162 
    163   @Test
    164   public void testDecodeCoordinateProperty() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
     148    assertEquals(0, ((String[]) method.invoke(null, null, (Function<JsonValue, String>) val -> null, String.class)).length);
     149  }
     150
     151  @Test
     152  void testDecodeCoordinateProperty() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    165153    Method decodeCoordinateProperty = JsonSequencesDecoder.class.getDeclaredMethod(
    166154      "decodeCoordinateProperty",
     
    172160    decodeCoordinateProperty.setAccessible(true);
    173161
    174     assertEquals(
    175       0,
    176       ((String[]) decodeCoordinateProperty.invoke(
    177         null, null, "key", (Function<JsonValue, String>) val -> "string", String.class
    178       )).length
    179     );
    180 
    181     assertEquals(
    182       0,
    183       ((String[]) decodeCoordinateProperty.invoke(
    184         null, JsonUtil.string2jsonObject("{\"coordinateProperties\":{\"key\":0}}"), "key", (Function<JsonValue, String>) val -> "string", String.class
    185       )).length
    186     );
    187   }
    188 
    189   @Test
    190   public void testDecodeLatLons()
     162    assertEquals(0, ((String[]) decodeCoordinateProperty.invoke(
     163      null, null, "key", (Function<JsonValue, String>) val -> "string", String.class
     164    )).length);
     165
     166    assertEquals(0, ((String[]) decodeCoordinateProperty.invoke(
     167      null, JsonUtil.string2jsonObject("{\"coordinateProperties\":{\"key\":0}}"), "key", (Function<JsonValue, String>) val -> "string", String.class
     168    )).length);
     169  }
     170
     171  @Test
     172  void testDecodeLatLons()
    191173      throws NoSuchMethodException, SecurityException, IllegalAccessException,
    192174      IllegalArgumentException, InvocationTargetException {
     
    206188    )).readObject());
    207189    assertEquals(3, example.length);
    208     assertNull(example[0]);
    209     assertNull(example[1]);
    210     assertNull(example[2]);
    211   }
    212 
    213   @Test
    214   public void testUtilityClass() {
     190    Assertions.assertNull(example[0]);
     191    Assertions.assertNull(example[1]);
     192    Assertions.assertNull(example[2]);
     193  }
     194
     195  @Test
     196  void testUtilityClass() {
    215197    TestUtil.testUtilityClass(JsonSequencesDecoder.class);
    216198  }
Note: See TracChangeset for help on using the changeset viewer.