@Test
public void connectNodeWithDebug(){
BluetoothDevice device = spy(Shadow.newInstanceOf(BluetoothDevice.class));
BluetoothDeviceShadow shadowDevice = Shadow.extract(device);
BluetoothGattService debugService = new BluetoothGattService(BLENodeDefines.Services
.Debug.DEBUG_SERVICE_UUID,BluetoothGattService.SERVICE_TYPE_PRIMARY);
debugService.addCharacteristic(
new BluetoothGattCharacteristic(BLENodeDefines.Services.Debug.DEBUG_STDERR_UUID,
BluetoothGattCharacteristic.PERMISSION_READ |
BluetoothGattCharacteristic.PERMISSION_WRITE,
BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic
.PROPERTY_NOTIFY));
debugService.addCharacteristic(
new BluetoothGattCharacteristic(BLENodeDefines.Services.Debug.DEBUG_TERM_UUID,
BluetoothGattCharacteristic.PERMISSION_READ |
BluetoothGattCharacteristic.PERMISSION_WRITE,
BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic
.PROPERTY_NOTIFY)
);
shadowDevice.addService(debugService);
Node node = createNode(device);
Assert.assertEquals(Node.State.Idle, node.getState());
node.connect(RuntimeEnvironment.application);
TestUtil.execAllAsyncTask();
verify(device).connectGatt(eq(RuntimeEnvironment.application), eq(false),
any(BluetoothGattCallback.class));
Assert.assertEquals(Node.State.Connected, node.getState());
Assert.assertTrue(node.getDebug()!=null);
}