]> git.basschouten.com Git - openhab-addons.git/blob
c4ea4c74aefce43ab4c6af61e75c0760bb1ecbdd
[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.is;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.junit.jupiter.api.Assertions.fail;
18
19 import java.nio.file.Path;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
24
25 /**
26  * Test cases for AbstractWeatherHandler. The tests provide mocks for supporting entities using Mockito.
27  *
28  * @author Sami Salonen - Initial contribution
29  */
30 @NonNullByDefault
31 public class FMIResponseParsingExceptionReportTest extends AbstractFMIResponseParsingTest {
32
33     private Path error1 = getTestResource("error1.xml");
34
35     @Test
36     public void testErrorResponse() {
37         try {
38             parseMultiPointCoverageXml(readTestResourceUtf8(error1));
39         } catch (FMIResponseException e) {
40             // OK
41             assertThat(e.getMessage(), is(
42                     "Exception report (OperationParsingFailed): [Invalid time interval!, The start time is later than the end time., URI: /wfs?endtime=1900-03-10T20%3A10%3A00Z&fmisid=101023&parameters=t2m%2Crh%2Cwd_10min%2Cws_10min%2Cwg_10min%2Cp_sea&request=getFeature&service=WFS&starttime=2019-03-10T10%3A10%3A00Z&storedquery_id=fmi%3A%3Aobservations%3A%3Aweather%3A%3Amultipointcoverage&timestep=60&version=2.0.0]"));
43             return;
44         } catch (Throwable e) {
45             fail("Wrong exception, was " + e.getClass().getName());
46         }
47         fail("FMIResponseException expected");
48     }
49 }