2 * Copyright (c) 2010-2023 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.mybmw.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.mybmw.internal.dto.vehicle.Vehicle;
22 import org.openhab.binding.mybmw.internal.util.FileReader;
23 import org.openhab.binding.mybmw.internal.utils.Constants;
24 import org.openhab.binding.mybmw.internal.utils.Converter;
25 import org.openhab.binding.mybmw.internal.utils.RemoteServiceUtils;
26 import org.openhab.core.thing.ThingTypeUID;
27 import org.openhab.core.types.CommandOption;
30 * The {@link VehiclePropertiesTest} tests stored fingerprint responses from BMW API
32 * @author Bernd Weymann - Initial contribution
35 public class VehiclePropertiesTest {
38 public void testUserInfo() {
39 String content = FileReader.readFileInString("src/test/resources/responses/I01_REX/vehicles.json");
40 List<Vehicle> vl = Converter.getVehicleList(content);
42 assertEquals(1, vl.size(), "Number of Vehicles");
43 Vehicle v = vl.get(0);
44 assertEquals(Constants.ANONYMOUS, v.vin, "VIN");
45 assertEquals("i3 94 (+ REX)", v.model, "Model");
46 assertEquals(Constants.BEV, v.driveTrain, "DriveTrain");
47 assertEquals("BMW", v.brand, "Brand");
48 assertEquals(2017, v.year, "Year of Construction");
52 public void testChannelUID() {
53 ThingTypeUID thingTypePHEV = new ThingTypeUID("mybmw", "plugin-hybrid-vehicle");
54 assertEquals("plugin-hybrid-vehicle", thingTypePHEV.getId(), "Vehicle Type");
58 public void testRemoteServiceOptions() {
59 String commandReference = "[CommandOption [command=light-flash, label=Flash Lights], CommandOption [command=vehicle-finder, label=Vehicle Finder], CommandOption [command=door-lock, label=Door Lock], CommandOption [command=door-unlock, label=Door Unlock], CommandOption [command=horn-blow, label=Horn Blow], CommandOption [command=climate-now-start, label=Start Climate], CommandOption [command=climate-now-stop, label=Stop Climate]]";
60 List<CommandOption> l = RemoteServiceUtils.getOptions(true);
61 assertEquals(commandReference, l.toString(), "Commad Options");