]> git.basschouten.com Git - openhab-addons.git/blob
817ff63def8a446bf1852716032f432952bf4722
[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 org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.mybmw.internal.dto.charge.ChargeProfile;
20 import org.openhab.binding.mybmw.internal.dto.vehicle.Vehicle;
21 import org.openhab.binding.mybmw.internal.util.FileReader;
22 import org.openhab.binding.mybmw.internal.utils.ChargeProfileWrapper;
23 import org.openhab.binding.mybmw.internal.utils.Constants;
24 import org.openhab.binding.mybmw.internal.utils.Converter;
25
26 /**
27  * The {@link ChargeProfileTest} is testing locale settings
28  *
29  * @author Bernd Weymann - Initial contribution
30  */
31 @NonNullByDefault
32 public class ChargeProfileTest {
33
34     @Test
35     public void testWeeklyPlanner() {
36         String json = FileReader
37                 .readFileInString("src/test/resources/responses/chargingprofile/weekly-planner-t2-active.json");
38         Vehicle v = Converter.getVehicle(Constants.ANONYMOUS, json);
39         ChargeProfile cp = v.status.chargingProfile;
40         String cpJson = Converter.getGson().toJson(cp);
41         ChargeProfileWrapper cpw = new ChargeProfileWrapper(v.status.chargingProfile);
42         assertEquals(cpJson, cpw.getJson(), "JSON comparison");
43     }
44
45     @Test
46     public void testTwoWeeksPlanner() {
47         String json = FileReader.readFileInString("src/test/resources/responses/chargingprofile/two-weeks-timer.json");
48         Vehicle v = Converter.getVehicle(Constants.ANONYMOUS, json);
49         ChargeProfile cp = v.status.chargingProfile;
50         String cpJson = Converter.getGson().toJson(cp);
51         ChargeProfileWrapper cpw = new ChargeProfileWrapper(v.status.chargingProfile);
52         assertEquals(cpJson, cpw.getJson(), "JSON comparison");
53     }
54 }