]> git.basschouten.com Git - openhab-addons.git/blob
971fccfdea567fb14ef8d2224c1c7d644b82d7e8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.junit.Assert.*;
17
18 import java.nio.file.Path;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.Test;
22 import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
23
24 /**
25  * Test cases for AbstractWeatherHandler. The tests provide mocks for supporting entities using Mockito.
26  *
27  * @author Sami Salonen - Initial contribution
28  */
29 @NonNullByDefault
30 public class FMIResponseParsingExceptionReportTest extends AbstractFMIResponseParsingTest {
31
32     private Path error1 = getTestResource("error1.xml");
33
34     @Test
35     public void testErrorResponse() {
36         try {
37             parseMultiPointCoverageXml(readTestResourceUtf8(error1));
38         } catch (FMIResponseException e) {
39             // OK
40             assertThat(e.getMessage(), is(
41                     "Exception report (OperationParsingFailed): [Invalid time interval!, The start time is later than the end time., URI:\n\t\t\t/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]"));
42             return;
43         } catch (Throwable e) {
44             fail("Wrong exception, was " + e.getClass().getName());
45         }
46         fail("FMIResponseException expected");
47     }
48 }