mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
Added a test case which ensures that TrackedRace.attachRegattaLog is
called when setting a TrackedRace to a RaceColumn
This commit is contained in:
1 parent
bd63a11f1a
commit
87019c44e2
1 file changed
+80
+80
@@ -0,0 +1,80 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.impl.RegattaLogImpl;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.impl.FlexibleLeaderboardImpl;
|
||||
import com.sap.sailing.domain.leaderboard.impl.LowPoint;
|
||||
import com.sap.sailing.domain.racelog.impl.EmptyRaceLogStore;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
import com.sap.sailing.domain.regattalog.RegattaLogStore;
|
||||
import com.sap.sailing.domain.test.mock.MockedTrackedRace;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
public class RegattaLogAttachOnTrackedRaceTest {
|
||||
|
||||
private class MyMockedRegattaLogStore implements RegattaLogStore {
|
||||
private Map<RegattaLikeIdentifier, RegattaLog> regattaLogs = new HashMap<>();
|
||||
@Override
|
||||
public RegattaLog getRegattaLog(RegattaLikeIdentifier regattaLikeId, boolean ignoreCache) {
|
||||
if(!regattaLogs.containsKey(regattaLikeId)) {
|
||||
regattaLogs.put(regattaLikeId, new RegattaLogImpl(regattaLikeId));
|
||||
}
|
||||
return regattaLogs.get(regattaLikeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRegattaLog(RegattaLikeIdentifier regattaLikeId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addImportedRegattaLog(RegattaLog regattaLog, RegattaLikeIdentifier identifier) {
|
||||
}
|
||||
}
|
||||
|
||||
private class MyMockedTrackedRace extends MockedTrackedRace {
|
||||
private static final long serialVersionUID = -5450144964435682919L;
|
||||
|
||||
private RegattaLog regattaLog;
|
||||
@Override
|
||||
public void attachRegattaLog(RegattaLog regattaLog) {
|
||||
this.regattaLog = regattaLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<RegattaLog> getAttachedRegattaLogs() {
|
||||
return Collections.singletonList(regattaLog);
|
||||
}
|
||||
}
|
||||
|
||||
private FlexibleLeaderboard leaderboard;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
leaderboard = new FlexibleLeaderboardImpl(EmptyRaceLogStore.INSTANCE, new MyMockedRegattaLogStore(), "", null, new LowPoint(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttachRegattaLogIsCalledWhenTrackedRaceIsSetToARaceColumn() {
|
||||
RaceColumn column = leaderboard.addRaceColumn("R1", false);
|
||||
TrackedRace trackedRace = new MyMockedTrackedRace();
|
||||
Fleet defaultFleet = Util.get(column.getFleets(), 0);
|
||||
column.setTrackedRace(defaultFleet, trackedRace);
|
||||
assertEquals(1, Util.size(trackedRace.getAttachedRegattaLogs()));
|
||||
assertSame(leaderboard.getRegattaLog(), Util.get(trackedRace.getAttachedRegattaLogs(), 0));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user