-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e516977
commit 0fe048a
Showing
3 changed files
with
43 additions
and
24 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
...droidble/src/test/groovy/com/polidea/rxandroidble2/exceptions/BleGattExceptionTest.groovy
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
rxandroidble/src/test/java/com/polidea/rxandroidble2/exceptions/BleGattExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.polidea.rxandroidble2.exceptions; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import android.bluetooth.BluetoothGatt; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import utils.MockUtils; | ||
|
||
public class BleGattExceptionTest { | ||
|
||
@Test | ||
public void toStringShouldContainMessage() { | ||
// given | ||
BluetoothGatt mockBtGatt = MockUtils.bluetoothGatt("AA:BB:CC:DD:EE:FF"); | ||
BleGattException out = new BleGattException(mockBtGatt, 10, BleGattOperationType.CONNECTION_STATE); | ||
|
||
// expect | ||
assertEquals(out.toString(), | ||
"com.polidea.rxandroidble2.exceptions.BleGattException: GATT exception from MAC='XX:XX:XX:XX:XX:XX', status 10 (GATT_NOT_FOUND), " + | ||
"type BleGattOperation{description='CONNECTION_STATE'}. " + | ||
"(Look up status 0x0a here " + | ||
"https://cs.android.com/android/platform/superproject/+/master:packages/modules/Bluetooth/system/stack/include/gatt_api.h)"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package utils; | ||
|
||
import android.bluetooth.BluetoothDevice; | ||
import android.bluetooth.BluetoothGatt; | ||
|
||
import org.mockito.Mockito; | ||
|
||
public class MockUtils { | ||
|
||
public static BluetoothGatt bluetoothGatt(String deviceAddress) { | ||
BluetoothGatt bluetoothGatt = Mockito.mock(BluetoothGatt.class); | ||
BluetoothDevice bluetoothDevice = Mockito.mock(BluetoothDevice.class); | ||
Mockito.when(bluetoothGatt.getDevice()).thenReturn(bluetoothDevice); | ||
Mockito.when(bluetoothDevice.getAddress()).thenReturn(deviceAddress); | ||
return bluetoothGatt; | ||
} | ||
} |