Merge remote-tracking branch 'server/master'

This commit is contained in:
Axel Uhl committed 2013-08-13 10:53:31 +02:00
commit c145142b35
2 files changed
+55 -1

No files matched your search

@@ -30,7 +30,7 @@ public class LeaderboardGroupMasterDataJsonSerializer implements JsonSerializer<
public static final String FIELD_LEADERBOARDS = "leaderboards";
public static final String FIELD_HAS_OVERALL_LEADERBOARD = "overallLeaderboard";
public static final String FIELD_OVERALL_LEADERBOARD_SCORING_SCHEME = "overallLeaderboardScoringScheme";
public static final String FIELD_OVERALL_LEADERBOARD_DISCARDING_THRESHOLDS = "overallLeaderboardScoringScheme";
public static final String FIELD_OVERALL_LEADERBOARD_DISCARDING_THRESHOLDS = "overallLeaderboardDiscardingThresholds";
public static final String FIELD_DESCRIPTION = "description";
public static final String FIELD_NAME = "name";
public static final String FIELD_DISPLAY_GROUPS_REVERSE = "displayGroupsReverse";
@@ -50,6 +50,8 @@ import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.media.MediaTrack;
import com.sap.sailing.domain.leaderboard.Leaderboard;
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
import com.sap.sailing.domain.leaderboard.ScoringScheme;
import com.sap.sailing.domain.leaderboard.ThresholdBasedResultDiscardingRule;
import com.sap.sailing.domain.leaderboard.impl.LowPoint;
import com.sap.sailing.domain.racelog.RaceLogEventFactory;
import com.sap.sailing.domain.racelog.RaceLogStartTimeEvent;
@@ -1193,4 +1195,56 @@ public class MasterDataImportTest {
Assert.assertTrue(leaderboardGroup2OnTarget.getLeaderboards().iterator().hasNext());
}
@Test
public void testMasterDataImportWithOverallLeaderboard() throws MalformedURLException, IOException, InterruptedException {
// Setup source service
RacingEventService sourceService = new RacingEventServiceImpl();
int[] discardRule = { 1, 2, 3, 4 };
ScoringScheme scheme = new LowPoint();
List<String> leaderboardNames = new ArrayList<String>();
sourceService.addLeaderboardGroup(TEST_GROUP_NAME, "testGroupDesc", false,
leaderboardNames, discardRule, scheme.getType());
// Serialize
TopLevelMasterDataSerializer serializer = new TopLevelMasterDataSerializer(
sourceService.getLeaderboardGroups(), sourceService.getAllEvents(),
sourceService.getPersistentRegattasForRaceIDs(), sourceService.getAllMediaTracks());
Set<String> names = new HashSet<String>();
names.add(TEST_GROUP_NAME);
JSONObject masterDataOverallObject = serializer.serialize(names);
Assert.assertNotNull(masterDataOverallObject);
// Delete all data above from the database, to allow recreating all of it on target server
deleteCreatedDataFromDatabase();
// Deserialization copied from doPost in MasterDataByLeaderboardGroupJsonPostServlet
RacingEventService destService = new RacingEventServiceImplMock();
DomainFactory domainFactory = DomainFactory.INSTANCE;
MasterDataImporter importer = new MasterDataImporter(domainFactory, destService);
//Test in override model, to find out if data that was created during import is overriden later on
// in the same import process. Number of creations is checked below.
MasterDataImportObjectCreationCount creationCount = importer.importMasterData(
masterDataOverallObject.toString(), true);
//Test correct number of creations
Assert.assertEquals(1,creationCount.getLeaderboardGroupCount());
LeaderboardGroup leaderboardGroupOnTarget = destService.getLeaderboardGroupByName(TEST_GROUP_NAME);
Assert.assertNotNull(leaderboardGroupOnTarget);
Leaderboard overallLeaderboard = leaderboardGroupOnTarget.getOverallLeaderboard();
Assert.assertNotNull(overallLeaderboard);
Assert.assertNotNull(overallLeaderboard.getResultDiscardingRule());
Assert.assertNotNull(overallLeaderboard.getScoringScheme());
Assert.assertEquals(scheme.getType(), overallLeaderboard.getScoringScheme().getType());
Assert.assertEquals(3, ((ThresholdBasedResultDiscardingRule) overallLeaderboard.getResultDiscardingRule())
.getDiscardIndexResultsStartingWithHowManyRaces()[2]);
}
}