Bug 5085: added and used constructor with UUID to CourseTemplateImpl

This commit is contained in:
Steffen Jacobs committed 2019-08-13 14:48:50 +02:00
1 parent c3a93fb64c
commit f14aadecf2
3 files changed
+14 -5

No files matched your search

@@ -3178,7 +3178,8 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
tagsDbObject.forEach(t -> tags.add(t.toString()));
final CourseTemplateImpl courseTemplateImpl = new CourseTemplateImpl(name, markTemplates, waypointTemplates, zeroBasedIndexOfRepeatablePartStart,
final CourseTemplateImpl courseTemplateImpl = new CourseTemplateImpl(id, name, markTemplates, waypointTemplates,
zeroBasedIndexOfRepeatablePartStart,
zeroBasedIndexOfRepeatablePartEnd);
courseTemplateImpl.setTags(tags);
return courseTemplateImpl;
@@ -7,6 +7,7 @@ import static org.junit.Assume.assumeNoException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
@@ -42,7 +43,7 @@ public class TestLapConfiguration {
gateRight = new MarkTemplateImpl("Leeward Gate Starboard", "4s", /* color */ null, /* shape */ null, /* pattern */ null, MarkType.BUOY);
startFinish = new ControlPointTemplateImpl("Start/Finish", Arrays.asList(startBoat, pin));
gate = new ControlPointTemplateImpl("Leeward Gate", Arrays.asList(gateLeft, gateRight));
courseTemplate = new CourseTemplateImpl("L",
courseTemplate = new CourseTemplateImpl(UUID.randomUUID(), "L",
/* marks */ Arrays.asList(startBoat, pin, top, gateLeft, gateRight),
/* waypoints */ Arrays.asList(new WaypointTemplateImpl(startFinish, PassingInstruction.Line),
new WaypointTemplateImpl(top, PassingInstruction.Port),
@@ -7,6 +7,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import com.sap.sailing.domain.coursetemplate.CourseTemplate;
import com.sap.sailing.domain.coursetemplate.MarkTemplate;
@@ -38,13 +39,19 @@ public class CourseTemplateImpl extends NamedWithUUIDImpl implements CourseTempl
*/
private final int zeroBasedIndexOfRepeatablePartEnd;
/** Creates a course template with a random UUID. */
public CourseTemplateImpl(String name, Iterable<MarkTemplate> marks, Iterable<WaypointTemplate> waypoints) {
this(name, marks, waypoints, -1, -1); // no repeatable part
this(UUID.randomUUID(), name, marks, waypoints);
}
public CourseTemplateImpl(UUID id, String name, Iterable<MarkTemplate> marks,
Iterable<WaypointTemplate> waypoints) {
this(id, name, marks, waypoints, -1, -1); // no repeatable part
}
public CourseTemplateImpl(String name, Iterable<MarkTemplate> marks, Iterable<WaypointTemplate> waypoints,
public CourseTemplateImpl(UUID id, String name, Iterable<MarkTemplate> marks, Iterable<WaypointTemplate> waypoints,
int zeroBasedIndexOfRepeatablePartStart, int zeroBasedIndexOfRepeatablePartEnd) {
super(name);
super(name, id);
if ((zeroBasedIndexOfRepeatablePartEnd == -1) != (zeroBasedIndexOfRepeatablePartStart == -1)) {
throw new IllegalArgumentException("Either both, start and end of repeatable sub-sequence indices must be -1 or none: "+
zeroBasedIndexOfRepeatablePartStart+".."+zeroBasedIndexOfRepeatablePartEnd);