mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 05:11:04 +00:00
added test about ignoring medalRace argument if column in leaderboard already exists
This commit is contained in:
1 parent
ba07d4d7e3
commit
e148f685ee
2 files changed
+29
-16
No files matched your search
+12
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -84,6 +85,17 @@ public class LeaderboardOfflineTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ensureMedalRaceParamIsIgnoredIfRaceColumnAlreadyExists() {
|
||||
Leaderboard leaderboard = new LeaderboardImpl("Test Leaderboard", new ScoreCorrectionImpl(), new ResultDiscardingRuleImpl(
|
||||
new int[] { 5, 8 }));
|
||||
final String columnName = "abc";
|
||||
setupRaces(1, 0);
|
||||
leaderboard.addRaceColumn(columnName, /* medalRace */ true);
|
||||
leaderboard.addRace(testRaces.iterator().next(), columnName, /* medalRace */ false);
|
||||
assertTrue(leaderboard.getRaceColumnByName(columnName).isMedalRace());
|
||||
}
|
||||
|
||||
protected void testLeaderboard(int numberOfStartedRaces, int numberOfNotStartedRaces, int firstDiscardingThreshold,
|
||||
int secondDiscardingThreshold, Integer carry, boolean addOneMedalRace, int numberOfUntrackedRaces) throws NoWindException {
|
||||
|
||||
+17
-16
@@ -21,19 +21,19 @@ import com.sap.sailing.domain.leaderboard.impl.ResultDiscardingRuleImpl;
|
||||
import com.sap.sailing.domain.leaderboard.impl.ScoreCorrectionImpl;
|
||||
import com.sap.sailing.domain.test.MockedTrackedRaceWithFixedRank;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sailing.mongodb.DomainObjectFactory;
|
||||
import com.sap.sailing.mongodb.MongoObjectFactory;
|
||||
import com.sap.sailing.mongodb.impl.DomainObjectFactoryImpl;
|
||||
import com.sap.sailing.mongodb.impl.MongoObjectFactoryImpl;
|
||||
import com.sap.sailing.util.Util;
|
||||
|
||||
public class TestStoringAndRetrievingLeaderboards extends AbstractMongoDBTest {
|
||||
@Test
|
||||
public void testStoreAndRetrieveSimpleLeaderboard() {
|
||||
String leaderboardName = "TestLeaderboard";
|
||||
int[] discardIndexResultsStartingWithHowManyRaces = new int[] { 5, 8 };
|
||||
final String leaderboardName = "TestLeaderboard";
|
||||
final int[] discardIndexResultsStartingWithHowManyRaces = new int[] { 5, 8 };
|
||||
LeaderboardImpl leaderboard = new LeaderboardImpl(leaderboardName, new ScoreCorrectionImpl(),
|
||||
new ResultDiscardingRuleImpl(discardIndexResultsStartingWithHowManyRaces));
|
||||
MongoObjectFactory.INSTANCE.storeLeaderboard(leaderboard);
|
||||
Leaderboard loadedLeaderboard = DomainObjectFactory.INSTANCE.loadLeaderboard(leaderboardName);
|
||||
new MongoObjectFactoryImpl(db).storeLeaderboard(leaderboard);
|
||||
Leaderboard loadedLeaderboard = new DomainObjectFactoryImpl(db).loadLeaderboard(leaderboardName);
|
||||
assertEquals(leaderboardName, loadedLeaderboard.getName());
|
||||
assertTrue(Arrays.equals(discardIndexResultsStartingWithHowManyRaces, loadedLeaderboard.getResultDiscardingRule()
|
||||
.getDiscardIndexResultsStartingWithHowManyRaces()));
|
||||
@@ -44,18 +44,15 @@ public class TestStoringAndRetrievingLeaderboards extends AbstractMongoDBTest {
|
||||
final String leaderboardName = "TestLeaderboard";
|
||||
final String raceColumnName = "My First Race";
|
||||
final int carriedPointsForWolfgangHunger = 3;
|
||||
int[] discardIndexResultsStartingWithHowManyRaces = new int[] { 5, 8 };
|
||||
final int[] discardIndexResultsStartingWithHowManyRaces = new int[] { 5, 8 };
|
||||
LeaderboardImpl leaderboard = new LeaderboardImpl(leaderboardName, new ScoreCorrectionImpl(),
|
||||
new ResultDiscardingRuleImpl(discardIndexResultsStartingWithHowManyRaces));
|
||||
Competitor competitor = new CompetitorImpl(123, "Wolfgang Hunger", new TeamImpl("STG", Collections.singleton(
|
||||
new PersonImpl("Wolfgang Hunger", new NationalityImpl("Germany", "GER"),
|
||||
/* dateOfBirth */ null, "This is famous Wolfgang Hunger")), new PersonImpl("Rigo van Maas", new NationalityImpl("The Netherlands", "NED"),
|
||||
/* dateOfBirth */ null, "This is Rigo, the coach")), new BoatImpl("Wolfgang Hunger's boat", new BoatClassImpl("505")));
|
||||
Competitor competitor = createCompetitor();
|
||||
TrackedRace raceWithOneCompetitor = new MockedTrackedRaceWithFixedRank(competitor, /* rank */ 1, /* started */ true);
|
||||
leaderboard.addRace(raceWithOneCompetitor, raceColumnName, /* medalRace */ false);
|
||||
leaderboard.setCarriedPoints(competitor, carriedPointsForWolfgangHunger);
|
||||
MongoObjectFactory.INSTANCE.storeLeaderboard(leaderboard);
|
||||
Leaderboard loadedLeaderboard = DomainObjectFactory.INSTANCE.loadLeaderboard(leaderboardName);
|
||||
new MongoObjectFactoryImpl(db).storeLeaderboard(leaderboard);
|
||||
Leaderboard loadedLeaderboard = new DomainObjectFactoryImpl(db).loadLeaderboard(leaderboardName);
|
||||
// attach tracked race to leaderboard to ensure that competitor object is assigned properly
|
||||
loadedLeaderboard.addRace(raceWithOneCompetitor, raceColumnName, /* medalRace, ignored */ false);
|
||||
assertEquals(leaderboardName, loadedLeaderboard.getName());
|
||||
@@ -66,8 +63,12 @@ public class TestStoringAndRetrievingLeaderboards extends AbstractMongoDBTest {
|
||||
assertEquals(carriedPointsForWolfgangHunger, loadedLeaderboard.getCarriedPoints(competitor));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMedalRaceParamIgnoredIfColumnAlreadyExists() {
|
||||
// TODO
|
||||
private Competitor createCompetitor() {
|
||||
Competitor competitor = new CompetitorImpl(123, "Wolfgang Hunger", new TeamImpl("STG", Collections.singleton(
|
||||
new PersonImpl("Wolfgang Hunger", new NationalityImpl("Germany", "GER"),
|
||||
/* dateOfBirth */ null, "This is famous Wolfgang Hunger")), new PersonImpl("Rigo van Maas", new NationalityImpl("The Netherlands", "NED"),
|
||||
/* dateOfBirth */ null, "This is Rigo, the coach")), new BoatImpl("Wolfgang Hunger's boat", new BoatClassImpl("505")));
|
||||
return competitor;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user