mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-23 22:19:13 +00:00
bug5715: added oneAlwaysStaysOne to Series and RaceColumn throughout
This commit is contained in:
+1
-1
@@ -410,7 +410,7 @@ public class LeaderboardDTODiffingTest {
|
||||
public void testPartialRaceColumnDTOCompaction() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
|
||||
// create a modified R9 RaceDTO clone in newVersion to make sure that even changing a property in the RaceDTO will keep the RaceColumnDTO from being omitted
|
||||
RaceColumnDTO r9 = newVersion.getRaceColumnByName("R9");
|
||||
RaceColumnDTO clonedR9 = new RaceColumnDTO("R9");
|
||||
RaceColumnDTO clonedR9 = new RaceColumnDTO("R9", /* oneAlwaysStaysOne */ false);
|
||||
cloner.clone(r9, clonedR9);
|
||||
// also clone the racesPerFleet map, or else we'd be modifying the previous version's one too
|
||||
final Field racesPerFleetField = clonedR9.getClass().getDeclaredField("racesPerFleet");
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.sap.sailing.domain.common.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
|
||||
public class ScoringSchemeTypeScoreScalingTest {
|
||||
private static final double DELTA = 0.0000001;
|
||||
|
||||
@Test
|
||||
public void testScalingThreeWithThree() {
|
||||
testScalingAndUnscaling(/* unscaled */ 3, /* factor */ 3, /* scaled */ 9, /* oneAlwaysStaysOne */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScalingOneWithThree() {
|
||||
testScalingAndUnscaling(/* unscaled */ 1, /* factor */ 3, /* scaled */ 3, /* oneAlwaysStaysOne */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScalingThreeWithTwo() {
|
||||
testScalingAndUnscaling(/* unscaled */ 3, /* factor */ 2, /* scaled */ 6, /* oneAlwaysStaysOne */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScalingOneWithTwo() {
|
||||
testScalingAndUnscaling(/* unscaled */ 1, /* factor */ 2, /* scaled */ 2, /* oneAlwaysStaysOne */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScalingWithThreeWithOneStaysOne() {
|
||||
testScalingAndUnscaling(/* unscaled */ 3, /* factor */ 3, /* scaled */ 7, /* oneAlwaysStaysOne */ true);
|
||||
testScalingAndUnscaling(/* unscaled */ 1, /* factor */ 3, /* scaled */ 1, /* oneAlwaysStaysOne */ true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScalingWithTwoWithOneStaysOne() {
|
||||
testScalingAndUnscaling(/* unscaled */ 3, /* factor */ 2, /* scaled */ 5, /* oneAlwaysStaysOne */ true);
|
||||
testScalingAndUnscaling(/* unscaled */ 1, /* factor */ 2, /* scaled */ 1, /* oneAlwaysStaysOne */ true);
|
||||
}
|
||||
|
||||
private void testScalingAndUnscaling(final double unscaled, final double factor, final double scaled,
|
||||
final boolean oneAlwaysStaysOne) {
|
||||
assertEquals(scaled, ScoringSchemeType.getScaledScore(factor, unscaled, oneAlwaysStaysOne), DELTA);
|
||||
assertEquals(unscaled, ScoringSchemeType.getUnscaledScore(factor, scaled, oneAlwaysStaysOne), DELTA);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user