]> git.basschouten.com Git - openhab-addons.git/blob
612cc295b78a6721022a50f73bceb7446eb1f1a4
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.assertEquals;
16
17 import java.util.List;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.bmwconnecteddrive.internal.dto.discovery.Vehicle;
22 import org.openhab.binding.bmwconnecteddrive.internal.dto.discovery.VehiclesContainer;
23 import org.openhab.binding.bmwconnecteddrive.internal.util.FileReader;
24 import org.openhab.core.thing.ThingTypeUID;
25
26 import com.google.gson.Gson;
27
28 /**
29  * The {@link ConnectedDriveTest} Test json responses from ConnectedDrive Portal
30  *
31  * @author Bernd Weymann - Initial contribution
32  */
33 @NonNullByDefault
34 @SuppressWarnings("null")
35 public class ConnectedDriveTest {
36     private static final Gson GSON = new Gson();
37
38     @Test
39     public void testUserInfo() {
40         String resource1 = FileReader.readFileInString("src/test/resources/webapi/connected-drive-account-info.json");
41         VehiclesContainer container = GSON.fromJson(resource1, VehiclesContainer.class);
42         List<Vehicle> vehicles = container.vehicles;
43         assertEquals(1, vehicles.size(), "Number of Vehicles");
44         Vehicle v = vehicles.get(0);
45         assertEquals("MY_REAL_VIN", v.vin, "VIN");
46         assertEquals("i3 94 (+ REX)", v.model, "Model");
47         assertEquals("BEV_REX", v.driveTrain, "DriveTrain");
48         assertEquals("BMW_I", v.brand, "Brand");
49         assertEquals(2017, v.yearOfConstruction, "Year of Construction");
50     }
51
52     @Test
53     public void testChannelUID() {
54         ThingTypeUID thingTypePHEV = new ThingTypeUID("bmwconnecteddrive", "plugin-hybrid-vehicle");
55         assertEquals("plugin-hybrid-vehicle", thingTypePHEV.getId(), "Vehicle Type");
56     }
57 }