mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 11:53:53 +00:00
fixed NPE in test case
This commit is contained in:
1 parent
236d01ab65
commit
9efbe42aef
1 file changed
+35
-21
+35
-21
@@ -8,9 +8,12 @@ import java.util.UUID;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import com.mongodb.MongoException;
|
||||
import com.sap.sailing.domain.base.ControlPointWithTwoMarks;
|
||||
import com.sap.sailing.domain.base.CourseBase;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.impl.ControlPointWithTwoMarksImpl;
|
||||
import com.sap.sailing.domain.base.impl.CourseDataImpl;
|
||||
@@ -27,6 +30,7 @@ import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.persistence.DomainObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoRaceLogStoreFactory;
|
||||
import com.sap.sailing.domain.persistence.PersistenceFactory;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStore;
|
||||
import com.sap.sailing.domain.regattalog.RegattaLogStore;
|
||||
import com.sap.sailing.domain.regattalog.impl.EmptyRegattaLogStore;
|
||||
@@ -38,39 +42,48 @@ public abstract class RaceLogMongoDBTest extends AbstractMongoDBTest {
|
||||
|
||||
String raceColumnName = "My.First$Race$1";
|
||||
TimePoint now = null;
|
||||
|
||||
|
||||
MongoObjectFactory mongoObjectFactory = null;
|
||||
DomainObjectFactory domainObjectFactory = null;
|
||||
|
||||
|
||||
public RaceLogMongoDBTest() throws UnknownHostException, MongoException {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
mongoObjectFactory = PersistenceFactory.INSTANCE.getMongoObjectFactory(getMongoService());
|
||||
domainObjectFactory = PersistenceFactory.INSTANCE.getDomainObjectFactory(getMongoService(),
|
||||
DomainFactory.INSTANCE);
|
||||
}
|
||||
|
||||
protected void compareCourseData(CourseBase storedCourse, CourseBase loadedCourse) {
|
||||
assertEquals(storedCourse.getFirstWaypoint().getPassingInstructions(), PassingInstruction.None);
|
||||
assertEquals(loadedCourse.getFirstWaypoint().getPassingInstructions(), PassingInstruction.None);
|
||||
Assert.assertTrue(storedCourse.getFirstWaypoint().getControlPoint() instanceof ControlPointWithTwoMarks);
|
||||
Assert.assertTrue(loadedCourse.getFirstWaypoint().getControlPoint() instanceof ControlPointWithTwoMarks);
|
||||
|
||||
ControlPointWithTwoMarks storedGate = (ControlPointWithTwoMarks) storedCourse.getFirstWaypoint().getControlPoint();
|
||||
ControlPointWithTwoMarks loadedGate = (ControlPointWithTwoMarks) loadedCourse.getFirstWaypoint().getControlPoint();
|
||||
|
||||
|
||||
ControlPointWithTwoMarks storedGate = (ControlPointWithTwoMarks) storedCourse.getFirstWaypoint()
|
||||
.getControlPoint();
|
||||
ControlPointWithTwoMarks loadedGate = (ControlPointWithTwoMarks) loadedCourse.getFirstWaypoint()
|
||||
.getControlPoint();
|
||||
|
||||
assertEquals(storedGate.getId(), loadedGate.getId());
|
||||
assertEquals(storedGate.getName(), loadedGate.getName());
|
||||
|
||||
|
||||
compareMarks(storedGate.getLeft(), loadedGate.getLeft());
|
||||
compareMarks(storedGate.getRight(), loadedGate.getRight());
|
||||
|
||||
|
||||
assertEquals(storedCourse.getLastWaypoint().getPassingInstructions(), PassingInstruction.Port);
|
||||
assertEquals(loadedCourse.getLastWaypoint().getPassingInstructions(), PassingInstruction.Port);
|
||||
Assert.assertTrue(storedCourse.getLastWaypoint().getControlPoint() instanceof Mark);
|
||||
Assert.assertTrue(loadedCourse.getLastWaypoint().getControlPoint() instanceof Mark);
|
||||
|
||||
|
||||
Mark storedMark = (Mark) storedCourse.getLastWaypoint().getControlPoint();
|
||||
Mark loadedMark = (Mark) loadedCourse.getLastWaypoint().getControlPoint();
|
||||
compareMarks(storedMark, loadedMark);
|
||||
}
|
||||
|
||||
|
||||
private void compareMarks(Mark storedMark, Mark loadedMark) {
|
||||
assertEquals(storedMark.getId(), loadedMark.getId());
|
||||
assertEquals(storedMark.getColor(), loadedMark.getColor());
|
||||
@@ -82,16 +95,17 @@ public abstract class RaceLogMongoDBTest extends AbstractMongoDBTest {
|
||||
|
||||
protected CourseBase createCourseBase() {
|
||||
CourseBase course = new CourseDataImpl("Test Course");
|
||||
|
||||
course.addWaypoint(0, new WaypointImpl(new ControlPointWithTwoMarksImpl(UUID.randomUUID(),
|
||||
new MarkImpl(UUID.randomUUID(), "Black", MarkType.BUOY, "black", "round", "circle"),
|
||||
new MarkImpl(UUID.randomUUID(), "Green", MarkType.BUOY, "green", "round", "circle"),
|
||||
"Upper gate")));
|
||||
course.addWaypoint(1, new WaypointImpl(new MarkImpl(UUID.randomUUID(), "White", MarkType.BUOY, "white", "conical", "bold"), PassingInstruction.Port));
|
||||
|
||||
|
||||
course.addWaypoint(0,
|
||||
new WaypointImpl(new ControlPointWithTwoMarksImpl(UUID.randomUUID(), new MarkImpl(UUID.randomUUID(),
|
||||
"Black", MarkType.BUOY, "black", "round", "circle"), new MarkImpl(UUID.randomUUID(), "Green",
|
||||
MarkType.BUOY, "green", "round", "circle"), "Upper gate")));
|
||||
course.addWaypoint(1, new WaypointImpl(new MarkImpl(UUID.randomUUID(), "White", MarkType.BUOY, "white",
|
||||
"conical", "bold"), PassingInstruction.Port));
|
||||
|
||||
return course;
|
||||
}
|
||||
|
||||
|
||||
protected void compareWind(Wind storedWindFix, Wind loadedWindFix) {
|
||||
assertEquals(storedWindFix.getTimePoint(), loadedWindFix.getTimePoint());
|
||||
assertNotNull(storedWindFix.getPosition());
|
||||
@@ -110,14 +124,14 @@ public abstract class RaceLogMongoDBTest extends AbstractMongoDBTest {
|
||||
SpeedWithBearing speedBearing = new KnotSpeedWithBearingImpl(10.4, bearing);
|
||||
return new WindImpl(position, now, speedBearing);
|
||||
}
|
||||
|
||||
|
||||
protected RaceLogStore getRaceLogStore() {
|
||||
return MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStore(mongoObjectFactory, domainObjectFactory);
|
||||
}
|
||||
|
||||
protected RegattaLogStore getRegattaLogStore() {
|
||||
return EmptyRegattaLogStore.INSTANCE;
|
||||
//TODO MongoRegattaLogStoreFactory.INSTANCE.getMongoRegattaLogStore(mongoObjectFactory, domainObjectFactory);
|
||||
// TODO MongoRegattaLogStoreFactory.INSTANCE.getMongoRegattaLogStore(mongoObjectFactory, domainObjectFactory);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user