fix for bug 3681, "greening" the test: removing an overall leaderboard from the server unlinks it from the respective leaderboard group

Change-Id: Id23a781a2e640d8ee68d68e6dae2ec2e85b30a82
This commit is contained in:
Axel Uhl committed 2016-06-01 17:34:56 +02:00
1 parent fecedb380a
commit d1af28800d
1 file changed
+7 -4
@@ -1004,15 +1004,15 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
}
/**
* Checks all groups, if they contain a leaderboard with the <code>removedLeaderboardName</code> and removes it from
* the group.
* Checks all groups, if they contain a leaderboard with the <code>removedLeaderboardName</code> or reference it as their
* overall leaderboard and removes it from the group or unlinks it as the overall leaderboard, respectively.
*
* @param removedLeaderboardName
*/
private void syncGroupsAfterLeaderboardRemove(String removedLeaderboardName, boolean doDatabaseUpdate) {
boolean groupNeedsUpdate = false;
for (LeaderboardGroup leaderboardGroup : leaderboardGroupsByName.values()) {
for (Leaderboard leaderboard : leaderboardGroup.getLeaderboards()) {
for (final Leaderboard leaderboard : leaderboardGroup.getLeaderboards()) {
if (leaderboard.getName().equals(removedLeaderboardName)) {
leaderboardGroup.removeLeaderboard(leaderboard);
groupNeedsUpdate = true;
@@ -1020,7 +1020,10 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
break;
}
}
if (leaderboardGroup.getOverallLeaderboard() != null && leaderboardGroup.getOverallLeaderboard().getName().equals(removedLeaderboardName)) {
leaderboardGroup.setOverallLeaderboard(null);
groupNeedsUpdate = true;
}
if (doDatabaseUpdate && groupNeedsUpdate) {
mongoObjectFactory.storeLeaderboardGroup(leaderboardGroup);
}