]> git.basschouten.com Git - openhab-addons.git/blob
13867e63b1c01d8c25eabdabb4f63996647bea92
[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.bluetooth.bluegiga.internal.attributeclient;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.bluetooth.bluegiga.internal.command.attributeclient.BlueGigaFindInformationFoundEvent;
20
21 /**
22  * Tests {@link BlueGigaFindInformationFoundEvent}.
23  *
24  * @author Pauli Anttila - Initial contribution
25  */
26 @NonNullByDefault
27 public class BlueGigaFindInformationFoundEventTest {
28
29     @Test
30     public void test16BitUUIDs() {
31         final int[] data = { 0x80, 0x06, 0x04, 0x04, 0x02, 0x0A, 0x00, 0x02, 0x00, 0x28 };
32         final String expectedUUID = "00002800-0000-1000-8000-00805F9B34FB";
33
34         BlueGigaFindInformationFoundEvent event = new BlueGigaFindInformationFoundEvent(data);
35         assertEquals(expectedUUID, event.getUuid().toString().toUpperCase());
36         assertEquals(2, event.getConnection());
37         assertEquals(10, event.getChrHandle());
38     }
39
40     @Test
41     public void test32BitUUIDs() {
42         final int[] data = { 0x80, 0x06, 0x04, 0x04, 0x02, 0x0A, 0x00, 0x04, 0x02, 0x01, 0x00, 0x28 };
43         final String expectedUUID = "28000102-0000-1000-8000-00805F9B34FB";
44
45         BlueGigaFindInformationFoundEvent event = new BlueGigaFindInformationFoundEvent(data);
46         assertEquals(expectedUUID, event.getUuid().toString().toUpperCase());
47         assertEquals(2, event.getConnection());
48         assertEquals(10, event.getChrHandle());
49     }
50
51     @Test
52     public void test128BitUUIDs() {
53         final int[] data = { 0x80, 0x14, 0x04, 0x04, 0x02, 0x0D, 0x00, 0x10, 0xBA, 0x5C, 0xF7, 0x93, 0x3B, 0x12, 0xD3,
54                 0x89, 0xE4, 0x11, 0xE7, 0xAD, 0x68, 0x2A, 0x2E, 0xB4 };
55         final String expectedUUID = "b42e2a68-ade7-11e4-89d3-123b93f75cba";
56
57         BlueGigaFindInformationFoundEvent event = new BlueGigaFindInformationFoundEvent(data);
58         assertEquals(expectedUUID, event.getUuid().toString().toLowerCase());
59         assertEquals(2, event.getConnection());
60         assertEquals(13, event.getChrHandle());
61     }
62 }