]> git.basschouten.com Git - openhab-addons.git/blob
206029cf9628b1b832bbf0c2669f6d1ec2ae43d8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.fmiweather;
14
15 import static org.hamcrest.CoreMatchers.*;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.junit.jupiter.api.Assertions.assertNotNull;
18
19 import java.math.BigDecimal;
20 import java.nio.file.Path;
21 import java.util.Set;
22
23 import org.eclipse.jdt.annotation.NonNullByDefault;
24 import org.junit.jupiter.api.Test;
25 import org.openhab.binding.fmiweather.internal.client.Location;
26
27 /**
28  * Test cases for Client.parseStations
29  *
30  * @author Sami Salonen - Initial contribution
31  */
32 @NonNullByDefault
33 public class ParsingStationsTest extends AbstractFMIResponseParsingTest {
34
35     private Path stations_xml = getTestResource("stations.xml");
36
37     @SuppressWarnings("unchecked")
38     @Test
39     public void testParseStations() {
40         Set<Location> stations = parseStations(readTestResourceUtf8(stations_xml));
41         assertNotNull(stations);
42         assertThat(stations.size(), is(3));
43         assertThat(stations,
44                 hasItems(
45                         deeplyEqualTo(new Location("Porvoo Kilpilahti satama", "100683", new BigDecimal("60.303725"),
46                                 new BigDecimal("25.549164"))),
47                         deeplyEqualTo(new Location("Parainen Utö", "100908", new BigDecimal("59.779094"),
48                                 new BigDecimal("21.374788"))),
49                         deeplyEqualTo(new Location("Lemland Nyhamn", "100909", new BigDecimal("59.959194"),
50                                 new BigDecimal("19.953667")))));
51     }
52 }