@Test
public void connectPeripheralAlreadyConnectedTest() throws Exception {

    application.grantPermissions(Manifest.permission.ACCESS_COARSE_LOCATION);
    BluetoothPeripheral peripheral = mock(BluetoothPeripheral.class);
    when(peripheral.getAddress()).thenReturn("12:23:34:98:76:54");
    when(peripheral.getType()).thenReturn(BluetoothDevice.DEVICE_TYPE_LE);

    central.connectPeripheral(peripheral, peripheralCallback);

    verify(peripheral).connect();

    // Grab the scan callback that is used
    Field field = BluetoothCentral.class.getDeclaredField("internalCallback");
    field.setAccessible(true);
    BluetoothPeripheral.InternalCallback internalCallback = (BluetoothPeripheral.InternalCallback) field.get(central);

    // Give connected event and see if we get callback
    internalCallback.connected(peripheral);

    verify(callback).onConnectedPeripheral(peripheral);

    central.connectPeripheral(peripheral, peripheralCallback);

    verify(peripheral, times(1)).connect();
}