Merge branch 'master' into bug3420

Conflicts:
	java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/FieldNames.java
	java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/MongoObjectFactoryImpl.java

Change-Id: I7347ab0c849aa43f08eebca569c884b6986bf6d0
This commit is contained in:
Axel Uhl committed 2016-01-22 15:39:16 +01:00
commit f57aed7de6
165 files changed
+4796 -5528

No files matched your search

@@ -21,6 +21,7 @@ import com.sap.sailing.domain.abstractlog.race.RaceLog;
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogRevokeEventImpl;
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogRegisterCompetitorEventImpl;
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogUseCompetitorsFromRaceLogEventImpl;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogRegisterCompetitorEvent;
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogRegisterCompetitorEventImpl;
@@ -107,7 +108,8 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
flexibleLeaderboard.addRaceColumn("R1", /* medalRace */ false);
RaceLog raceLog = flexibleLeaderboard.getRacelog("R1", LeaderboardNameConstants.DEFAULT_FLEET_NAME);
final int passId = 1;
final LogEventAuthorImpl author = new LogEventAuthorImpl("Me", 0);
final LogEventAuthorImpl author = new LogEventAuthorImpl("Me", 0);
raceLog.add(new RaceLogUseCompetitorsFromRaceLogEventImpl(MillisecondsTimePoint.now(), author, MillisecondsTimePoint.now(), UUID.randomUUID(), passId));
final Map<Competitor, RaceLogRegisterCompetitorEvent> competitorOnRaceLogRegistrationEvents = new HashMap<>();
for (Competitor c : compLists[0]) {
final RaceLogRegisterCompetitorEvent registerCompetitorEvent = new RaceLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), author, passId, c);
@@ -164,26 +166,45 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
}
@Test
public void testSimpleCompetitorListOnOneRaceLogAndRegattaLogInFlexibleLeaderboard() {
public void testSimpleCompetitorListOnOneRaceLogAndRegattaLogInFlexibleLeaderboard() throws NotRevokableException {
flexibleLeaderboard.addRaceColumn("R1", /* medalRace */ false);
RegattaLog regattaLog = flexibleLeaderboard.getRegattaLog();
for (Competitor c : compLists[0]) {
regattaLog.add(new RegattaLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), UUID.randomUUID(), c));
}
RaceLog raceLog = flexibleLeaderboard.getRacelog("R1", LeaderboardNameConstants.DEFAULT_FLEET_NAME);
for (Competitor c : compLists[1]) {
raceLog.add(new RaceLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), 1, c));
final LogEventAuthorImpl author = new LogEventAuthorImpl("Me", 0);
int passId = 1;
final RaceLogUseCompetitorsFromRaceLogEventImpl usesCompetitorsFromRaceLogEvent = new RaceLogUseCompetitorsFromRaceLogEventImpl(MillisecondsTimePoint.now(), author, MillisecondsTimePoint.now(), UUID.randomUUID(), passId);
raceLog.add(usesCompetitorsFromRaceLogEvent);
for (Competitor c : compLists[1]) {
raceLog.add(new RaceLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), 1, c));
}
Set<Competitor> expected = new HashSet<>(compLists[0]);
expected.addAll(compLists[1]);
//expected are only the competitors in the RaceLog, because only one RaceColumn is
//registered, which has the competitors registered in the RaceLog.
assertRegattaAndRaceCompetitors(new HashSet<>(compLists[1]));
// Now we revoke that the race log provides the competitors for R1; the competitors should then
// snap back to those competitors taken from the regatta log for both, the rentire leaderboard
// as well as for the race column
raceLog.revokeEvent(author, usesCompetitorsFromRaceLogEvent);
assertRegattaAndRaceCompetitors(new HashSet<>(compLists[0]));
// And now re-introduce per-race competitors and validate again that the cache adjusts properly:
raceLog.add(new RaceLogUseCompetitorsFromRaceLogEventImpl(MillisecondsTimePoint.now(), author, MillisecondsTimePoint.now(), UUID.randomUUID(), passId));
assertRegattaAndRaceCompetitors(new HashSet<>(compLists[1]));
}
private void assertRegattaAndRaceCompetitors(Set<Competitor> expected) {
Set<Competitor> actual = new HashSet<>();
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(), actual);
assertEquals(expected, actual);
Set<Competitor> actualForRace = new HashSet<>();
//For the race only the competitors registered on RaceLog as RaceLogUseCompetitorsFromRaceLogEvent is present
Set<Competitor> expectedForRace = new HashSet<>(expected);
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(
flexibleLeaderboard.getRaceColumnByName("R1"),
flexibleLeaderboard.getFleet(LeaderboardNameConstants.DEFAULT_FLEET_NAME)), actualForRace);
assertEquals(expected, actualForRace);
assertEquals(expectedForRace, actualForRace);
}
@Test
@@ -251,6 +272,9 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
@Test
public void testSimpleCompetitorListOnOneRaceLogInRegattaLeaderboard() {
RaceLog raceLog = regattaLeaderboard.getRacelog("R1", "Yellow");
final LogEventAuthorImpl author = new LogEventAuthorImpl("Me", 0);
int passId = 1;
raceLog.add(new RaceLogUseCompetitorsFromRaceLogEventImpl(MillisecondsTimePoint.now(), author, MillisecondsTimePoint.now(), UUID.randomUUID(), passId));
for (Competitor c : compLists[0]) {
raceLog.add(new RaceLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), 1, c));
}
@@ -307,6 +331,7 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
}
final RaceLog raceLog = regattaLeaderboard.getRacelog("R1", "Yellow");
final int passId = 1;
raceLog.add(new RaceLogUseCompetitorsFromRaceLogEventImpl(MillisecondsTimePoint.now(), author, MillisecondsTimePoint.now(), UUID.randomUUID(), passId));
final Map<Competitor, RaceLogRegisterCompetitorEvent> competitorOnRaceLogRegistrationEvents = new HashMap<>();
for (Competitor c : compLists[passId]) {
final RaceLogRegisterCompetitorEvent registerCompetitorEvent = new RaceLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), author, passId, c);
@@ -325,14 +350,15 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
Util.addAll(regattaLeaderboard.getCompetitors(), actualWithoutSuppressed);
assertEquals(expectedWithoutSuppressed, actualWithoutSuppressed);
Set<Competitor> actualForRaceYellow = new HashSet<>();
Set<Competitor> expectedFoRaceYellow = new HashSet<>(compLists[passId]);
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Yellow")), actualForRaceYellow);
assertEquals(expected, actualForRaceYellow);
assertEquals(expectedFoRaceYellow, actualForRaceYellow);
actualForRaceYellow = new HashSet<>(); // try another time; cache should of course yield an equal result (although
// we're not asserting here that the result actually comes from the cache)
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Yellow")), actualForRaceYellow);
assertEquals(expected, actualForRaceYellow);
assertEquals(expectedFoRaceYellow, actualForRaceYellow);
// But now it gets interesting: we're revoking a competitor registration on the race log and assert
// that the competitor is gone from the list:
final Competitor competitorToRevokeFromRaceLog = compLists[passId].get(2);
@@ -341,9 +367,9 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
// we're not asserting here that the result actually comes from the cache)
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Yellow")), actualForRaceYellow);
expected.remove(competitorToRevokeFromRaceLog);
assertEquals(expected.size(), actualForRaceYellow.size());
assertEquals(expected, actualForRaceYellow);
expectedFoRaceYellow.remove(competitorToRevokeFromRaceLog);
assertEquals(expectedFoRaceYellow.size(), actualForRaceYellow.size());
assertEquals(expectedFoRaceYellow, actualForRaceYellow);
}
}
@@ -488,6 +488,27 @@ public class MockedTrackedRace implements DynamicTrackedRace {
public Iterable<? extends RaceColumn> getRaceColumns() {
return null;
}
@Override
public Iterable<Competitor> getCompetitorsRegisteredInRegattaLog() {
return null;
}
@Override
public void registerCompetitor(Competitor competitor) {
}
@Override
public void registerCompetitors(Iterable<Competitor> competitor) {
}
@Override
public void deregisterCompetitor(Competitor competitor) {
}
@Override
public void deregisterCompetitors(Iterable<Competitor> competitor) {
}
};
}
@@ -906,10 +927,6 @@ public class MockedTrackedRace implements DynamicTrackedRace {
return null;
}
@Override
public void waitForLoadingFromGPSFixStoreToFinishRunning(RaceLog forRaceLog) throws InterruptedException {
}
@Override
public void addRaceAbortedListener(RaceAbortedListener listener) {
}
@@ -554,10 +554,6 @@ public class MockedTrackedRaceWithStartTimeAndRanks implements TrackedRace {
return null;
}
@Override
public void waitForLoadingFromGPSFixStoreToFinishRunning(RaceLog forRaceLog) throws InterruptedException {
}
@Override
public void addRaceAbortedListener(RaceAbortedListener listener) {
}