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 TypeTest {
28 public void testParseTypeWithUnknownRawValue() {
30 String json = "{ \"key_localized\": \"Devicetype\", \"value_raw\": 99, \"value_localized\": \"Car Vaccuum Robot\" }";
33 Type type = new Gson().fromJson(json, Type.class);
37 assertEquals("Devicetype", type.getKeyLocalized().get());
38 assertEquals(DeviceType.UNKNOWN, type.getValueRaw());
39 assertEquals("Car Vaccuum Robot", type.getValueLocalized().get());
43 public void testParseTypeWithKnownRawValue() {
45 String json = "{ \"key_localized\": \"Devicetype\", \"value_raw\": 1, \"value_localized\": \"Washing Machine\" }";
48 Type type = new Gson().fromJson(json, Type.class);
52 assertEquals("Devicetype", type.getKeyLocalized().get());
53 assertEquals(DeviceType.WASHING_MACHINE, type.getValueRaw());
54 assertEquals("Washing Machine", type.getValueLocalized().get());