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.*;
17 import java.io.FileReader;
18 import java.util.TreeMap;
20 import org.junit.jupiter.api.BeforeAll;
21 import org.junit.jupiter.api.Test;
22 import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator;
23 import org.openhab.binding.lametrictime.internal.api.test.AbstractTest;
25 import com.google.gson.Gson;
30 * @author Gregory Moyer - Initial contribution
32 public class UpdateActionTest extends AbstractTest {
33 private static Gson gson;
36 public static void setUpBeforeClass() {
37 gson = GsonGenerator.create(true);
41 @SuppressWarnings("serial")
42 public void testSerialize() throws Exception {
43 UpdateAction action = new UpdateAction().withId("countdown.configure")
45 .withParameters(new TreeMap<String, Parameter>(){{put("duration", new IntegerParameter().withValue(30));}});
47 assertEquals(readJson("update-action.json"), gson.toJson(action));
51 public void testDeserialize() throws Exception {
52 try (FileReader reader = new FileReader(getTestDataFile("update-action.json"))) {
53 assertThrows(UnsupportedOperationException.class, () -> gson.fromJson(reader, UpdateAction.class));