From 2e686866ffad7de9a282706d45a7bf1cd46c942b Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Thu, 29 Sep 2016 16:37:45 +0200 Subject: [PATCH] fixed more tests by mocking both variants of getApproximatePosition Change-Id: I51bacd50a7b7863fbd9374b90267d641b1717333 --- .../StarbordSideOfStartLineRecognitionTest.java | 5 ++++- .../domain/test/TargetTimeEstimationTest.java | 17 ++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/StarbordSideOfStartLineRecognitionTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/StarbordSideOfStartLineRecognitionTest.java index 2434b9ce7af..c8a621c5707 100755 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/StarbordSideOfStartLineRecognitionTest.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/StarbordSideOfStartLineRecognitionTest.java @@ -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; } diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/TargetTimeEstimationTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/TargetTimeEstimationTest.java index b4a8a8bf09a..94b58e36ce3 100644 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/TargetTimeEstimationTest.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/TargetTimeEstimationTest.java @@ -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 boatSpeedWithBearingWithConfidencePort = new SpeedWithBearingWithConfidenceImpl(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 boatSpeedWithBearingWithConfidencePort = new SpeedWithBearingWithConfidenceImpl(speedWithBearingPort, 1, null);