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.nanoleaf.internal;
15 import static org.hamcrest.CoreMatchers.is;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.hamcrest.Matchers.greaterThan;
19 import java.util.List;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.junit.jupiter.api.Test;
24 import org.openhab.binding.nanoleaf.internal.model.TouchEvent;
25 import org.openhab.binding.nanoleaf.internal.model.TouchEvents;
27 import com.google.gson.Gson;
30 * Test for the TouchEvents
32 * @author Stefan Höhn - Initial contribution
36 public class TouchTest {
38 private final Gson gson = new Gson();
41 public void testTheRightLayoutView() {
42 String json = "{\"events\":[{\"panelId\":48111,\"gesture\":1}]}";
44 TouchEvents touchEvents = gson.fromJson(json, TouchEvents.class);
45 if (touchEvents == null) {
46 touchEvents = new TouchEvents();
48 List<TouchEvent> events = touchEvents.getEvents();
49 assertThat(events.size(), greaterThan(0));
50 assertThat(events.size(), is(1));
52 TouchEvent touchEvent = events.get(0);
53 assertThat(touchEvent.getPanelId(), is("48111"));
54 assertThat(touchEvent.getGesture(), is(1));