  @Test
  public void whenConnectionLostOccurs() {

    PahoRxMqttCallback rxMqttCallback = spy(PahoRxMqttCallback.create(cause -> {}, (recon, uri) -> {}, t -> {}));

    PahoRxMqttException exception = new PahoRxMqttException(
        new MqttException(MqttException.REASON_CODE_CONNECTION_LOST));

    ArgumentCaptor<Throwable> onConnectionLostCauseArgumentCaptor = ArgumentCaptor.forClass(Throwable.class);

    rxMqttCallback.connectionLost(exception);

    verify(rxMqttCallback).connectionLost(onConnectionLostCauseArgumentCaptor.capture());

    assertThat(onConnectionLostCauseArgumentCaptor.getValue()).isNotNull();
    assertThat(onConnectionLostCauseArgumentCaptor.getValue()).isInstanceOf(PahoRxMqttException.class);
    assertThat(onConnectionLostCauseArgumentCaptor.getValue()).hasCauseInstanceOf(MqttException.class);
    assertThat(onConnectionLostCauseArgumentCaptor.getValue()).isEqualTo(exception);
  }