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.mielecloud.internal.webservice.api.json;
15 import static org.junit.jupiter.api.Assertions.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
20 import com.google.gson.Gson;
23 * @author Björn Lange - Initial contribution
26 public class StatusTest {
28 public void testParseStatusWithUnknownRawValue() {
30 String json = "{ \"key_localized\": \"State\", \"value_raw\": 99, \"value_localized\": \"Booting\" }";
33 Status status = new Gson().fromJson(json, Status.class);
36 assertNotNull(status);
37 assertEquals("State", status.getKeyLocalized().get());
38 assertEquals(Integer.valueOf(99), status.getValueRaw().get());
39 assertEquals("Booting", status.getValueLocalized().get());
43 public void testParseStatusWithKnownRawValue() {
45 String json = "{ \"key_localized\": \"State\", \"value_raw\": 1, \"value_localized\": \"Off\" }";
48 Status status = new Gson().fromJson(json, Status.class);
51 assertNotNull(status);
52 assertEquals("State", status.getKeyLocalized().get());
53 assertEquals(Integer.valueOf(StateType.OFF.getCode()), status.getValueRaw().get());
54 assertEquals("Off", status.getValueLocalized().get());