mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-21 21:25:38 +00:00
fixed tests for TestLapConfiguration
This commit is contained in:
+37
-19
@@ -7,7 +7,9 @@ import static org.junit.Assume.assumeNoException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -17,9 +19,11 @@ import com.sap.sailing.domain.common.MarkType;
|
||||
import com.sap.sailing.domain.common.PassingInstruction;
|
||||
import com.sap.sailing.domain.coursetemplate.ControlPointTemplate;
|
||||
import com.sap.sailing.domain.coursetemplate.CourseTemplate;
|
||||
import com.sap.sailing.domain.coursetemplate.MarkRole;
|
||||
import com.sap.sailing.domain.coursetemplate.MarkTemplate;
|
||||
import com.sap.sailing.domain.coursetemplate.WaypointTemplate;
|
||||
import com.sap.sailing.domain.coursetemplate.impl.CourseTemplateImpl;
|
||||
import com.sap.sailing.domain.coursetemplate.impl.MarkRoleImpl;
|
||||
import com.sap.sailing.domain.coursetemplate.impl.MarkRolePairImpl;
|
||||
import com.sap.sailing.domain.coursetemplate.impl.MarkTemplateImpl;
|
||||
import com.sap.sailing.domain.coursetemplate.impl.RepeatablePartImpl;
|
||||
@@ -29,32 +33,48 @@ import com.sap.sse.common.Util;
|
||||
public class TestLapConfiguration {
|
||||
private CourseTemplate courseTemplate;
|
||||
private MarkTemplate startBoat;
|
||||
private MarkRole startBoatRole;
|
||||
private MarkTemplate pin;
|
||||
private MarkRole pinRole;
|
||||
private MarkTemplate top;
|
||||
private MarkRole one;
|
||||
private MarkTemplate gateLeft;
|
||||
private MarkRole threeP;
|
||||
private MarkTemplate gateRight;
|
||||
private MarkRole threeS;
|
||||
private ControlPointTemplate startFinish;
|
||||
private ControlPointTemplate gate;
|
||||
private Map<MarkRole, MarkTemplate> defaultMarkTemplatesForMarkRoles;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
startBoat = new MarkTemplateImpl("Start Boat", "SB", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.STARTBOAT);
|
||||
startBoatRole = new MarkRoleImpl(UUID.randomUUID(), "Start Boat", "SB");
|
||||
pin = new MarkTemplateImpl("Pin End", "Pin", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.BUOY);
|
||||
pinRole = new MarkRoleImpl(UUID.randomUUID(), "Pin End", "P");
|
||||
top = new MarkTemplateImpl("Windward Mark", "1", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.BUOY);
|
||||
one = new MarkRoleImpl(UUID.randomUUID(), "Windward Mark", "1");
|
||||
gateLeft = new MarkTemplateImpl("Leeward Gate Port", "4p", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.BUOY);
|
||||
threeP = new MarkRoleImpl(UUID.randomUUID(), "Leeward Gate Port", "3p");
|
||||
gateRight = new MarkTemplateImpl("Leeward Gate Starboard", "4s", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.BUOY);
|
||||
startFinish = new MarkRolePairImpl("Start/Finish", "Start/Finish", startBoat, pin);
|
||||
gate = new MarkRolePairImpl("Leeward Gate", "Leeward Gate", gateLeft, gateRight);
|
||||
courseTemplate = new CourseTemplateImpl(UUID.randomUUID(), "L",
|
||||
shortName,
|
||||
threeS = new MarkRoleImpl(UUID.randomUUID(), "Leeward Gate Starboard", "3s");
|
||||
startFinish = new MarkRolePairImpl("Start/Finish", "S/F", startBoatRole, pinRole);
|
||||
gate = new MarkRolePairImpl("Leeward Gate", "LG", threeP, threeS);
|
||||
defaultMarkTemplatesForMarkRoles = new HashMap<>();
|
||||
defaultMarkTemplatesForMarkRoles.put(startBoatRole, startBoat);
|
||||
defaultMarkTemplatesForMarkRoles.put(pinRole, pin);
|
||||
defaultMarkTemplatesForMarkRoles.put(one, top);
|
||||
defaultMarkTemplatesForMarkRoles.put(threeP, gateLeft);
|
||||
defaultMarkTemplatesForMarkRoles.put(threeS, gateRight);
|
||||
courseTemplate = new CourseTemplateImpl(UUID.randomUUID(), "Windward/Leeward", "L",
|
||||
/* marks */ Arrays.asList(startBoat, pin, top, gateLeft, gateRight),
|
||||
/* waypoints */ Arrays.asList(new WaypointTemplateImpl(startFinish, PassingInstruction.Line),
|
||||
new WaypointTemplateImpl(top, PassingInstruction.Port),
|
||||
new WaypointTemplateImpl(one, PassingInstruction.Port),
|
||||
new WaypointTemplateImpl(gate, PassingInstruction.Gate),
|
||||
new WaypointTemplateImpl(top, PassingInstruction.Port),
|
||||
new WaypointTemplateImpl(one, PassingInstruction.Port),
|
||||
new WaypointTemplateImpl(startFinish, PassingInstruction.Line)),
|
||||
defaultMarkTemplatesForMarkRoles,
|
||||
/* associatedRoles */ Collections.emptyMap(),
|
||||
defaultMarkTemplatesForRoles,
|
||||
/* optionaImageURL */ null, new RepeatablePartImpl(/* zeroBasedIndexOfRepeatablePartStart */ 1,
|
||||
/* zeroBasedIndexOfRepeatablePartEnd */ 3), /* Default Number of Laps */ 1);
|
||||
}
|
||||
@@ -62,7 +82,7 @@ public class TestLapConfiguration {
|
||||
@Test
|
||||
public void testSimpleCourseWithOneLap() {
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypointTemplates(1);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, top, startFinish);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, one, startFinish);
|
||||
verify(waypointsOfOneLapper, expected);
|
||||
}
|
||||
|
||||
@@ -79,14 +99,14 @@ public class TestLapConfiguration {
|
||||
@Test
|
||||
public void testSimpleCourseWithTwoLaps() {
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypointTemplates(2);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, top, gate, top, startFinish);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, one, gate, one, startFinish);
|
||||
verify(waypointsOfOneLapper, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCourseWithThreeLaps() {
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypointTemplates(3);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, top, gate, top, gate, top, startFinish);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, one, gate, one, gate, one, startFinish);
|
||||
verify(waypointsOfOneLapper, expected);
|
||||
}
|
||||
|
||||
@@ -94,13 +114,13 @@ public class TestLapConfiguration {
|
||||
public void testExceptionInCaseMarkIsMissing() {
|
||||
startBoat = new MarkTemplateImpl("Start Boat", "SB", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.STARTBOAT);
|
||||
pin = new MarkTemplateImpl("Pin End", "Pin", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.BUOY);
|
||||
startFinish = new MarkRolePairImpl("Start/Finish","Start/Finish", startBoat, pin);
|
||||
startFinish = new MarkRolePairImpl("Start/Finish","Start/Finish", startBoatRole, pinRole);
|
||||
try {
|
||||
courseTemplate = new CourseTemplateImpl("Test",
|
||||
shortName,
|
||||
courseTemplate = new CourseTemplateImpl("Test", "T",
|
||||
/* marks */ Arrays.asList(startBoat),
|
||||
/* waypoints */ Arrays.asList(new WaypointTemplateImpl(startFinish, PassingInstruction.Line)),
|
||||
/* associatedRoles */ Collections.emptyMap(), defaultMarkTemplatesForRoles, /* optionaImageURL */ null);
|
||||
/* defaultMarkRolesForMarkTemplates */ Collections.emptyMap(),
|
||||
/* defaultMarkTemplatesForRoles */ Collections.emptyMap(), /* optionaImageURL */ null);
|
||||
fail("Expected an IllegalArgumentException due to missing mark <pin> but it wasn't thrown");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
@@ -109,13 +129,11 @@ public class TestLapConfiguration {
|
||||
|
||||
@Test
|
||||
public void testZeroLapsOkIfNoRepeatablePart() {
|
||||
startBoat = new MarkTemplateImpl("Start Boat", "SB", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.STARTBOAT);
|
||||
pin = new MarkTemplateImpl("Pin End", "Pin", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.BUOY);
|
||||
startFinish = new MarkRolePairImpl("Start/Finish", "Start/Finish", startBoat, pin);
|
||||
courseTemplate = new CourseTemplateImpl("Test", shortName,
|
||||
courseTemplate = new CourseTemplateImpl("Test", "T",
|
||||
/* marks */ Arrays.asList(startBoat, pin),
|
||||
/* waypoints */ Arrays.asList(new WaypointTemplateImpl(startFinish, PassingInstruction.Line)),
|
||||
/* associatedRoles */ Collections.emptyMap(), defaultMarkTemplatesForRoles, /* optionaImageURL */ null);
|
||||
defaultMarkTemplatesForMarkRoles,
|
||||
/* defaultMarkTemplatesForRoles */ Collections.emptyMap(), /* optionaImageURL */ null);
|
||||
try {
|
||||
courseTemplate.getWaypointTemplates(0);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
Reference in New Issue
Block a user