From e35ae864104e2222af73682fc68052ee60ef3692 Mon Sep 17 00:00:00 2001 From: Dariusz Seweryn Date: Sun, 17 Mar 2024 11:45:06 +0100 Subject: [PATCH] Migrated BleCannotSetCharacteristicNotificationExceptionTest. --- ...acteristicNotificationExceptionTest.groovy | 28 ------------------ ...aracteristicNotificationExceptionTest.java | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) delete mode 100644 rxandroidble/src/test/groovy/com/polidea/rxandroidble2/exceptions/BleCannotSetCharacteristicNotificationExceptionTest.groovy create mode 100644 rxandroidble/src/test/java/com/polidea/rxandroidble2/exceptions/BleCannotSetCharacteristicNotificationExceptionTest.java diff --git a/rxandroidble/src/test/groovy/com/polidea/rxandroidble2/exceptions/BleCannotSetCharacteristicNotificationExceptionTest.groovy b/rxandroidble/src/test/groovy/com/polidea/rxandroidble2/exceptions/BleCannotSetCharacteristicNotificationExceptionTest.groovy deleted file mode 100644 index 329a4b04a..000000000 --- a/rxandroidble/src/test/groovy/com/polidea/rxandroidble2/exceptions/BleCannotSetCharacteristicNotificationExceptionTest.groovy +++ /dev/null @@ -1,28 +0,0 @@ -package com.polidea.rxandroidble2.exceptions - -import android.bluetooth.BluetoothGattCharacteristic -import spock.lang.Specification - -/** - * Tests BleCannotSetCharacteristicNotificationException - */ -class BleCannotSetCharacteristicNotificationExceptionTest extends Specification { - - BleCannotSetCharacteristicNotificationException objectUnderTest - - BluetoothGattCharacteristic mockCharacteristic = Mock BluetoothGattCharacteristic - - def "toString should include message"() { - - given: - mockCharacteristic.uuid >> new UUID(1, 2) - when: - objectUnderTest = new BleCannotSetCharacteristicNotificationException(mockCharacteristic, - BleCannotSetCharacteristicNotificationException.CANNOT_SET_LOCAL_NOTIFICATION, new Exception("because")) - - then: - assert objectUnderTest.toString() == - "com.polidea.rxandroidble2.exceptions.BleCannotSetCharacteristicNotificationException: " + - "Cannot set local notification (code 1) with characteristic UUID 00000000-0000-0001-0000-000000000002" - } -} diff --git a/rxandroidble/src/test/java/com/polidea/rxandroidble2/exceptions/BleCannotSetCharacteristicNotificationExceptionTest.java b/rxandroidble/src/test/java/com/polidea/rxandroidble2/exceptions/BleCannotSetCharacteristicNotificationExceptionTest.java new file mode 100644 index 000000000..25b59ba4e --- /dev/null +++ b/rxandroidble/src/test/java/com/polidea/rxandroidble2/exceptions/BleCannotSetCharacteristicNotificationExceptionTest.java @@ -0,0 +1,29 @@ +package com.polidea.rxandroidble2.exceptions; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import android.bluetooth.BluetoothGattCharacteristic; + +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import java.util.UUID; + +public class BleCannotSetCharacteristicNotificationExceptionTest { + + @Test + public void toStringShouldContainMessage() { + // given + BluetoothGattCharacteristic mockCharacteristic = Mockito.mock(BluetoothGattCharacteristic.class); + Mockito.when(mockCharacteristic.getUuid()).thenReturn(new UUID(1, 2)); + BleCannotSetCharacteristicNotificationException out = new BleCannotSetCharacteristicNotificationException( + mockCharacteristic, + BleCannotSetCharacteristicNotificationException.CANNOT_SET_LOCAL_NOTIFICATION, + new Exception("because")); + + // expect + assertEquals(out.toString(), + "com.polidea.rxandroidble2.exceptions.BleCannotSetCharacteristicNotificationException: " + + "Cannot set local notification (code 1) with characteristic UUID 00000000-0000-0001-0000-000000000002"); + } +}