added tests for bug 469 and improved Javadocs around the topic

This commit is contained in:
Axel Uhl committed 2012-06-07 11:33:31 +02:00
1 parent d7517c7321
commit dae1d4fd1d
3 files changed
+20 -6

No files matched your search

@@ -59,10 +59,12 @@ public class LeaderboardScoringAndRankingTest extends AbstractLeaderboardTest {
}
/**
* Asserts that the competitors ranking worse than the disqualified competitor advance by one
* Asserts that the competitors ranking worse than the disqualified competitor advance by one in the
* {@link Leaderboard#getCompetitorsFromBestToWorst(TimePoint)} ordering. Note that this does not test
* the total points given for those competitors.
*/
@Test
public void testOneStartedRaceWithDifferentScoresAndDisqualification() {
public void testOneStartedRaceWithDifferentScoresAndDisqualification() throws NoWindException {
List<Competitor> competitors = createCompetitors(10);
Regatta regatta = createRegatta(/* qualifying */0, new String[] { "Default" }, /* final */1,
new String[] { "Default" },
@@ -83,6 +85,15 @@ public class LeaderboardScoringAndRankingTest extends AbstractLeaderboardTest {
assertEquals(competitors.subList(0, 5), rankedCompetitors.subList(0, 5));
assertEquals(competitors.subList(6, 10), rankedCompetitors.subList(5, 9));
assertEquals(competitors.get(5), rankedCompetitors.get(9));
// Now test the total points and make sure the other competitors advanced by one, too
assertEquals(11, leaderboard.getTotalPoints(competitors.get(5), f1Column, now));
for (int i=0; i<5; i++) {
assertEquals(i+1, leaderboard.getTotalPoints(competitors.get(i), f1Column, now));
}
for (int i=6; i<10; i++) {
assertEquals(i, leaderboard.getTotalPoints(competitors.get(i), f1Column, now));
}
}
@Test
@@ -77,7 +77,11 @@ public interface Leaderboard extends Named {
* Shorthand for {@link TrackedRace#getRank(Competitor, com.sap.sailing.domain.common.TimePoint)} with the
* additional logic that in case the <code>race</code> hasn't {@link TrackedRace#hasStarted(TimePoint) started} yet
* or no {@link TrackedRace} exists for <code>race</code>, 0 will be returned for all those competitors. The tracked
* race for the correct {@link Fleet} is determined using {@link RaceColumn#getTrackedRace(Competitor)}.
* race for the correct {@link Fleet} is determined using {@link RaceColumn#getTrackedRace(Competitor)}.<p>
*
* For each competitor tracking-wise ranking better than <code>competitor</code> but with
* a {@link #getMaxPointsReason(Competitor, RaceColumn, TimePoint) disqualification reason} given, <code>competitor</code>'s
* rank is improved by one.
*
* @param competitor
* a competitor contained in the {@link #getCompetitors()} result
@@ -119,9 +119,8 @@ public class ScoreCorrectionImpl implements SettableScoreCorrection {
/**
* Under the assumption that the competitor is not assigned the maximum score due to disqualification or other
* reasons, computes the corrected score. This default implementation uses <code>uncorrectedScore</code> without
* changes. Subclasses may wish to allow for optionally overwriting this uncorrected score to handle, e.g.,
* differences between what the tracking results suggest and what the jury or race committee decided.
* reasons, computes the corrected score. If {@link #correctedScores} contains an entry for the <code>competitor</code>'s key,
* it is used. Otherwise, the <code>uncorrectedScore</code> is returned.
*/
protected int getCorrectedNonMaxedScore(Competitor competitor, RaceColumn raceColumn, int uncorrectedScore) {
Integer correctedNonMaxedScore = correctedScores.get(raceColumn.getKey(competitor));