added failing test case for bug 4387

Change-Id: I5059f3cc94db585fa3a5da64ac50a285b13a1e6f
This commit is contained in:
Axel Uhl committed 2017-12-03 15:22:14 +01:00
1 parent 28ffdac19f
commit 2e07176410
5 files changed
+32 -6

No files matched your search

@@ -13,9 +13,4 @@ import com.sap.sse.common.WithID;
*/
public interface DynamicSensorFixTrack<ItemType extends WithID & Serializable, FixT extends SensorFix> extends
SensorFixTrack<ItemType, FixT>, DynamicTrack<FixT> {
/**
* Invoked when this track is added to a tracked race. This default implementation
* does nothing.
*/
default void addedToTrackedRace(TrackedRace trackedRace) {}
}
@@ -25,4 +25,10 @@ public interface DynamicTrack<FixType extends Timed> extends Track<FixType> {
* @return <code>true</code> if the element was added, <code>false</code> otherwise.
*/
boolean add(FixType fix, boolean replace);
/**
* Invoked when this track is added to a tracked race. The method is also invoked after de-serializing the
* containing {@link TrackedRace}. This default implementation does nothing.
*/
default void addedToTrackedRace(TrackedRace trackedRace) {}
}
@@ -92,7 +92,7 @@ public class BravoFixTrackImpl<ItemType extends WithID & Serializable> extends S
setGpsTrack(gpsTrack);
}
protected GPSFixTrack<ItemType, GPSFixMoving> getGpsTrack() {
public GPSFixTrack<ItemType, GPSFixMoving> getGpsTrack() {
return gpsTrack;
}
@@ -636,6 +636,9 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException, PatchFailedException {
ois.defaultReadObject();
getRace().getCourse().addCourseListener(this);
for (DynamicTrack<?> sensorTrack : sensorTracks.values()) {
sensorTrack.addedToTrackedRace(this);
}
raceStates = new WeakHashMap<>();
attachedRaceLogs = new ConcurrentHashMap<>();
attachedRegattaLogs = new ConcurrentHashMap<>();
@@ -3,6 +3,7 @@ package com.sap.sailing.server.replication.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -45,11 +46,13 @@ import com.sap.sailing.domain.persistence.MongoWindStore;
import com.sap.sailing.domain.persistence.MongoWindStoreFactory;
import com.sap.sailing.domain.persistence.PersistenceFactory;
import com.sap.sailing.domain.test.PositionAssert;
import com.sap.sailing.domain.tracking.BravoFixTrack;
import com.sap.sailing.domain.tracking.DynamicTrackedRace;
import com.sap.sailing.domain.tracking.DynamicTrackedRegatta;
import com.sap.sailing.domain.tracking.GPSFixTrack;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sailing.domain.tracking.WindTrack;
import com.sap.sailing.domain.tracking.impl.CompetitorBravoFixTrackImpl;
import com.sap.sailing.server.operationaltransformation.AddDefaultRegatta;
import com.sap.sailing.server.operationaltransformation.AddRaceDefinition;
import com.sap.sailing.server.operationaltransformation.CreateTrackedRace;
@@ -138,6 +141,25 @@ public class TrackedRaceContentsReplicationTest extends AbstractServerReplicatio
}
}
/**
* See also bug4387: test that after replicating the TrackedRace the CompetitorBravoFixTrackImpl's gpsTrack object
* points to the track from the TrackedRace to which the CompetitorBravoFixTrackImpl belongs.
*/
@Test
public void testBravoFixTrackReplication() throws InterruptedException {
trackedRace.getOrCreateSensorTrack(competitor, BravoFixTrack.TRACK_NAME, () -> new CompetitorBravoFixTrackImpl(competitor, BravoFixTrack.TRACK_NAME, /* hasExtendedFixes */ false,
trackedRace.getTrack(competitor)));
Thread.sleep(1000);
DynamicTrackedRace replicaTrackedRace = replica.getTrackedRace(raceIdentifier);
Competitor replicaCompetitor = replicaTrackedRace.getRace().getCompetitors().iterator().next();
assertNotNull(replicaCompetitor);
GPSFixTrack<Competitor, GPSFixMoving> competitorTrack = replicaTrackedRace.getTrack(replicaCompetitor);
CompetitorBravoFixTrackImpl competitorSensorTrack = replicaTrackedRace.getOrCreateSensorTrack(
replicaCompetitor, BravoFixTrack.TRACK_NAME, () -> new CompetitorBravoFixTrackImpl(replicaCompetitor, BravoFixTrack.TRACK_NAME, /* hasExtendedFixes */ false,
replicaTrackedRace.getTrack(replicaCompetitor)));
assertSame(competitorTrack, competitorSensorTrack.getGpsTrack());
}
@Test
public void testMarkFixReplication() throws InterruptedException {
final GPSFixMovingImpl fix = new GPSFixMovingImpl(new DegreePosition(2, 3), new MillisecondsTimePoint(3456),