@Test
void subscribeNewDevice() {

    // SETUP
    when(this.messageMetadata.getDeviceIdentification()).thenReturn("test-metadata-device-id");
    when(this.messageMetadata.getIpAddress()).thenReturn("test-metadata-host");
    when(this.mqttDeviceRepository.findByDeviceIdentification(
            this.messageMetadata.getDeviceIdentification())).thenReturn(null);
    when(this.mqttClientAdapterFactory.create(any(MqttDevice.class), eq(this.messageMetadata),
            eq(this.instance))).thenReturn(this.mqttClientAdapter);
    // CALL
    this.instance.subscribe(this.messageMetadata);
    // VERIFY
    verify(this.mqttDeviceRepository).save(this.deviceCaptor.capture());
    final MqttDevice savedDevice = this.deviceCaptor.getValue();
    assertEquals(this.messageMetadata.getDeviceIdentification(), savedDevice.getDeviceIdentification());
    assertEquals(DEFAULT_QOS.name(), savedDevice.getQos());
    assertEquals(this.messageMetadata.getIpAddress(), savedDevice.getHost());
    assertEquals(DEFAULT_TOPICS, savedDevice.getTopics());
    assertEquals(DEFAULT_PORT, savedDevice.getPort());
    verify(this.mqttClientAdapter).connect();
}