Commit 7853e7da authored by Andreas Muttscheller's avatar Andreas Muttscheller

Add UnitTests for TimetableInformation

parent ae40d5b9
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="64" height="64" viewBox="0 0 32 32" version="1.1" preserveAspectRatio="xMidYMid" id="svg2" inkscape:version="0.48.4 r9939" sodipodi:docname="kafka-icon.svg">
<metadata id="metadata12">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
</cc:Work>
</rdf:RDF>
</metadata>
<defs id="defs10"/>
<sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="1396" inkscape:window-height="1018" id="namedview8" showgrid="false" inkscape:zoom="25.625" inkscape:cx="16" inkscape:cy="16" inkscape:window-x="65" inkscape:window-y="24" inkscape:window-maximized="0" inkscape:current-layer="svg2"/>
<g id="g4" transform="matrix(0.06703178,0,0,0.06703204,5.6095866,1.015081)">
<path d="m 237.61686,249.26774 c -18.59017,0 -35.25655,8.23614 -46.66953,21.20309 L 161.7022,249.76736 c 3.10449,-8.54739 4.88702,-17.72533 4.88702,-27.33167 0,-9.4398 -1.72051,-18.46383 -4.72278,-26.88489 l 29.17966,-20.4841 c 11.41184,12.90148 28.03457,21.09283 46.57076,21.09283 34.31246,0 62.23218,-27.91513 62.23218,-62.23218 0,-34.317049 -27.91972,-62.232171 -62.23218,-62.232171 -34.31245,0 -62.23217,27.915122 -62.23217,62.232171 0,6.14236 0.92802,12.06535 2.59339,17.67479 L 148.7789,172.09659 C 136.58147,156.96465 119.01923,146.39928 99.009473,143.1742 l 0,-35.19108 c 28.189617,-5.9207 49.429457,-30.966782 49.429457,-60.894136 0,-34.317052 -27.91971,-62.232174 -62.232167,-62.232174 -34.312458,0 -62.232174,27.915122 -62.232174,62.232174 0,29.526515 20.689694,54.263646 48.315386,60.606996 l 0,35.6482 c -37.701782,6.61786 -66.4656712,39.52106 -66.4656712,79.09151 0,39.7634 29.0487252,72.7872 67.0227102,79.17994 l 0,37.64206 c -27.908231,6.13432 -48.872425,31.02306 -48.872425,60.75057 0,34.31705 27.919716,62.23217 62.232174,62.23217 34.312457,0 62.232167,-27.91512 62.232167,-62.23217 0,-29.72751 -20.96419,-54.61625 -48.872418,-60.75057 l 0,-37.6432 C 119.18232,298.3113 136.42182,287.95497 148.49406,273.1584 l 29.44038,20.83786 c -1.63437,5.5589 -2.54975,11.42332 -2.54975,17.50366 0,34.31705 27.91972,62.23217 62.23217,62.23217 34.31246,0 62.23218,-27.91512 62.23218,-62.23217 0,-34.31705 -27.91972,-62.23218 -62.23218,-62.23218 l 0,0 z m 0,-145.51353 c 16.63882,0 30.172,13.53892 30.172,30.17314 0,16.63422 -13.53318,30.17199 -30.172,30.17199 -16.63881,0 -30.17199,-13.53777 -30.17199,-30.17199 0,-16.63422 13.53318,-30.17314 30.17199,-30.17314 l 0,0 z M 56.033622,47.088984 c 0,-16.63422 13.534327,-30.171992 30.173141,-30.171992 16.638817,0 30.171987,13.537772 30.171987,30.171992 0,16.63422 -13.53317,30.171991 -30.171987,30.171991 -16.638814,0 -30.173141,-13.537771 -30.173141,-30.171991 l 0,0 z M 116.37875,400.00826 c 0,16.63422 -13.53317,30.17199 -30.171987,30.17199 -16.638814,0 -30.173141,-13.53777 -30.173141,-30.17199 0,-16.63422 13.534327,-30.172 30.173141,-30.172 16.638817,0 30.171987,13.53778 30.171987,30.172 l 0,0 z M 86.204466,264.51568 c -23.206133,0 -42.084588,-18.87501 -42.084588,-42.07999 0,-23.20613 18.878455,-42.08459 42.084588,-42.08459 23.204984,0 42.083434,18.87846 42.083434,42.08459 0,23.20498 -18.87845,42.07999 -42.083434,42.07999 l 0,0 z m 151.412394,77.15738 c -16.63881,0 -30.17199,-13.53892 -30.17199,-30.17314 0,-16.63422 13.53318,-30.17199 30.17199,-30.17199 16.63882,0 30.172,13.53777 30.172,30.17199 0,16.63422 -13.53318,30.17314 -30.172,30.17314 l 0,0 z" id="path6" inkscape:connector-curvature="0" style="fill:#000000"/>
</g>
</svg>
This diff is collapsed.
<mxfile modified="2019-01-02T13:21:19.303Z" host="www.draw.io" agent="Mozilla/5.0 (X11; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0" etag="00ecYJwWnRM8-VmAG63W" version="10.0.16" type="device"><diagram name="Page-1" id="75ae5057-2f1f-a65a-41a6-c58fb5237df7">7VxZd6JYF/01eaxajEYfVYghLRgVY/SlFwJBEMRPUIRf/+3DoDikurq6Uj1UpVdW6x3OOXfvc/a9DKk7vhsceltjs1RDy/bvOMY63PHSHcexAtfA/6glLVqaHF80OFvXKgedGsZuZpeNTNm6cy07OhsYh6Efu5vzRjNcr20zPmszttswOR/2FvrnXjeGY181jE3Dv26dula8LFtZhjl1PNqusyxdN8WyY2GYK2cb7talvzuOf8t/iu7AqGyV46OlYYVJrYmX7/juNgzj4lNw6No+YVvBVsx7eKf3GPfWXsdfM2H21FyYY4WfyOO3dPWbqYrPs0/Nwsre8Hd2tYw82DitAMqXaJMR9o7vJEs3tscbw6TeBCmBtmUc+GX3dVBlnHt7G9uHWlMZZM8OAzvephhS9jbuP4vFnDKjhBLA5EQPV5GwrDEjVEgbZUo4R9snWPChROZPoNT6Y5TCXey7a7t7zFIGaFhGtMyRoy+EgIu86xsL238OIzd2wzX6FmEch0FtQNt3HeqIQwLXKL+ZQNTenqONlNqQ/+DgUHF+NpKI/+wbwcIyfn/brc3CQ+fN9f1u6IfbPFT+QWyK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+vM/+5maNfLqxLeTj+1UO5lLv6Xw7cko1PzGdGqF7TS88sfWs6V0PCt7fIju8uReR7cH9rs/qlK1+tK1eHyG9XlVbrUqE+TFaOrj5WV67febypK1u66vyPycqxrn5SWbn1kuQvWfn6Ewb7jbJy4+TDXp18Pu64wv6I48r1y5g/j6xUdfVPlJXSyifufMYHqsyvi6K/pDK88N1UBqZ+mMpUYX+sylzfHf95Lor4f/JF0Y+Xma/4E+RfMvMFbWh+450XsQqpurUvfIzEXPqpAv5Qgam0ty4wRVWRwFz+Bd9/TWCqkvonCszHK4pw/YRPrz10XaQ52+GGgllbtN9sDfdrtpl/6x33q4ewHP9xT2Hx9fQvfxSUnv55FV7+Pw==</diagram></mxfile>
\ No newline at end of file
......@@ -124,13 +124,13 @@ object TimetableInformation {
val prettyTrainName = if (line.isEmpty) s"$tlC $tlN" else s"$tlC $line ($tlN)"
val arPpth = (s \ "ar" \@ "ppth").split("\\|")
val dpPpth = (s \ "dp" \@ "ppth").split("\\|")
val arPpth = (s \ "ar" \@ "ppth").split("\\|").filter(_.nonEmpty)
val dpPpth = (s \ "dp" \@ "ppth").split("\\|").filter(_.nonEmpty)
// arPpth and dpPpth have always one element -> split returns a list with
// one string if no delimiter was found -> the string itself
val from = if (arPpth.head.isEmpty) station else arPpth(0)
val to = if (dpPpth.head.isEmpty) station else dpPpth.reverse(0)
val from = if (arPpth.isEmpty) station else arPpth(0)
val to = if (dpPpth.isEmpty) station else dpPpth.reverse(0)
val cancelled = (s \ "ar" \@ "cs") == "c" || (s \ "dp" \@ "cs") == "c"
val plannedTime: LocalDateTime = if ((s \ "dp" \@ "pt").nonEmpty) {
......
<?xml version='1.0' encoding='UTF-8'?>
<s id="-1448145632787747533-1901301510-8">
<tl f="F" t="p" o="80" c="ICE" n="1574"/>
<ar pt="1901301640" pp="11" ppth="Karlsruhe Hbf|Bruchsal|Wiesloch-Walldorf|Heidelberg Hbf|Weinheim(Bergstr)Hbf|Bensheim|Darmstadt Hbf"/>
<dp pt="1901301649" pp="11" ppth="Frankfurt(Main)West|Friedberg(Hess)|Gie&#223;en|Marburg(Lahn)|Stadtallendorf|Treysa|Wabern(Bz Kassel)|Kassel-Wilhelmsh&#246;he|G&#246;ttingen|Hannover Hbf|Celle|Uelzen|L&#252;neburg|Hamburg-Harburg|Hamburg Hbf|Hamburg Dammtor|Hamburg-Altona"/>
</s>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8'?>
<s id="-1448145632787747533-1901301510-8">
<tl f="F" t="p" o="80" c="ICE" n="1574"/>
<ar pt="1901301640" cs="c" pp="11" ppth="Karlsruhe Hbf|Bruchsal|Wiesloch-Walldorf|Heidelberg Hbf|Weinheim(Bergstr)Hbf|Bensheim|Darmstadt Hbf"/>
<dp pt="1901301649" cs="c" pp="11" ppth="Frankfurt(Main)West|Friedberg(Hess)|Gie&#223;en|Marburg(Lahn)|Stadtallendorf|Treysa|Wabern(Bz Kassel)|Kassel-Wilhelmsh&#246;he|G&#246;ttingen|Hannover Hbf|Celle|Uelzen|L&#252;neburg|Hamburg-Harburg|Hamburg Hbf|Hamburg Dammtor|Hamburg-Altona"/>
</s>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8'?>
<s id="-556489836466450408-1901311455-9">
<tl f="N" t="p" o="800553" c="RE" n="15225"/>
<ar pt="1901311603" pp="21" l="20" ppth="Limburg(Lahn)|Eschhofen|Niederbrechen|Bad Camberg|Idstein(Taunus)|Niedernhausen(Taunus)|Hofheim(Taunus)|Frankfurt-H&#246;chst"/>
</s>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8'?>
<s id="1959904200152427246-1901311650-1">
<tl f="S" t="p" o="800528" c="S" n="35755"/>
<dp pt="1901311650" pp="2" l="7" ppth="Frankfurt-Niederrad|Frankfurt am Main - Stadion|Zeppelinheim|Walldorf(Hess)|M&#246;rfelden|Gro&#223; Gerau-Dornberg|Gro&#223; Gerau-Dornheim|Riedstadt-Wolfskehlen|Riedstadt-Goddelau"/>
</s>
\ No newline at end of file
package de.codecentric.amuttsch.bahndelayinfo.models
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import org.scalatest.FunSpec
import scala.io.Source
import scala.xml.XML
class TimetableInformationTest extends FunSpec {
val apiDateTimePattern: DateTimeFormatter = DateTimeFormatter.ofPattern("yyMMddHHmm")
describe("A TimetableInformation") {
describe("that is valid") {
it("should parse xml ICE stop") {
val stop = Source.fromResource("TimetableInformationICE.xml")
val stopXml = XML.loadString(stop.mkString)
val tti = TimetableInformation.fromXML(stopXml, "Frankurt(Main)Hbf", "8000105")
assert(tti.id == "-1448145632787747533-1901301510-8")
assert(tti.eva == "8000105")
assert(tti.station == "Frankurt(Main)Hbf")
assert(!tti.cancelled)
assert(tti.from == "Karlsruhe Hbf")
assert(tti.to == "Hamburg-Altona")
assert(!tti.finalStop)
assert(tti.plannedTime.isEqual(LocalDateTime.parse("1901301649", apiDateTimePattern)))
assert(tti.delayInMinutes == 0)
assert(tti.isHistory)
assert(tti.train == "ICE 1574")
}
it("should parse xml ICE stop that is cancelled") {
val stop = Source.fromResource("TimetableInformationICE_cancelled.xml")
val stopXml = XML.loadString(stop.mkString)
val tti = TimetableInformation.fromXML(stopXml, "Frankurt(Main)Hbf", "8000105")
assert(tti.id == "-1448145632787747533-1901301510-8")
assert(tti.eva == "8000105")
assert(tti.station == "Frankurt(Main)Hbf")
assert(tti.cancelled)
assert(tti.from == "Karlsruhe Hbf")
assert(tti.to == "Hamburg-Altona")
assert(!tti.finalStop)
assert(tti.plannedTime.isEqual(LocalDateTime.parse("1901301649", apiDateTimePattern)))
assert(tti.delayInMinutes == 0)
assert(tti.isHistory)
assert(tti.train == "ICE 1574")
}
it("should parse xml S-Bahn stop that starts at station") {
val stop = Source.fromResource("TimetableInformationS7.xml")
val stopXml = XML.loadString(stop.mkString)
val tti = TimetableInformation.fromXML(stopXml, "Frankurt(Main)Hbf", "8000105")
assert(tti.id == "1959904200152427246-1901311650-1")
assert(tti.eva == "8000105")
assert(tti.station == "Frankurt(Main)Hbf")
assert(!tti.cancelled)
assert(tti.from == "Frankurt(Main)Hbf")
assert(tti.to == "Riedstadt-Goddelau")
assert(!tti.finalStop)
assert(tti.plannedTime.isEqual(LocalDateTime.parse("1901311650", apiDateTimePattern)))
assert(tti.delayInMinutes == 0)
assert(tti.isHistory)
assert(tti.train == "S 7 (35755)")
}
it("should parse xml RE stop that terminates at station") {
val stop = Source.fromResource("TimetableInformationRE.xml")
val stopXml = XML.loadString(stop.mkString)
val tti = TimetableInformation.fromXML(stopXml, "Frankurt(Main)Hbf", "8000105")
assert(tti.id == "-556489836466450408-1901311455-9")
assert(tti.eva == "8000105")
assert(tti.station == "Frankurt(Main)Hbf")
assert(!tti.cancelled)
assert(tti.from == "Limburg(Lahn)")
assert(tti.to == "Frankurt(Main)Hbf")
assert(tti.finalStop)
assert(tti.plannedTime.isEqual(LocalDateTime.parse("1901311603", apiDateTimePattern)))
assert(tti.delayInMinutes == 0)
assert(tti.isHistory)
assert(tti.train == "RE 20 (15225)")
}
it("should extract to and parse from json") {
val stop = Source.fromResource("TimetableInformationRE.xml")
val stopXml = XML.loadString(stop.mkString)
val tti = TimetableInformation.fromXML(stopXml, "Frankurt(Main)Hbf", "8000105")
val ttiFromJson = TimetableInformation.fromJson(tti.toJson)
assert(tti == ttiFromJson)
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment