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.bluegiga.internal.attributeclient;
15 import static org.junit.jupiter.api.Assertions.*;
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;
22 * Tests {@link BlueGigaFindInformationFoundEvent}.
24 * @author Pauli Anttila - Initial contribution
27 public class BlueGigaFindInformationFoundEventTest {
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";
34 BlueGigaFindInformationFoundEvent event = new BlueGigaFindInformationFoundEvent(data);
35 assertEquals(expectedUUID, event.getUuid().toString().toUpperCase());
36 assertEquals(2, event.getConnection());
37 assertEquals(10, event.getChrHandle());
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";
45 BlueGigaFindInformationFoundEvent event = new BlueGigaFindInformationFoundEvent(data);
46 assertEquals(expectedUUID, event.getUuid().toString().toUpperCase());
47 assertEquals(2, event.getConnection());
48 assertEquals(10, event.getChrHandle());
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";
57 BlueGigaFindInformationFoundEvent event = new BlueGigaFindInformationFoundEvent(data);
58 assertEquals(expectedUUID, event.getUuid().toString().toLowerCase());
59 assertEquals(2, event.getConnection());
60 assertEquals(13, event.getChrHandle());