]> git.basschouten.com Git - openhab-addons.git/blob
ece7d6778dcfb93158f8db9f85eff30630f274d7
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.mybmw.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.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;
28
29 /**
30  * The {@link VehiclePropertiesTest} tests stored fingerprint responses from BMW API
31  *
32  * @author Bernd Weymann - Initial contribution
33  */
34 @NonNullByDefault
35 public class VehiclePropertiesTest {
36
37     @Test
38     public void testUserInfo() {
39         String content = FileReader.readFileInString("src/test/resources/responses/I01_REX/vehicles.json");
40         List<Vehicle> vl = Converter.getVehicleList(content);
41
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");
49     }
50
51     @Test
52     public void testChannelUID() {
53         ThingTypeUID thingTypePHEV = new ThingTypeUID("mybmw", "plugin-hybrid-vehicle");
54         assertEquals("plugin-hybrid-vehicle", thingTypePHEV.getId(), "Vehicle Type");
55     }
56
57     @Test
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");
62     }
63 }