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 final static String testAirPurifierResponseBasedOnCore400S = "{\n" +
34 " \"msg\": \"request success\",\n" +
35 " \"traceId\": \"1634255391\",\n" +
36 " \"screenStatus\": \"on1\",\n" +
37 " \"airQuality\": 1,\n" +
39 " \"mode\": \"manual\",\n" +
40 " \"deviceName\": \"Lounge Air Purifier\",\n" +
41 " \"currentFirmVersion\": \"1.0.17\",\n" +
42 " \"childLock\": \"off1\",\n" +
43 " \"deviceStatus\": \"on2\",\n" +
44 " \"deviceImg\": \"https://image.vesync.com/defaultImages/Core_400S_Series/icon_core400s_purifier_160.png\",\n" +
45 " \"connectionStatus\": \"online\"\n" +
49 public void testParseV1AirPurifierDeviceDetailsResponse() {
50 VesyncV1AirPurifierDeviceDetailsResponse response = VeSyncConstants.GSON.fromJson(testAirPurifierResponseBasedOnCore400S,
51 VesyncV1AirPurifierDeviceDetailsResponse.class);
53 if (response != null) {
54 assertEquals("on1", response.getScreenStatus());
55 assertEquals(1, response.getAirQuality());
56 assertEquals(2, response.getLevel());
57 assertEquals("manual", response.getMode());
58 assertEquals("Lounge Air Purifier", response.getDeviceName());
59 assertEquals("1.0.17", response.getCurrentFirmVersion());
60 assertEquals("off1", response.getChildLock());
61 assertEquals("on2", response.getDeviceStatus());
62 assertEquals("https://image.vesync.com/defaultImages/Core_400S_Series/icon_core400s_purifier_160.png", response.getDeviceImgUrl());
63 assertEquals("online", response.getConnectionStatus());
65 fail("GSON returned null");