mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 22:37:15 +00:00
Merge master into bug2851
This commit is contained in:
commit
07d999cc9e
735 files changed
+13792
-6515
No files matched your search
+9
-8
@@ -24,6 +24,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.BoatDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTOImpl;
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
@@ -232,8 +233,8 @@ public class LeaderboardDTODiffingTest {
|
||||
@Test
|
||||
public void testCompetitorListChange() {
|
||||
newVersion.competitors = new ArrayList<CompetitorDTO>(newVersion.competitors); // clone competitor list so it's not identical to that of previous version
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", Color.RED, "someone@nobody.de", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
/* imageURL */ null, /* flagImageURL */ null, new BoatClassDTO("505", 5.05), /* timeOnTimeFactor */ null,
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", Color.RED, "someone@nobody.de", "DE", "GER", "Germany", "912p09871203987",
|
||||
/* imageURL */ null, /* flagImageURL */ null, new BoatDTO("LSC", "GER 1234"), new BoatClassDTO("505", 5.05), /* timeOnTimeFactor */ null,
|
||||
/* timeOnDistanceAllowancePerNauticalMile */ null);
|
||||
newVersion.competitors.add(13, somebodyNew); // insert a competitor; this should mess up all others' indexes; check if this works
|
||||
CompetitorDTO wolfgang = getPreviousCompetitorByName("HUNGER +JESS");
|
||||
@@ -253,8 +254,8 @@ public class LeaderboardDTODiffingTest {
|
||||
Util.addAll(newVersion.getSuppressedCompetitors(), newSuppressedCompetitors);
|
||||
newVersion.setSuppressedCompetitors(newSuppressedCompetitors);
|
||||
newVersion.competitors = new ArrayList<CompetitorDTO>(newVersion.competitors); // clone competitor list so it's not identical to that of previous version
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", Color.RED, "someone@nobody.de", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
/* imageURL */ null, /* flagImageURL */ null, new BoatClassDTO("505", 5.05), /* timeOnTimeFactor */ null,
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", Color.RED, "someone@nobody.de", "DE", "GER", "Germany", "912p09871203987",
|
||||
/* imageURL */ null, /* flagImageURL */ null, new BoatDTO("LSC", "GER 1234"), new BoatClassDTO("505", 5.05), /* timeOnTimeFactor */ null,
|
||||
/* timeOnDistanceAllowancePerNauticalMile */ null);
|
||||
newVersion.setSuppressed(newVersion.competitors.get(13), true); // suppress an existing competitor; compaction should reduce this to a single number only
|
||||
newVersion.setSuppressed(somebodyNew, true); // check that mixed mode with existing and new competitors works as well
|
||||
@@ -276,8 +277,8 @@ public class LeaderboardDTODiffingTest {
|
||||
@Test
|
||||
public void testDisplayNameChange() {
|
||||
newVersion.competitors = new ArrayList<CompetitorDTO>(newVersion.competitors); // clone competitor list so it's not identical to that of previous version
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", Color.RED, "someone@nobody.de", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
/* imageURL */ null, /* flagImageURL */ null, new BoatClassDTO("505", 5.05), /* timeOnTimeFactor */ null,
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", Color.RED, "someone@nobody.de", "DE", "GER", "Germany", "912p09871203987",
|
||||
/* imageURL */ null, /* flagImageURL */ null, new BoatDTO("LSC", "GER 1234"), new BoatClassDTO("505", 5.05), /* timeOnTimeFactor */ null,
|
||||
/* timeOnDistanceAllowancePerNauticalMile */ null);
|
||||
newVersion.competitors.add(somebodyNew);
|
||||
newVersion.competitorDisplayNames = new HashMap<CompetitorDTO, String>(newVersion.competitorDisplayNames);
|
||||
@@ -306,8 +307,8 @@ public class LeaderboardDTODiffingTest {
|
||||
List<CompetitorDTO> newOrdering = new ArrayList<CompetitorDTO>(newVersion.getCompetitorsFromBestToWorst(r9));
|
||||
newVersion.setCompetitorsFromBestToWorst(r9, newOrdering);
|
||||
newVersion.competitors = new ArrayList<CompetitorDTO>(newVersion.competitors); // clone competitor list so it's not identical to that of previous version
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", Color.RED, "someone@nobody.de", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
/* imageURL */ null, /* flagImageURL */ null, new BoatClassDTO("505", 5.05), /* timeOnTimeFactor */ null,
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", Color.RED, "someone@nobody.de", "DE", "GER", "Germany", "912p09871203987",
|
||||
/* imageURL */ null, /* flagImageURL */ null, new BoatDTO("LSC", "GER 1234"), new BoatClassDTO("505", 5.05), /* timeOnTimeFactor */ null,
|
||||
/* timeOnDistanceAllowancePerNauticalMile */ null);
|
||||
newVersion.competitors.add(somebodyNew);
|
||||
newOrdering.add(somebodyNew);
|
||||
|
||||
+33
-2
@@ -28,6 +28,7 @@ import com.sap.sailing.domain.common.PassingInstruction;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.common.impl.KnotSpeedImpl;
|
||||
import com.sap.sailing.domain.common.impl.NauticalMileDistance;
|
||||
import com.sap.sailing.domain.common.tracking.impl.GPSFixImpl;
|
||||
import com.sap.sailing.domain.markpassingcalculation.impl.WaypointPositionAndDistanceCache;
|
||||
import com.sap.sailing.domain.racelog.tracking.EmptyGPSFixStore;
|
||||
@@ -127,6 +128,33 @@ public class WaypointPositionAndDistanceCacheTest {
|
||||
assertEquals(5, recalculations); // one for each waypoint, one for the distance; second request recalculates except start/finish position
|
||||
}
|
||||
|
||||
/**
|
||||
* A white-box text for bug 3364: when multiple cache entries exist in the map, invalidating a cache entry can cause a
|
||||
* ConcurrentModificationException.
|
||||
*/
|
||||
@Test
|
||||
public void testInvalidateByNewMarkPositionWithMultipleMarkPositionsInCache() {
|
||||
assertEquals(60, cache.getApproximateDistance(start, windwardWaypoint, now).getNauticalMiles(), 0.01);
|
||||
trackedRace.getOrCreateTrack(windward).add(new GPSFixImpl(new DegreePosition(1, 0).translateGreatCircle(
|
||||
new DegreeBearingImpl(0), new KnotSpeedImpl(20).travel(now, now.plus(timeRangeResolution.divide(10)))),
|
||||
now.plus(timeRangeResolution.divide(10)))); // does not affect the cache interval
|
||||
trackedRace.getOrCreateTrack(windward).add(new GPSFixImpl(new DegreePosition(1, 0).translateGreatCircle(
|
||||
new DegreeBearingImpl(0), new KnotSpeedImpl(20).travel(now, now.plus(timeRangeResolution.times(2)))),
|
||||
now.plus(timeRangeResolution.times(2))));
|
||||
trackedRace.getOrCreateTrack(windward).add(new GPSFixImpl(new DegreePosition(1, 0).translateGreatCircle(
|
||||
new DegreeBearingImpl(0), new KnotSpeedImpl(20).travel(now, now.plus(timeRangeResolution.times(3)))),
|
||||
now.plus(timeRangeResolution.times(3))));
|
||||
assertEquals(60, cache.getApproximateDistance(start, windwardWaypoint, now).getNauticalMiles(), 0.01);
|
||||
assertEquals(60+new NauticalMileDistance(20).scale(timeRangeResolution.divide(Duration.ONE_HOUR)).getNauticalMiles(), cache.getApproximateDistance(start, windwardWaypoint, now.plus(timeRangeResolution)).getNauticalMiles(), 0.01);
|
||||
assertEquals(60+new NauticalMileDistance(20).scale(timeRangeResolution.times(2).divide(Duration.ONE_HOUR)).getNauticalMiles(), cache.getApproximateDistance(start, windwardWaypoint, now.plus(timeRangeResolution.times(2))).getNauticalMiles(), 0.01);
|
||||
trackedRace.getOrCreateTrack(windward).add(new GPSFixImpl(new DegreePosition(1, 0).translateGreatCircle(
|
||||
new DegreeBearingImpl(0), new KnotSpeedImpl(20).travel(now, now.plus(timeRangeResolution.minus(1)))),
|
||||
now.plus(timeRangeResolution.minus(1)))); // cause cache invalidation with several entries in the map
|
||||
recalculations = 0;
|
||||
assertEquals(60+new NauticalMileDistance(20).scale(timeRangeResolution.divide(Duration.ONE_HOUR)).getNauticalMiles(), cache.getApproximateDistance(start, windwardWaypoint, now.plus(timeRangeResolution)).getNauticalMiles(), 0.01);
|
||||
assertEquals(2, recalculations); // distance calculation also requires position calculation, therefore 2, not 1
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewMarkPositionAffectingEntryOppositeOrder() {
|
||||
assertEquals(60, cache.getApproximateDistance(start, windwardWaypoint, now).getNauticalMiles(), 0.01);
|
||||
@@ -140,10 +168,13 @@ public class WaypointPositionAndDistanceCacheTest {
|
||||
|
||||
@Test
|
||||
public void testNewMarkPositionNotAffectingEntry() {
|
||||
assertEquals(60, cache.getApproximateDistance(start, windwardWaypoint, now).getNauticalMiles(), 0.01);
|
||||
trackedRace.getOrCreateTrack(windward).add(new GPSFixImpl(new DegreePosition(1, 0).translateGreatCircle(
|
||||
new DegreeBearingImpl(0), new KnotSpeedImpl(20).travel(now, now.plus(timeRangeResolution))),
|
||||
now.plus(timeRangeResolution))); // does not affect the cache interval
|
||||
now.plus(timeRangeResolution)));
|
||||
assertEquals(60, cache.getApproximateDistance(start, windwardWaypoint, now).getNauticalMiles(), 0.01);
|
||||
trackedRace.getOrCreateTrack(windward).add(new GPSFixImpl(new DegreePosition(1, 0).translateGreatCircle(
|
||||
new DegreeBearingImpl(0), new KnotSpeedImpl(20).travel(now, now.plus(timeRangeResolution.times(2)))),
|
||||
now.plus(timeRangeResolution.times(2)))); // only affects back to now.plus(timeRangeResolution) but not all the way back to now
|
||||
assertEquals(60, cache.getApproximateDistance(start, windwardWaypoint, now).getNauticalMiles(), 0.01);
|
||||
assertEquals(60, cache.getApproximateDistance(windwardWaypoint, start, now).getNauticalMiles(), 0.01);
|
||||
assertEquals(3, recalculations); // one for the position of each waypoint, one for the distance; second / third request from cache
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@ public abstract class AbstractTracTracLiveTest extends StoredTrackBasedTest {
|
||||
}
|
||||
|
||||
public static URI getCourseDesignUpdateURI() throws URISyntaxException {
|
||||
return new URI("http://tracms.traclive.dk/update_course");
|
||||
return new URI("http://" + TracTracConnectionConstants.HOST_NAME + "/update_course");
|
||||
}
|
||||
|
||||
public static String getTracTracUsername() {
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sailing.domain.tractracadapter.impl.DomainFactoryImpl;
|
||||
|
||||
public class DomainFactoryImplTest {
|
||||
private DomainFactoryImpl domainFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
domainFactory = new DomainFactoryImpl(DomainFactory.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetDominantBoatClass_TestNullCollection() {
|
||||
Assert.assertEquals(null, domainFactory.getDominantBoatClass(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDominantBoatClass_TestEmptyCollection() {
|
||||
List<String> emptyList = new ArrayList<>();
|
||||
Assert.assertEquals(null, domainFactory.getDominantBoatClass(emptyList));
|
||||
}
|
||||
@Test
|
||||
public void testGetDominantBoatClass_TestWithOneObject() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("LSR");
|
||||
Assert.assertEquals("Laser Int.", domainFactory.getDominantBoatClass(list).getDisplayName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDominantBoatClass_TestWithTheSameCount() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("LSR");
|
||||
list.add("18.Footer");
|
||||
String result = domainFactory.getDominantBoatClass(list).getDisplayName();
|
||||
if(!(result == "Laser Int." || result == "18Footer")) {
|
||||
Assert.assertEquals("Laser Int.", result);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDominantBoatClass_TestWithMoreThanOneObject() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("LSR");
|
||||
list.add("18.Footer");
|
||||
list.add("LSR");
|
||||
String result = domainFactory.getDominantBoatClass(list).getDisplayName();
|
||||
Assert.assertEquals("Laser Int.", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDominantBoatClass_TestWithSynonymNames() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("LSR");
|
||||
list.add("18.Footer");
|
||||
list.add("18.Footer");
|
||||
list.add("Laser Int.");
|
||||
list.add("Laser");
|
||||
String result = domainFactory.getDominantBoatClass(list).getDisplayName();
|
||||
Assert.assertEquals("Laser Int.", result);
|
||||
}
|
||||
}
|
||||
+6
@@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Boat;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
@@ -75,6 +76,11 @@ public class MockedTrackedRaceWithFixedRank extends MockedTrackedRace {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boat getBoatOfCompetitorById(Serializable competitorID) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sap.sailing.domain.base.Boat;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
@@ -50,6 +51,10 @@ public class MockedTrackedRaceWithFixedRankAndManyCompetitors extends MockedTrac
|
||||
public Serializable getId() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Boat getBoatOfCompetitorById(Serializable competitorID) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user