2 * Copyright (c) 2010-2022 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;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import static org.junit.jupiter.api.Assertions.fail;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.Test;
20 import org.openhab.binding.vesync.internal.VeSyncConstants;
21 import org.openhab.binding.vesync.internal.dto.responses.VesyncResponse;
24 * The {@link VesyncResponseTest} class implements unit test case for {@link VesyncResponse}
26 * @author David Goodyear - Initial contribution
29 public class VesyncResponseTest {
32 public void checkBaseFields() {
33 String baseTestResponse = "{\"traceId\":\"1234569876\",\r\n\"code\": 142,\r\n\"msg\": \"Response Text\"\r\n}";
34 VesyncResponse response = VeSyncConstants.GSON.fromJson(baseTestResponse, VesyncResponse.class);
35 if (response != null) {
36 assertEquals("1234569876", response.getTraceId());
37 assertEquals("142", response.getCode());
38 assertEquals("Response Text", response.msg);
39 assertEquals(false, response.isMsgSuccess());
41 fail("GSON returned null");
46 public void checkResponseSuccessMsg() {
47 String baseTestResponse = "{\"traceId\":\"1234569876\",\r\n\"code\": 142,\r\n\"msg\": \"request success\"\r\n}";
48 VesyncResponse response = VeSyncConstants.GSON.fromJson(baseTestResponse, VesyncResponse.class);
49 if (response != null) {
50 assertEquals(true, response.isMsgSuccess());
52 fail("GSON returned null");