Changeset 36064 in osm for applications/editors/josm/plugins/MicrosoftStreetside
- Timestamp:
- 2023-03-21T14:49:10+01:00 (20 months ago)
- 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 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 4 import static org.junit. Assert.assertFalse;5 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 7 import org.junit. Test;7 import org.junit.jupiter.api.Test; 8 8 import org.openstreetmap.josm.data.coor.LatLon; 9 9 10 public class StreetsideAbstractImageTest { 11 12 /*@Rule 13 public JOSMTestRules rules = new StreetsideTestRules().platform();*/ 14 10 class StreetsideAbstractImageTest { 15 11 @Test 16 publicvoid testIsModified() {12 void testIsModified() { 17 13 StreetsideImage img = new StreetsideImage("key___________________", new LatLon(0, 0), 0); 18 14 assertFalse(img.isModified()); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideDataTest.java
r34434 r36064 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertThrows; 5 8 6 9 import java.util.Arrays; 7 10 import java.util.concurrent.ConcurrentSkipListSet; 8 11 9 import org.junit. Before;10 import org.junit. Ignore;11 import org.junit. Test;12 import org.junit.jupiter.api.BeforeEach; 13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.condition.DisabledIf; 12 15 import org.openstreetmap.josm.data.coor.LatLon; 13 16 … … 18 21 * @see StreetsideData 19 22 */ 20 public class StreetsideDataTest { 23 @DisabledIf(value = "org.openstreetmap.josm.plugins.streetside.utils.TestUtil#cannotLoadImages", disabledReason = "At JOSM maintainer request (flaky?)") 24 class StreetsideDataTest { 21 25 22 26 /*@Rule … … 33 37 * objects and a {@link StreetsideSequence} object. 34 38 */ 35 @Before 39 @BeforeEach 36 40 public void setUp() { 37 41 img1 = new StreetsideImage("id1__________________", new LatLon(0.1, 0.1), 90); … … 51 55 * another one in the database, the one that is being added should be ignored. 52 56 */ 53 @Ignore54 57 @Test 55 public void addTest() {58 void testAdd() { 56 59 data = new StreetsideData(); 57 60 assertEquals(0, data.getImages().size()); … … 69 72 * Test that the size is properly calculated. 70 73 */ 71 @Ignore72 74 @Test 73 public void sizeTest() {75 void testSize() { 74 76 assertEquals(4, data.getImages().size()); 75 77 data.add(new StreetsideImage("id5__________________", new LatLon(0.1, 0.1), 90)); … … 81 83 * and {@link StreetsideData#getHighlightedImage()} methods. 82 84 */ 83 @Ignore84 85 @Test 85 public void highlighTest() {86 void testHighlight() { 86 87 data.setHighlightedImage(img1); 87 88 assertEquals(img1, data.getHighlightedImage()); 88 89 89 90 data.setHighlightedImage(null); 90 assert Equals(null,data.getHighlightedImage());91 assertNull(data.getHighlightedImage()); 91 92 } 92 93 … … 94 95 * Tests the selection of images. 95 96 */ 96 @Ignore97 97 @Test 98 public void selectTest() {98 void testSelect() { 99 99 data.setSelectedImage(img1); 100 100 assertEquals(img1, data.getSelectedImage()); … … 104 104 105 105 data.setSelectedImage(null); 106 assert Equals(null,data.getSelectedImage());106 assertNull(data.getSelectedImage()); 107 107 } 108 108 … … 111 111 * {@link StreetsideData#selectPrevious()} methods. 112 112 */ 113 @Ignore114 113 @Test 115 public void nextAndPreviousTest() {114 void testNextAndPrevious() { 116 115 data.setSelectedImage(img1); 117 116 … … 126 125 } 127 126 128 @Ignore 129 @Test(expected=IllegalStateException.class) 130 public void nextOfNullImgTest() { 127 @Test 128 void testNextOfNullImg() { 131 129 data.setSelectedImage(null); 132 data.selectNext();130 assertThrows(IllegalStateException.class, data::selectNext); 133 131 } 134 132 135 @Ignore 136 @Test(expected=IllegalStateException.class) 137 public void previousOfNullImgTest() { 133 @Test 134 void testPreviousOfNullImg() { 138 135 data.setSelectedImage(null); 139 data.selectPrevious();136 assertThrows(IllegalStateException.class, data::selectPrevious); 140 137 } 141 138 … … 144 141 * multiselected List should reset. 145 142 */ 146 @Ignore147 143 @Test 148 public void multiSelectTest() {144 void testMultiSelect() { 149 145 assertEquals(0, data.getMultiSelectedImages().size()); 150 146 data.setSelectedImage(img1); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideLayerTest.java
r34434 r36064 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 8 9 import org.junit.Ignore; 10 import org.junit.Rule; 11 import org.junit.Test; 9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.condition.DisabledIf; 12 11 import org.openstreetmap.josm.data.coor.LatLon; 13 12 import org.openstreetmap.josm.data.imagery.ImageryInfo; … … 15 14 import org.openstreetmap.josm.gui.layer.Layer; 16 15 import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils; 17 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;18 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 18 import org.openstreetmap.josm.testutils.annotations.Main; 19 import org.openstreetmap.josm.testutils.annotations.Projection; 19 20 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?)") 25 class StreetsideLayerTest { 25 26 private static Layer getDummyLayer() { 26 27 return ImageryLayer.create(new ImageryInfo("dummy", "https://example.org")); 27 28 } 28 29 29 @Ignore30 30 @Test 31 publicvoid testGetIcon() {31 void testGetIcon() { 32 32 assertNotNull(StreetsideLayer.getInstance().getIcon()); 33 33 } 34 34 35 @Ignore36 35 @Test 37 publicvoid testIsMergable() {36 void testIsMergable() { 38 37 assertFalse(StreetsideLayer.getInstance().isMergable(getDummyLayer())); 39 38 } 40 39 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)); 45 45 } 46 46 47 @Ignore48 47 @Test 49 publicvoid testSetVisible() {48 void testSetVisible() { 50 49 StreetsideLayer.getInstance().getData().add(new StreetsideImage(CubemapUtils.TEST_IMAGE_ID, new LatLon(0.0, 0.0), 0.0)); 51 50 StreetsideLayer.getInstance().getData().add(new StreetsideImage(CubemapUtils.TEST_IMAGE_ID, new LatLon(0.0, 0.0), 0.0)); … … 56 55 StreetsideLayer.getInstance().setVisible(false); 57 56 for (StreetsideAbstractImage img : StreetsideLayer.getInstance().getData().getImages()) { 58 assert Equals(false,img.isVisible());57 assertFalse(img.isVisible()); 59 58 } 60 59 … … 62 61 StreetsideLayer.getInstance().setVisible(true); 63 62 for (StreetsideAbstractImage img : StreetsideLayer.getInstance().getData().getImages()) { 64 assert Equals(true,img.isVisible());63 assertTrue(img.isVisible()); 65 64 } 66 65 } 67 66 68 @Ignore69 67 @Test 70 publicvoid testGetInfoComponent() {68 void testGetInfoComponent() { 71 69 Object comp = StreetsideLayer.getInstance().getInfoComponent(); 72 70 assertTrue(comp instanceof String); … … 74 72 } 75 73 76 @Ignore77 74 @Test 78 publicvoid testClearInstance() {75 void testClearInstance() { 79 76 StreetsideLayer.getInstance(); 80 77 assertTrue(StreetsideLayer.hasInstance()); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideSequenceTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside; 3 3 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; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 8 7 9 8 import java.util.Arrays; 10 9 11 import org.junit.Before; 12 import org.junit.Test; 13 10 import org.junit.jupiter.api.BeforeEach; 11 import org.junit.jupiter.api.Test; 14 12 import org.openstreetmap.josm.data.coor.LatLon; 15 13 … … 20 18 * @see StreetsideSequence 21 19 */ 22 publicclass StreetsideSequenceTest {20 class StreetsideSequenceTest { 23 21 24 22 private final StreetsideImage img1 = new StreetsideImage("key1", new LatLon(0.1, 0.1), 90); … … 33 31 * {@link StreetsideSequence} object. 34 32 */ 35 @Before 33 @BeforeEach 36 34 public void setUp() { 37 35 seq.add(Arrays.asList(img1, img2, img3, img4)); … … 43 41 */ 44 42 @Test 45 public void nextAndPreviousTest() {43 void testNextAndPrevious() { 46 44 assertEquals(img2, img1.next()); 47 45 assertEquals(img1, img2.previous()); … … 60 58 // Test IllegalArgumentException when asking for the next image of an image 61 59 // 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 68 62 // Test IllegalArgumentException when asking for the previous image of an 69 63 // 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)); 76 65 } 77 66 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cache/CachesTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.cache; 3 3 4 import org.junit.Test;5 4 5 import org.junit.jupiter.api.Test; 6 6 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil; 7 7 8 publicclass CachesTest {8 class CachesTest { 9 9 10 10 @Test 11 publicvoid testUtilityClass() {11 void testUtilityClass() { 12 12 TestUtil.testUtilityClass(Caches.class); 13 13 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cache/StreetsideCacheTest.java
r34386 r36064 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.streetside.cache; 3 //License: GPL. For details, see LICENSE file.4 3 5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 8 7 9 import org.junit.Rule; 10 import org.junit.Test; 8 import org.junit.jupiter.api.Test; 9 import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache.Type; 10 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 11 11 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 13 class StreetsideCacheTest { 20 14 21 15 @Test 22 public void test() {16 void testCache() { 23 17 StreetsideCache cache = new StreetsideCache("00000", Type.FULL_IMAGE); 24 18 assertNotNull(cache.getUrl()); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapUtilsTest.java
r34432 r36064 1 1 package org.openstreetmap.josm.plugins.streetside.cubemap; 2 2 3 import static org.junit.Assert.assertEquals;4 3 5 import org.junit.Ignore; 6 import org.junit.Test; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 7 5 8 public class CubemapUtilsTest { 6 import org.junit.jupiter.api.Disabled; 7 import org.junit.jupiter.api.Test; 9 8 10 @SuppressWarnings("static-method") 9 class CubemapUtilsTest { 10 11 11 @Test 12 public finalvoid testConvertDecimal2Quaternary() {13 final long decimal0 = 680730040 l;14 final long decimal1 = 680931568 l;12 void testConvertDecimal2Quaternary() { 13 final long decimal0 = 680730040L; 14 final long decimal1 = 680931568L; 15 15 String res = CubemapUtils.convertDecimal2Quaternary(decimal0); 16 16 assertEquals("220210301312320", res); … … 19 19 } 20 20 21 @SuppressWarnings("static-method")22 21 @Test 23 public finalvoid testConvertQuaternary2Decimal() {22 void testConvertQuaternary2Decimal() { 24 23 final String quadKey0 = "220210301312320"; 25 24 final String quadKey1 = "220211203003300"; … … 30 29 } 31 30 32 @SuppressWarnings("static-method") 33 @Ignore 31 @Disabled 34 32 @Test 35 public finalvoid testGetFaceNumberForCount() {33 void testGetFaceNumberForCount() { 36 34 String faceNrFront = CubemapUtils.getFaceNumberForCount(0); 37 35 String faceNrRight = CubemapUtils.getFaceNumberForCount(1); … … 48 46 } 49 47 50 @SuppressWarnings("static-method") 51 @Ignore 48 @Disabled 52 49 @Test 53 public finalvoid testGetCount4FaceNumber() {50 void testGetCount4FaceNumber() { 54 51 int count4Front = CubemapUtils.getCount4FaceNumber("01"); 55 52 int count4Right = CubemapUtils.getCount4FaceNumber("02"); … … 66 63 } 67 64 68 @SuppressWarnings("static-method")69 65 @Test 70 public finalvoid testConvertDoubleCountNrto16TileNr() {66 void testConvertDoubleCountNrto16TileNr() { 71 67 String x0y0 = CubemapUtils.convertDoubleCountNrto16TileNr("00"); 72 68 String x0y1 = CubemapUtils.convertDoubleCountNrto16TileNr("01"); … … 92 88 assertEquals(x1y0, "02"); 93 89 assertEquals(x1y1, "03"); 94 assertEquals(x1y2, "12");90 assertEquals(x1y2, "12"); 95 91 assertEquals(x1y3, "13"); 96 92 assertEquals(x2y0, "20"); … … 99 95 assertEquals(x2y3, "31"); 100 96 assertEquals(x3y0, "22"); 101 assertEquals(x3y1, "23");97 assertEquals(x3y1, "23"); 102 98 assertEquals(x3y2, "32"); 103 99 assertEquals(x3y3, "33"); 104 100 } 105 106 101 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/TileDownloadingTaskTest.java
r34428 r36064 1 1 package org.openstreetmap.josm.plugins.streetside.cubemap; 2 2 3 import static org.junit.Assert.assertEquals; 4 import static org.junit. Assert.fail;3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.util.ArrayList; … … 11 11 import java.util.concurrent.Future; 12 12 13 import org.junit. Ignore;14 import org.junit. Test;13 import org.junit.jupiter.api.Disabled; 14 import org.junit.jupiter.api.Test; 15 15 16 public class TileDownloadingTaskTest { 16 @Disabled 17 class TileDownloadingTaskTest { 17 18 18 @SuppressWarnings("static-method")19 @Ignore20 19 @Test 21 public final void testCall(){20 final void testCall() throws InterruptedException { 22 21 ExecutorService pool = Executors.newFixedThreadPool(1); 23 22 List<Callable<List<String>>> tasks = new ArrayList<>(1); 24 23 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"); 32 26 } 33 27 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/ImageDisplayTest.java
r34432 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.gui; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.awt.GraphicsEnvironment; … … 11 11 import javax.swing.JFrame; 12 12 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; 13 import org.junit.jupiter.api.Test; 14 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 17 15 18 16 /** 19 17 * Tests {@link StreetsideImageDisplay} 20 18 */ 21 public class ImageDisplayTest { 22 23 @Rule 24 public JOSMTestRules rules = new StreetsideTestRules().preferences(); 19 @BasicPreferences 20 class ImageDisplayTest { 25 21 26 22 private static final BufferedImage DUMMY_IMAGE = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); 27 23 28 24 @Test 29 publicvoid testImagePersistence() {25 void testImagePersistence() { 30 26 StreetsideImageDisplay display = new StreetsideImageDisplay(); 31 27 display.setImage(DUMMY_IMAGE, null); … … 39 35 40 36 @Test 41 publicvoid testMouseWheelMoved() {37 void testMouseWheelMoved() { 42 38 if (GraphicsEnvironment.isHeadless()) { 43 39 return; … … 65 61 */ 66 62 @Test 67 publicvoid testMouseClicked() {63 void testMouseClicked() { 68 64 if (GraphicsEnvironment.isHeadless()) { 69 65 return; -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/StreetsidePreferenceSettingTest.java
r34434 r36064 1 1 package org.openstreetmap.josm.plugins.streetside.gui; 2 2 3 import static org.junit.Assert.assertEquals; 4 import static org.junit.Assert.assertFalse; 3 import static org.junit.jupiter.api.Assertions.assertEquals; 5 4 import static org.openstreetmap.josm.plugins.streetside.utils.TestUtil.getPrivateFieldValue; 6 5 … … 11 10 import javax.swing.SpinnerNumberModel; 12 11 13 import org.junit. Ignore;14 import org.junit. Rule;15 import org.junit. Test;12 import org.junit.jupiter.api.Assertions; 13 import org.junit.jupiter.api.Disabled; 14 import org.junit.jupiter.api.Test; 16 15 import org.openstreetmap.josm.data.preferences.BooleanProperty; 17 16 import org.openstreetmap.josm.data.preferences.StringProperty; 18 17 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 19 18 import 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; 19 import org.openstreetmap.josm.testutils.annotations.Main; 22 20 23 public class StreetsidePreferenceSettingTest { 24 25 @Rule 26 public JOSMTestRules rules = new StreetsideTestRules().main(); 27 21 @Main 22 @Disabled 23 class StreetsidePreferenceSettingTest { 28 24 // TODO: repair broken unit test from Mapillary 29 @Ignore30 25 @Test 31 publicvoid testAddGui() {26 void testAddGui() { 32 27 if (GraphicsEnvironment.isHeadless()) { 33 28 return; … … 42 37 } 43 38 44 @Ignore45 39 @Test 46 publicvoid testIsExpert() {47 assertFalse(new StreetsidePreferenceSetting().isExpert());40 void testIsExpert() { 41 Assertions.assertFalse(new StreetsidePreferenceSetting().isExpert()); 48 42 } 49 43 50 44 @SuppressWarnings("unchecked") 51 @Ignore52 45 @Test 53 publicvoid testOk() {46 void testOk() { 54 47 StreetsidePreferenceSetting settings = new StreetsidePreferenceSetting(); 55 48 -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/boilerplate/SelectableLabelTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.gui.boilerplate; 3 3 4 import static org.junit. Assert.assertFalse;5 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 7 import org.junit. Test;7 import org.junit.jupiter.api.Test; 8 8 9 public class SelectableLabelTest { 9 10 class SelectableLabelTest { 10 11 @Test 11 public void test() {12 void testSelectableLabel() { 12 13 SelectableLabel l1 = new SelectableLabel(); 13 14 assertFalse(l1.isEditable()); … … 15 16 assertTrue(l2.getText().contains("some text")); 16 17 assertFalse(l2.isEditable()); 17 18 18 } 19 19 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/history/StreetsideRecordTest.java
r34433 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.history; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.fail; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 7 8 import java.util.Arrays; … … 9 10 import java.util.concurrent.ConcurrentSkipListSet; 10 11 11 import org.junit.Before; 12 import org.junit.Ignore; 13 import org.junit.Rule; 14 import org.junit.Test; 12 import org.junit.jupiter.api.BeforeEach; 13 import org.junit.jupiter.api.Disabled; 14 import org.junit.jupiter.api.Test; 15 15 import org.openstreetmap.josm.data.coor.LatLon; 16 16 import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage; … … 22 22 import org.openstreetmap.josm.plugins.streetside.history.commands.CommandUnjoin; 23 23 import 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;24 import org.openstreetmap.josm.testutils.annotations.Main; 25 import org.openstreetmap.josm.testutils.annotations.Projection; 26 26 27 27 /** … … 30 30 * @author nokutu 31 31 */ 32 public class StreetsideRecordTest { 33 34 @Rule 35 public JOSMTestRules rules = new StreetsideTestRules().main().projection(); 32 @Main 33 @Projection 34 @Disabled 35 class StreetsideRecordTest { 36 36 37 37 private StreetsideRecord record; … … 44 44 * objects. 45 45 */ 46 @Before 46 @BeforeEach 47 47 public void setUp() { 48 48 record = new StreetsideRecord(); … … 58 58 * Test commands in general. 59 59 */ 60 @Ignore 61 @Test 62 public void commandTest() { 60 @Test 61 void testCommand() { 63 62 StreetsideCommand cmd12 = new CommandMove( 64 63 new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)), … … 115 114 * Tests {@link CommandMove} class. 116 115 */ 117 @Ignore 118 @Test 119 public void commandMoveTest() { 116 @Test 117 void testCommandMove() { 120 118 CommandMove cmd1 = new CommandMove( 121 119 new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)), … … 150 148 * Tests {@link CommandTurn} class. 151 149 */ 152 @Ignore 153 @Test 154 public void commandTurnTest() { 150 @Test 151 void testCommandTurn() { 155 152 CommandTurn cmd1 = new CommandTurn( 156 153 new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)), … … 182 179 * Tests {@link CommandJoin} class. 183 180 */ 184 @Ignore 185 @Test 186 public void commandJoinClass() { 181 @Test 182 void testCommandJoinClass() { 187 183 CommandJoin cmd1 = new CommandJoin(img1, img2); 188 184 CommandJoin cmd2 = new CommandJoin(img2, img3); … … 199 195 } 200 196 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)); 211 205 } 212 206 … … 214 208 * Tests {@link CommandUnjoin} class. 215 209 */ 216 @Ignore 217 @Test 218 public void commandUnjoinClass() { 210 @Test 211 void testCommandUnjoinClass() { 219 212 CommandJoin join1 = new CommandJoin(img1, img2); 220 213 CommandJoin join2 = new CommandJoin(img2, img3); … … 237 230 assertEquals(1, img2.getSequence().getImages().size()); 238 231 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)); 245 234 } 246 235 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/io/download/SequenceDownloadRunnableTest.java
r34577 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.io.download; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 6 7 import java.lang.reflect.Field; … … 9 10 import java.util.function.Function; 10 11 11 import org.junit.AfterClass; 12 import org.junit.Ignore; 13 import org.junit.Rule; 14 import org.junit.Test; 12 import org.junit.jupiter.api.Disabled; 13 import org.junit.jupiter.api.Test; 15 14 import org.openstreetmap.josm.data.Bounds; 16 import org.openstreetmap.josm.gui.MainApplication;17 15 import org.openstreetmap.josm.plugins.streetside.StreetsideLayer; 18 16 import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties; 19 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules; 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 import org.openstreetmap.josm.testutils.annotations.LayerManager; 21 18 22 public class SequenceDownloadRunnableTest { 23 24 @Rule 25 public JOSMTestRules rules = new StreetsideTestRules(); 19 @Disabled 20 @LayerManager 21 class SequenceDownloadRunnableTest { 26 22 27 23 private static final Function<Bounds, URL> SEARCH_SEQUENCES_URL_GEN = b -> { … … 30 26 private Field urlGenField; 31 27 32 @AfterClass33 public static void tearDown() {34 MainApplication.getLayerManager().resetState();35 }36 28 37 @Ignore38 29 @Test 39 publicvoid testRun1() throws IllegalArgumentException, IllegalAccessException {30 void testRun1() throws IllegalArgumentException, IllegalAccessException { 40 31 testNumberOfDecodedImages(4, SEARCH_SEQUENCES_URL_GEN, new Bounds(7.246497, 16.432955, 7.249027, 16.432976)); 41 32 } 42 33 43 @Ignore44 34 @Test 45 publicvoid testRun2() throws IllegalArgumentException, IllegalAccessException {35 void testRun2() throws IllegalArgumentException, IllegalAccessException { 46 36 testNumberOfDecodedImages(0, SEARCH_SEQUENCES_URL_GEN, new Bounds(0, 0, 0, 0)); 47 37 } 48 38 49 @Ignore50 39 @Test 51 publicvoid testRun3() throws IllegalArgumentException, IllegalAccessException {40 void testRun3() throws IllegalArgumentException, IllegalAccessException { 52 41 testNumberOfDecodedImages(0, b -> { 53 42 try { return new URL("https://streetside/nonexistentURL"); } catch (MalformedURLException e) { return null; } … … 55 44 } 56 45 57 @Ignore58 46 @Test 59 publicvoid testRun4() throws IllegalArgumentException, IllegalAccessException {47 void testRun4() throws IllegalArgumentException, IllegalAccessException { 60 48 StreetsideProperties.CUT_OFF_SEQUENCES_AT_BOUNDS.put(true); 61 49 testNumberOfDecodedImages(4, SEARCH_SEQUENCES_URL_GEN, new Bounds(7.246497, 16.432955, 7.249027, 16.432976)); 62 50 } 63 51 64 @Ignore65 52 @Test 66 publicvoid testRun5() throws IllegalArgumentException, IllegalAccessException {53 void testRun5() throws IllegalArgumentException, IllegalAccessException { 67 54 StreetsideProperties.CUT_OFF_SEQUENCES_AT_BOUNDS.put(true); 68 55 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 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 5 6 6 7 import java.awt.image.BufferedImage; … … 8 9 import javax.swing.ImageIcon; 9 10 10 import org.junit. Test;11 import org.junit.jupiter.api.Test; 11 12 12 public class ImageUtilTest { 13 14 class ImageUtilTest { 13 15 14 16 @Test 15 publicvoid testUtilityClass() {17 void testUtilityClass() { 16 18 TestUtil.testUtilityClass(ImageUtil.class); 17 19 } 18 20 19 21 @Test 20 publicvoid testScaleImageIcon() {22 void testScaleImageIcon() { 21 23 ImageIcon largeLandscape = new ImageIcon(new BufferedImage(72, 60, BufferedImage.TYPE_4BYTE_ABGR)); 22 24 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 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 5 8 6 9 import javax.swing.JOptionPane; 7 10 8 import org.junit. Test;11 import org.junit.jupiter.api.Test; 9 12 import org.openstreetmap.josm.TestUtils; 10 13 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; … … 16 19 * @see PluginState 17 20 */ 18 publicclass PluginStateTest {21 class PluginStateTest { 19 22 20 23 /** … … 22 25 */ 23 26 @Test 24 public void downloadTest() {25 assert Equals(false,PluginState.isDownloading());27 void testDownload() { 28 assertFalse(PluginState.isDownloading()); 26 29 PluginState.startDownload(); 27 assert Equals(true,PluginState.isDownloading());30 assertTrue(PluginState.isDownloading()); 28 31 PluginState.startDownload(); 29 assert Equals(true,PluginState.isDownloading());32 assertTrue(PluginState.isDownloading()); 30 33 PluginState.finishDownload(); 31 assert Equals(true,PluginState.isDownloading());34 assertTrue(PluginState.isDownloading()); 32 35 PluginState.finishDownload(); 33 assert Equals(false,PluginState.isDownloading());36 assertFalse(PluginState.isDownloading()); 34 37 } 35 38 … … 38 41 */ 39 42 @Test 40 public void uploadTest() {43 void testUpload() { 41 44 TestUtils.assumeWorkingJMockit(); 42 45 JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(); … … 45 48 JOptionPane.OK_OPTION 46 49 ); 47 assert Equals(false,PluginState.isUploading());50 assertFalse(PluginState.isUploading()); 48 51 PluginState.addImagesToUpload(2); 49 52 assertEquals(2, PluginState.getImagesToUpload()); 50 53 assertEquals(0, PluginState.getImagesUploaded()); 51 assert Equals(true,PluginState.isUploading());54 assertTrue(PluginState.isUploading()); 52 55 PluginState.imageUploaded(); 53 56 assertEquals(1, PluginState.getImagesUploaded()); 54 assert Equals(true,PluginState.isUploading());57 assertTrue(PluginState.isUploading()); 55 58 PluginState.imageUploaded(); 56 assert Equals(false,PluginState.isUploading());59 assertFalse(PluginState.isUploading()); 57 60 assertEquals(2, PluginState.getImagesToUpload()); 58 61 assertEquals(2, PluginState.getImagesUploaded()); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideColorSchemeTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 5 4 6 import javax.swing.JComponent; 5 7 6 import org.junit. Test;8 import org.junit.jupiter.api.Test; 7 9 8 publicclass StreetsideColorSchemeTest {10 class StreetsideColorSchemeTest { 9 11 10 12 @Test 11 publicvoid testUtilityClass() {13 void testUtilityClass() { 12 14 TestUtil.testUtilityClass(StreetsideColorScheme.class); 13 15 } 14 16 15 17 @Test 16 publicvoid testStyleAsDefaultPanel() {17 StreetsideColorScheme.styleAsDefaultPanel();18 StreetsideColorScheme.styleAsDefaultPanel((JComponent[]) null);18 void testStyleAsDefaultPanel() { 19 assertDoesNotThrow(() -> StreetsideColorScheme.styleAsDefaultPanel()); 20 assertDoesNotThrow(() -> StreetsideColorScheme.styleAsDefaultPanel((JComponent[]) null)); 19 21 } 20 22 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsidePropertiesTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 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; 4 import org.junit.jupiter.api.Test; 9 5 10 6 public class StreetsidePropertiesTest { 11 12 @Rule13 public JOSMTestRules rules = new StreetsideTestRules();14 15 7 @Test 16 public void test () {8 public void testUtilityClass() { 17 9 TestUtil.testUtilityClass(StreetsideProperties.class); 18 10 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideURLTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNull;6 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 7 8 8 import java.lang.reflect.InvocationTargetException; … … 11 11 import java.net.URL; 12 12 13 import org.junit.Ignore; 14 import org.junit.Test; 13 import org.junit.jupiter.api.Assertions; 14 import org.junit.jupiter.api.Disabled; 15 import org.junit.jupiter.api.Test; 15 16 16 publicclass StreetsideURLTest {17 class StreetsideURLTest { 17 18 // TODO: replace with Streetside URL @rrh 18 19 private static final String CLIENT_ID_QUERY_PART = "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"; … … 44 45 45 46 @Test 46 publicvoid testParseNextFromHeaderValue() throws MalformedURLException {47 void testParseNextFromHeaderValue() throws MalformedURLException { 47 48 String headerVal = 48 49 "<https://a.streetside.com/v3/sequences?page=1&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"first\", " + 49 50 "<https://a.streetside.com/v3/sequences?page=2&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"prev\", " + 50 51 "<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)); 55 53 } 56 54 57 55 @Test 58 publicvoid testParseNextFromHeaderValue2() throws MalformedURLException {56 void testParseNextFromHeaderValue2() throws MalformedURLException { 59 57 String headerVal = 60 58 "<https://urlFirst>; rel=\"first\", " + … … 66 64 67 65 @Test 68 publicvoid testParseNextFromHeaderValueNull() {69 assert Equals(null,StreetsideURL.APIv3.parseNextFromLinkHeaderValue(null));66 void testParseNextFromHeaderValueNull() { 67 assertNull(StreetsideURL.APIv3.parseNextFromLinkHeaderValue(null)); 70 68 } 71 69 72 70 @Test 73 publicvoid testParseNextFromHeaderValueMalformed() {74 assert Equals(null,StreetsideURL.APIv3.parseNextFromLinkHeaderValue("<###>; rel=\"next\", blub"));71 void testParseNextFromHeaderValueMalformed() { 72 assertNull(StreetsideURL.APIv3.parseNextFromLinkHeaderValue("<###>; rel=\"next\", blub")); 75 73 } 76 74 … … 85 83 }*/ 86 84 87 @ Ignore85 @Disabled 88 86 @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")); 94 89 } 95 90 96 @Test (expected = IllegalArgumentException.class)97 publicvoid testIllegalBrowseImageURL() {98 StreetsideURL.MainWebsite.browseImage(null);91 @Test 92 void testIllegalBrowseImageURL() { 93 assertThrows(IllegalArgumentException.class, () -> StreetsideURL.MainWebsite.browseImage(null)); 99 94 } 100 95 101 @ Ignore96 @Disabled 102 97 @Test 103 publicvoid testConnectURL() {98 void testConnectURL() { 104 99 /*assertUrlEquals( 105 100 StreetsideURL.MainWebsite.connect("http://redirect-host/ä"), … … 128 123 } 129 124 130 @ Ignore125 @Disabled 131 126 @Test 132 publicvoid testUploadSecretsURL() throws MalformedURLException {127 void testUploadSecretsURL() throws MalformedURLException { 133 128 /*assertEquals( 134 129 new URL("https://a.streetside.com/v2/me/uploads/secrets?"+CLIENT_ID_QUERY_PART), … … 137 132 } 138 133 139 @ Ignore134 @Disabled 140 135 @Test 141 publicvoid testUserURL() throws MalformedURLException {136 void testUserURL() throws MalformedURLException { 142 137 /*assertEquals( 143 138 new URL("https://a.streetside.com/v3/me?"+CLIENT_ID_QUERY_PART), … … 147 142 148 143 @Test 149 publicvoid testString2MalformedURL()144 void testString2MalformedURL() 150 145 throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { 151 146 Method method = StreetsideURL.class.getDeclaredMethod("string2URL", String[].class); 152 147 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) 155 150 } 156 151 157 152 @Test 158 publicvoid testUtilityClass() {153 void testUtilityClass() { 159 154 TestUtil.testUtilityClass(StreetsideURL.class); 160 155 TestUtil.testUtilityClass(StreetsideURL.APIv3.class); … … 173 168 parameterIsPresent |= actualParams[acIndex].equals(expectedParams[exIndex]); 174 169 } 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."); 179 171 } 180 172 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideUtilsTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import org.apache.commons.imaging.common.RationalNumber; 7 7 import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants; 8 import org.junit. Test;8 import org.junit.jupiter.api.Test; 9 9 10 10 /** … … 15 15 * 16 16 */ 17 publicclass StreetsideUtilsTest {17 class StreetsideUtilsTest { 18 18 19 19 @Test 20 publicvoid testUtilityClass() {20 void testUtilityClass() { 21 21 TestUtil.testUtilityClass(StreetsideUtils.class); 22 22 } … … 27 27 */ 28 28 @Test 29 public void degMinSecToDoubleTest() {29 void testDegMinSecToDouble() { 30 30 RationalNumber[] num = new RationalNumber[3]; 31 31 num[0] = new RationalNumber(1, 1); -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/TestUtil.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertTrue;6 import static org.junit. Assert.fail;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 import static org.junit.jupiter.api.Assertions.fail; 7 7 8 8 import java.awt.GraphicsEnvironment; … … 15 15 16 16 import org.junit.runners.model.InitializationError; 17 17 import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin; 18 import org.openstreetmap.josm.spi.preferences.Config; 19 import org.openstreetmap.josm.spi.preferences.MemoryPreferences; 18 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 import org.openstreetmap.josm.tools.ImageProvider; 19 22 import org.openstreetmap.josm.tools.Logging; 20 23 import org.openstreetmap.josm.tools.Utils; … … 27 30 private TestUtil() { 28 31 // 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; 29 44 } 30 45 -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/api/JsonDecoderTest.java
r34386 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils.api; 3 3 4 import static org.junit.Assert.assertNull; 4 5 import static org.junit.jupiter.api.Assertions.assertNull; 5 6 6 7 import java.io.ByteArrayInputStream; … … 11 12 import javax.json.JsonObject; 12 13 13 import org.junit.Test; 14 14 import org.junit.jupiter.api.Test; 15 15 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil; 16 16 17 publicclass JsonDecoderTest {17 class JsonDecoderTest { 18 18 19 19 @Test 20 publicvoid testUtilityClass() {20 void testUtilityClass() { 21 21 TestUtil.testUtilityClass(JsonDecoder.class); 22 22 } 23 23 24 24 @Test 25 publicvoid testDecodeDoublePair() {25 void testDecodeDoublePair() { 26 26 assertNull(JsonDecoder.decodeDoublePair(null)); 27 27 } -
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/api/JsonSequencesDecoderTest.java
r34432 r36064 2 2 package org.openstreetmap.josm.plugins.streetside.utils.api; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assertNull; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 6 import static org.openstreetmap.josm.plugins.streetside.utils.api.JsonDecoderTest.assertDecodesToNull; 8 7 … … 19 18 import javax.json.JsonValue; 20 19 21 import org.junit.Ignore; 22 import org.junit.Test; 20 import org.junit.jupiter.api.Assertions; 21 import org.junit.jupiter.api.Disabled; 22 import org.junit.jupiter.api.Test; 23 23 import org.openstreetmap.josm.data.coor.LatLon; 24 24 import org.openstreetmap.josm.plugins.streetside.StreetsideImage; … … 27 27 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil; 28 28 29 publicclass JsonSequencesDecoderTest {30 31 @ Ignore32 @Test 33 publicvoid testDecodeSequences() {29 class JsonSequencesDecoderTest { 30 31 @Disabled 32 @Test 33 void testDecodeSequences() { 34 34 Collection<StreetsideSequence> exampleSequences = JsonDecoder.decodeFeatureCollection( 35 35 Json.createReader(this.getClass().getResourceAsStream("test/data/api/v3/responses/searchSequences.json")).readObject(), … … 51 51 assertEquals(329.94820000000004, seq.getImages().get(3).getHe(), 1e-10); 52 52 53 assertEquals(new LatLon(7.246497, 16.432958), 54 assertEquals(new LatLon(7.246567, 16.432955), 55 assertEquals(new LatLon(7.248372, 16.432971), 56 assertEquals(new LatLon(7.249027, 16.432976), 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()); 57 57 58 58 assertEquals(1_457_963_093_860L, seq.getCd()); // 2016-03-14T13:44:53.860 UTC … … 60 60 61 61 @Test 62 publicvoid testDecodeSequencesInvalid() {62 void testDecodeSequencesInvalid() { 63 63 // null input 64 64 assertEquals(0, JsonDecoder.decodeFeatureCollection(null, JsonSequencesDecoder::decodeSequence).size()); … … 76 76 77 77 @Test 78 publicvoid testDecodeSequencesWithArbitraryObjectAsFeature() {78 void testDecodeSequencesWithArbitraryObjectAsFeature() { 79 79 assertNumberOfDecodedSequences(0, "{\"type\": \"FeatureCollection\", \"features\": [{}]}"); 80 80 } 81 81 82 82 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() { 95 92 StreetsideSequence exampleSequence = JsonSequencesDecoder.decodeSequence( 96 93 Json.createReader(this.getClass().getResourceAsStream("/api/v3/responses/sequence.json")).readObject() … … 100 97 assertEquals(2, exampleSequence.getImages().size()); 101 98 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() { 114 105 // null input 115 assertNull(JsonSequencesDecoder.decodeSequence(null));106 Assertions.assertNull(JsonSequencesDecoder.decodeSequence(null)); 116 107 // `properties` key is not set 117 108 assertDecodesToNull(JsonSequencesDecoder::decodeSequence, "{\"type\": \"Feature\"}"); … … 150 141 */ 151 142 @Test 152 publicvoid testDecodeJsonArray()143 void testDecodeJsonArray() 153 144 throws NoSuchMethodException, SecurityException, IllegalAccessException, 154 145 IllegalArgumentException, InvocationTargetException { 155 146 Method method = JsonSequencesDecoder.class.getDeclaredMethod("decodeJsonArray", JsonArray.class, Function.class, Class.class); 156 147 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 { 165 153 Method decodeCoordinateProperty = JsonSequencesDecoder.class.getDeclaredMethod( 166 154 "decodeCoordinateProperty", … … 172 160 decodeCoordinateProperty.setAccessible(true); 173 161 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() 191 173 throws NoSuchMethodException, SecurityException, IllegalAccessException, 192 174 IllegalArgumentException, InvocationTargetException { … … 206 188 )).readObject()); 207 189 assertEquals(3, example.length); 208 assertNull(example[0]);209 assertNull(example[1]);210 assertNull(example[2]);211 } 212 213 @Test 214 publicvoid testUtilityClass() {190 Assertions.assertNull(example[0]); 191 Assertions.assertNull(example[1]); 192 Assertions.assertNull(example[2]); 193 } 194 195 @Test 196 void testUtilityClass() { 215 197 TestUtil.testUtilityClass(JsonSequencesDecoder.class); 216 198 }
Note:
See TracChangeset
for help on using the changeset viewer.