TrackPointAssert: removed helper methods.

This commit is contained in:
Dennis Guse
2021-06-29 18:58:06 +02:00
parent 0edb72aaed
commit a20cc17215
5 changed files with 142 additions and 100 deletions
@@ -14,6 +14,7 @@ import org.junit.runners.JUnit4;
import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;
import java.util.List;
import de.dennisguse.opentracks.content.data.Distance;
@@ -81,16 +82,28 @@ public class GPXImportTest {
// first segment
TrackPointAssert a = new TrackPointAssert();
a.assertEquals(List.of(
a.expect(TrackPoint.Type.SEGMENT_START_AUTOMATIC, "2021-01-07T21:51:59.179Z", 14.0, 3.0, 10.0),
a.expect(TrackPoint.Type.TRACKPOINT, "2021-01-07T21:52:00.653Z", 14.001, 3.0, 10.0)
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, Instant.parse("2021-01-07T21:51:59.179Z"))
.setLatitude(3)
.setLongitude(14)
.setAltitude(10),
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2021-01-07T21:52:00.653Z"))
.setLatitude(3)
.setLongitude(14.001)
.setAltitude(10)
.setSpeed(Speed.of(75.4192)),
a.expect(TrackPoint.Type.TRACKPOINT, "2021-01-07T21:52:01.010Z", 14.002, 3.0, 10.0)
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2021-01-07T21:52:01.010Z"))
.setLatitude(3)
.setLongitude(14.002)
.setAltitude(10)
.setSpeed(Speed.of(311.3948)),
a.expect(TrackPoint.Type.SEGMENT_END_MANUAL, "2021-01-07T21:52:02.658Z"),
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse("2021-01-07T21:52:02.658Z")),
// created resume trackpoint with time of next valid trackpoint
a.expect(TrackPoint.Type.SEGMENT_START_MANUAL, "2021-01-07T21:52:03.873Z"),
a.expect(TrackPoint.Type.TRACKPOINT, "2021-01-07T21:52:04.103Z", 14.003, 3.0, 10.0)
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse("2021-01-07T21:52:03.873Z")),
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2021-01-07T21:52:04.103Z"))
.setLatitude(3)
.setLongitude(14.003)
.setAltitude(10)
), importedTrackPoints);
}
}
@@ -14,6 +14,7 @@ import org.junit.runners.JUnit4;
import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;
import java.util.List;
import de.dennisguse.opentracks.content.data.Distance;
@@ -81,13 +82,22 @@ public class KMLImportTest {
List<TrackPoint> importedTrackPoints = TestDataUtil.getTrackPoints(contentProviderUtils, importTrackId);
TrackPointAssert a = new TrackPointAssert();
a.assertEquals(List.of(
a.expect(TrackPoint.Type.SEGMENT_START_MANUAL, "2021-05-29T18:06:21.767Z"),
a.expect(TrackPoint.Type.TRACKPOINT, "2021-05-29T18:06:22.042Z", 14.0, 3.0, 10.0),
a.expect(TrackPoint.Type.TRACKPOINT, "2021-05-29T18:06:22.192Z", 14.001, 3.0, 10.0)
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse("2021-05-29T18:06:21.767Z")),
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2021-05-29T18:06:22.042Z"))
.setLatitude(3)
.setLongitude(14)
.setAltitude(10),
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2021-05-29T18:06:22.192Z"))
.setLatitude(3)
.setLongitude(14.001)
.setAltitude(10)
.setSpeed(Speed.of(741.1196)),
a.expect(TrackPoint.Type.TRACKPOINT, "2021-05-29T18:06:22.318Z", 14.002, 3.0, 10.0)
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2021-05-29T18:06:22.318Z"))
.setLatitude(3)
.setLongitude(14.002)
.setAltitude(10)
.setSpeed(Speed.of(882.2853)),
a.expect(TrackPoint.Type.SEGMENT_END_MANUAL, "2021-05-29T18:06:22.512Z")
new TrackPoint(TrackPoint.Type.SEGMENT_END_MANUAL, Instant.parse("2021-05-29T18:06:22.512Z"))
), importedTrackPoints);
}
@@ -122,8 +132,11 @@ public class KMLImportTest {
TrackPointAssert a = new TrackPointAssert();
a.assertEquals(List.of(
a.expect(TrackPoint.Type.TRACKPOINT, "2021-05-29T18:06:21.767Z", 14.0, 3.0, 10.0),
a.expect(TrackPoint.Type.SEGMENT_START_MANUAL, "2021-05-29T18:06:22.042Z")
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2021-05-29T18:06:21.767Z"))
.setLatitude(3)
.setLongitude(14)
.setAltitude(10),
new TrackPoint(TrackPoint.Type.SEGMENT_START_MANUAL, Instant.parse("2021-05-29T18:06:22.042Z"))
), importedTrackPoints);
}
@@ -160,24 +173,42 @@ public class KMLImportTest {
TrackPointAssert a = new TrackPointAssert();
a.assertEquals(List.of(
// first 3 trackpoints
a.expect(TrackPoint.Type.SEGMENT_START_AUTOMATIC, "2020-11-28T17:06:22.401Z", 1.234156, 12.340097, 469.286376953125)
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, Instant.parse("2020-11-28T17:06:22.401Z"))
.setLatitude(12.340097)
.setLongitude(1.234156)
.setAltitude(469.286376953125)
.setAltitudeGain(0f)
.setSpeed(Speed.of(0.539)),
a.expect(TrackPoint.Type.TRACKPOINT, "2020-11-28T17:06:25.448Z", 1.23415, 12.340036, 439.1626281738281)
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-11-28T17:06:25.448Z"))
.setLatitude(12.340036)
.setLongitude(1.23415)
.setAltitude(439.1626281738281)
.setAltitudeGain(0f)
.setSpeed(Speed.of(0.1577)),
a.expect(TrackPoint.Type.TRACKPOINT, "2020-11-28T17:06:47.888Z", 1.23405, 12.340057, 421.8070983886719)
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-11-28T17:06:47.888Z"))
.setLatitude(12.340057)
.setLongitude(1.23405)
.setAltitude(421.8070983886719)
.setAltitudeGain(0f)
.setSpeed(Speed.of(0)),
// created resume trackpoint with time of next valid trackpoint
a.expect(TrackPoint.Type.SEGMENT_START_AUTOMATIC, "2020-11-28T17:06:55.861Z", 1.23405, 12.340057, 419.93902587890625)
new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, Instant.parse("2020-11-28T17:06:55.861Z"))
.setLatitude(12.340057)
.setLongitude(1.23405)
.setAltitude(419.93902587890625)
.setAltitudeGain(0f)
.setSpeed(Speed.of(0)),
a.expect(TrackPoint.Type.TRACKPOINT, "2020-11-28T17:06:56.905Z", 1.23405, 12.340057, 419.9036560058594)
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-11-28T17:06:56.905Z"))
.setLatitude(12.340057)
.setLongitude(1.23405)
.setAltitude(419.9036560058594)
.setAltitudeGain(0f)
.setSpeed(Speed.of(0)),
a.expect(TrackPoint.Type.TRACKPOINT, "2020-11-28T17:07:20.870Z", 1.234046, 12.340082, 417.99432373046875)
new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.parse("2020-11-28T17:07:20.870Z"))
.setLatitude(12.340082)
.setLongitude(1.234046)
.setAltitude(417.99432373046875)
.setAltitudeGain(0f)
.setSpeed(Speed.of(0))
), importedTrackPoints);
@@ -5,7 +5,6 @@ import org.junit.Assert;
import java.util.List;
import de.dennisguse.opentracks.content.data.TrackPoint;
import de.dennisguse.opentracks.util.StringUtils;
public class TrackPointAssert {
@@ -88,41 +87,6 @@ public class TrackPointAssert {
}
}
public TrackPoint expect(final TrackPoint.Type type) {
return new TrackPoint(type);
}
public TrackPoint expect(final TrackPoint.Type type, float accuracy) {
TrackPoint tp = new TrackPoint(type);
tp.setAccuracy(accuracy);
return tp;
}
public TrackPoint expect(final TrackPoint.Type type, float accuracy, float heartrate) {
TrackPoint tp = new TrackPoint(type);
tp.setAccuracy(accuracy);
tp.setHeartRate_bpm(heartrate);
return tp;
}
public TrackPoint expecHeartrate(final TrackPoint.Type type, float heartrate) {
TrackPoint tp = new TrackPoint(type);
tp.setHeartRate_bpm(heartrate);
return tp;
}
public TrackPoint expect(final TrackPoint.Type type, final String when) {
return new TrackPoint(type, StringUtils.parseTime(when));
}
public TrackPoint expect(final TrackPoint.Type type, final String when, final double longitude, final double latitude, final double altitude) {
TrackPoint tp = expect(type, when);
tp.setLongitude(longitude);
tp.setLatitude(latitude);
tp.setAltitude(altitude);
return tp;
}
public TrackPointAssert ignoreTime() {
this.assertTime = false;
return this;