mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-06 20:33:54 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
59fab2d664
8 files changed
+86
-3
No files matched your search
BIN
Binary file not shown.
+25
@@ -3,6 +3,7 @@ package com.sap.sailing.kiworesultimport.test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -57,6 +58,30 @@ public class ParserTest {
|
||||
return getInputStream("2011-06-18_49er_Wettfahrt_2_Extra.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyIsafID() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
|
||||
ResultListParser parser = ResultListParserFactory.INSTANCE.createResultListParser();
|
||||
ResultList resultList = parser.parse(getSampleInputStream());
|
||||
assertNotNull(resultList);
|
||||
assertNull(resultList.getVerteilung().getBoatBySailID("SWE 1196").getCrew().getSkipper().getIsaf());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyStatus() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
|
||||
ResultListParser parser = ResultListParserFactory.INSTANCE.createResultListParser();
|
||||
ResultList resultList = parser.parse(getSampleInputStream());
|
||||
assertNotNull(resultList);
|
||||
assertNull(resultList.getVerteilung().getBoatBySailID("SWE 1196").getRaces().getRaces().iterator().next().getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonEmptyStatus() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
|
||||
ResultListParser parser = ResultListParserFactory.INSTANCE.createResultListParser();
|
||||
ResultList resultList = parser.parse(getSampleInputStream());
|
||||
assertNotNull(resultList);
|
||||
assertEquals("DNC", resultList.getVerteilung().getBoatBySailID("GER 1199").getRaces().getRaces().iterator().next().getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testObtainingResultList() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
|
||||
ResultListParser parser = ResultListParserFactory.INSTANCE.createResultListParser();
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.sap.sailing.kiworesultimport.test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ZipStreamTest {
|
||||
private final static String ZIP_EXAMPLE_FILE = "RESOURCES/Kieler_Woche_2011_Export.zip";
|
||||
|
||||
@Test
|
||||
public void testOpenZip() throws IOException {
|
||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(ZIP_EXAMPLE_FILE));
|
||||
boolean foundStartberichteDir = false;
|
||||
ZipEntry nextEntry = zis.getNextEntry();
|
||||
while (nextEntry != null) {
|
||||
if (nextEntry.getName().startsWith("Startberichte\\")) {
|
||||
foundStartberichteDir = true;
|
||||
}
|
||||
nextEntry = zis.getNextEntry();
|
||||
}
|
||||
zis.close();
|
||||
assertTrue(foundStartberichteDir);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.sap.sailing.kiworesultimport;
|
||||
|
||||
import com.sap.sailing.domain.common.MaxPointsReason;
|
||||
|
||||
public interface Race {
|
||||
String getStatus();
|
||||
|
||||
Double getPoints();
|
||||
|
||||
Integer getNumber();
|
||||
|
||||
MaxPointsReason getMaxPointsReason();
|
||||
}
|
||||
+18
@@ -2,6 +2,7 @@ package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sap.sailing.domain.common.MaxPointsReason;
|
||||
import com.sap.sailing.kiworesultimport.Race;
|
||||
|
||||
public class RaceImpl extends AbstractNodeWrapper implements Race {
|
||||
@@ -20,4 +21,21 @@ public class RaceImpl extends AbstractNodeWrapper implements Race {
|
||||
return Integer.valueOf(getNode().getAttributes().getNamedItem("number").getNodeValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
final Node namedItem = getNode().getAttributes().getNamedItem("status");
|
||||
return namedItem == null || namedItem.getNodeValue() == null || namedItem.getNodeValue().trim().length() == 0 ? null : namedItem.getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaxPointsReason getMaxPointsReason() {
|
||||
MaxPointsReason result;
|
||||
String status = getStatus();
|
||||
if (status != null) {
|
||||
result = MaxPointsReason.valueOf(status);
|
||||
} else {
|
||||
result = MaxPointsReason.NONE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -16,7 +16,11 @@ public class SkipperImpl extends NamedImpl implements Skipper {
|
||||
|
||||
@Override
|
||||
public URL getIsaf() throws MalformedURLException, DOMException {
|
||||
return new URL(getNode().getAttributes().getNamedItem("isaf").getNodeValue());
|
||||
final String nodeValue = getNode().getAttributes().getNamedItem("isaf").getNodeValue();
|
||||
URL result = null;
|
||||
if (nodeValue != null && nodeValue.trim().length() > 0) {
|
||||
result = new URL(nodeValue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -48,6 +48,7 @@ public abstract class AbstractMongoDBTest {
|
||||
DBCollection c = theDB.getCollection(collectionName.name());
|
||||
c.drop();
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
||||
protected MongoDBService getMongoService() {
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class TestStoringAndRetrievingWindData extends AbstractMongoDBTest {
|
||||
}
|
||||
|
||||
{
|
||||
Thread.sleep(3000); // wait until MongoDB has recorded the change and made it visible
|
||||
Thread.sleep(1000); // wait until MongoDB has recorded the change and made it visible
|
||||
Mongo mongo = newMongo();
|
||||
assertNotNull(mongo);
|
||||
DB db = mongo.getDB(getDBConfiguration().getDatabaseName());
|
||||
|
||||
Reference in new issue
Block a user