mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-21 21:25:38 +00:00
adding junit test cases for serialization and deserialization of orc certificate
This commit is contained in:
+394
@@ -0,0 +1,394 @@
|
||||
{
|
||||
"rms":[
|
||||
|
||||
{
|
||||
"NatAuth":"GRE",
|
||||
"BIN":"GR4988",
|
||||
"CertNo":"000905",
|
||||
"RefNo":"GRE01015120",
|
||||
"SailNo":"GRE-4988",
|
||||
"YachtName":"GLAFKI II2",
|
||||
"Class":"ONE-OFF",
|
||||
"Builder":"MIKE PARRY",
|
||||
"Designer":"ROB HUMPHREYS",
|
||||
"Address3":"IO CHANION",
|
||||
"C_Type":"CLUB",
|
||||
"Division":"R",
|
||||
"IssueDate":"2019-03-09T22:09:46.000Z",
|
||||
"Age_Year":1981,
|
||||
"CrewWT":520,
|
||||
"LOA":9.225,
|
||||
"IMSL":7.118,
|
||||
"Draft":1.784,
|
||||
"MB":3.158,
|
||||
"Dspl_Measurement":2427,
|
||||
"Stability_Index":112.6,
|
||||
"Dynamic_Allowance":0,
|
||||
"GPH":657.9,
|
||||
"TMF_Inshore":0.9475,
|
||||
"ILCWA":712.4,
|
||||
"TMF_Offshore":0.9351,
|
||||
"OSN":641.6,
|
||||
"CDL":7.481,
|
||||
"TN_Offshore_Low":0.9136,
|
||||
"TN_Offshore_Medium":1.1487,
|
||||
"TN_Offshore_High":1.2752,
|
||||
"TN_Inshore_Low":0.7117,
|
||||
"TN_Inshore_Medium":0.946,
|
||||
"TN_Inshore_High":1.0685,
|
||||
"TND_Offshore_Low":738.8,
|
||||
"TND_Offshore_Medium":587.6,
|
||||
"TND_Offshore_High":529.3,
|
||||
"TND_Inshore_Low":948.4,
|
||||
"TND_Inshore_Medium":713.5,
|
||||
"TND_Inshore_High":631.7,
|
||||
"Double_Handed_TOD":null,
|
||||
"Double_Handed_TOT":null,
|
||||
"OSN_Jibs":661,
|
||||
"TMF_Jibs":0.9077,
|
||||
"Dspl_Sailing":2955,
|
||||
"WSS":15.63,
|
||||
"Area_Main":30.18,
|
||||
"Area_Jib":23.35,
|
||||
"Area_Sym":49.95,
|
||||
"Area_ASym":49.37,
|
||||
"GPH_Jibs":679.9,
|
||||
"GPH_Jibs_TOT":0.8825,
|
||||
"GPH_DH":0,
|
||||
"GPH_DH_TOT":0,
|
||||
"Allowances":{
|
||||
"Beat":[
|
||||
1036.9,
|
||||
864.7,
|
||||
780.4,
|
||||
754,
|
||||
743.7,
|
||||
739.4,
|
||||
737.3
|
||||
],
|
||||
"Run":[
|
||||
1049.1,
|
||||
843,
|
||||
709.9,
|
||||
625.2,
|
||||
569.2,
|
||||
535.4,
|
||||
481.8
|
||||
],
|
||||
"BeatAngle":[
|
||||
40.8,
|
||||
40.8,
|
||||
38.2,
|
||||
37.2,
|
||||
36.8,
|
||||
36.8,
|
||||
37.5
|
||||
],
|
||||
"GybeAngle":[
|
||||
147.5,
|
||||
151,
|
||||
153.5,
|
||||
168.9,
|
||||
180,
|
||||
180,
|
||||
180
|
||||
],
|
||||
"WL":[
|
||||
1043,
|
||||
853.8,
|
||||
745.2,
|
||||
689.6,
|
||||
656.5,
|
||||
637.4,
|
||||
609.5
|
||||
],
|
||||
"CR":[
|
||||
890.9,
|
||||
726.2,
|
||||
639.4,
|
||||
589.6,
|
||||
559.1,
|
||||
538.7,
|
||||
511.2
|
||||
],
|
||||
"OC":[
|
||||
1043.6,
|
||||
805.8,
|
||||
678.6,
|
||||
609.8,
|
||||
572.4,
|
||||
541.2,
|
||||
486.8
|
||||
],
|
||||
"NS":[
|
||||
929.4,
|
||||
753.6,
|
||||
660.1,
|
||||
606.1,
|
||||
572.9,
|
||||
551,
|
||||
522.5
|
||||
],
|
||||
"OL":[
|
||||
991.7,
|
||||
813.8,
|
||||
724.1,
|
||||
679.6,
|
||||
654.6,
|
||||
638.3,
|
||||
611.9
|
||||
],
|
||||
"R52.1":[
|
||||
{
|
||||
"twsInKts":7.5,
|
||||
"allInSPNM":561.1
|
||||
},
|
||||
{
|
||||
"twsInKts":8.5,
|
||||
"allInSPNM":562.1
|
||||
},
|
||||
{
|
||||
"twsInKts":9.5,
|
||||
"allInSPNM":563.1
|
||||
},
|
||||
{
|
||||
"twsInKts":12.5,
|
||||
"allInSPNM":564.1
|
||||
},
|
||||
{
|
||||
"twsInKts":16.5,
|
||||
"allInSPNM":565.1
|
||||
},
|
||||
{
|
||||
"twsInKts":20.5,
|
||||
"allInSPNM":566.1
|
||||
},
|
||||
{
|
||||
"twsInKts":30.5,
|
||||
"allInSPNM":567.1
|
||||
}
|
||||
|
||||
],
|
||||
"R60.1":[
|
||||
{
|
||||
"twsInKts":7.5,
|
||||
"allInSPNM":511.1
|
||||
},
|
||||
{
|
||||
"twsInKts":8.5,
|
||||
"allInSPNM":512.1
|
||||
},
|
||||
{
|
||||
"twsInKts":9.5,
|
||||
"allInSPNM":513.1
|
||||
},
|
||||
{
|
||||
"twsInKts":12.5,
|
||||
"allInSPNM":514.1
|
||||
},
|
||||
{
|
||||
"twsInKts":16.5,
|
||||
"allInSPNM":515.1
|
||||
},
|
||||
{
|
||||
"twsInKts":20.5,
|
||||
"allInSPNM":516.1
|
||||
},
|
||||
{
|
||||
"twsInKts":30.5,
|
||||
"allInSPNM":517.1
|
||||
}
|
||||
|
||||
],
|
||||
"R75.1":[
|
||||
{
|
||||
"twsInKts":7.5,
|
||||
"allInSPNM":521.1
|
||||
},
|
||||
{
|
||||
"twsInKts":8.5,
|
||||
"allInSPNM":522.1
|
||||
},
|
||||
{
|
||||
"twsInKts":9.5,
|
||||
"allInSPNM":523.1
|
||||
},
|
||||
{
|
||||
"twsInKts":12.5,
|
||||
"allInSPNM":524.1
|
||||
},
|
||||
{
|
||||
"twsInKts":16.5,
|
||||
"allInSPNM":525.1
|
||||
},
|
||||
{
|
||||
"twsInKts":20.5,
|
||||
"allInSPNM":526.1
|
||||
},
|
||||
{
|
||||
"twsInKts":30.5,
|
||||
"allInSPNM":527.1
|
||||
}
|
||||
|
||||
],
|
||||
"R150.1":[
|
||||
{
|
||||
"twsInKts":7.5,
|
||||
"allInSPNM":531.1
|
||||
},
|
||||
{
|
||||
"twsInKts":8.5,
|
||||
"allInSPNM":532.1
|
||||
},
|
||||
{
|
||||
"twsInKts":9.5,
|
||||
"allInSPNM":533.1
|
||||
},
|
||||
{
|
||||
"twsInKts":12.5,
|
||||
"allInSPNM":534.1
|
||||
},
|
||||
{
|
||||
"twsInKts":16.5,
|
||||
"allInSPNM":535.1
|
||||
},
|
||||
{
|
||||
"twsInKts":20.5,
|
||||
"allInSPNM":536.1
|
||||
},
|
||||
{
|
||||
"twsInKts":30.5,
|
||||
"allInSPNM":537.1
|
||||
}
|
||||
|
||||
],
|
||||
"R90.1":[
|
||||
{
|
||||
"twsInKts":7.5,
|
||||
"allInSPNM":541.1
|
||||
},
|
||||
{
|
||||
"twsInKts":8.5,
|
||||
"allInSPNM":542.1
|
||||
},
|
||||
{
|
||||
"twsInKts":9.5,
|
||||
"allInSPNM":543.1
|
||||
},
|
||||
{
|
||||
"twsInKts":12.5,
|
||||
"allInSPNM":544.1
|
||||
},
|
||||
{
|
||||
"twsInKts":16.5,
|
||||
"allInSPNM":545.1
|
||||
},
|
||||
{
|
||||
"twsInKts":20.5,
|
||||
"allInSPNM":546.1
|
||||
},
|
||||
{
|
||||
"twsInKts":30.5,
|
||||
"allInSPNM":547.1
|
||||
}
|
||||
|
||||
],
|
||||
"R110.1":[
|
||||
{
|
||||
"twsInKts":7.5,
|
||||
"allInSPNM":551.1
|
||||
},
|
||||
{
|
||||
"twsInKts":8.5,
|
||||
"allInSPNM":552.1
|
||||
},
|
||||
{
|
||||
"twsInKts":9.5,
|
||||
"allInSPNM":553.1
|
||||
},
|
||||
{
|
||||
"twsInKts":12.5,
|
||||
"allInSPNM":554.1
|
||||
},
|
||||
{
|
||||
"twsInKts":16.5,
|
||||
"allInSPNM":555.1
|
||||
},
|
||||
{
|
||||
"twsInKts":20.5,
|
||||
"allInSPNM":556.1
|
||||
},
|
||||
{
|
||||
"twsInKts":30.5,
|
||||
"allInSPNM":557.1
|
||||
}
|
||||
|
||||
],
|
||||
"R120.1":[
|
||||
{
|
||||
"twsInKts":7.5,
|
||||
"allInSPNM":571.1
|
||||
},
|
||||
{
|
||||
"twsInKts":8.5,
|
||||
"allInSPNM":572.1
|
||||
},
|
||||
{
|
||||
"twsInKts":9.5,
|
||||
"allInSPNM":573.1
|
||||
},
|
||||
{
|
||||
"twsInKts":12.5,
|
||||
"allInSPNM":574.1
|
||||
},
|
||||
{
|
||||
"twsInKts":16.5,
|
||||
"allInSPNM":575.1
|
||||
},
|
||||
{
|
||||
"twsInKts":20.5,
|
||||
"allInSPNM":576.1
|
||||
},
|
||||
{
|
||||
"twsInKts":30.5,
|
||||
"allInSPNM":577.1
|
||||
}
|
||||
|
||||
],
|
||||
"R135.1":[
|
||||
{
|
||||
"twsInKts":7.5,
|
||||
"allInSPNM":581.1
|
||||
},
|
||||
{
|
||||
"twsInKts":8.5,
|
||||
"allInSPNM":582.1
|
||||
},
|
||||
{
|
||||
"twsInKts":9.5,
|
||||
"allInSPNM":583.1
|
||||
},
|
||||
{
|
||||
"twsInKts":12.5,
|
||||
"allInSPNM":584.1
|
||||
},
|
||||
{
|
||||
"twsInKts":16.5,
|
||||
"allInSPNM":585.1
|
||||
},
|
||||
{
|
||||
"twsInKts":20.5,
|
||||
"allInSPNM":586.1
|
||||
},
|
||||
{
|
||||
"twsInKts":30.5,
|
||||
"allInSPNM":587.1
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
+215
@@ -0,0 +1,215 @@
|
||||
{
|
||||
"rms": [
|
||||
{
|
||||
"NatAuth": "GRE",
|
||||
"BIN": "GR49735",
|
||||
"CertNo": "000021",
|
||||
"RefNo": "GRE01015829",
|
||||
"SailNo": "GRE-49735",
|
||||
"YachtName": "NEMO",
|
||||
"Class": "PHANTOM 34",
|
||||
"Builder": "Genzel",
|
||||
"Designer": "Streuer",
|
||||
"Address3": "NO RAHON",
|
||||
"C_Type": "CLUB",
|
||||
"Division": "C",
|
||||
"IssueDate": "2019-06-11T21:37:02.000Z",
|
||||
"Age_Year": 1988,
|
||||
"CrewWT": 400,
|
||||
"LOA": 10.3,
|
||||
"IMSL": 8.518,
|
||||
"Draft": 1.777,
|
||||
"MB": 3.15,
|
||||
"Dspl_Measurement": 6386,
|
||||
"Stability_Index": 131.7,
|
||||
"Dynamic_Allowance": 0.702,
|
||||
"GPH": 780.1,
|
||||
"TMF_Inshore": 0.8017,
|
||||
"ILCWA": 842,
|
||||
"TMF_Offshore": 0.798,
|
||||
"OSN": 751.9,
|
||||
"CDL": 7.056,
|
||||
"TN_Offshore_Low": 0.7209,
|
||||
"TN_Offshore_Medium": 0.9908,
|
||||
"TN_Offshore_High": 1.1542,
|
||||
"TN_Inshore_Low": 0.5529,
|
||||
"TN_Inshore_Medium": 0.7913,
|
||||
"TN_Inshore_High": 0.9571,
|
||||
"TND_Offshore_Low": 936.3,
|
||||
"TND_Offshore_Medium": 681.3,
|
||||
"TND_Offshore_High": 584.8,
|
||||
"TND_Inshore_Low": 1220.8,
|
||||
"TND_Inshore_Medium": 853,
|
||||
"TND_Inshore_High": 705.3,
|
||||
"Double_Handed_TOD": null,
|
||||
"Double_Handed_TOT": null,
|
||||
"OSN_Jibs": 751.9,
|
||||
"TMF_Jibs": 0.798,
|
||||
"Dspl_Sailing": 7116,
|
||||
"WSS": 27.39,
|
||||
"Area_Main": 24.97,
|
||||
"Area_Jib": 35.81,
|
||||
"Area_Sym": 0,
|
||||
"Area_ASym": 0,
|
||||
"GPH_Jibs": 780.1,
|
||||
"GPH_Jibs_TOT": 0.7691,
|
||||
"GPH_DH": 0,
|
||||
"GPH_DH_TOT": 0,
|
||||
"Allowances": {
|
||||
"Beat": [
|
||||
1363.4,
|
||||
1113.9,
|
||||
981.7,
|
||||
892.9,
|
||||
841.8,
|
||||
822.5,
|
||||
818.8
|
||||
],
|
||||
"Run": [
|
||||
1368.9,
|
||||
1036.8,
|
||||
849.8,
|
||||
734.8,
|
||||
653.5,
|
||||
592.3,
|
||||
531
|
||||
],
|
||||
"BeatAngle": [
|
||||
45.9,
|
||||
43.6,
|
||||
42.7,
|
||||
43.1,
|
||||
43.2,
|
||||
42.8,
|
||||
43
|
||||
],
|
||||
"GybeAngle": [
|
||||
167.1,
|
||||
167.8,
|
||||
168.9,
|
||||
170,
|
||||
170.1,
|
||||
171.4,
|
||||
175.4
|
||||
],
|
||||
"WL": [
|
||||
1366.2,
|
||||
1075.4,
|
||||
915.7,
|
||||
813.8,
|
||||
747.7,
|
||||
707.4,
|
||||
674.9
|
||||
],
|
||||
"CR": [
|
||||
1111.7,
|
||||
882.2,
|
||||
754.7,
|
||||
678,
|
||||
630.1,
|
||||
599.8,
|
||||
567.2
|
||||
],
|
||||
"OC": [
|
||||
1366.4,
|
||||
1009.6,
|
||||
820.8,
|
||||
702.4,
|
||||
636.3,
|
||||
593.1,
|
||||
536.8
|
||||
],
|
||||
"NS": [
|
||||
1111.7,
|
||||
882.2,
|
||||
754.7,
|
||||
678,
|
||||
630.1,
|
||||
599.8,
|
||||
567.2
|
||||
],
|
||||
"OL": [
|
||||
1299.8,
|
||||
1037,
|
||||
892.2,
|
||||
800.5,
|
||||
743.6,
|
||||
712.9,
|
||||
687.5
|
||||
],
|
||||
"R52": [
|
||||
866.3,
|
||||
724.9,
|
||||
642.2,
|
||||
586.7,
|
||||
561.7,
|
||||
553.2,
|
||||
549.9
|
||||
],
|
||||
"R60": [
|
||||
806.5,
|
||||
682.9,
|
||||
605,
|
||||
562.4,
|
||||
542.9,
|
||||
534.7,
|
||||
530.6
|
||||
],
|
||||
"R75": [
|
||||
763.8,
|
||||
648.6,
|
||||
578.1,
|
||||
545.2,
|
||||
527.6,
|
||||
516,
|
||||
505.8
|
||||
],
|
||||
"R90": [
|
||||
770.4,
|
||||
649.9,
|
||||
575.9,
|
||||
541.5,
|
||||
522.6,
|
||||
506.7,
|
||||
486.6
|
||||
],
|
||||
"R110": [
|
||||
841.2,
|
||||
690.9,
|
||||
599.3,
|
||||
550.4,
|
||||
525.7,
|
||||
508.1,
|
||||
476.4
|
||||
],
|
||||
"R120": [
|
||||
899.7,
|
||||
728.7,
|
||||
628.2,
|
||||
564.5,
|
||||
533.7,
|
||||
514.4,
|
||||
481.6
|
||||
],
|
||||
"R135": [
|
||||
1027.7,
|
||||
808.1,
|
||||
690.6,
|
||||
609.2,
|
||||
558.7,
|
||||
532,
|
||||
498
|
||||
],
|
||||
"R150": [
|
||||
1205.8,
|
||||
924.1,
|
||||
770,
|
||||
674,
|
||||
602.7,
|
||||
557.4,
|
||||
514.8
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.sap.sailing.server.gateway.deserialization.test.racelog;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.orc.ORCCertificate;
|
||||
import com.sap.sailing.domain.orc.ORCCertificatesCollection;
|
||||
import com.sap.sailing.domain.orc.ORCCertificatesImporter;
|
||||
import com.sap.sailing.server.gateway.deserialization.racelog.impl.ORCCertificateJsonDeserializer;
|
||||
import com.sap.sailing.server.gateway.serialization.racelog.impl.ORCCertificateJsonSerializer;
|
||||
|
||||
public class ORCCertificateJsonDeserializerTest {
|
||||
private ORCCertificateJsonSerializer serializer;
|
||||
private ORCCertificateJsonDeserializer deserializer;
|
||||
private static final String RESOURCES = "resources/rms/";
|
||||
@Before
|
||||
public void setup() {
|
||||
deserializer = new ORCCertificateJsonDeserializer();
|
||||
serializer = new ORCCertificateJsonSerializer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOldFormateOrcCertificateDeserializer() throws FileNotFoundException, IOException, ParseException {
|
||||
File fileGER = new File(RESOURCES + "newFormatCertificate.json");
|
||||
ORCCertificatesCollection importer = ORCCertificatesImporter.INSTANCE.read(new FileInputStream(fileGER));
|
||||
Iterator<ORCCertificate> iterator = importer.getCertificates().iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
ORCCertificate certificate = iterator.next();
|
||||
JSONObject serializedCertificate =serializer.serialize(certificate);
|
||||
assertNotNull(serializedCertificate);
|
||||
ORCCertificate certificateAfterDeserialize = deserializer.deserialize(serializedCertificate);
|
||||
assertEquals(certificate.getId(), certificateAfterDeserialize.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrcCertificateOldFormatDeserializer() throws IOException, ParseException {
|
||||
File fileGER = new File(RESOURCES + "oldFormatCertificate.json");
|
||||
ORCCertificatesCollection importer = ORCCertificatesImporter.INSTANCE.read(new FileInputStream(fileGER));
|
||||
Iterator<ORCCertificate> iterator = importer.getCertificates().iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
ORCCertificate certificate = iterator.next();
|
||||
JSONObject serializedCertificate =serializer.serialize(certificate);
|
||||
assertNotNull(serializedCertificate);
|
||||
ORCCertificate certificateAfterDeserialize = deserializer.deserialize(serializedCertificate);
|
||||
assertEquals(certificate.getId(), certificateAfterDeserialize.getId());
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.sap.sailing.server.gateway.serialization.test;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.orc.ORCCertificate;
|
||||
import com.sap.sailing.domain.orc.ORCCertificatesCollection;
|
||||
import com.sap.sailing.domain.orc.ORCCertificatesImporter;
|
||||
import com.sap.sailing.server.gateway.serialization.racelog.impl.ORCCertificateJsonSerializer;
|
||||
|
||||
public class ORCCertificateJsonSerializerTest {
|
||||
private ORCCertificateJsonSerializer serializer;
|
||||
private static final String RESOURCES = "resources/rms/";
|
||||
@Before
|
||||
public void setUp() {
|
||||
serializer = new ORCCertificateJsonSerializer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrcCertificateNewFormatSerializer() throws IOException, ParseException {
|
||||
File fileGER = new File(RESOURCES + "newFormatCertificate.json");
|
||||
ORCCertificatesCollection importer = ORCCertificatesImporter.INSTANCE.read(new FileInputStream(fileGER));
|
||||
Iterator<ORCCertificate> iterator = importer.getCertificates().iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
ORCCertificate certificate = iterator.next();
|
||||
JSONObject serializedCertificate =serializer.serialize(certificate);
|
||||
assertNotNull(serializedCertificate);
|
||||
}
|
||||
@Test
|
||||
public void testOrcCertificateOldFormatSerializer() throws IOException, ParseException {
|
||||
File fileGER = new File(RESOURCES + "oldFormatCertificate.json");
|
||||
ORCCertificatesCollection importer = ORCCertificatesImporter.INSTANCE.read(new FileInputStream(fileGER));
|
||||
Iterator<ORCCertificate> iterator = importer.getCertificates().iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
ORCCertificate certificate = iterator.next();
|
||||
JSONObject serializedCertificate =serializer.serialize(certificate);
|
||||
assertNotNull(serializedCertificate);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user