bug6076: a first implementation of a new bundle for Vakaros file import

This commit is contained in:
Axel Uhl committed 2025-02-03 15:44:18 +01:00
1 parent 6fdc7b21bc
commit 5f8c4aa6ff
49 files changed
+567 -22

No files matched your search

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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>
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.sap.sailing.domain.vakarosadapter.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test
Bundle-SymbolicName: com.sap.sailing.domain.vakarosadapter.test
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: SAP
Fragment-Host: com.sap.sailing.domain.vakarosadapter
Automatic-Module-Name: com.sap.sailing.domain.vakarosadapter.test
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.sap.sailing.domain.common,
com.sap.sse.common,
org.junit;version="[4.13.0,5.0.0)"
Require-Bundle: org.hamcrest;bundle-version="2.2.0"
@@ -0,0 +1,5 @@
source.. = src/,\
resources/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>root</artifactId>
<groupId>com.sap.sailing</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.sap.sailing.domain.vakarosadapter.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
</project>
@@ -0,0 +1,109 @@
package com.sap.sailing.domain.vakarosadapter.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.nio.charset.Charset;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import com.sap.sailing.domain.common.sensordata.BravoExtendedSensorDataMetadata;
import com.sap.sailing.domain.common.tracking.DoubleVectorFix;
import com.sap.sailing.domain.common.tracking.GPSFix;
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
import com.sap.sailing.domain.trackfiles.TrackFileImportDeviceIdentifier;
import com.sap.sailing.domain.trackimport.FormatNotSupportedException;
import com.sap.sailing.domain.trackimport.GPSFixImporter.Callback;
import com.sap.sailing.domain.vakarosadapter.VakarosGPSFixImporter;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
public class TestReadingVakarosFiles {
private final static double EPSILON = 0.000000001;
private VakarosGPSFixImporter importer;
@Before
public void setUp() {
importer = new VakarosGPSFixImporter();
}
@Test
public void testReadFileWithLoadValues() throws FormatNotSupportedException, IOException, ParseException {
final String sourceName = "/GDF-8-11-2024.csv.gz";
final Map<TrackFileImportDeviceIdentifier, List<GPSFix>> gpsFixes = new HashMap<>();
final Map<TrackFileImportDeviceIdentifier, List<DoubleVectorFix>> sensorFixes = new HashMap<>();
readAndAssertNotEmpty(sourceName, gpsFixes, sensorFixes);
// check for presence of fixes corresponding to line:
// timestamp,latitude,longitude,sog_kts,cog,hdg_true,roll,pitch,load_GDF2,load_GDF1
// 2024-11-08T08:38:56.077,41.7387700,12.2457483,0.000,113.1,125.4,-1.7,4.6,1.40,141.20
final TimePoint timePoint = TimePoint.of(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").parse("2024-11-08T08:38:56.077"+"Z"));
boolean foundGPSFix = false;
for (final GPSFix fix : gpsFixes.values().iterator().next()) {
final GPSFixMoving fixMoving = (GPSFixMoving) fix;
if (fix.getTimePoint().equals(timePoint) &&
Math.abs(fix.getPosition().getLatDeg() - 41.7387700) < EPSILON &&
Math.abs(fix.getPosition().getLngDeg() - 12.2457483) < EPSILON &&
Math.abs(fixMoving.getSpeed().getKnots() - 0.000) < EPSILON &&
Math.abs(fixMoving.getSpeed().getBearing().getDegrees() - 113.1) < EPSILON &&
Math.abs(fixMoving.getOptionalTrueHeading().getDegrees() - 125.4) < EPSILON) {
foundGPSFix = true;
break;
}
}
assertTrue(foundGPSFix);
boolean foundSensorFix = false;
for (final DoubleVectorFix sensorFix : sensorFixes.values().iterator().next()) {
if (sensorFix.getTimePoint().equals(timePoint) &&
Math.abs(sensorFix.get(BravoExtendedSensorDataMetadata.HEEL.getColumnIndex()) - -1.7) < EPSILON &&
Math.abs(sensorFix.get(BravoExtendedSensorDataMetadata.PITCH.getColumnIndex()) - 4.6) < EPSILON &&
Math.abs(sensorFix.get(BravoExtendedSensorDataMetadata.EXPEDITION_KICKER_TENSION.getColumnIndex()) - 1.4) < EPSILON &&
Math.abs(sensorFix.get(BravoExtendedSensorDataMetadata.FORESTAY_LOAD.getColumnIndex()) - 141.2) < EPSILON) {
foundSensorFix = true;
break;
}
}
assertTrue(foundSensorFix);
}
private void readAndAssertNotEmpty(final String sourceName,
final Map<TrackFileImportDeviceIdentifier, List<GPSFix>> gpsFixes,
final Map<TrackFileImportDeviceIdentifier, List<DoubleVectorFix>> sensorFixes)
throws FormatNotSupportedException, IOException {
final Callback callback = new Callback() {
@Override
public void addFix(GPSFix newFix, TrackFileImportDeviceIdentifier device) {
gpsFixes.computeIfAbsent(device, d->new ArrayList<>()).add(newFix);
}
@Override
public void addSensorFixes(Iterable<DoubleVectorFix> newSensorFixes, TrackFileImportDeviceIdentifier device) {
Util.addAll(newSensorFixes, sensorFixes.computeIfAbsent(device, d->new ArrayList<>()));
}
};
importer.importFixes(getClass().getResourceAsStream(sourceName), Charset.forName("UTF-8"), callback, /* inferSpeedAndBearing */ false, sourceName);
assertFalse(gpsFixes.isEmpty());
assertFalse(sensorFixes.isEmpty());
for (final List<GPSFix> gpsFixList : gpsFixes.values()) {
assertFalse(gpsFixList.isEmpty());
}
for (final List<DoubleVectorFix> sensorFixList : sensorFixes.values()) {
assertFalse(sensorFixList.isEmpty());
}
}
@Test
public void testReadFileWithoutLoadValues() throws FormatNotSupportedException, IOException {
final String sourceName = "/GDF-13-12-2024.csv.zip";
final Map<TrackFileImportDeviceIdentifier, List<GPSFix>> gpsFixes = new HashMap<>();
final Map<TrackFileImportDeviceIdentifier, List<DoubleVectorFix>> sensorFixes = new HashMap<>();
readAndAssertNotEmpty(sourceName, gpsFixes, sensorFixes);
}
}