mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-13 15:50:59 +00:00
added a test case for competitor compression
This commit is contained in:
1 parent
5406ede546
commit
c7976fe553
2 files changed
+22
-3
No files matched your search
+7
-2
@@ -356,11 +356,13 @@ public class IncrementalLeaderboardDTO extends LeaderboardDTO implements Increme
|
||||
RaceColumnDTO previousRaceColumn = previousVersion.getRaceColumnByName(raceColumnNameForWhichCompetitorOrderingPerRaceUnchanged);
|
||||
setCompetitorsFromBestToWorst(raceColumn, previousVersion.getCompetitorsFromBestToWorst(previousRaceColumn));
|
||||
}
|
||||
final Set<CompetitorDTO> rowsUnchangedForCompetitors = new HashSet<CompetitorDTO>();
|
||||
if (rowsUnchanged != null) {
|
||||
if (rows == null) {
|
||||
rows = new HashMap<CompetitorDTO, LeaderboardRowDTO>();
|
||||
}
|
||||
for (Pair<CompetitorDTO, Void> rowUnchanged : rowsUnchanged.getAllUnchangedCompetitorsAndKeys(previousVersion)) {
|
||||
rowsUnchangedForCompetitors.add(rowUnchanged.getA());
|
||||
rows.put(rowUnchanged.getA(), previousVersion.rows.get(rowUnchanged.getA()));
|
||||
}
|
||||
}
|
||||
@@ -370,8 +372,11 @@ public class IncrementalLeaderboardDTO extends LeaderboardDTO implements Increme
|
||||
if (unchangedLeaderboardEntries != null) {
|
||||
for (Pair<CompetitorDTO, String> competitorAndColumnName : allUnchangedLeaderboardEntriesAsCompetitorsAndColumnNames) {
|
||||
CompetitorDTO previousCompetitor = competitorAndColumnName.getA();
|
||||
LeaderboardEntryDTO previousEntry = previousVersion.rows.get(previousCompetitor).fieldsByRaceColumnName.get(competitorAndColumnName.getB());
|
||||
rows.get(previousCompetitor).fieldsByRaceColumnName.put(competitorAndColumnName.getB(), previousEntry);
|
||||
if (!rowsUnchangedForCompetitors.contains(previousCompetitor)) { // only care if not the entire row was marked unchanged
|
||||
LeaderboardEntryDTO previousEntry = previousVersion.rows.get(previousCompetitor).fieldsByRaceColumnName.get(
|
||||
competitorAndColumnName.getB());
|
||||
rows.get(previousCompetitor).fieldsByRaceColumnName.put(competitorAndColumnName.getB(), previousEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (legDetailsUnchanged != null) {
|
||||
|
||||
+15
-1
@@ -17,6 +17,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.Cloner;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.IncrementalLeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
@@ -154,5 +155,18 @@ public class LeaderboardDTODiffingTest {
|
||||
assertEquals(rowsBeforeStripping, applied.rows);
|
||||
}
|
||||
|
||||
// TODO write a test where a competitor is added and where a competitor is removed to check that competitors compression works properly; ensure that all orders remain unchanged
|
||||
@Test
|
||||
public void testCompetitorListChange() {
|
||||
CompetitorDTO somebodyNew = new CompetitorDTO("Someone New", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
new BoatClassDTO("505", 5.05));
|
||||
newVersion.competitors.add(13, somebodyNew); // insert a competitor; this should mess up all others' indexes; check if this works
|
||||
CompetitorDTO wolfgang = getPreviousCompetitorByName("HUNGER +JESS");
|
||||
newVersion.competitors.remove(wolfgang);
|
||||
newVersion.rows.remove(wolfgang); // remove another competitor
|
||||
List<CompetitorDTO> newCompetitorsBeforeStripping = new ArrayList<CompetitorDTO>(newVersion.competitors);
|
||||
newVersion.strip(previousVersion);
|
||||
assertNull(newVersion.competitors); // but there should be an added competitor that we can't see through the public interface
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(newCompetitorsBeforeStripping, applied.competitors);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user