]> git.basschouten.com Git - openhab-addons.git/blob
50cb7a52f454f8d990d347dbf49e834d1935f868
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.Matchers.*;
17 import static org.junit.Assert.assertThat;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.junit.Test;
22 import org.openhab.binding.nanoleaf.internal.model.TouchEvent;
23 import org.openhab.binding.nanoleaf.internal.model.TouchEvents;
24
25 import com.google.gson.Gson;
26
27 /**
28  * Test for the TouchEvents
29  *
30  * @author Stefan Höhn - Initial contribution
31  */
32
33 @NonNullByDefault
34 public class TouchTest {
35
36     private final Gson gson = new Gson();
37
38     @Test
39     public void testTheRightLayoutView() {
40         String json = "{\"events\":[{\"panelId\":48111,\"gesture\":1}]}";
41         @Nullable
42         TouchEvents touchEvents = gson.fromJson(json, TouchEvents.class);
43         assertThat(touchEvents.getEvents().size(), greaterThan(0));
44         assertThat(touchEvents.getEvents().size(), is(1));
45         @Nullable
46         TouchEvent touchEvent = touchEvents.getEvents().get(0);
47         assertThat(touchEvent.getPanelId(), is("48111"));
48         assertThat(touchEvent.getGesture(), is(1));
49     }
50 }