]> git.basschouten.com Git - openhab-addons.git/blob
1e7294d10842918efda1b70845dac69142ce12c0
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.nanoleaf.internal;
14
15 import static org.hamcrest.CoreMatchers.is;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.hamcrest.Matchers.greaterThan;
18
19 import java.util.List;
20
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;
26
27 import com.google.gson.Gson;
28
29 /**
30  * Test for the TouchEvents
31  *
32  * @author Stefan Höhn - Initial contribution
33  */
34
35 @NonNullByDefault
36 public class TouchTest {
37
38     private final Gson gson = new Gson();
39
40     @Test
41     public void testTheRightLayoutView() {
42         String json = "{\"events\":[{\"panelId\":48111,\"gesture\":1}]}";
43
44         TouchEvents touchEvents = gson.fromJson(json, TouchEvents.class);
45         if (touchEvents == null) {
46             touchEvents = new TouchEvents();
47         }
48         List<TouchEvent> events = touchEvents.getEvents();
49         assertThat(events.size(), greaterThan(0));
50         assertThat(events.size(), is(1));
51         @Nullable
52         TouchEvent touchEvent = events.get(0);
53         assertThat(touchEvent.getPanelId(), is("48111"));
54         assertThat(touchEvent.getGesture(), is(1));
55     }
56 }