]> git.basschouten.com Git - openhab-addons.git/blob
0ac8bcf08505b89197af28c65e1a926363142696
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.bmwconnecteddrive.internal.dto;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.bmwconnecteddrive.internal.dto.statistics.LastTrip;
20 import org.openhab.binding.bmwconnecteddrive.internal.dto.statistics.LastTripContainer;
21 import org.openhab.binding.bmwconnecteddrive.internal.util.FileReader;
22
23 import com.google.gson.Gson;
24
25 /**
26  * The {@link LastTripTest} Test json responses from ConnectedDrive Portal
27  *
28  * @author Bernd Weymann - Initial contribution
29  */
30 @NonNullByDefault
31 @SuppressWarnings("null")
32 public class LastTripTest {
33     private static final Gson GSON = new Gson();
34
35     @Test
36     public void testUserInfo() {
37         String content = FileReader.readFileInString("src/test/resources/webapi/last-trip.json");
38         LastTripContainer lt = GSON.fromJson(content, LastTripContainer.class);
39         LastTrip trip = lt.lastTrip;
40         assertNotNull(trip);
41         assertEquals(2.0, trip.totalDistance, 0.01, "Distance Driven");
42     }
43 }