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.vesync.internal.handler.responses.v1;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.junit.jupiter.api.Test;
17 import org.openhab.binding.vesync.internal.VeSyncConstants;
18 import org.openhab.binding.vesync.internal.dto.responses.VesyncLoginResponse;
19 import org.openhab.binding.vesync.internal.dto.responses.v1.VesyncV1AirPurifierDeviceDetailsResponse;
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.fail;
25 * The {@link VesyncV1AirPurifierDeviceDetailsTest} class implements unit test case for {@link VesyncLoginResponse}
27 * @author David Goodyear - Initial contribution
30 public class VesyncV1AirPurifierDeviceDetailsTest {
32 public static final String testAirPurifierResponseBasedOnCore400S = """
35 "msg": "request success",
36 "traceId": "1634255391",
37 "screenStatus": "on1",
41 "deviceName": "Lounge Air Purifier",
42 "currentFirmVersion": "1.0.17",
44 "deviceStatus": "on2",
45 "deviceImg": "https://image.vesync.com/defaultImages/Core_400S_Series/icon_core400s_purifier_160.png",
46 "connectionStatus": "online"
51 public void testParseV1AirPurifierDeviceDetailsResponse() {
52 VesyncV1AirPurifierDeviceDetailsResponse response = VeSyncConstants.GSON.fromJson(testAirPurifierResponseBasedOnCore400S,
53 VesyncV1AirPurifierDeviceDetailsResponse.class);
55 if (response != null) {
56 assertEquals("on1", response.getScreenStatus());
57 assertEquals(1, response.getAirQuality());
58 assertEquals(2, response.getLevel());
59 assertEquals("manual", response.getMode());
60 assertEquals("Lounge Air Purifier", response.getDeviceName());
61 assertEquals("1.0.17", response.getCurrentFirmVersion());
62 assertEquals("off1", response.getChildLock());
63 assertEquals("on2", response.getDeviceStatus());
64 assertEquals("https://image.vesync.com/defaultImages/Core_400S_Series/icon_core400s_purifier_160.png", response.getDeviceImgUrl());
65 assertEquals("online", response.getConnectionStatus());
67 fail("GSON returned null");