resort to default regatta for TrackedRace / RaceDefinition lookup while trying to remove existing

Change-Id: I5ed69350a0b647125e1da371e10112eaa2e9ee50
This commit is contained in:
Axel Uhl committed 2017-12-20 10:02:02 +01:00
1 parent 20d8804e28
commit 4271d8c9cc
2 files changed
+7 -8

No files matched your search

@@ -384,19 +384,19 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl
} else {
effectiveRegatta = regatta;
}
// removeRace may detach the domain regatta from the domain factory if that
// removed the last race; therefore, it's important to getOrCreate the
// domain regatta *after* calling removeRace
final RaceDefinition raceDefinition = domainFactory.removeRace(tractracRace.getEvent(), tractracRace, effectiveRegatta, trackedRegattaRegistry);
if (raceDefinition != null) {
trackedRegattaRegistry.removeRace(effectiveRegatta, raceDefinition);
}
// if regatta is still null, no previous assignment of any of the races in this TracTrac event to a Regatta was
// found;
// in this case, create a default regatta based on the TracTrac event data
this.regatta = effectiveRegatta == null ? domainFactory.getOrCreateDefaultRegatta(
raceLogStore, regattaLogStore, tractracRace, trackedRegattaRegistry) : effectiveRegatta;
trackedRegatta = trackedRegattaRegistry.getOrCreateTrackedRegatta(this.regatta);
// removeRace may detach the domain regatta from the domain factory if that
// removed the last race; therefore, it's important to getOrCreate the
// domain regatta *after* calling removeRace
final RaceDefinition raceDefinition = domainFactory.removeRace(tractracRace.getEvent(), tractracRace, this.regatta, trackedRegattaRegistry);
if (raceDefinition != null) {
trackedRegattaRegistry.removeRace(this.regatta, raceDefinition);
}
receivers = new HashSet<Receiver>();
for (Receiver receiver : domainFactory.getUpdateReceivers(getTrackedRegatta(), delayToLiveInMillis,
simulator, windStore, this, trackedRegattaRegistry, raceLogResolver, tractracRace,
@@ -80,7 +80,6 @@ public class RaceTrackerTest {
RaceDefinition race = raceHandle.getRace(); // wait for RaceDefinition to be completely wired in Regatta
logger.info("Obtained race: "+race);
assertNotNull(race);
// TODO the following assertion fails; this suggests that the race obtained above hasn't properly been entered into the regatta. Why???
assertTrue(!Util.isEmpty(raceHandle.getRegatta().getAllRaces()));
}