@Test
public void subscriptionFailedFromAdaptable() {

    final TopicPath topicPath = TopicPath.fromNamespace("_")
            .things()
            .twin()
            .search()
            .failed()
            .build();
    final JsonPointer path = JsonPointer.empty();
    final SubscriptionProtocolErrorException error = SubscriptionProtocolErrorException.newBuilder()
            .message("Mock error")
            .build();
    final SubscriptionFailed expected =
            SubscriptionFailed.of(TestConstants.SUBSCRIPTION_ID, error, TestConstants.DITTO_HEADERS_V_2_NO_STATUS);
    final Adaptable adaptable = Adaptable.newBuilder(topicPath)
            .withPayload(Payload.newBuilder(path)
                    .withValue(JsonObject.of(String.format("{\"subscriptionId\": \"%s\", \"error\": %s}",
                            TestConstants.SUBSCRIPTION_ID, error.toJson())))
                    .build())
            .withHeaders(TestConstants.DITTO_HEADERS_V_2_NO_STATUS)
            .build();
    final SubscriptionEvent<?> actual = underTest.fromAdaptable(adaptable);
    assertWithExternalHeadersThat(actual).isEqualTo(expected);
}