mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
refs bug 1354
# Implemented 'UpdateSpecificRegatta' OT for updating Regatta objects. Currently only changing the course area is allowed. # Added tests for the replication of 'UpdateSpecificRegatta'.
This commit is contained in:
1 parent
aa2f1e0bdf
commit
f79f6b2cad
4 files changed
+102
No files matched your search
+47
@@ -44,6 +44,53 @@ public class RegattaReplicationTest extends AbstractServerReplicationTest {
|
||||
assertNull(replicatedRegatta.getDefaultCourseArea());
|
||||
assertTrue(regattaId.equals(replicatedRegatta.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSpecificRegattaReplication() throws InterruptedException {
|
||||
Regatta replicatedRegatta;
|
||||
|
||||
final UUID alphaCourseAreaId = UUID.randomUUID();
|
||||
final UUID tvCourseAreaId = UUID.randomUUID();
|
||||
|
||||
Event event = master.addEvent("Event", "Venue", ".", true, UUID.randomUUID(), Collections.<String>emptyList());
|
||||
master.addCourseArea(event.getId(), "Alpha", alphaCourseAreaId);
|
||||
master.addCourseArea(event.getId(), "TV", tvCourseAreaId);
|
||||
|
||||
UUID currentCourseAreaId = null;
|
||||
Regatta masterRegatta = master.createRegatta("Kiel Week 2012", "49er", UUID.randomUUID(), Collections.<Series>emptyList(),
|
||||
/* persistent */ true, DomainFactory.INSTANCE.createScoringScheme(ScoringSchemeType.LOW_POINT), currentCourseAreaId);
|
||||
|
||||
// Test for 'null'
|
||||
master.updateRegatta(new RegattaName(masterRegatta.getName()), currentCourseAreaId);
|
||||
Thread.sleep(1000);
|
||||
replicatedRegatta = replica.getRegatta(new RegattaName(masterRegatta.getName()));
|
||||
assertNotNull(replicatedRegatta);
|
||||
assertNull(replicatedRegatta.getDefaultCourseArea());
|
||||
|
||||
// Test for 'alpha'
|
||||
currentCourseAreaId = alphaCourseAreaId;
|
||||
master.updateRegatta(new RegattaName(masterRegatta.getName()), currentCourseAreaId);
|
||||
Thread.sleep(1000);
|
||||
replicatedRegatta = replica.getRegatta(new RegattaName(masterRegatta.getName()));
|
||||
assertNotNull(replicatedRegatta);
|
||||
assertEquals(currentCourseAreaId, replicatedRegatta.getDefaultCourseArea().getId());
|
||||
|
||||
// Test for 'tv'
|
||||
currentCourseAreaId = tvCourseAreaId;
|
||||
master.updateRegatta(new RegattaName(masterRegatta.getName()), currentCourseAreaId);
|
||||
Thread.sleep(1000);
|
||||
replicatedRegatta = replica.getRegatta(new RegattaName(masterRegatta.getName()));
|
||||
assertNotNull(replicatedRegatta);
|
||||
assertEquals(currentCourseAreaId, replicatedRegatta.getDefaultCourseArea().getId());
|
||||
|
||||
// Test back to 'null'
|
||||
currentCourseAreaId = null;
|
||||
master.updateRegatta(new RegattaName(masterRegatta.getName()), currentCourseAreaId);
|
||||
Thread.sleep(1000);
|
||||
replicatedRegatta = replica.getRegatta(new RegattaName(masterRegatta.getName()));
|
||||
assertNotNull(replicatedRegatta);
|
||||
assertNull(replicatedRegatta.getDefaultCourseArea());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultRegattaReplication() throws InterruptedException {
|
||||
|
||||
@@ -378,6 +378,8 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* @param series the series must not have any {@link RaceColumn}s yet
|
||||
*/
|
||||
Regatta createRegatta(String regattaBaseName, String boatClassName, Serializable id, Iterable<? extends Series> series, boolean persistent, ScoringScheme scoringScheme, Serializable defaultCourseAreaId);
|
||||
|
||||
Regatta updateRegatta(RegattaIdentifier regattaIdentifier, Serializable newDefaultCourseAreaId);
|
||||
|
||||
/**
|
||||
* Adds <code>raceDefinition</code> to the {@link Regatta} such that it will appear in {@link Regatta#getAllRaces()}
|
||||
|
||||
+17
@@ -127,6 +127,7 @@ import com.sap.sailing.server.operationaltransformation.UpdateEvent;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateMarkPassings;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateRaceDelayToLive;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateRaceTimes;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateSpecificRegatta;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateTrackedRaceStatus;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateWindAveragingTime;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateWindSourcesToExclude;
|
||||
@@ -1173,6 +1174,22 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
regatta.removeRaceColumnListener(raceLogScoringReplicator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Regatta updateRegatta(RegattaIdentifier regattaIdentifier, Serializable newDefaultCourseAreaId) {
|
||||
// We're not doing any renaming of the regatta itself, therefore we don't have to sync on the maps.
|
||||
Regatta regatta = getRegatta(regattaIdentifier);
|
||||
synchronized(regatta) {
|
||||
CourseArea newCourseArea = getCourseArea(newDefaultCourseAreaId);
|
||||
if (newCourseArea != regatta.getDefaultCourseArea()) {
|
||||
regatta.setDefaultCourseArea(newCourseArea);
|
||||
mongoObjectFactory.storeRegatta(regatta);
|
||||
}
|
||||
|
||||
replicate(new UpdateSpecificRegatta(regattaIdentifier, newDefaultCourseAreaId));
|
||||
}
|
||||
return regatta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRace(Regatta regatta, RaceDefinition race) throws MalformedURLException,
|
||||
IOException, InterruptedException {
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class UpdateSpecificRegatta extends AbstractRacingEventServiceOperation<Regatta>{
|
||||
private static final long serialVersionUID = 8755035775682718882L;
|
||||
|
||||
private final RegattaIdentifier regattaIdentifier;
|
||||
private final Serializable newDefaultCourseAreaId;
|
||||
|
||||
public UpdateSpecificRegatta(RegattaIdentifier regattaIdentifier, Serializable newDefaultCourseAreaId) {
|
||||
this.regattaIdentifier = regattaIdentifier;
|
||||
this.newDefaultCourseAreaId = newDefaultCourseAreaId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Regatta internalApplyTo(RacingEventService toState) throws Exception {
|
||||
return toState.updateRegatta(regattaIdentifier, newDefaultCourseAreaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user