Add test for missing rain amount
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 27 May 2016 22:22:11 +0000 (00:22 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 27 May 2016 22:22:11 +0000 (00:22 +0200)
src/main/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilter.kt
src/test/kotlin/net/pterodactylus/rhynodge/webpages/weather/wettercom/WetterComFilterTest.kt
src/test/resources/net/pterodactylus/rhynodge/webpages/weather/wettercom/wetter.com.html

index cf8cd3f..bf6f97e 100644 (file)
@@ -69,7 +69,7 @@ class WetterComFilter : Filter {
             hourElement.extractText(".weather-strip__3 .text--left:eq(0) .flag__body span:eq(0)").filter { (it >= '0') and (it <= '9') }.toDouble() / 100.0
 
     private fun parseRainAmount(hourElement: Element) =
-            hourElement.extractText(".weather-strip__3 .text--left:eq(0) .flag__body span:eq(1)").trim().split(" ")[1].toDouble()
+            hourElement.extractText(".weather-strip__3 .text--left:eq(0) .flag__body span:eq(1)").trim().split(" ").getOrNull(1)?.toDouble() ?: 0.0
 
     private fun parseWindDirection(hourElement: Element) =
             hourElement.extractText(".weather-strip__3 .text--left:eq(1) .flag__body span:eq(0)").trim().split(",")[0].toWindDirection()
index 6fc4995..aa72f3c 100644 (file)
@@ -69,7 +69,7 @@ class WetterComFilterTest {
                 HourState(14, 16.0, 0.75, 0.4, WindDirection.NORTHWEST, 12.0, "Regenschauer", "http://ls2.wettercomassets.com/wcomv5/images/icons/small/d_81_S.png?201605201518"),
                 HourState(15, 15.0, 0.85, 0.2, WindDirection.WEST, 12.0, "leichter Regen", "http://ls1.wettercomassets.com/wcomv5/images/icons/small/d_61_S.png?201605201518"),
                 HourState(16, 14.0, 0.9, 0.2, WindDirection.WEST, 14.0, "leichter Regen", "http://ls2.wettercomassets.com/wcomv5/images/icons/small/n_61_S.png?201605201518"),
-                HourState(17, 14.0, 0.9, 0.2, WindDirection.NORTHWEST, 12.0, "leichter Regen", "http://ls2.wettercomassets.com/wcomv5/images/icons/small/n_61_S.png?201605201518"),
+                HourState(17, 14.0, 0.9, 0.0, WindDirection.NORTHWEST, 12.0, "leichter Regen", "http://ls2.wettercomassets.com/wcomv5/images/icons/small/n_61_S.png?201605201518"),
                 HourState(18, 14.0, 0.9, 0.2, WindDirection.WEST, 12.0, "leichter Regen", "http://ls2.wettercomassets.com/wcomv5/images/icons/small/n_61_S.png?201605201518"),
                 HourState(19, 13.0, 0.85, 0.1, WindDirection.NORTHWEST, 11.0, "leichter Regen", "http://ls2.wettercomassets.com/wcomv5/images/icons/small/n_61_S.png?201605201518"),
                 HourState(20, 13.0, 0.8, 0.01, WindDirection.WEST, 11.0, "leichter Regen", "http://ls2.wettercomassets.com/wcomv5/images/icons/small/n_61_S.png?201605201518"),
index d076b11..6da0b95 100644 (file)
                                                                                                                                </div>
                                                                                                                                <div class="flag__body pl-- nowrap">
                                                                                                                                        <span>90 %</span>
-                                                                                                                                       <span> | 0.2 l/m²</span>
                                                                                                                                </div>
                                                                                                                        </div>
                                                                                                                </div>