2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.bmwconnecteddrive.internal.dto;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import java.util.List;
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;
26 import com.google.gson.Gson;
29 * The {@link ConnectedDriveTest} Test json responses from ConnectedDrive Portal
31 * @author Bernd Weymann - Initial contribution
34 @SuppressWarnings("null")
35 public class ConnectedDriveTest {
36 private static final Gson GSON = new Gson();
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");
53 public void testChannelUID() {
54 ThingTypeUID thingTypePHEV = new ThingTypeUID("bmwconnecteddrive", "plugin-hybrid-vehicle");
55 assertEquals("plugin-hybrid-vehicle", thingTypePHEV.getId(), "Vehicle Type");