95099c11974bd501fba69dc4fa787786984c1177
java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/LeaderboardScoringAndRankingForLowPointsTest.java
| ... | ... | @@ -179,7 +179,7 @@ public class LeaderboardScoringAndRankingForLowPointsTest extends LeaderboardSco |
| 179 | 179 | final List<Fleet> fleets = new ArrayList<>(); |
| 180 | 180 | final Fleet defaultFleet = new FleetImpl("Default"); |
| 181 | 181 | fleets.add(defaultFleet); |
| 182 | - final List<String> raceColumnNames = Arrays.asList("R1", "R2", "R3"); |
|
| 182 | + final List<String> raceColumnNames = Arrays.asList("R1", "R2", "R3", "R4", "R5"); |
|
| 183 | 183 | Series openingSeries = new SeriesImpl("Opening", /* isMedal */ false, |
| 184 | 184 | /* isFleetsCanRunInParallel */ true, fleets, raceColumnNames, |
| 185 | 185 | /* trackedRegattaRegistry */ null); |
| ... | ... | @@ -195,14 +195,16 @@ public class LeaderboardScoringAndRankingForLowPointsTest extends LeaderboardSco |
| 195 | 195 | series.add(medalSeries); |
| 196 | 196 | final Regatta regatta = setupRegatta(/* use first two wins */ false); // regular LowPoint |
| 197 | 197 | final List<Competitor> competitors = createCompetitors(20); |
| 198 | - openingSeries.getRaceColumnByName("R1").setTrackedRace(defaultFleet, new MockedTrackedRaceWithStartTimeAndRanks(now, competitors)); |
|
| 199 | - openingSeries.getRaceColumnByName("R2").setTrackedRace(defaultFleet, new MockedTrackedRaceWithStartTimeAndRanks(now, competitors)); |
|
| 200 | - openingSeries.getRaceColumnByName("R3").setTrackedRace(defaultFleet, new MockedTrackedRaceWithStartTimeAndRanks(now, competitors)); |
|
| 198 | + for (final RaceColumn openingSeriesRaceColumn : openingSeries.getRaceColumns()) { |
|
| 199 | + openingSeriesRaceColumn.setTrackedRace(defaultFleet, new MockedTrackedRaceWithStartTimeAndRanks(now, competitors)); |
|
| 200 | + } |
|
| 201 | 201 | final Leaderboard leaderboard = createLeaderboard(regatta, /* discarding thresholds */ new int[0]); |
| 202 | 202 | final RaceColumn carryColumn = leaderboard.getRaceColumnByName("Carry"); |
| 203 | + final Competitor thirdAfterOpeningSeries = Util.get(leaderboard.getCompetitorsFromBestToWorst(now), 2); |
|
| 204 | + final double scoreOfThirdAfterOpeningSeries = leaderboard.getNetPoints(thirdAfterOpeningSeries, now); |
|
| 203 | 205 | for (int medalRaceCompetitorIndex=0; medalRaceCompetitorIndex<10; medalRaceCompetitorIndex++) { |
| 204 | - final double regularScore = 3*(medalRaceCompetitorIndex+1); // 3, 6, 9, ... |
|
| 205 | - leaderboard.getScoreCorrection().correctScore(competitors.get(medalRaceCompetitorIndex), carryColumn, Math.min(regularScore, 3*3+18)); |
|
| 206 | + final double regularScore = leaderboard.getNetPoints(competitors.get(medalRaceCompetitorIndex), now); |
|
| 207 | + leaderboard.getScoreCorrection().correctScore(competitors.get(medalRaceCompetitorIndex), carryColumn, Math.min(regularScore, scoreOfThirdAfterOpeningSeries+18)); |
|
| 206 | 208 | } |
| 207 | 209 | final RaceColumn f1 = leaderboard.getRaceColumnByName("F1"); |
| 208 | 210 | final RaceColumn f2 = leaderboard.getRaceColumnByName("F2"); |
| ... | ... | @@ -212,10 +214,10 @@ public class LeaderboardScoringAndRankingForLowPointsTest extends LeaderboardSco |
| 212 | 214 | // construct a tie between C1 and C2 (index 0 and 1, respectively); the tie is expected to be broken |
| 213 | 215 | // in favor of C2 because C2 must have performed better in the medal races F1/F2 due to the worse |
| 214 | 216 | // carried score |
| 215 | - assertEquals(3.0, leaderboard.getNetPoints(competitors.get(0), carryColumn, now), EPSILON); |
|
| 217 | + assertEquals(raceColumnNames.size(), leaderboard.getNetPoints(competitors.get(0), carryColumn, now), EPSILON); |
|
| 216 | 218 | leaderboard.getScoreCorrection().correctScore(competitors.get(0), f1, 5.0); |
| 217 | 219 | leaderboard.getScoreCorrection().correctScore(competitors.get(0), f2, 3.0); // medal series: 3 (Carry) + 5 + 3 = 11 |
| 218 | - assertEquals(6.0, leaderboard.getNetPoints(competitors.get(1), carryColumn, now), EPSILON); |
|
| 220 | + assertEquals(2*raceColumnNames.size(), leaderboard.getNetPoints(competitors.get(1), carryColumn, now), EPSILON); |
|
| 219 | 221 | leaderboard.getScoreCorrection().correctScore(competitors.get(1), f1, 1.0); |
| 220 | 222 | leaderboard.getScoreCorrection().correctScore(competitors.get(1), f2, 4.0); // medal series: 6 (Carry) + 1 + 4 = 11 |
| 221 | 223 | // construct a tie between C9 and C10 (index 8 and 9, respectively); the tie is expected to be broken |
| ... | ... | @@ -224,25 +226,36 @@ public class LeaderboardScoringAndRankingForLowPointsTest extends LeaderboardSco |
| 224 | 226 | // best score. |
| 225 | 227 | assertEquals(leaderboard.getNetPoints(competitors.get(8), carryColumn, now), leaderboard.getNetPoints(competitors.get(9), carryColumn, now), EPSILON); |
| 226 | 228 | leaderboard.getScoreCorrection().correctScore(competitors.get(8), f1, 6.0); |
| 227 | - leaderboard.getScoreCorrection().correctScore(competitors.get(8), f1, 8.0); |
|
| 228 | - leaderboard.getScoreCorrection().correctScore(competitors.get(9), f1, 7.0); |
|
| 229 | + leaderboard.getScoreCorrection().correctScore(competitors.get(8), f2, 8.0); |
|
| 229 | 230 | leaderboard.getScoreCorrection().correctScore(competitors.get(9), f1, 7.0); |
| 230 | - // construct scores for the remaining competitors C3..C8 |
|
| 231 | + leaderboard.getScoreCorrection().correctScore(competitors.get(9), f2, 7.0); |
|
| 232 | + // construct a tie between C7 and C8 (index 6 and 7, respectively); the tie is based on |
|
| 233 | + // equal carried points and equal medal series points throughout (both DNF in F1 and F2), |
|
| 234 | + // but C7 is expected to be ranked better because of the better rank in the opening series, |
|
| 235 | + // only it got "squashed" to the same reduced points as those of C8, but the tie break would |
|
| 236 | + // have to go by opening series rank as a last resort: |
|
| 237 | + assertEquals(leaderboard.getNetPoints(competitors.get(6), carryColumn, now), leaderboard.getNetPoints(competitors.get(7), carryColumn, now), EPSILON); |
|
| 238 | + leaderboard.getScoreCorrection().correctScore(competitors.get(6), f1, 11.0); |
|
| 239 | + leaderboard.getScoreCorrection().setMaxPointsReason(competitors.get(6), f1, MaxPointsReason.DNF); |
|
| 240 | + leaderboard.getScoreCorrection().correctScore(competitors.get(6), f2, 11.0); |
|
| 241 | + leaderboard.getScoreCorrection().setMaxPointsReason(competitors.get(6), f2, MaxPointsReason.DNF); |
|
| 242 | + leaderboard.getScoreCorrection().correctScore(competitors.get(7), f1, 11.0); |
|
| 243 | + leaderboard.getScoreCorrection().setMaxPointsReason(competitors.get(7), f1, MaxPointsReason.DNF); |
|
| 244 | + leaderboard.getScoreCorrection().correctScore(competitors.get(7), f2, 11.0); |
|
| 245 | + leaderboard.getScoreCorrection().setMaxPointsReason(competitors.get(7), f2, MaxPointsReason.DNF); |
|
| 246 | + // construct scores for the remaining competitors C3..C6 |
|
| 231 | 247 | leaderboard.getScoreCorrection().correctScore(competitors.get(2), f1, 2.0); |
| 232 | 248 | leaderboard.getScoreCorrection().correctScore(competitors.get(3), f1, 3.0); |
| 233 | 249 | leaderboard.getScoreCorrection().correctScore(competitors.get(4), f1, 4.0); |
| 234 | 250 | leaderboard.getScoreCorrection().correctScore(competitors.get(5), f1, 8.0); |
| 235 | - leaderboard.getScoreCorrection().correctScore(competitors.get(6), f1, 9.0); |
|
| 236 | - leaderboard.getScoreCorrection().correctScore(competitors.get(7), f1, 10.0); |
|
| 237 | 251 | leaderboard.getScoreCorrection().correctScore(competitors.get(2), f2, 1.0); |
| 238 | 252 | leaderboard.getScoreCorrection().correctScore(competitors.get(3), f2, 2.0); |
| 239 | 253 | leaderboard.getScoreCorrection().correctScore(competitors.get(4), f2, 5.0); |
| 240 | 254 | leaderboard.getScoreCorrection().correctScore(competitors.get(5), f2, 6.0); |
| 241 | - leaderboard.getScoreCorrection().correctScore(competitors.get(6), f2, 9.0); |
|
| 242 | - leaderboard.getScoreCorrection().correctScore(competitors.get(7), f2, 10.0); |
|
| 243 | 255 | final Iterable<Competitor> ranking = leaderboard.getCompetitorsFromBestToWorst(now); |
| 244 | - assertTrue(Util.indexOf(ranking, competitors.get(1)) < Util.indexOf(ranking, competitors.get(0))); |
|
| 256 | + assertTrue(Util.indexOf(ranking, competitors.get(6)) < Util.indexOf(ranking, competitors.get(7))); |
|
| 245 | 257 | assertTrue(Util.indexOf(ranking, competitors.get(8)) < Util.indexOf(ranking, competitors.get(9))); |
| 258 | + assertTrue(Util.indexOf(ranking, competitors.get(1)) < Util.indexOf(ranking, competitors.get(0))); |
|
| 246 | 259 | } |
| 247 | 260 | |
| 248 | 261 | @Test |