Changeset 12164 in josm for trunk/test/unit/org
- Timestamp:
- 2017-05-15T16:04:38+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java
r10906 r12164 2 2 package org.openstreetmap.josm.data.gpx; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertTrue; 7 import static org.junit.Assert.fail; 8 9 import java.util.Collections; 10 11 import org.junit.Before; 4 12 import org.junit.Rule; 5 13 import org.junit.Test; … … 22 30 public JOSMTestRules test = new JOSMTestRules(); 23 31 32 private GpxData data; 33 34 /** 35 * @throws java.lang.Exception 36 */ 37 @Before 38 public void setUp() throws Exception { 39 data = new GpxData(); 40 } 41 42 43 /** 44 * Test method for {@link GpxData#mergeFrom(GpxData)}. 45 */ 46 @Test 47 public void testMergeFrom() { 48 fail("Not yet implemented"); 49 } 50 51 /** 52 * Test method for {@link GpxData#getTracks()}, {@link GpxData#addTrack(GpxTrack)}, {@link GpxData#removeTrack(GpxTrack)}. 53 */ 54 @Test 55 public void testTracks() { 56 assertEquals(0, data.getTracks().size()); 57 58 ImmutableGpxTrack track1 = emptyGpxTrack(); 59 ImmutableGpxTrack track2 = emptyGpxTrack(); 60 data.addTrack(track1); 61 assertEquals(1, data.getTracks().size()); 62 data.addTrack(track2); 63 assertEquals(2, data.getTracks().size()); 64 assertTrue(data.getTracks().contains(track1)); 65 assertTrue(data.getTracks().contains(track2)); 66 67 data.removeTrack(track1); 68 assertEquals(1, data.getTracks().size()); 69 assertFalse(data.getTracks().contains(track1)); 70 assertTrue(data.getTracks().contains(track2)); 71 } 72 73 /** 74 * Test method for {@link GpxData#addTrack(GpxTrack)}. 75 */ 76 @Test(expected = IllegalArgumentException.class) 77 public void testAddTrackFails() { 78 ImmutableGpxTrack track1 = emptyGpxTrack(); 79 data.addTrack(track1); 80 data.addTrack(track1); 81 } 82 83 /** 84 * Test method for {@link GpxData#removeTrack(GpxTrack)}. 85 */ 86 @Test(expected = IllegalArgumentException.class) 87 public void testRemoveTrackFails() { 88 ImmutableGpxTrack track1 = emptyGpxTrack(); 89 data.addTrack(track1); 90 data.removeTrack(track1); 91 data.removeTrack(track1); 92 } 93 94 /** 95 * Test method for {@link GpxData#getRoutes()}, {@link GpxData#addRoute(GpxRoute)}, {@link GpxData#removeRoute(GpxRoute)}. 96 */ 97 @Test 98 public void testRoutes() { 99 assertEquals(0, data.getTracks().size()); 100 101 GpxRoute route1 = new GpxRoute(); 102 GpxRoute route2 = new GpxRoute(); 103 data.addRoute(route1); 104 assertEquals(1, data.getRoutes().size()); 105 data.addRoute(route2); 106 assertEquals(2, data.getRoutes().size()); 107 assertTrue(data.getRoutes().contains(route1)); 108 assertTrue(data.getRoutes().contains(route2)); 109 110 data.removeRoute(route1); 111 assertEquals(1, data.getRoutes().size()); 112 assertFalse(data.getRoutes().contains(route1)); 113 assertTrue(data.getRoutes().contains(route2)); 114 } 115 116 /** 117 * Test method for {@link GpxData#addRoute(GpxRoute)}. 118 */ 119 @Test(expected = IllegalArgumentException.class) 120 public void testAddRouteFails() { 121 GpxRoute route1 = new GpxRoute(); 122 data.addRoute(route1); 123 data.addRoute(route1); 124 } 125 126 /** 127 * Test method for {@link GpxData#removeRoute(GpxRoute)}. 128 */ 129 @Test(expected = IllegalArgumentException.class) 130 public void testRemoveRouteFails() { 131 GpxRoute route1 = new GpxRoute(); 132 data.addRoute(route1); 133 data.removeRoute(route1); 134 data.removeRoute(route1); 135 } 136 137 /** 138 * Test method for {@link GpxData#getWaypoints()}, {@link GpxData#addWaypoint(WayPoint)}, {@link GpxData#removeWaypoint(WayPoint)}. 139 */ 140 @Test 141 public void testWaypoints() { 142 assertEquals(0, data.getTracks().size()); 143 144 WayPoint waypoint1 = new WayPoint(LatLon.ZERO); 145 WayPoint waypoint2 = new WayPoint(LatLon.ZERO); 146 data.addWaypoint(waypoint1); 147 assertEquals(1, data.getWaypoints().size()); 148 data.addWaypoint(waypoint2); 149 assertEquals(2, data.getWaypoints().size()); 150 assertTrue(data.getWaypoints().contains(waypoint1)); 151 assertTrue(data.getWaypoints().contains(waypoint2)); 152 153 data.removeWaypoint(waypoint1); 154 assertEquals(1, data.getWaypoints().size()); 155 assertFalse(data.getWaypoints().contains(waypoint1)); 156 assertTrue(data.getWaypoints().contains(waypoint2)); 157 } 158 159 /** 160 * Test method for {@link GpxData#addWaypoint(WayPoint)}. 161 */ 162 @Test(expected = IllegalArgumentException.class) 163 public void testAddWaypointFails() { 164 WayPoint waypoint1 = new WayPoint(LatLon.ZERO); 165 data.addWaypoint(waypoint1); 166 data.addWaypoint(waypoint1); 167 } 168 169 /** 170 * Test method for {@link GpxData#removeWaypoint(WayPoint)}. 171 */ 172 @Test(expected = IllegalArgumentException.class) 173 public void testRemoveWaypointFails() { 174 WayPoint waypoint1 = new WayPoint(LatLon.ZERO); 175 data.addWaypoint(waypoint1); 176 data.removeWaypoint(waypoint1); 177 data.removeWaypoint(waypoint1); 178 } 179 180 /** 181 * Test method for {@link GpxData#hasTrackPoints()}. 182 */ 183 @Test 184 public void testHasTrackPoints() { 185 assertFalse(data.hasTrackPoints()); 186 ImmutableGpxTrack track1 = emptyGpxTrack(); 187 data.addTrack(track1); 188 assertFalse(data.hasTrackPoints()); 189 ImmutableGpxTrack track2 = singleWaypointGpxTrack(); 190 data.addTrack(track2); 191 assertTrue(data.hasTrackPoints()); 192 } 193 194 /** 195 * Test method for {@link GpxData#getTrackPoints()}. 196 */ 197 @Test 198 public void testGetTrackPoints() { 199 assertEquals(0, data.getTrackPoints().count()); 200 ImmutableGpxTrack track1 = singleWaypointGpxTrack(); 201 data.addTrack(track1); 202 assertEquals(1, data.getTrackPoints().count()); 203 ImmutableGpxTrack track2 = singleWaypointGpxTrack(); 204 data.addTrack(track2); 205 assertEquals(2, data.getTrackPoints().count()); 206 } 207 208 /** 209 * Test method for {@link GpxData#hasRoutePoints()}. 210 */ 211 @Test 212 public void testHasRoutePoints() { 213 fail("Not yet implemented"); 214 } 215 216 /** 217 * Test method for {@link GpxData#isEmpty()}. 218 */ 219 @Test 220 public void testIsEmpty() { 221 fail("Not yet implemented"); 222 } 223 224 /** 225 * Test method for {@link GpxData#getMetaBounds()}. 226 */ 227 @Test 228 public void testGetMetaBounds() { 229 fail("Not yet implemented"); 230 } 231 232 /** 233 * Test method for {@link GpxData#recalculateBounds()}. 234 */ 235 @Test 236 public void testRecalculateBounds() { 237 fail("Not yet implemented"); 238 } 239 240 /** 241 * Test method for {@link GpxData#length()}. 242 */ 243 @Test 244 public void testLength() { 245 fail("Not yet implemented"); 246 } 247 248 /** 249 * Test method for {@link GpxData#getMinMaxTimeForTrack(GpxTrack)}. 250 */ 251 @Test 252 public void testGetMinMaxTimeForTrack() { 253 fail("Not yet implemented"); 254 } 255 256 /** 257 * Test method for {@link GpxData#getMinMaxTimeForAllTracks()}. 258 */ 259 @Test 260 public void testGetMinMaxTimeForAllTracks() { 261 fail("Not yet implemented"); 262 } 263 264 /** 265 * Test method for {@link GpxData#nearestPointOnTrack(org.openstreetmap.josm.data.coor.EastNorth, double)}. 266 */ 267 @Test 268 public void testNearestPointOnTrack() { 269 fail("Not yet implemented"); 270 } 271 272 /** 273 * Test method for {@link GpxData#getLinesIterable(boolean[])}. 274 */ 275 @Test 276 public void testGetLinesIterable() { 277 fail("Not yet implemented"); 278 } 279 280 /** 281 * Test method for {@link GpxData#resetEastNorthCache()}. 282 */ 283 @Test 284 public void testResetEastNorthCache() { 285 fail("Not yet implemented"); 286 } 287 288 /** 289 * Test method for {@link GpxData#getDataSources()}. 290 */ 291 @Test 292 public void testGetDataSources() { 293 fail("Not yet implemented"); 294 } 295 296 /** 297 * Test method for {@link GpxData#getDataSourceArea()}. 298 */ 299 @Test 300 public void testGetDataSourceArea() { 301 fail("Not yet implemented"); 302 } 303 304 /** 305 * Test method for {@link GpxData#getDataSourceBounds()}. 306 */ 307 @Test 308 public void testGetDataSourceBounds() { 309 fail("Not yet implemented"); 310 } 311 312 /** 313 * Test method for {@link GpxData#addChangeListener(GpxData.GpxDataChangeListener)}. 314 */ 315 @Test 316 public void testAddChangeListener() { 317 fail("Not yet implemented"); 318 } 319 320 /** 321 * Test method for {@link GpxData#addWeakChangeListener(GpxData.GpxDataChangeListener)}. 322 */ 323 @Test 324 public void testAddWeakChangeListener() { 325 fail("Not yet implemented"); 326 } 327 328 /** 329 * Test method for {@link GpxData#removeChangeListener(GpxData.GpxDataChangeListener)}. 330 */ 331 @Test 332 public void testRemoveChangeListener() { 333 fail("Not yet implemented"); 334 } 335 336 private static ImmutableGpxTrack emptyGpxTrack() { 337 return new ImmutableGpxTrack(Collections.emptyList(), Collections.emptyMap()); 338 } 339 340 private static ImmutableGpxTrack singleWaypointGpxTrack() { 341 return new ImmutableGpxTrack(Collections.singleton(Collections.singleton(new WayPoint(LatLon.ZERO))), Collections.emptyMap()); 342 } 343 24 344 /** 25 345 * Unit test of methods {@link GpxData#equals} and {@link GpxData#hashCode}. … … 28 348 public void testEqualsContract() { 29 349 EqualsVerifier.forClass(GpxData.class).usingGetClass() 30 .withIgnoredFields("attr", "creator", "fromServer", "storageFile" )350 .withIgnoredFields("attr", "creator", "fromServer", "storageFile", "listeners") 31 351 .withPrefabValues(WayPoint.class, new WayPoint(LatLon.NORTH_POLE), new WayPoint(LatLon.SOUTH_POLE)) 32 352 .verify();
Note:
See TracChangeset
for help on using the changeset viewer.