mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-22 21:55:39 +00:00
Bug 5085: adjusted CourseTemplate to fit new model definition
This commit is contained in:
+6
-5
@@ -55,7 +55,7 @@ public class TestLapConfiguration {
|
||||
|
||||
@Test
|
||||
public void testSimpleCourseWithOneLap() {
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypoints(1);
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypointTemplates(1);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, top, startFinish);
|
||||
verify(waypointsOfOneLapper, expected);
|
||||
}
|
||||
@@ -72,14 +72,14 @@ public class TestLapConfiguration {
|
||||
|
||||
@Test
|
||||
public void testSimpleCourseWithTwoLaps() {
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypoints(2);
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypointTemplates(2);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, top, gate, top, startFinish);
|
||||
verify(waypointsOfOneLapper, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleCourseWithThreeLaps() {
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypoints(3);
|
||||
final Iterable<WaypointTemplate> waypointsOfOneLapper = courseTemplate.getWaypointTemplates(3);
|
||||
final List<ControlPointTemplate> expected = Arrays.asList(startFinish, top, gate, top, gate, top, startFinish);
|
||||
verify(waypointsOfOneLapper, expected);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class TestLapConfiguration {
|
||||
courseTemplate = new CourseTemplateImpl("Test", /* marks */ Arrays.asList(startBoat, pin),
|
||||
/* waypoints */ Arrays.asList(new WaypointTemplateImpl(startFinish, PassingInstruction.Line)));
|
||||
try {
|
||||
courseTemplate.getWaypoints(0);
|
||||
courseTemplate.getWaypointTemplates(0);
|
||||
} catch (IllegalArgumentException e) {
|
||||
assumeNoException("No IllegalArgumentException should have been thrown for zero laps because the course has no repeatable part", e);
|
||||
}
|
||||
@@ -116,7 +116,8 @@ public class TestLapConfiguration {
|
||||
@Test
|
||||
public void testIllegalArgumentExceptionForZeroLaps() {
|
||||
try {
|
||||
courseTemplate.getWaypoints(/* illegal to request 0 laps if course template defines repeatable part */ 0);
|
||||
courseTemplate
|
||||
.getWaypointTemplates(/* illegal to request 0 laps if course template defines repeatable part */ 0);
|
||||
fail("Expected an IllegalArgumentException but none was thrown");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// expected
|
||||
|
||||
+5
-2
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.domain.coursetemplate;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.common.security.SecuredDomainType;
|
||||
@@ -42,7 +43,7 @@ public interface CourseTemplate extends WithOptionalRepeatablePart, NamedWithUUI
|
||||
* waypoint sequence but, e.g., as proposals for spare or alternative marks. For example, templates for alternative
|
||||
* marks for the windward mark may be returned to quickly accommodate for wind shifts.
|
||||
*/
|
||||
Iterable<MarkTemplate> getMarks();
|
||||
Iterable<MarkTemplate> getMarkTemplates();
|
||||
|
||||
/**
|
||||
* Returns a sequence of {@link WaypointTemplate}s that can be use to construct a course. If this course template
|
||||
@@ -61,7 +62,9 @@ public interface CourseTemplate extends WithOptionalRepeatablePart, NamedWithUUI
|
||||
* repetitions of the repeatable part is usually one less than the number of laps, therefore this
|
||||
* limitation.
|
||||
*/
|
||||
Iterable<WaypointTemplate> getWaypoints(int numberOfLaps);
|
||||
Iterable<WaypointTemplate> getWaypointTemplates(int numberOfLaps);
|
||||
|
||||
Map<MarkTemplate, String> getAssociatedRoles();
|
||||
|
||||
public static TypeRelativeObjectIdentifier getTypeRelativeObjectIdentifier(UUID courseTemplateUUID) {
|
||||
return new TypeRelativeObjectIdentifier(courseTemplateUUID.toString());
|
||||
|
||||
+16
-2
@@ -1,9 +1,11 @@
|
||||
package com.sap.sailing.domain.coursetemplate.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sap.sailing.domain.coursetemplate.CourseTemplate;
|
||||
@@ -20,6 +22,8 @@ public class CourseTemplateImpl extends NamedWithUUIDImpl implements CourseTempl
|
||||
|
||||
private final ArrayList<WaypointTemplate> waypoints;
|
||||
|
||||
private final Map<MarkTemplate, String> associatedRoles = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The index into {@link #waypoints} of the first waypoint that is to be cloned for repetitive laps.
|
||||
* -1 means no repeatable part.
|
||||
@@ -73,13 +77,13 @@ public class CourseTemplateImpl extends NamedWithUUIDImpl implements CourseTempl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<MarkTemplate> getMarks() {
|
||||
public Iterable<MarkTemplate> getMarkTemplates() {
|
||||
return marks;
|
||||
}
|
||||
|
||||
// TODO move to CourseTemplateConfigurations
|
||||
@Override
|
||||
public Iterable<WaypointTemplate> getWaypoints(int numberOfLaps) {
|
||||
public Iterable<WaypointTemplate> getWaypointTemplates(int numberOfLaps) {
|
||||
final Iterable<WaypointTemplate> result;
|
||||
if (hasRepeatablePart()) {
|
||||
if (numberOfLaps < 1) {
|
||||
@@ -117,4 +121,14 @@ public class CourseTemplateImpl extends NamedWithUUIDImpl implements CourseTempl
|
||||
return hasRepeatablePart() ? new Pair<>(zeroBasedIndexOfRepeatablePartStart, zeroBasedIndexOfRepeatablePartEnd)
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<MarkTemplate, String> getAssociatedRoles() {
|
||||
return associatedRoles;
|
||||
}
|
||||
|
||||
public void setAssociatedRoles(Map<MarkTemplate, String> associatedRoles) {
|
||||
this.associatedRoles.clear();
|
||||
this.associatedRoles.putAll(associatedRoles);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user