mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 10:09:42 +00:00
add failing testcase for RaceLogStartTimeEvent deserialization
This commit is contained in:
1 parent
bdd3113e14
commit
43db0476eb
3 files changed
+1600
No files matched your search
@@ -3,5 +3,6 @@
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
File diff suppressed because it is too large.
Load diff
+56
@@ -0,0 +1,56 @@
|
||||
package com.sap.sailing.server.gateway.deserialization.test.racelog;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogRaceStatusEvent;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.server.gateway.deserialization.impl.Helpers;
|
||||
import com.sap.sailing.server.gateway.deserialization.racelog.impl.RaceLogDeserializer;
|
||||
import com.sap.sailing.server.gateway.deserialization.racelog.impl.RaceLogEventDeserializer;
|
||||
|
||||
public class RaceLogDeserializationTest {
|
||||
private RaceLog parsedRaceLog;
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException, ParseException {
|
||||
parsedRaceLog = deserializeFromFile();
|
||||
}
|
||||
|
||||
private static RaceLog deserializeFromFile() throws IOException, ParseException {
|
||||
InputStream raceLogStream = RaceLogDeserializationTest.class.getResourceAsStream("/racelog.json");
|
||||
RaceLogDeserializer deserializer = new RaceLogDeserializer(RaceLogEventDeserializer.create(DomainFactory.INSTANCE));
|
||||
|
||||
Object parsedRaceLog = JSONValue.parseWithException(new InputStreamReader(raceLogStream));
|
||||
JSONObject parsedRaceLogJson = Helpers.toJSONObjectSafe(parsedRaceLog);
|
||||
|
||||
return deserializer.deserialize(parsedRaceLogJson);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNextStatusDeserialization() throws IOException, ParseException {
|
||||
parsedRaceLog.lockForRead();
|
||||
for (RaceLogEvent event : parsedRaceLog.getFixes()) {
|
||||
if (event instanceof RaceLogRaceStatusEvent) {
|
||||
RaceLogRaceStatus status = ((RaceLogRaceStatusEvent) event).getNextStatus();
|
||||
if (status == null) {
|
||||
System.out.println(event);
|
||||
}
|
||||
assertNotNull(status);
|
||||
}
|
||||
}
|
||||
parsedRaceLog.unlockAfterRead();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user