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.lametrictime.internal.api.local.dto;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import java.io.FileReader;
19 import org.junit.jupiter.api.BeforeAll;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator;
22 import org.openhab.binding.lametrictime.internal.api.test.AbstractTest;
24 import com.google.gson.Gson;
29 * @author Gregory Moyer - Initial contribution
31 public class AudioTest extends AbstractTest {
32 private static Gson gson;
35 public static void setUpBeforeClass() {
36 gson = GsonGenerator.create(true);
40 public void testSerializeAllFields() throws Exception {
41 Audio audio = new Audio().withVolume(42);
42 assertEquals(readJson("audio.json"), gson.toJson(audio));
46 public void testDeserializeAllFields() throws Exception {
47 try (FileReader reader = new FileReader(getTestDataFile("audio.json"))) {
48 Audio audio = gson.fromJson(reader, Audio.class);
49 assertEquals(Integer.valueOf(42), audio.getVolume());