mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-21 03:30:12 +00:00
Sailing Events are fully replicated when created/added, added
replication test for event creation
This commit is contained in:
1 parent
02b225f307
commit
a2231263f7
6 files changed
+92
-53
No files matched your search
+1
-1
@@ -2827,7 +2827,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
|
||||
@Override
|
||||
public EventDTO createEvent(String eventName, String venue, String publicationUrl, boolean isPublic) {
|
||||
return convertToEventDTO(getService().apply(new CreateEvent(eventName, venue, publicationUrl, isPublic, new ArrayList<String>())));
|
||||
return convertToEventDTO(getService().apply(new CreateEvent(eventName, venue, publicationUrl, isPublic, UUID.randomUUID(), new ArrayList<String>())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -62,7 +62,8 @@ public class EventsJsonExportServlet extends JsonExportServlet {
|
||||
"Kieler Woche 2012 - Where Sailing meets people",
|
||||
"Schilksee",
|
||||
"http://www.youtube.com",
|
||||
true, Collections.<String>emptyList());
|
||||
true, UUID.randomUUID(),
|
||||
Collections.<String>emptyList());
|
||||
|
||||
Venue schilksee = kielerWocheEvent.getVenue();
|
||||
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.sap.sailing.server.replication.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
|
||||
public class EventReplicationTest extends AbstractServerReplicationTest {
|
||||
|
||||
@Test
|
||||
public void testEventReplication() throws InterruptedException {
|
||||
final String eventName = "ESS Masquat";
|
||||
final String venueName = "Masquat, Oman";
|
||||
final String publicationUrl = "http://ess40.sapsailing.com";
|
||||
final boolean isPublic = false;
|
||||
List<String> regattas = new ArrayList<String>();
|
||||
regattas.add("Day1");
|
||||
regattas.add("Day2");
|
||||
Event masterEvent = master.addEvent(eventName, venueName, publicationUrl, isPublic, UUID.randomUUID(), regattas);
|
||||
|
||||
Thread.sleep(1000);
|
||||
Event replicatedEvent = replica.getEvent(masterEvent.getId());
|
||||
assertNotNull(replicatedEvent);
|
||||
assertEquals(replicatedEvent.getName(), eventName);
|
||||
assertEquals(replicatedEvent.getPublicationUrl(), publicationUrl);
|
||||
assertEquals(replicatedEvent.getVenue().getName(), venueName);
|
||||
}
|
||||
}
|
||||
@@ -453,11 +453,13 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* The publication URL of the new event
|
||||
* @param isPublic
|
||||
* Indicates whether the event is public accessible via the publication URL or not
|
||||
* @param id
|
||||
* The id of the new event
|
||||
* @param regattaNames
|
||||
* The names of the regattas contained in the new event.<br />
|
||||
* @return The new event
|
||||
*/
|
||||
Event addEvent(String eventName, String venueName, String publicationUrl, boolean isPublic, List<String> regattaNames);
|
||||
Event addEvent(String eventName, String venueName, String publicationUrl, boolean isPublic, Serializable id, List<String> regattaNames);
|
||||
|
||||
/**
|
||||
* Updates a sailing event with the name <code>eventName</code>, the venue<code>venue</code> and the
|
||||
|
||||
+4
-3
@@ -19,7 +19,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -109,6 +108,7 @@ import com.sap.sailing.server.operationaltransformation.AddDefaultRegatta;
|
||||
import com.sap.sailing.server.operationaltransformation.AddRaceDefinition;
|
||||
import com.sap.sailing.server.operationaltransformation.AddSpecificRegatta;
|
||||
import com.sap.sailing.server.operationaltransformation.ConnectTrackedRaceToLeaderboardColumn;
|
||||
import com.sap.sailing.server.operationaltransformation.CreateEvent;
|
||||
import com.sap.sailing.server.operationaltransformation.CreateTrackedRace;
|
||||
import com.sap.sailing.server.operationaltransformation.RecordCompetitorGPSFix;
|
||||
import com.sap.sailing.server.operationaltransformation.RecordMarkGPSFix;
|
||||
@@ -1544,13 +1544,14 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event addEvent(String eventName, String venue, String publicationUrl, boolean isPublic, List<String> regattaNames) {
|
||||
Event result = new EventImpl(eventName, venue, publicationUrl, isPublic, UUID.randomUUID());
|
||||
public Event addEvent(String eventName, String venue, String publicationUrl, boolean isPublic, Serializable id, List<String> regattaNames) {
|
||||
Event result = new EventImpl(eventName, venue, publicationUrl, isPublic, id);
|
||||
synchronized (eventsById) {
|
||||
if (eventsById.containsKey(result.getId())) {
|
||||
throw new IllegalArgumentException("Event with ID " + result.getId() + " already exists which is pretty surprising...");
|
||||
}
|
||||
eventsById.put(result.getId(), result);
|
||||
replicate(new CreateEvent(eventName, venue, publicationUrl, isPublic, id, regattaNames));
|
||||
}
|
||||
mongoObjectFactory.storeEvent(result);
|
||||
return result;
|
||||
|
||||
+48
-47
@@ -1,47 +1,48 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class CreateEvent extends AbstractEventOperation<Event> {
|
||||
private static final long serialVersionUID = 308389324918359960L;
|
||||
private final String venue;
|
||||
private final String publicationUrl;
|
||||
private final boolean isPublic;
|
||||
private final List<String> regattaNames;
|
||||
private final String eventName;
|
||||
|
||||
public CreateEvent(String eventName, String venue, String publicationUrl, boolean isPublic, List<String> regattaNames) {
|
||||
super(/* id */ null);
|
||||
this.eventName = eventName;
|
||||
this.venue = venue;
|
||||
this.regattaNames = regattaNames;
|
||||
this.publicationUrl = publicationUrl;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event internalApplyTo(RacingEventService toState) {
|
||||
return toState.addEvent(getEventName(), venue, publicationUrl, isPublic, regattaNames);
|
||||
}
|
||||
|
||||
}
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class CreateEvent extends AbstractEventOperation<Event> {
|
||||
private static final long serialVersionUID = 308389324918359960L;
|
||||
private final String venue;
|
||||
private final String publicationUrl;
|
||||
private final boolean isPublic;
|
||||
private final List<String> regattaNames;
|
||||
private final String eventName;
|
||||
|
||||
public CreateEvent(String eventName, String venue, String publicationUrl, boolean isPublic, Serializable id, List<String> regattaNames) {
|
||||
super(id);
|
||||
this.eventName = eventName;
|
||||
this.venue = venue;
|
||||
this.regattaNames = regattaNames;
|
||||
this.publicationUrl = publicationUrl;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event internalApplyTo(RacingEventService toState) {
|
||||
return toState.addEvent(getEventName(), venue, publicationUrl, isPublic, getId(), regattaNames);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user