test for legDetails problem that doesn't fail yet where it should

This commit is contained in:
Axel Uhl committed 2013-06-26 10:25:55 +02:00
1 parent d7899a9cd0
commit 5169f846ef
1 file changed
+18
@@ -34,6 +34,7 @@ import com.sap.sailing.domain.common.dto.LegEntryDTO;
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
import com.sap.sailing.domain.common.dto.RaceDTO;
import com.sap.sailing.domain.common.impl.Util;
import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.domain.test.StoredTrackBasedTest;
import com.sap.sailing.util.ClonerImpl;
@@ -118,6 +119,15 @@ public class LeaderboardDTODiffingTest {
@Test
public void testStrippingExceptOneColumnInOneRace() {
Map<Pair<CompetitorDTO, String>, List<LegEntryDTO>> previousLegDetailsBeforeStripping = new HashMap<>();
for (Map.Entry<CompetitorDTO, LeaderboardRowDTO> e : previousVersion.rows.entrySet()) {
for (Map.Entry<String, LeaderboardEntryDTO> e2 : e.getValue().fieldsByRaceColumnName.entrySet()) {
if (e2.getValue().legDetails != null) {
previousLegDetailsBeforeStripping.put(new Pair<CompetitorDTO, String>(e.getKey(), e2.getKey()),
new ArrayList<>(e2.getValue().legDetails));
}
}
}
HashMap<CompetitorDTO, LeaderboardRowDTO> newRows = new HashMap<CompetitorDTO, LeaderboardRowDTO>(newVersion.rows);
double newDistance = 1234;
String nameOfRaceColumnToChange = "R9";
@@ -144,6 +154,14 @@ public class LeaderboardDTODiffingTest {
newVersion.rows = newRows;
Map<CompetitorDTO, LeaderboardRowDTO> rowsBeforeStripping = newVersion.rows;
newVersion.strip(previousVersion);
// see bug 1455; check that the stripping doesn't kill the previous leaderboard's legDetails lists
for (Map.Entry<Pair<CompetitorDTO, String>, List<LegEntryDTO>> e : previousLegDetailsBeforeStripping.entrySet()) {
final LeaderboardRowDTO leaderboardRowDTO = previousVersion.rows.get(e.getKey().getA());
if (leaderboardRowDTO != null) {
List<LegEntryDTO> newLegDetails = leaderboardRowDTO.fieldsByRaceColumnName.get(e.getKey().getB()).legDetails;
assertEquals(e.getValue(), newLegDetails);
}
}
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
assertNotNull(newVersion.rows);
assertEquals(previousVersion.rows.size()-17, newVersion.rows.size()); // all rows have changed except for 17 that have no leg details in leg 8