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.vehicle;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import static org.junit.jupiter.api.Assertions.assertNotNull;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.mybmw.internal.handler.backend.JsonStringDeserializer;
20 import org.openhab.binding.mybmw.internal.util.FileReader;
21 import org.openhab.binding.mybmw.internal.utils.VehicleStatusUtils;
22 import org.openhab.core.library.types.DateTimeType;
24 import com.google.gson.Gson;
28 * checks basic data of state of vehicle
30 * @author Bernd Weymann - Initial contribution
31 * @author Martin Grassl - refactoring
33 public class VehicleStateContainerTest {
35 public void testVehicleStateDeserializationByGson() {
36 String vehicleStateJson = FileReader.fileToString("responses/MILD_HYBRID/vehicles_state.json");
37 Gson gson = new Gson();
39 VehicleStateContainer vehicle = gson.fromJson(vehicleStateJson, VehicleStateContainer.class);
41 assertNotNull(vehicle);
45 public void testVehicleStateDeserializationByConverter() {
46 String vehicleStateJson = FileReader.fileToString("responses/MILD_HYBRID/vehicles_state.json");
48 VehicleStateContainer vehicleStateContainer = JsonStringDeserializer.getVehicleState(vehicleStateJson);
50 assertNotNull(vehicleStateContainer);
51 assertEquals("2024-06-01T00:00",
52 ((DateTimeType) VehicleStatusUtils
53 .getNextServiceDate(vehicleStateContainer.getState().getRequiredServices())).getZonedDateTime()
54 .toLocalDateTime().toString(),
57 assertEquals("2022-12-21T15:41:23Z", vehicleStateContainer.getState().getLastUpdatedAt(), "Last update time");