mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-15 16:51:07 +00:00
fixed more tests by mocking both variants of getApproximatePosition
Change-Id: I51bacd50a7b7863fbd9374b90267d641b1717333
This commit is contained in:
1 parent
804bd605b4
commit
2e686866ff
2 files changed
+14
-8
No files matched your search
+4
-1
@@ -11,6 +11,7 @@ import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogResolver;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
@@ -27,6 +28,7 @@ import com.sap.sailing.domain.common.tracking.impl.GPSFixImpl;
|
||||
import com.sap.sailing.domain.ranking.OneDesignRankingMetric;
|
||||
import com.sap.sailing.domain.tracking.DynamicGPSFixTrack;
|
||||
import com.sap.sailing.domain.tracking.LineDetails;
|
||||
import com.sap.sailing.domain.tracking.MarkPositionAtTimePointCache;
|
||||
import com.sap.sailing.domain.tracking.impl.DynamicGPSFixTrackImpl;
|
||||
import com.sap.sailing.domain.tracking.impl.DynamicTrackedRaceImpl;
|
||||
import com.sap.sailing.domain.tracking.impl.TrackedLegImpl;
|
||||
@@ -137,7 +139,6 @@ public class StarbordSideOfStartLineRecognitionTest {
|
||||
Position startStarboardPosition = new DegreePosition(0, 1);
|
||||
Position windwardPosition = new DegreePosition(10, 0.5);
|
||||
MockedTrackedRaceImpl trackedRace = createTrackedRaceWithMarkPositions(startPortPosition, startStarboardPosition, windwardPosition);
|
||||
|
||||
Position p = trackedRace.getOrCreateTrack(trackedRace.getStartLine(now).getStarboardMarkWhileApproachingLine()).
|
||||
getEstimatedPosition(now, /* extrapolate */ false);
|
||||
assertEquals(startStarboardPosition, p);
|
||||
@@ -184,6 +185,8 @@ public class StarbordSideOfStartLineRecognitionTest {
|
||||
when(trackedRace.getTrackedLeg(course.getFirstLeg())).thenReturn(trackedLeg);
|
||||
when(trackedRace.getApproximatePosition(startWaypoint, now)).thenCallRealMethod();
|
||||
when(trackedRace.getApproximatePosition(windwardWaypoint, now)).thenCallRealMethod();
|
||||
when(trackedRace.getApproximatePosition(Matchers.eq(startWaypoint), Matchers.eq(now), Matchers.any(MarkPositionAtTimePointCache.class))).thenCallRealMethod();
|
||||
when(trackedRace.getApproximatePosition(Matchers.eq(windwardWaypoint), Matchers.eq(now), Matchers.any(MarkPositionAtTimePointCache.class))).thenCallRealMethod();
|
||||
return trackedRace;
|
||||
}
|
||||
|
||||
|
||||
+10
-7
@@ -11,6 +11,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
@@ -37,6 +38,7 @@ import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.WindImpl;
|
||||
import com.sap.sailing.domain.polars.NotEnoughDataHasBeenAddedException;
|
||||
import com.sap.sailing.domain.polars.PolarDataService;
|
||||
import com.sap.sailing.domain.tracking.MarkPositionAtTimePointCache;
|
||||
import com.sap.sailing.domain.tracking.TrackedLeg;
|
||||
import com.sap.sailing.domain.tracking.impl.DynamicTrackedRaceImpl;
|
||||
import com.sap.sailing.domain.tracking.impl.TrackedLegImpl;
|
||||
@@ -123,9 +125,10 @@ public class TargetTimeEstimationTest {
|
||||
when(leg.getFrom()).thenReturn(from);
|
||||
when(leg.getTo()).thenReturn(to);
|
||||
|
||||
when(trackedRace.getApproximatePosition(from, timepoint)).thenReturn(startOfLeg);
|
||||
when(trackedRace.getApproximatePosition(to, timepoint)).thenReturn(endOfLeg);
|
||||
|
||||
when(trackedRace.getApproximatePosition(eq(from), eq(timepoint))).thenReturn(startOfLeg);
|
||||
when(trackedRace.getApproximatePosition(eq(to), eq(timepoint))).thenReturn(endOfLeg);
|
||||
when(trackedRace.getApproximatePosition(eq(from), eq(timepoint), any(MarkPositionAtTimePointCache.class))).thenReturn(startOfLeg);
|
||||
when(trackedRace.getApproximatePosition(eq(to), eq(timepoint), any(MarkPositionAtTimePointCache.class))).thenReturn(endOfLeg);
|
||||
|
||||
SpeedWithBearing speedWithBearingPort = new KnotSpeedWithBearingImpl(6, new DegreeBearingImpl(-45));
|
||||
SpeedWithBearingWithConfidence<Void> boatSpeedWithBearingWithConfidencePort = new SpeedWithBearingWithConfidenceImpl<Void>(speedWithBearingPort, 1, null);
|
||||
@@ -141,7 +144,6 @@ public class TargetTimeEstimationTest {
|
||||
//Actual test of functionality
|
||||
Duration duration = trackedLeg.getEstimatedTimeToComplete(mockedPolars, timepoint);
|
||||
assertEquals(213513, duration.asMillis(), 100);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,9 +177,10 @@ public class TargetTimeEstimationTest {
|
||||
when(leg.getFrom()).thenReturn(from);
|
||||
when(leg.getTo()).thenReturn(to);
|
||||
|
||||
when(trackedRace.getApproximatePosition(from, timepoint)).thenReturn(startOfLeg);
|
||||
when(trackedRace.getApproximatePosition(to, timepoint)).thenReturn(endOfLeg);
|
||||
|
||||
when(trackedRace.getApproximatePosition(eq(from), eq(timepoint))).thenReturn(startOfLeg);
|
||||
when(trackedRace.getApproximatePosition(eq(to), eq(timepoint))).thenReturn(endOfLeg);
|
||||
when(trackedRace.getApproximatePosition(eq(from), eq(timepoint), any(MarkPositionAtTimePointCache.class))).thenReturn(startOfLeg);
|
||||
when(trackedRace.getApproximatePosition(eq(to), eq(timepoint), any(MarkPositionAtTimePointCache.class))).thenReturn(endOfLeg);
|
||||
|
||||
SpeedWithBearing speedWithBearingPort = new KnotSpeedWithBearingImpl(11, new DegreeBearingImpl(150));
|
||||
SpeedWithBearingWithConfidence<Void> boatSpeedWithBearingWithConfidencePort = new SpeedWithBearingWithConfidenceImpl<Void>(speedWithBearingPort, 1, null);
|
||||
|
||||
Reference in new issue
Block a user