java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/CourseChangeBasedTrackApproximationTest.java
... ...
@@ -47,11 +47,13 @@ public class CourseChangeBasedTrackApproximationTest extends OnlineTracTracBased
47 47
new URL("file:///" + new File("resources/event_20110609_KielerWoch-505_Race_2.txt").getCanonicalPath()),
48 48
/* liveUri */ null, /* storedUri */ storedUri,
49 49
new ReceiverType[] { ReceiverType.RACECOURSE, ReceiverType.RAWPOSITIONS });
50
+ getTrackedRace().waitUntilNotLoading();
50 51
assertFalse(Util.isEmpty(getTrackedRace().getRace().getCompetitors()));
51
- final DynamicGPSFixTrack<Competitor, GPSFixMoving> sampleTrack = getTrackedRace().getTrack(getTrackedRace().getRace().getCompetitors().iterator().next());
52
+ final Competitor sampleCompetitor = getTrackedRace().getRace().getCompetitors().iterator().next();
53
+ final DynamicGPSFixTrack<Competitor, GPSFixMoving> sampleTrack = getTrackedRace().getTrack(sampleCompetitor);
52 54
sampleTrack.lockForRead();
53 55
try {
54
- assertFalse(Util.isEmpty(sampleTrack.getRawFixes()));
56
+ assertFalse(Util.isEmpty(sampleTrack.getRawFixes()), "Track of competitor "+sampleCompetitor.getName()+" is empty");
55 57
} finally {
56 58
sampleTrack.unlockAfterRead();
57 59
}
... ...
@@ -93,6 +95,7 @@ public class CourseChangeBasedTrackApproximationTest extends OnlineTracTracBased
93 95
sampleTrack.unlockAfterRead();
94 96
}
95 97
final CourseChangeBasedTrackApproximation lateInitApproximation = new CourseChangeBasedTrackApproximation(trackCopy, sampleCompetitor.getBoat().getBoatClass());
98
+ assertEquals(earlyInitApproximation.getNumberOfFixesAdded(), lateInitApproximation.getNumberOfFixesAdded(), "Number of fixes added to approximators differs");
96 99
final Iterable<GPSFixMoving> earlyInitResult = earlyInitApproximation.approximate(from, to);
97 100
final Iterable<GPSFixMoving> lateInitResult = lateInitApproximation.approximate(from, to);
98 101
assertEquals(Util.size(earlyInitResult), Util.size(lateInitResult), "Different numbers of approximation points for competitor "+sampleCompetitor.getName());
java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/CourseChangeBasedTrackApproximation.java
... ...
@@ -62,9 +62,10 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
62 62
63 63
/**
64 64
* The set needs no special synchronization; all methods on this {@link CourseChangeBasedTrackApproximation} object
65
- * that may mutate it are {@code synchronized} methods.
65
+ * that may read or mutate it are {@code synchronized} methods.
66 66
*/
67 67
private final NavigableSet<GPSFixMoving> maneuverCandidates;
68
+ private int numberOfFixesAdded;
68 69
69 70
/**
70 71
* The fix window consists of the list of fixes, a corresponding list with the course changes at each fix within the
... ...
@@ -155,6 +156,7 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
155 156
final GPSFixMoving result;
156 157
final SpeedWithBearing nextSpeed = next.isEstimatedSpeedCached() ? next.getCachedEstimatedSpeed() : track.getEstimatedSpeed(next.getTimePoint());
157 158
if (nextSpeed != null) {
159
+ numberOfFixesAdded++;
158 160
int insertPosition = window.size();
159 161
GPSFixMoving previous;
160 162
SpeedWithBearing previousSpeed;
... ...
@@ -340,7 +342,7 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
340 342
private synchronized void addAllFixesOfTrack() {
341 343
track.lockForRead();
342 344
try {
343
- for (final GPSFixMoving fix : track.getFixes()) {
345
+ for (final GPSFixMoving fix : track.getRawFixes()) {
344 346
addFix(fix);
345 347
}
346 348
} finally {
... ...
@@ -363,6 +365,10 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
363 365
}
364 366
}
365 367
368
+ public int getNumberOfFixesAdded() {
369
+ return numberOfFixesAdded;
370
+ }
371
+
366 372
/**
367 373
* We want the listener relationship with the track to be serialized, e.g., during initial load / replication
368 374
*/
... ...
@@ -417,7 +423,7 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
417 423
}
418 424
419 425
/**
420
- * Precondition: the caller holds at least a read lock on {@link #maneuverCandidatesLock}
426
+ * Precondition: the caller owns this object's monitor ({@code synchronized})
421 427
*/
422 428
private GPSFixMoving getExistingManeuverCandidateInRange(TimeRange leftPartOfTimeRangeToReScan) {
423 429
final GPSFixMoving firstCandidateAtOrAfterStartOfTimeRange = maneuverCandidates.ceiling(