mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 07:02:02 +01:00
Simplify DateTimeType handling for DWD Unwetter
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
b724595c2a
commit
b5f36cbfa8
@ -21,7 +21,6 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZoneId;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -105,31 +104,22 @@ public class DwdWarningsDataTest {
|
||||
|
||||
@Test
|
||||
public void testGetExpires() {
|
||||
// Conversion is needed as getExpires returns the Date with the System Default Zone
|
||||
assertThat(((DateTimeType) warningsData.getExpires(0)).getZonedDateTime().withZoneSameInstant(ZoneId.of("UTC"))
|
||||
.toString(), is("2018-12-22T18:00Z[UTC]"));
|
||||
assertThat(((DateTimeType) warningsData.getExpires(1)).getZonedDateTime().withZoneSameInstant(ZoneId.of("UTC"))
|
||||
.toString(), is("2018-12-23T01:00Z[UTC]"));
|
||||
assertThat(((DateTimeType) warningsData.getExpires(0)).getInstant().toString(), is("2018-12-22T18:00:00Z"));
|
||||
assertThat(((DateTimeType) warningsData.getExpires(1)).getInstant().toString(), is("2018-12-23T01:00:00Z"));
|
||||
assertThat(warningsData.getExpires(2), is(UnDefType.UNDEF));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOnset() {
|
||||
// Conversion is needed as getOnset returns the Date with the System Default Zone
|
||||
assertThat(((DateTimeType) warningsData.getOnset(0)).getZonedDateTime().withZoneSameInstant(ZoneId.of("UTC"))
|
||||
.toString(), is("2018-12-21T10:00Z[UTC]"));
|
||||
assertThat(((DateTimeType) warningsData.getOnset(1)).getZonedDateTime().withZoneSameInstant(ZoneId.of("UTC"))
|
||||
.toString(), is("2018-12-22T18:00Z[UTC]"));
|
||||
assertThat(((DateTimeType) warningsData.getOnset(0)).getInstant().toString(), is("2018-12-21T10:00:00Z"));
|
||||
assertThat(((DateTimeType) warningsData.getOnset(1)).getInstant().toString(), is("2018-12-22T18:00:00Z"));
|
||||
assertThat(warningsData.getOnset(2), is(UnDefType.UNDEF));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEffective() {
|
||||
// Conversion is needed as getEffective returns the Date with the System Default Zone
|
||||
assertThat(((DateTimeType) warningsData.getEffective(0)).getZonedDateTime()
|
||||
.withZoneSameInstant(ZoneId.of("UTC")).toString(), is("2018-12-22T03:02Z[UTC]"));
|
||||
assertThat(((DateTimeType) warningsData.getEffective(1)).getZonedDateTime()
|
||||
.withZoneSameInstant(ZoneId.of("UTC")).toString(), is("2018-12-22T10:15Z[UTC]"));
|
||||
assertThat(((DateTimeType) warningsData.getEffective(0)).getInstant().toString(), is("2018-12-22T03:02:00Z"));
|
||||
assertThat(((DateTimeType) warningsData.getEffective(1)).getInstant().toString(), is("2018-12-22T10:15:00Z"));
|
||||
assertThat(warningsData.getEffective(2), is(UnDefType.UNDEF));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user