mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 12:03:58 +00:00
extended test cases for CompetitorProviderFromRaceColumnsAndRegattaLike
This commit is contained in:
1 parent
1ff1773760
commit
4a4fb39f65
1 file changed
+155
+155
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -12,6 +13,11 @@ import java.util.UUID;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.impl.LogEventAuthorImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogRegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.impl.BoatClassImpl;
|
||||
import com.sap.sailing.domain.base.impl.CourseAreaImpl;
|
||||
@@ -19,6 +25,7 @@ import com.sap.sailing.domain.base.impl.FleetImpl;
|
||||
import com.sap.sailing.domain.base.impl.RegattaImpl;
|
||||
import com.sap.sailing.domain.base.impl.SeriesImpl;
|
||||
import com.sap.sailing.domain.common.BoatClassMasterdata;
|
||||
import com.sap.sailing.domain.common.LeaderboardNameConstants;
|
||||
import com.sap.sailing.domain.leaderboard.impl.CompetitorProviderFromRaceColumnsAndRegattaLike;
|
||||
import com.sap.sailing.domain.leaderboard.impl.FlexibleLeaderboardImpl;
|
||||
import com.sap.sailing.domain.leaderboard.impl.LowPoint;
|
||||
@@ -81,6 +88,70 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRace = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(
|
||||
flexibleLeaderboard.getRaceColumnByName("R1"),
|
||||
flexibleLeaderboard.getFleet(LeaderboardNameConstants.DEFAULT_FLEET_NAME)), actualForRace);
|
||||
assertEquals(expected, actualForRace);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCompetitorListOnOneRaceLogInFlexibleLeaderboard() {
|
||||
flexibleLeaderboard.addRaceColumn("R1", /* medalRace */ false);
|
||||
RaceLog raceLog = flexibleLeaderboard.getRacelog("R1", LeaderboardNameConstants.DEFAULT_FLEET_NAME);
|
||||
for (Competitor c : compLists[0]) {
|
||||
raceLog.add(RaceLogEventFactory.INSTANCE.createRegisterCompetitorEvent(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), 1, c));
|
||||
}
|
||||
Set<Competitor> expected = new HashSet<>(compLists[0]);
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRace = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(
|
||||
flexibleLeaderboard.getRaceColumnByName("R1"),
|
||||
flexibleLeaderboard.getFleet(LeaderboardNameConstants.DEFAULT_FLEET_NAME)), actualForRace);
|
||||
assertEquals(expected, actualForRace);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCompetitorListOnRegattaLogInFlexibleLeaderboard() {
|
||||
flexibleLeaderboard.addRaceColumn("R1", /* medalRace */ false);
|
||||
RegattaLog regattaLog = flexibleLeaderboard.getRegattaLog();
|
||||
for (Competitor c : compLists[0]) {
|
||||
regattaLog.add(new RegattaLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), MillisecondsTimePoint.now(), UUID.randomUUID(), c));
|
||||
}
|
||||
Set<Competitor> expected = new HashSet<>(compLists[0]);
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRace = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(
|
||||
flexibleLeaderboard.getRaceColumnByName("R1"),
|
||||
flexibleLeaderboard.getFleet(LeaderboardNameConstants.DEFAULT_FLEET_NAME)), actualForRace);
|
||||
assertEquals(expected, actualForRace);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCompetitorListOnOneRaceLogAndRegattaLogInFlexibleLeaderboard() {
|
||||
flexibleLeaderboard.addRaceColumn("R1", /* medalRace */ false);
|
||||
RegattaLog regattaLog = flexibleLeaderboard.getRegattaLog();
|
||||
for (Competitor c : compLists[0]) {
|
||||
regattaLog.add(new RegattaLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), MillisecondsTimePoint.now(), UUID.randomUUID(), c));
|
||||
}
|
||||
RaceLog raceLog = flexibleLeaderboard.getRacelog("R1", LeaderboardNameConstants.DEFAULT_FLEET_NAME);
|
||||
for (Competitor c : compLists[1]) {
|
||||
raceLog.add(RaceLogEventFactory.INSTANCE.createRegisterCompetitorEvent(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), 1, c));
|
||||
}
|
||||
Set<Competitor> expected = new HashSet<>(compLists[0]);
|
||||
expected.addAll(compLists[1]);
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRace = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(
|
||||
flexibleLeaderboard.getRaceColumnByName("R1"),
|
||||
flexibleLeaderboard.getFleet(LeaderboardNameConstants.DEFAULT_FLEET_NAME)), actualForRace);
|
||||
assertEquals(expected, actualForRace);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,6 +165,16 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRace1 = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(
|
||||
flexibleLeaderboard.getRaceColumnByName("R1"),
|
||||
flexibleLeaderboard.getFleet(LeaderboardNameConstants.DEFAULT_FLEET_NAME)), actualForRace1);
|
||||
Set<Competitor> actualForRace2 = new HashSet<>();
|
||||
Util.addAll(competitorProviderFlexibleLeaderboard.getAllCompetitors(
|
||||
flexibleLeaderboard.getRaceColumnByName("R2"),
|
||||
flexibleLeaderboard.getFleet(LeaderboardNameConstants.DEFAULT_FLEET_NAME)), actualForRace2);
|
||||
assertEquals(new HashSet<>(compLists[0]), actualForRace1);
|
||||
assertEquals(new HashSet<>(compLists[1]), actualForRace2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,6 +185,14 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRaceYellow = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
|
||||
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Yellow")), actualForRaceYellow);
|
||||
assertEquals(expected, actualForRaceYellow);
|
||||
Set<Competitor> actualForRaceBlue = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
|
||||
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Blue")), actualForRaceBlue);
|
||||
assertEquals(Collections.emptySet(), actualForRaceBlue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -117,5 +206,71 @@ public class CompetitorProviderCacheInvalidationTest extends AbstractLeaderboard
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRaceYellow = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
|
||||
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Yellow")), actualForRaceYellow);
|
||||
assertEquals(new HashSet<>(compLists[0]), actualForRaceYellow);
|
||||
Set<Competitor> actualForRaceBlue = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
|
||||
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Blue")), actualForRaceBlue);
|
||||
assertEquals(new HashSet<>(compLists[1]), actualForRaceBlue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCompetitorListOnOneRaceLogInRegattaLeaderboard() {
|
||||
RaceLog raceLog = regattaLeaderboard.getRacelog("R1", "Yellow");
|
||||
for (Competitor c : compLists[0]) {
|
||||
raceLog.add(RaceLogEventFactory.INSTANCE.createRegisterCompetitorEvent(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), 1, c));
|
||||
}
|
||||
Set<Competitor> expected = new HashSet<>(compLists[0]);
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRaceYellow = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
|
||||
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Yellow")), actualForRaceYellow);
|
||||
assertEquals(new HashSet<>(compLists[0]), actualForRaceYellow);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCompetitorListOnRegattaLogInRegattaLeaderboard() {
|
||||
RegattaLog regattaLog = regattaLeaderboard.getRegatta().getRegattaLog();
|
||||
for (Competitor c : compLists[0]) {
|
||||
regattaLog.add(new RegattaLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), MillisecondsTimePoint.now(), UUID.randomUUID(), c));
|
||||
}
|
||||
Set<Competitor> expected = new HashSet<>(compLists[0]);
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRaceYellow = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
|
||||
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Yellow")), actualForRaceYellow);
|
||||
assertEquals(new HashSet<>(compLists[0]), actualForRaceYellow);
|
||||
Set<Competitor> actualForRaceBlue = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
|
||||
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Blue")), actualForRaceBlue);
|
||||
assertEquals(new HashSet<>(compLists[0]), actualForRaceBlue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCompetitorListOnOneRaceLogAndRegattaLogInRegattaLeaderboard() {
|
||||
RegattaLog regattaLog = regattaLeaderboard.getRegatta().getRegattaLog();
|
||||
for (Competitor c : compLists[0]) {
|
||||
regattaLog.add(new RegattaLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), MillisecondsTimePoint.now(), UUID.randomUUID(), c));
|
||||
}
|
||||
RaceLog raceLog = regattaLeaderboard.getRacelog("R1", "Yellow");
|
||||
for (Competitor c : compLists[1]) {
|
||||
raceLog.add(RaceLogEventFactory.INSTANCE.createRegisterCompetitorEvent(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Me", 0), 1, c));
|
||||
}
|
||||
Set<Competitor> expected = new HashSet<>(compLists[0]);
|
||||
expected.addAll(compLists[1]);
|
||||
Set<Competitor> actual = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(), actual);
|
||||
assertEquals(expected, actual);
|
||||
Set<Competitor> actualForRaceYellow = new HashSet<>();
|
||||
Util.addAll(competitorProviderRegattaLeaderboard.getAllCompetitors(
|
||||
regattaLeaderboard.getRaceColumnByName("R1"), regattaLeaderboard.getFleet("Yellow")), actualForRaceYellow);
|
||||
assertEquals(expected, actualForRaceYellow);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user