@Test
public void aggregateAuthenticationFailures() {

    final DittoHeaders fooHeader = DittoHeaders.newBuilder().putHeader("foo-header", "foo").build();
    final DittoRuntimeException exceptionA =
            DittoRuntimeException.newBuilder("test:my.error", HttpStatusCode.UNAUTHORIZED)
                    .dittoHeaders(fooHeader)
                    .description("do this")
                    .build();
    final DittoHeaders barHeader = DittoHeaders.newBuilder().putHeader("bar-header", "bar").build();
    final DittoRuntimeException exceptionB =
            DittoRuntimeException.newBuilder("test:my.error", HttpStatusCode.UNAUTHORIZED)
                    .dittoHeaders(barHeader)
                    .description("do that")
                    .build();
    final DittoHeaders expectedHeaders = DittoHeaders.newBuilder()
            .putHeaders(fooHeader)
            .putHeaders(barHeader)
            .build();
    final List<AuthenticationResult> authenticationResults =
            Arrays.asList(DefaultAuthenticationResult.failed(KNOWN_DITTO_HEADERS, exceptionA),
                    DefaultAuthenticationResult.failed(KNOWN_DITTO_HEADERS, exceptionB));
    final DittoRuntimeException dittoRuntimeException =
            underTest.aggregateAuthenticationFailures(authenticationResults);
    assertThat(dittoRuntimeException).isExactlyInstanceOf(GatewayAuthenticationFailedException.class);
    assertThat(dittoRuntimeException).hasMessage(
            "Multiple authentication mechanisms were applicable but none succeeded.");
    assertThat(dittoRuntimeException.getDescription()).contains(
            "For a successful authentication see the following suggestions: { do this }, { do that }.");
    assertThat(dittoRuntimeException.getDittoHeaders()).containsAllEntriesOf(expectedHeaders);
}