mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-23 14:08:40 +00:00
fixed FREG parser to cope with multi-line TD strings
This commit is contained in:
+1014
File diff suppressed because it is too large
Load Diff
+19
@@ -18,6 +18,7 @@ import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
import com.sap.sailing.freg.resultimport.CompetitorRow;
|
||||
import com.sap.sailing.freg.resultimport.RegattaResults;
|
||||
import com.sap.sailing.freg.resultimport.impl.FregHtmlParser;
|
||||
|
||||
public class SimpleHtmlParsingTest {
|
||||
@@ -29,6 +30,24 @@ public class SimpleHtmlParsingTest {
|
||||
br.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiLineTD() throws IOException {
|
||||
final InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("Coupe-internationale-de-france.htm");
|
||||
FregHtmlParser parser = new FregHtmlParser();
|
||||
final RegattaResults regattaResults = parser.getRegattaResults(resourceAsStream);
|
||||
List<CompetitorRow> result = regattaResults.getCompetitorResults();
|
||||
assertFalse(result.isEmpty());
|
||||
assertEquals(57, result.size());
|
||||
assertTrue(regattaResults.getMetadata().contains("PRE- WORLD \n 2012 - COUPE INTERNATIONALE DE FRANCE 505"));
|
||||
for (CompetitorRow row : result) {
|
||||
if (Util.contains(row.getNames(), "MARTIN Aline")) {
|
||||
assertEquals("FRA 8716", row.getSailID());
|
||||
assertEquals(111, row.getScoreAfterDiscarding(), 0.000000001);
|
||||
assertEquals(230.00, row.getTotalPointsBeforeDiscarding(), 0.000000001);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyAndDashedScores() throws IOException {
|
||||
final InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("pre_world_505_s.htm");
|
||||
|
||||
+4
-3
@@ -44,16 +44,17 @@ public class FregHtmlParser {
|
||||
if (foundSlashTr) {
|
||||
end = slashTrMatcher.start();
|
||||
inTr = false;
|
||||
trContents.append(readLine.substring(start, end));
|
||||
tableRows.add(trContents.toString());
|
||||
trContents.delete(0, trContents.length());
|
||||
} else {
|
||||
end = readLine.length();
|
||||
}
|
||||
trContents.append(readLine.substring(start, end));
|
||||
if (!foundSlashTr) {
|
||||
trContents.append('\n');
|
||||
readLine = br.readLine();
|
||||
start = 0;
|
||||
} else {
|
||||
tableRows.add(trContents.toString());
|
||||
trContents.delete(0, trContents.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user