mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
# removed all direct access to MillisecondsTimePoint.now() (and similar) in RaceState and Procedures, you have to provide the current time
# added a test for IndividualRecallFinder # fixed a bug in IndividualRecallFinder discovered by test # fixed a bug in GateStartRacingProcedure
This commit is contained in:
1 parent
a9691de5e9
commit
a414b61f88
25 files changed
+174
-95
No files matched your search
+3
-3
@@ -1,7 +1,7 @@
|
||||
package com.sap.sailing.domain.racelog.analyzing.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -47,7 +47,7 @@ public class FinishingTimeFinderTest extends PassAwareRaceLogAnalyzerTest<Finish
|
||||
raceLog.add(event1);
|
||||
raceLog.add(event2);
|
||||
|
||||
assertEquals(event2.getTimePoint(), analyzer.analyze());
|
||||
assertSame(event2.getTimePoint(), analyzer.analyze());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -60,6 +60,6 @@ public class FinishingTimeFinderTest extends PassAwareRaceLogAnalyzerTest<Finish
|
||||
raceLog.add(event1);
|
||||
raceLog.add(event2);
|
||||
|
||||
assertEquals(event1.getTimePoint(), analyzer.analyze());
|
||||
assertSame(event1.getTimePoint(), analyzer.analyze());
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.sap.sailing.domain.racelog.analyzing.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventAuthor;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
import com.sap.sailing.domain.racelog.analyzing.impl.IndividualRecallFinder;
|
||||
|
||||
public class IndividualRecallFinderTest extends PassAwareRaceLogAnalyzerTest<IndividualRecallFinder, TimePoint> {
|
||||
|
||||
@Override
|
||||
protected TargetPair getTargetEventsAndResultForPassAwareTests(
|
||||
int passId, RaceLogEventAuthor author) {
|
||||
RaceLogFlagEvent event = createEvent(RaceLogFlagEvent.class, 1, passId, author);
|
||||
when(event.getUpperFlag()).thenReturn(Flags.XRAY);
|
||||
when(event.isDisplayed()).thenReturn(true);
|
||||
return new TargetPair(Arrays.asList(event), event.getTimePoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndividualRecallFinder createAnalyzer(RaceLog raceLog) {
|
||||
return new IndividualRecallFinder(raceLog) {
|
||||
@Override
|
||||
protected boolean isRelevant(RaceLogFlagEvent flagEvent) {
|
||||
return flagEvent.getUpperFlag().equals(Flags.XRAY) && flagEvent.isDisplayed();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullForNone() {
|
||||
RaceLogEvent event1 = createEvent(RaceLogEvent.class, 1);
|
||||
raceLog.add(event1);
|
||||
assertNull(analyzer.analyze());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMostRecent() {
|
||||
RaceLogFlagEvent event1 = createEvent(RaceLogFlagEvent.class, 1);
|
||||
when(event1.getUpperFlag()).thenReturn(Flags.XRAY);
|
||||
when(event1.isDisplayed()).thenReturn(true);
|
||||
RaceLogFlagEvent event2 = createEvent(RaceLogFlagEvent.class, 2);
|
||||
when(event2.getUpperFlag()).thenReturn(Flags.XRAY);
|
||||
when(event2.isDisplayed()).thenReturn(true);
|
||||
|
||||
raceLog.add(event1);
|
||||
raceLog.add(event2);
|
||||
|
||||
assertEquals(event2.getTimePoint(), analyzer.analyze());
|
||||
}
|
||||
|
||||
}
|
||||
+6
-4
@@ -35,6 +35,7 @@ public class RaceStateTest {
|
||||
private RaceLogEventFactory factory;
|
||||
private RacingProcedureType defaultRacingProcedureType;
|
||||
private RaceStateChangedListener listener;
|
||||
private TimePoint nowMock;
|
||||
|
||||
private RaceState state;
|
||||
|
||||
@@ -45,6 +46,7 @@ public class RaceStateTest {
|
||||
factory = RaceLogEventFactory.INSTANCE;
|
||||
defaultRacingProcedureType = RacingProcedureType.RRS26;
|
||||
listener = mock(RaceStateChangedListener.class);
|
||||
nowMock = mock(TimePoint.class);
|
||||
|
||||
state = new RaceState2Impl(raceLog, author, factory, defaultRacingProcedureType);
|
||||
}
|
||||
@@ -68,7 +70,7 @@ public class RaceStateTest {
|
||||
state.addChangedListener(listener);
|
||||
|
||||
TimePoint startTime = MillisecondsTimePoint.now().plus(60 * 60 * 1000);
|
||||
state.setStartTime(startTime);
|
||||
state.setStartTime(nowMock, startTime);
|
||||
|
||||
assertEquals(startTime, state.getStartTime());
|
||||
assertEquals(RaceLogRaceStatus.SCHEDULED, state.getStatus());
|
||||
@@ -113,10 +115,10 @@ public class RaceStateTest {
|
||||
public void testInvalidateAfterAdvancePass() throws InterruptedException {
|
||||
state.addChangedListener(listener);
|
||||
|
||||
state.setStartTime(new MillisecondsTimePoint(1));
|
||||
state.setStartTime(nowMock, new MillisecondsTimePoint(1));
|
||||
Thread.sleep(100);
|
||||
state.setFinishedTime(new MillisecondsTimePoint(10));
|
||||
state.setCourseDesign(mock(CourseBase.class));
|
||||
state.setCourseDesign(nowMock, mock(CourseBase.class));
|
||||
|
||||
state.setAdvancePass(mock(TimePoint.class));
|
||||
|
||||
@@ -137,7 +139,7 @@ public class RaceStateTest {
|
||||
RacingProcedure oldProcedure = state.getRacingProcedure();
|
||||
assertEquals(defaultRacingProcedureType, oldProcedure.getType());
|
||||
|
||||
state.setRacingProcedure(RacingProcedureType.ESS);
|
||||
state.setRacingProcedure(nowMock, RacingProcedureType.ESS);
|
||||
|
||||
RacingProcedure newProcedure = state.getRacingProcedure();
|
||||
assertEquals(RacingProcedureType.ESS, newProcedure.getType());
|
||||
|
||||
Reference in new issue
Block a user