DefaultAuthenticationResult implements AuthenticationResult { public static AuthenticationResult successful(final DittoHeaders dittoHeaders, final AuthorizationContext authorizationContext) { return new DefaultAuthenticationResult(dittoHeaders, checkNotNull(authorizationContext, "authorizationContext"), null); } 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 getSuccessfulInstanceWithNullDittoHeaders() { assertThatNullPointerException() .isThrownBy(() -> DefaultAuthenticationResult.successful(null, authorizationContext)) .withMessage("The dittoHeaders must not be null!") .withNoCause(); }
@Test public void getSuccessfulInstanceWithNullAuthorizationContext() { assertThatNullPointerException() .isThrownBy(() -> DefaultAuthenticationResult.successful(dittoHeaders, null)) .withMessage("The authorizationContext must not be null!") .withNoCause(); }
@Test public void getReasonOfFailureFromSuccessfulInstance() { final AuthenticationResult underTest = DefaultAuthenticationResult.successful(dittoHeaders, authorizationContext); assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(underTest::getReasonOfFailure) .withMessage("Authentication was successful!") .withNoCause(); }