DefaultAuthenticationResult implements AuthenticationResult { public static AuthenticationResult failed(final DittoHeaders dittoHeaders, final Throwable reasonOfFailure) { return new DefaultAuthenticationResult(dittoHeaders, null, checkNotNull(reasonOfFailure, "reasonOfFailure")); } private  DefaultAuthenticationResult(final DittoHeaders dittoHeaders,
            @Nullable final AuthorizationContext authorizationContext, @Nullable final Throwable reasonOfFailure); static AuthenticationResult successful(final DittoHeaders dittoHeaders,
            final AuthorizationContext authorizationContext); static AuthenticationResult failed(final DittoHeaders dittoHeaders, final Throwable reasonOfFailure); @Override boolean isSuccess(); @Override AuthorizationContext getAuthorizationContext(); @Override DittoHeaders getDittoHeaders(); @Override Throwable getReasonOfFailure(); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void getFailedInstanceWithNullDittoHeaders() { assertThatNullPointerException() .isThrownBy(() -> DefaultAuthenticationResult.failed(null, reasonOfFailure)) .withMessage("The dittoHeaders must not be null!") .withNoCause(); }
@Test public void getFailedInstanceWithNullReasonOfFailure() { assertThatNullPointerException() .isThrownBy(() -> DefaultAuthenticationResult.failed(dittoHeaders, null)) .withMessage("The reasonOfFailure must not be null!") .withNoCause(); }
@Test public void getAuthorizationContextFromFailedInstanceOfRuntimeException() { final AuthenticationResult underTest = DefaultAuthenticationResult.failed(dittoHeaders, reasonOfFailure); assertThatThrownBy(underTest::getAuthorizationContext).isEqualTo(reasonOfFailure); }
@Test public void getAuthorizationContextFromFailedInstanceOfError() { final AssertionError assertionError = new AssertionError("This is a test."); final AuthenticationResult underTest = DefaultAuthenticationResult.failed(dittoHeaders, assertionError); assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(underTest::getAuthorizationContext) .withCause(assertionError); }