Speed.ZERO as constant.

This commit is contained in:
Dennis Guse
2025-11-02 08:30:15 +01:00
parent a5e5d0ca51
commit fffeb40200
15 changed files with 42 additions and 45 deletions
@@ -29,7 +29,7 @@ public class ChartPointTest {
Statistics statistics = new Statistics(null, null, Duration.ofSeconds(1000), null, null, null, null, null, null, null);
// when
ChartPoint point = ChartPoint.create(statistics, TrackStubUtils.createDefaultTrackPoint(), Speed.of(0), false, UnitSystem.IMPERIAL_FEET);
ChartPoint point = ChartPoint.create(statistics, TrackStubUtils.createDefaultTrackPoint(), Speed.ZERO, false, UnitSystem.IMPERIAL_FEET);
// then
assertEquals(1000000, (long) point.timeOrDistance());
@@ -41,7 +41,7 @@ public class ChartPointTest {
Statistics statistics = new Statistics(null, null, null, null, Distance.of(1000), null, null, null, null, null);
// when
ChartPoint point = ChartPoint.create(statistics, TrackStubUtils.createDefaultTrackPoint(), Speed.of(0), true, UnitSystem.METRIC);
ChartPoint point = ChartPoint.create(statistics, TrackStubUtils.createDefaultTrackPoint(), Speed.ZERO, true, UnitSystem.METRIC);
// then
assertEquals(1, (long) point.timeOrDistance());
@@ -28,7 +28,7 @@ public class SpeedFormatterTest {
assertEquals("4:59", formatter.getSpeedParts(Speed.of(3.34)).first);
assertEquals("5:00", formatter.getSpeedParts(Speed.of(3.33)).first);
assertEquals("min/km", formatter.getSpeedParts(Speed.zero()).second);
assertEquals("min/km", formatter.getSpeedParts(Speed.ZERO).second);
}
@Test
@@ -39,7 +39,7 @@ public class SpeedFormatterTest {
.build(context);
assertEquals("8:02", formatter.getSpeedParts(Speed.of(3.34)).first);
assertEquals("min/mi", formatter.getSpeedParts(Speed.zero()).second);
assertEquals("min/mi", formatter.getSpeedParts(Speed.ZERO).second);
}
@Test
@@ -50,7 +50,7 @@ public class SpeedFormatterTest {
.build(context);
assertEquals("9:14", formatter.getSpeedParts(Speed.of(3.34)).first);
assertEquals("min/NM", formatter.getSpeedParts(Speed.zero()).second);
assertEquals("min/NM", formatter.getSpeedParts(Speed.ZERO).second);
}
@Test
@@ -61,7 +61,7 @@ public class SpeedFormatterTest {
.build(context);
assertEquals("11.9", formatter.getSpeedParts(Speed.of(3.31)).first);
assertEquals("km/h", formatter.getSpeedParts(Speed.zero()).second);
assertEquals("km/h", formatter.getSpeedParts(Speed.ZERO).second);
}
@Test
@@ -72,7 +72,7 @@ public class SpeedFormatterTest {
.build(context);
assertEquals("7.5", formatter.getSpeedParts(Speed.of(3.34)).first);
assertEquals("mph", formatter.getSpeedParts(Speed.zero()).second);
assertEquals("mph", formatter.getSpeedParts(Speed.ZERO).second);
}
@Test
@@ -83,7 +83,7 @@ public class SpeedFormatterTest {
.build(context);
assertEquals("6.5", formatter.getSpeedParts(Speed.of(3.34)).first);
assertEquals("kn", formatter.getSpeedParts(Speed.zero()).second);
assertEquals("kn", formatter.getSpeedParts(Speed.ZERO).second);
}
@Test
@@ -203,7 +203,7 @@ public class KMLTrackImporterTest {
12.340057, 1.23405, null,
Altitude.WGS84.of(421.8070983886719), null,
null,
Speed.of(0))),
Speed.ZERO)),
// created resume trackpoint with time of next valid trackpoint
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC,
new Position(
@@ -211,21 +211,21 @@ public class KMLTrackImporterTest {
12.340057, 1.23405, null,
Altitude.WGS84.of(419.93902587890625), null,
null,
Speed.of(0))),
Speed.ZERO)),
new TrackPoint(TrackPoint.Type.TRACKPOINT,
new Position(
Instant.parse("2020-11-28T17:06:56.905Z"),
12.340057, 1.23405, null,
Altitude.WGS84.of(419.9036560058594), null,
null,
Speed.of(0))),
Speed.ZERO)),
new TrackPoint(TrackPoint.Type.TRACKPOINT,
new Position(
Instant.parse("2020-11-28T17:07:20.870Z"),
12.340082, 1.234046, null,
Altitude.WGS84.of(417.99432373046875), null,
null,
Speed.of(0)))
Speed.ZERO))
), importedTrackPoints);
}
@@ -125,6 +125,6 @@ public class SensorDataCyclingTest {
// TODO See #953
// assertEquals(2, current.getValue().getDistance().toM(), 0.01);
// assertEquals(2, current.getValue().getSpeed().toMPS(), 0.01);
assertEquals(new AggregatorCyclingDistanceSpeed.Data(Distance.of(0), Distance.of(0), Speed.of(0)), current.getAggregatedValue(Instant.MIN));
assertEquals(new AggregatorCyclingDistanceSpeed.Data(Distance.of(0), Distance.of(0), Speed.ZERO), current.getAggregatedValue(Instant.MIN));
}
}
@@ -44,7 +44,7 @@ public class TrackRecordingServiceNotificationManagerTest {
null, null, Distance.of(999f),
Altitude.WGS84.of(10), null,
null,
Speed.of(0))
Speed.ZERO)
);
when(notificationCompatBuilder.setOnlyAlertOnce(anyBoolean()))
@@ -110,7 +110,7 @@ public class TrackRecordingServiceRecordingTest {
// then
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(startTime), Duration.ZERO, Duration.ZERO, Distance.of(0), Speed.zero(), new AltitudeExtremities(0.0, 0.0), null, null, null)
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(startTime), Duration.ZERO, Duration.ZERO, Distance.of(0), Speed.ZERO, new AltitudeExtremities(0.0, 0.0), null, null, null)
, contentProviderUtils.getTrack(trackId).getStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -124,7 +124,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.of(0), Speed.zero(), new AltitudeExtremities(0.0, 0.0), new AltitudeGainLoss(0, 0), null, null)
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.of(0), Speed.ZERO, new AltitudeExtremities(0.0, 0.0), new AltitudeGainLoss(0, 0), null, null)
, contentProviderUtils.getTrack(trackId).getStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -199,7 +199,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(pauseTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.of(0), Speed.zero(), new AltitudeExtremities(0.0, 0.0), new AltitudeGainLoss(0, 0), null, null)
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(pauseTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.of(0), Speed.ZERO, new AltitudeExtremities(0.0, 0.0), new AltitudeGainLoss(0, 0), null, null)
, contentProviderUtils.getTrack(trackId).getStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -214,7 +214,7 @@ public class TrackRecordingServiceRecordingTest {
service.resumeTrack(trackId);
// then
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(resumeTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.of(0), Speed.zero(), new AltitudeExtremities(0.0, 0.0), new AltitudeGainLoss(0, 0), null, null)
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(resumeTime), Duration.ofSeconds(1), Duration.ofSeconds(1), Distance.of(0), Speed.ZERO, new AltitudeExtremities(0.0, 0.0), new AltitudeGainLoss(0, 0), null, null)
, contentProviderUtils.getTrack(trackId).getStatistics());
new TrackPointAssert().assertEquals(List.of(
@@ -538,7 +538,7 @@ public class TrackRecordingServiceRecordingTest {
sendGPSLocation(trackPointCreator, gps1, 45.0, 35.0, 100, 15);
// then
Statistics startStatistics = new Statistics(Instant.parse(startTime), Instant.parse(startTime), Duration.ofSeconds(0), Duration.ofSeconds(0), Distance.of(0), Speed.of(0), new AltitudeExtremities(0.0, 0.0), null, null, null);
Statistics startStatistics = new Statistics(Instant.parse(startTime), Instant.parse(startTime), Duration.ofSeconds(0), Duration.ofSeconds(0), Distance.of(0), Speed.ZERO, new AltitudeExtremities(0.0, 0.0), null, null, null);
assertEquals(startStatistics, contentProviderUtils.getTrack(trackId).getStatistics());
@@ -556,7 +556,7 @@ public class TrackRecordingServiceRecordingTest {
service.endCurrentTrack();
// then
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(10), Duration.ofSeconds(10), Distance.of(0), Speed.of(0), new AltitudeExtremities(0.0, 0.0), new AltitudeGainLoss(0, 0), null, null)
assertEquals(new Statistics(Instant.parse(startTime), Instant.parse(stopTime), Duration.ofSeconds(10), Duration.ofSeconds(10), Distance.of(0), Speed.ZERO, new AltitudeExtremities(0.0, 0.0), new AltitudeGainLoss(0, 0), null, null)
, contentProviderUtils.getTrack(trackId).getStatistics());
// then
@@ -730,7 +730,7 @@ public class TrackRecordingServiceRecordingTest {
45.001, 35d, Distance.of(1),
null, null,
null,
Speed.of(0))) //Sensor data is now outdated, but we do not fall back to GPS.
Speed.ZERO)) //Sensor data is now outdated, but we do not fall back to GPS.
.setSensorDistance(Distance.of(0))
), TestDataUtil.getTrackPoints(contentProviderUtils, trackId));
}
@@ -37,9 +37,9 @@ public class TrackStatisticsUpdaterTest {
assertEquals(Duration.ZERO, statistics.getTotalTime());
assertEquals(Duration.ZERO, statistics.getMovingTime());
assertEquals(Speed.of(0), statistics.getAverageSpeed());
assertEquals(Speed.of(0), statistics.getAverageMovingSpeed());
assertEquals(Speed.of(0), statistics.getMaxSpeed());
assertEquals(Speed.ZERO, statistics.getAverageSpeed());
assertEquals(Speed.ZERO, statistics.getAverageMovingSpeed());
assertEquals(Speed.ZERO, statistics.getMaxSpeed());
assertNull(statistics.getTotalAltitudeGain());
assertNull(statistics.getTotalAltitudeLoss());
@@ -64,9 +64,9 @@ public class TrackStatisticsUpdaterTest {
assertEquals(Duration.ZERO, statistics.getTotalTime());
assertEquals(Duration.ZERO, statistics.getMovingTime());
assertEquals(Speed.of(0), statistics.getAverageSpeed());
assertEquals(Speed.of(0), statistics.getAverageMovingSpeed());
assertEquals(Speed.of(0), statistics.getMaxSpeed());
assertEquals(Speed.ZERO, statistics.getAverageSpeed());
assertEquals(Speed.ZERO, statistics.getAverageMovingSpeed());
assertEquals(Speed.ZERO, statistics.getMaxSpeed());
assertNull(statistics.getTotalAltitudeGain());
assertNull(statistics.getTotalAltitudeLoss());