]> git.basschouten.com Git - openhab-addons.git/blob
6876a45aed3954c02fab8c7b81f29d9c5f0ead42
[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.vehicle;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16
17 import org.junit.jupiter.api.Test;
18 import org.openhab.binding.mybmw.internal.handler.backend.JsonStringDeserializer;
19 import org.openhab.binding.mybmw.internal.util.FileReader;
20
21 /**
22  * 
23  * checks the transformation of the capabilities to string lists
24  * 
25  * @author Bernd Weymann - Initial contribution
26  * @author Martin Grassl - refactoring
27  */
28 public class VehicleCapabilitiesTest {
29     @Test
30     void testGetCapabilitiesAsString() {
31         String content = FileReader.fileToString("responses/BEV/vehicles_state.json");
32         VehicleStateContainer vehicleStateContainer = JsonStringDeserializer.getVehicleState(content);
33
34         String servicesSupportedReference = "BmwCharging;ChargingHistory;ChargingPlan;CustomerEsim;DCSContractManagement;RemoteHistory;ScanAndCharge";
35         String servicesUnsupportedReference = "CarSharing;ChargeNowForBusiness;ClimateTimer;EvGoCharging;MiniCharging;RemoteEngineStart;RemoteHistoryDeletion;RemoteParking;Sustainability;WifiHotspotService";
36         String servicesEnabledReference = "ChargingHospitality;ChargingLoudness;ChargingPowerLimit;ChargingSettings;ChargingTargetSoc";
37         String servicesDisabledReference = "DataPrivacy;EasyCharge;NonLscFeature;SustainabilityAccumulatedView";
38         assertEquals(servicesSupportedReference, vehicleStateContainer.getCapabilities()
39                 .getCapabilitiesAsString(VehicleCapabilities.SUPPORTED_SUFFIX, true), "Services supported");
40         assertEquals(servicesUnsupportedReference, vehicleStateContainer.getCapabilities()
41                 .getCapabilitiesAsString(VehicleCapabilities.SUPPORTED_SUFFIX, false), "Services unsupported");
42         assertEquals(servicesEnabledReference, vehicleStateContainer.getCapabilities()
43                 .getCapabilitiesAsString(VehicleCapabilities.ENABLED_SUFFIX, true), "Services enabled");
44         assertEquals(servicesDisabledReference, vehicleStateContainer.getCapabilities()
45                 .getCapabilitiesAsString(VehicleCapabilities.ENABLED_SUFFIX, false), "Services disabled");
46     }
47 }