1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.gpx;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 | import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
---|
6 |
|
---|
7 | import java.time.Instant;
|
---|
8 |
|
---|
9 | import org.junit.jupiter.api.Test;
|
---|
10 | import org.openstreetmap.josm.TestUtils;
|
---|
11 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
12 |
|
---|
13 | import nl.jqno.equalsverifier.EqualsVerifier;
|
---|
14 | import nl.jqno.equalsverifier.Warning;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Unit tests for class {@link WayPoint}.
|
---|
18 | */
|
---|
19 | class WayPointTest {
|
---|
20 | /**
|
---|
21 | * Unit test of methods {@link WayPoint#equals} and {@link WayPoint#hashCode}.
|
---|
22 | */
|
---|
23 | @Test
|
---|
24 | void testEqualsContract() {
|
---|
25 | TestUtils.assumeWorkingEqualsVerifier();
|
---|
26 | GpxExtensionCollection col = new GpxExtensionCollection();
|
---|
27 | col.add("josm", "from-server", "true");
|
---|
28 | EqualsVerifier.forClass(WayPoint.class).usingGetClass()
|
---|
29 | .suppress(Warning.NONFINAL_FIELDS)
|
---|
30 | .withIgnoredFields("customColoring", "dir", "drawLine", "east", "north", "eastNorthCacheKey")
|
---|
31 | .withPrefabValues(GpxExtensionCollection.class, new GpxExtensionCollection(), col)
|
---|
32 | .verify();
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Unit test of copy constructor {@link WayPoint#WayPoint(WayPoint)}
|
---|
37 | */
|
---|
38 | @Test
|
---|
39 | void testConstructor() {
|
---|
40 | WayPoint wp1 = new WayPoint(new LatLon(12., 34.));
|
---|
41 | wp1.setInstant(Instant.ofEpochMilli(123_456_789));
|
---|
42 | WayPoint wp2 = new WayPoint(wp1);
|
---|
43 | assertEquals(wp1, wp2);
|
---|
44 | assertEquals(wp1.getInstant(), wp2.getInstant());
|
---|
45 | wp2.setInstant(Instant.ofEpochMilli(234_456_789));
|
---|
46 | assertNotEquals(wp1, wp2);
|
---|
47 | assertNotEquals(wp1.getInstant(), wp2.getInstant());
|
---|
48 | }
|
---|
49 | }
|
---|