Use a single hour state for all weather services
[rhynodge.git] / src / test / kotlin / net / pterodactylus / rhynodge / webpages / weather / wettercom / WetterComStateTest.kt
index 93667ea..d32e563 100644 (file)
@@ -1,6 +1,7 @@
 package net.pterodactylus.rhynodge.webpages.weather.wettercom
 
 import com.fasterxml.jackson.databind.ObjectMapper
+import net.pterodactylus.rhynodge.webpages.weather.HourState
 import net.pterodactylus.rhynodge.webpages.weather.WindDirection
 import org.hamcrest.MatcherAssert.assertThat
 import org.hamcrest.Matchers.`is`
@@ -28,11 +29,11 @@ class WetterComStateTest {
     fun statesWithTheSameHoursAreEqual() {
         val now = Instant.now().atZone(ZoneId.of("Europe/Berlin"))
         val firstState = WetterComState(ZonedDateTime.from(now))
-        firstState.addHour(HourState(0, 10.0, 0.05, 0.0, WindDirection.NORTH, 5.0, "Fine", "http://1"))
-        firstState.addHour(HourState(1, 12.0, 0.1, 2.0, WindDirection.WEST, 8.0, "Superb", "http://2"))
+        firstState += HourState(0, 10, null, 0.05, 0.0, WindDirection.NORTH, 5, null, null, "Fine", "http://1")
+        firstState += HourState(1, 12, null, 0.1, 2.0, WindDirection.WEST, 8, null, null, "Superb", "http://2")
         val secondState = WetterComState(ZonedDateTime.from(now))
-        secondState.addHour(HourState(0, 10.0, 0.05, 0.0, WindDirection.NORTH, 5.0, "Fine", "http://1"))
-        secondState.addHour(HourState(1, 12.0, 0.1, 2.0, WindDirection.WEST, 8.0, "Superb", "http://2"))
+        secondState += HourState(0, 10, null, 0.05, 0.0, WindDirection.NORTH, 5, null, null, "Fine", "http://1")
+        secondState += HourState(1, 12, null, 0.1, 2.0, WindDirection.WEST, 8, null, null, "Superb", "http://2")
         assertThat(firstState, `is`(secondState))
     }
 
@@ -40,8 +41,8 @@ class WetterComStateTest {
     fun iteratingDeliversHourStates() {
         val now = Instant.now().atZone(ZoneId.of("Europe/Berlin"))
         val firstState = WetterComState(ZonedDateTime.from(now))
-        firstState.addHour(HourState(0, 10.0, 0.05, 0.0, WindDirection.NORTH, 5.0, "Fine", "http://1"))
-        firstState.addHour(HourState(1, 12.0, 0.1, 2.0, WindDirection.WEST, 8.0, "Superb", "http://2"))
+        firstState += HourState(0, 10, null, 0.05, 0.0, WindDirection.NORTH, 5, null, null, "Fine", "http://1")
+        firstState += HourState(1, 12, null, 0.1, 2.0, WindDirection.WEST, 8, null, null, "Superb", "http://2")
         assertThat(firstState.iterator().asSequence().toList(), `is`(firstState.hours as Iterable<HourState>))
     }
 
@@ -50,8 +51,8 @@ class WetterComStateTest {
         val objectMapper = ObjectMapper()
         val now = Instant.now().atZone(ZoneId.of("Europe/Berlin"))
         val originalState = WetterComState(ZonedDateTime.from(now))
-        originalState.addHour(HourState(0, 10.0, 0.05, 0.0, WindDirection.NORTH, 5.0, "Fine", "http://1"))
-        originalState.addHour(HourState(1, 12.0, 0.1, 2.0, WindDirection.WEST, 8.0, "Superb", "http://2"))
+        originalState += HourState(0, 10, null, 0.05, 0.0, WindDirection.NORTH, 5, null, null, "Fine", "http://1")
+        originalState += HourState(1, 12, null, 0.1, 2.0, WindDirection.WEST, 8, null, null, "Superb", "http://2")
         val json = objectMapper.writeValueAsString(originalState)
         println(json)
         val parsedState = objectMapper.readValue(json, WetterComState::class.java)