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.bluetooth.enoceanble.internal;
15 import static org.junit.jupiter.api.Assertions.assertFalse;
16 import static org.junit.jupiter.api.Assertions.assertTrue;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.Test;
22 * {@link EnoceanBlePtm215EventTest} is testing the {@link EnoceanBlePtm215Event} class
23 * using some sample manufacturerData
25 * @author Patrick Fink - Initial contribution
28 public class EnoceanBlePtm215EventTest {
31 public void testButton1Dir1Pressed() {
32 byte[] button1Dir2PressedBytes = { -38, 3, 53, 5, 0, 0, 17, 54, 81, 61, 54 };
33 EnoceanBlePtm215Event button1Dir2PressedEvent = new EnoceanBlePtm215Event(button1Dir2PressedBytes);
35 assertTrue(button1Dir2PressedEvent.isPressed());
36 assertTrue(button1Dir2PressedEvent.isButton1());
37 assertTrue(button1Dir2PressedEvent.isDir1());
41 public void testButton1Dir1Released() {
42 byte[] button1Dir2ReleasedBytes = { -38, 3, 54, 5, 0, 0, 16, -83, -25, 103, 3 };
43 EnoceanBlePtm215Event button1Dir2ReleasedEvent = new EnoceanBlePtm215Event(button1Dir2ReleasedBytes);
45 assertFalse(button1Dir2ReleasedEvent.isPressed());
46 assertTrue(button1Dir2ReleasedEvent.isButton1());
47 assertTrue(button1Dir2ReleasedEvent.isDir1());
51 public void testButton1Dir2Pressed() {
52 byte[] button1Dir2PressedBytes = { -38, 3, -97, 32, 0, 0, 9, -99, -15, 16, -74 };
53 EnoceanBlePtm215Event button1Dir2PressedEvent = new EnoceanBlePtm215Event(button1Dir2PressedBytes);
55 assertTrue(button1Dir2PressedEvent.isPressed());
56 assertTrue(button1Dir2PressedEvent.isButton1());
57 assertTrue(button1Dir2PressedEvent.isDir2());
61 public void testButton1Dir2Released() {
62 byte[] button1Dir2ReleasedBytes = { -38, 3, -96, 32, 0, 0, 8, -87, -96, 98, 74 };
63 EnoceanBlePtm215Event button1Dir2ReleasedEvent = new EnoceanBlePtm215Event(button1Dir2ReleasedBytes);
65 assertFalse(button1Dir2ReleasedEvent.isPressed());
66 assertTrue(button1Dir2ReleasedEvent.isButton1());
67 assertTrue(button1Dir2ReleasedEvent.isDir2());
71 public void testButton2Dir1Pressed() {
72 byte[] button2Dir1PressedBytes = { -38, 3, -91, 32, 0, 0, 5, 89, 104, 24, -67 };
73 EnoceanBlePtm215Event button2Dir1PressedEvent = new EnoceanBlePtm215Event(button2Dir1PressedBytes);
75 assertTrue(button2Dir1PressedEvent.isPressed());
76 assertTrue(button2Dir1PressedEvent.isButton2());
77 assertTrue(button2Dir1PressedEvent.isDir1());
81 public void testButton2Dir1Released() {
82 byte[] button2Dir1ReleasedBytes = { -38, 3, -90, 32, 0, 0, 4, 120, 52, -115, 61 };
83 EnoceanBlePtm215Event button2Dir1ReleasedEvent = new EnoceanBlePtm215Event(button2Dir1ReleasedBytes);
84 assertFalse(button2Dir1ReleasedEvent.isPressed());
85 assertTrue(button2Dir1ReleasedEvent.isButton2());
86 assertTrue(button2Dir1ReleasedEvent.isDir1());
90 public void testButton2Dir2Pressed() {
91 byte[] button2Dir2PressedBytes = { -38, 3, -95, 32, 0, 0, 3, -105, -33, 62, 45 };
92 EnoceanBlePtm215Event button2Dir1PressedEvent = new EnoceanBlePtm215Event(button2Dir2PressedBytes);
93 assertTrue(button2Dir1PressedEvent.isPressed());
94 assertTrue(button2Dir1PressedEvent.isButton2());
95 assertTrue(button2Dir1PressedEvent.isDir2());
99 public void testButton2Dir2Released() {
100 byte[] button2Dir2ReleasedBytes = { -38, 3, -94, 32, 0, 0, 2, 59, 118, 52, -69 };
101 EnoceanBlePtm215Event button2Dir2ReleasedEvent = new EnoceanBlePtm215Event(button2Dir2ReleasedBytes);
103 assertFalse(button2Dir2ReleasedEvent.isPressed());
104 assertTrue(button2Dir2ReleasedEvent.isButton2());
105 assertTrue(button2Dir2ReleasedEvent.isDir2());